Thursday, 15 March 2012

winapi - C++ Win32 Control Procedure within a Class -



winapi - C++ Win32 Control Procedure within a Class -

what trying do, create edit command , procedure within class. have tried various things, , tried using parts of similar question asked: win32 c++ create window , procedure within class.

at moment, took them apart.

main_class.h class mainclass { private: hwnd hwndmain; // main windows handle hinstance hinstancemain; // main windows instance hwnd htextarea; public: bool init(hwnd _hwnd, hinstance _hinstance); bool showinfotextarea(); }; main_class.cpp // heres question bool mainclass::showinfotextarea() { if (htextarea != null) homecoming true; // if not null, textarea displayed. // creating edit textarea htextarea = createwindowex(0, l"edit", l"", ws_child | ws_visible | ws_vscroll | ws_hscroll | es_multiline | es_autovscroll | es_autohscroll, screen_width+5, 0, window_width-screen_width-10, window_height-30, hwndmain, (hmenu)idc_ctrl_edit, getmodulehandle(null), null); if (htextarea == null) { messagebox(null, l"could not create test text control. programme close.", null, mb_ok | mb_iconexclamation); homecoming false; } // dozens of attempts like: // lpeditwndproc = (wndproc)setwindowlongptr(htextarea, gwlp_wndproc, (long_ptr)editcontrolproc); // lpeditwndproc = (wndproc)setwindowlongptr(htextarea, gwlp_wndproc, (long_ptr)mainclass::editcontrolproc); // tried static callback functions, etc. //every seek compiler said: there missing braces ( ) editcontrolproc } // working, separated: wndproc lpeditwndproc; lresult callback editcontrolproc(hwnd hwndedit, uint umsg, wparam wparam, lparam lparam) { switch (umsg) { default: homecoming callwindowproc(lpeditwndproc, hwndedit, umsg, wparam, lparam); } homecoming 0; // done }

with (various) attempts compiler said: there missing braces ( ) editcontrolproc, or said type mismatch when trying define lpeditwndproc.

i missing out on simple?

useage:

main.cpp mainclass mainclass; mainclass.showinfotextarea();

thanks. if missing info allow me know.

jonathan potter's comment solution.

for reads:

mainclass.h class mainclass { private: hwnd hwndmain; hinstance hinstancemain; hwnd htextarea; static lresult callback editcontrolproc (hwnd hwnd, uint msg, wparam wparam, lparam lparam, uint_ptr uidsubclass, dword_ptr dwrefdata); public: bool init(hwnd _hwnd, hinstance _hinstance); bool showinfotextarea(); }; mainclass.cpp // show textarea bool mainclass::showinfotextarea() { if (htextarea != null) homecoming true; // if not null, textarea displayed. // creating edit textarea htextarea = createwindowex(0, l"edit", l"", ws_child | ws_visible | ws_vscroll | ws_hscroll | es_multiline | es_autovscroll | es_autohscroll, screen_width+5, 0, window_width-screen_width-10, window_height-30, hwndmain, (hmenu)idc_ctrl_edit, getmodulehandle(null), null); if (htextarea == null) { messagebox(null, l"could not create test text control. programme close.", null, mb_ok | mb_iconexclamation); homecoming false; } setwindowsubclass(htextarea, editcontrolproc, 0, 0); } // works lresult callback mainclass::editcontrolproc(hwnd hwnd, uint msg, wparam wparam, lparam lparam, uint_ptr uidsubclass, dword_ptr dwrefdata) { switch (msg) { case wm_keydown: messagebox(0,0,0,0); break; default: homecoming defsubclassproc(hwnd, msg, wparam, lparam); break; } homecoming 0; // done }

c++ winapi stored-procedures

No comments:

Post a Comment