PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

how to use win32 control in edgelib

Hi,
Could I use windows controls in edgelib application? such as button control, listbox control and so on.
I ever create a button in funtion OnDisplayInit() using win32 api CreateWindow(...), but i can't handle the button messages in OnNativeEvent(). Can anybody give me some advises?
Hi Sunfred,

Did you create the windows with WS_CHILD?

You can also try to subclass the window. Here is a small example:

Code:

WNDPROC orig_winproc;

//Subclassed window procedure
BOOL CALLBACK SubClass_WinProc(HWND hwnd, UINT wmsg, WPARAM wparam, LPARAM lparam)
{
ClassMain *main = (WNDPROC)GetWindowLong(hwnd, GWL_USERDATA);
//handle your own messages here
return(CallWindowProc(orig_winproc, hwnd, wmsg, wparam, lparam));
}

//Your function to create controls
void ClassMain::CreateControl(void)
{
//Your call to CreateWindow
orig_winproc = (WNDPROC)SetWindowLong(your_hwnd, GWL_WNDPROC, (LONG)SubClass_WinProc);
SetWindowLong(your_hwnd, GWL_USERDATA, (unsigned long)this);
}
hi edge,
Thank you for your help!
And yes, I did create the windows with WS_CHILD flag.But I couldn't capture the message I need by using your code.Maybe there is something wrong with my codes, i'll check them later.
Still I have a question about SHOWING a windows control in edgelib (surface).I successfully create a button in OnDisplayInit(), but how could I show it in edgelib surface?

Thanks!
Hi Sunfred,

The best way is to use the GDI display mode. In OnDisplayConfig set the config->openmethod to DOM_GDI. The button should be drawn over your EDGELIB surface.
Hi edge,
Unfortuantly, it does't seem to work even I set "config->openmethod = DOM_GDI".
The button has been created successfully and can response click action within it's rect.But it's black!When I click within the area, it changes to white.
Maybe I should draw controls myself.

Thanks for your help!
Hi Sunfred,

I suggest drawing the controls yourself.

Another (more complicated) method is to show the backbuffer manually. This requires several calls to SetFlipRect and Flip to 'draw the backbuffer around your control'.