Search found 67 matches

by shawnee
Thu May 10, 2018 7:46 am
Forum: C++ Development
Topic: Get selected column in virtual wxListCtrl
Replies: 12
Views: 2652

Re: Re:

Does event.GetPoint().x really work? In my codes, it always 0. I checked the header file in v3.1, GetPoint() returns the value of m_pointDrag. It seems not mouse clicking position. Like i wrote: The docs say that GetPoint() is only valid for drag events, but i tested it on MSW and it also works her...
by shawnee
Wed May 09, 2018 3:12 pm
Forum: C++ Development
Topic: Get selected column in virtual wxListCtrl
Replies: 12
Views: 2652

Re:

You could try iterating over the column widths and compare it with the x-position of the mouse click: void myListCtrl::OnItemRightClick(wxListEvent& event) { int column; int x=0; for(column=0; column<GetColumnCount(); column++) { x+=GetColumnWidth(column); if(x>=event.GetPoint().x) break; } wxLogDe...
by shawnee
Tue Jan 16, 2018 11:31 am
Forum: C++ Development
Topic: set user data for ribbonbuttonbar event
Replies: 3
Views: 669

Re: set user data for ribbonbuttonbar event

The documentation for userData says: userData Optional data to be associated with the event table entry. wxWidgets will take ownership of this pointer, i.e. it will be destroyed when the event handler is disconnected or at the program termination. This pointer can be retrieved using wxEvent::GetEve...
by shawnee
Tue Jan 16, 2018 8:32 am
Forum: wxWidgets Development (Chinese)
Topic: Ribbon动态事件绑定的userdata传入问题(wx3.1)
Replies: 1
Views: 1504

Re: Ribbon动态事件绑定的userdata传入问题(wx3.1)

我从别的帖子找到了解决方法,https://forums.wxwidgets.org/viewtopic.php?f=1&t=39934&p=161254&hilit=userdata#p161249 定义一个通用类,专门存放宿主指针。 template<class T> class wxExUserData : public wxObject { public: T * Class() { return cls; } private: T * cls; public: wxExUserData(T * cl) : cls(cl) {} virtual ~wxExUserData() {}; ...
by shawnee
Tue Jan 16, 2018 8:09 am
Forum: C++ Development
Topic: set user data for ribbonbuttonbar event
Replies: 3
Views: 669

Re: set user data for ribbonbuttonbar event

I find out the way from this post: https://forums.wxwidgets.org/viewtopic.php?f=1&t=39934&p=161254&hilit=userdata#p161249 template<class T> class wxExUserData : public wxObject { public: T * Class() { return cls; } private: T * cls; public: wxExUserData(T * cl) : cls(cl) {} virtual ~wxExUserData() {...
by shawnee
Tue Jan 16, 2018 2:55 am
Forum: wxWidgets Development (Chinese)
Topic: Ribbon动态事件绑定的userdata传入问题(wx3.1)
Replies: 1
Views: 1504

Ribbon动态事件绑定的userdata传入问题(wx3.1)

大家好, 我在做Ribbon控件动态绑定事件的时候,Debug模式下碰到一个crash问题。我用的是wx3.1。 示例代码如下(仅列出关键代码,其他代码已忽略): #define wxID_App_TEST 100000 /////////////////////////////////// class myFrame : public wxFrame { private: int user_id; private: wxRibbonBar *create_ribbon(); wxRibbonBar * ribbbon; private: void OnClick(wxRibbonButton...
by shawnee
Tue Jan 16, 2018 2:44 am
Forum: C++ Development
Topic: set user data for ribbonbuttonbar event
Replies: 3
Views: 669

set user data for ribbonbuttonbar event

I'm using wxWidgets 3.1, I got a crash problem if I pass userdata to wxEVT_RIBBONBUTTONBAR_CLICKED event callback. I used dynamic event binding and run under Debug mode. Here is my example codes: #define wxID_App_TEST 100000 /////////////////////////////////// class myFrame : public wxFrame { privat...