Sign in to follow this  

[.net] Invoking event

This topic is 3577 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've got a problem here in invoking event in a class that was derived from a ListView. I added a new event called OnVScroll to check if the user slide the listView scrollbar. The purpose is if user slide listView1 scrollbar then listView2 also synchronized. Here is the code: static int const SBS_VERT = 1; static int const SB_THUMBPOSITION = 4; [DllImport("user32.dll", CharSet=CharSet::Auto, CallingConvention=CallingConvention::StdCall)] static IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp); [DllImport("user32.dll")] static int GetScrollPos(IntPtr hWnd, int nBar); [DllImport("user32.dll")] static int SetScrollPos(IntPtr hWnd, int nBar, int nPos, bool bRedraw); ref class MyListView: ListView { public: MyListView() { WM_HSCROLL = 0x0114; WM_VSCROLL = 0x0115; WM_MOUSEWHEEL = 0x020A; } Void MyListView::OnVScroll(System::Windows::Forms::Message %m) { } //end of OnVScroll private: int WM_HSCROLL; int WM_VSCROLL; int WM_MOUSEWHEEL; protected: virtual void WndProc(System::Windows::Forms::Message %m) override { if( m.Msg == WM_HSCROLL || m.Msg == WM_VSCROLL || m.Msg == WM_MOUSEWHEEL ) MyListView::OnVScroll(m); else ListView::WndProc(m); } }; //end of class MyListView*/ On the event OnVScroll, I want to call : SendMessage(lvSource->Handle, m.Msg, m.WParam, m.LParam); I've placed this code OUTSIDE MyListView class, along with other built-in events like Button1_Click, etc: private: System::Void MyListView::OnVScroll( System::Windows::Forms::Message %m ) { SendMessage( lvSource->Handle, m.Msg, m.WParam, m.LParam ); } //end of OnVScroll But it generated error like this: Results.cpp c:\chris\sample test\diffengtest\mydiff\Results.h(487) : error C3254: 'MyDiff::Results' : class contains explicit override 'OnVScroll' but does not derive from an interface that contains the function declaration c:\chris\sample test\diffengtest\mydiff\Results.h(487) : error C2838: 'OnVScroll' : illegal qualified name in member declaration MyDiff.cpp c:\chris\sample test\diffengtest\mydiff\Results.h(487) : error C3254: 'MyDiff::Results' : class contains explicit override 'OnVScroll' but does not derive from an interface that contains the function declaration c:\chris\sample test\diffengtest\mydiff\Results.h(487) : error C2838: 'OnVScroll' : illegal qualified name in member declaration AssemblyInfo.cpp What is wrong and how to fix this? Thank you very much.

Share this post


Link to post
Share on other sites

This topic is 3577 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Guest
This topic is now closed to further replies.
Sign in to follow this