turn a win32 exe into a reusable control?
Here''s the thing, I''ve created a simple control which uses the callback functions for the WM_MOUSEMOVE/WM_LBUTTONDOWN/etc messages (win32/GDI) - move mouse over point on grid, change color, move point when mousebutton is down, etc..
I would like to make it reusable, so that all I have to do is something like:
CGui g_editor; // instance of class CGui
:: ::
:: ::
mainloop() {
g_editor.UpdateControl(g_hwnd);
}
then ideally it would respond to my mouse messages or any other input I add into it later.. how would I set that up, as a callback (or a thread)?
Do I need to RegisterEx() another window for my small control I want to place on my client window? And then do another CreateWindowEx() in WinMain?
Or would it be better to use the GetAsyncKeyState(VK_LBUTTON) and drop the callback altogether?
I fseek, therefore I fam.
I commented out my callback function and changed my mouse input into:
if (GetAsyncKeyState(VK_LBUTTON)) ....
when I move my mouse around with the button down, the mouse lags behind and comes to almost a crawl, it''s almost as if the puter is moving my mouse... creeepy..
would it be due to some buffer that needs flushing? if so how?
I fseek, therefore I fam.
if (GetAsyncKeyState(VK_LBUTTON)) ....
when I move my mouse around with the button down, the mouse lags behind and comes to almost a crawl, it''s almost as if the puter is moving my mouse... creeepy..
would it be due to some buffer that needs flushing? if so how?
I fseek, therefore I fam.
looks like one sure way is using a MDI window, hope I can stuff it into a class and forgit the painful parts of coding it..
I fseek, therefore I fam.
I fseek, therefore I fam.
If you want to create a custom control that can be used by several applications, do the following:
1) Create a DLL for the custom control
2) In your application, load the DLL
3) In the DLL''s DllMain function, when a DLL_PROCESS_ATTACH event occurs, register the control''s window class with the CS_GLOBALCLASS style
4) In your application, create an instance of the control using CreateWindowEx (ex_style, "control name", ...).
5) Get and set properties using the SendMessage function.
Your control will automatically receive WM_MOUSEMOVE, WM_KEYUP, etc messages when it has the focus / mouse is over it.
Hope that helps.
Skizz
1) Create a DLL for the custom control
2) In your application, load the DLL
3) In the DLL''s DllMain function, when a DLL_PROCESS_ATTACH event occurs, register the control''s window class with the CS_GLOBALCLASS style
4) In your application, create an instance of the control using CreateWindowEx (ex_style, "control name", ...).
5) Get and set properties using the SendMessage function.
Your control will automatically receive WM_MOUSEMOVE, WM_KEYUP, etc messages when it has the focus / mouse is over it.
Hope that helps.
Skizz
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement