Win32 Question
Hi,
Venturing into the 'wonderful' world of win32 programming and am stuck. I have been working through some tutorials and cant find any info on what i want. I have been learning how to create menus dialogues forms and cursors etc. All the examples till now have had a big white client area but what i want to do is put stuff in there. For no i want just one button and one textbox.
Question 1:
How do i do this, put buttons in the client area?
Question 2:
Once they are there how do i read the on-click event?
Thanks
ace
theForgers's Win32 API Tutorial
#define BUTTON 4000
CreateWindowEx(WS_EX_WINDOWEDGE, "BUTTON", "Button Text", WS_CHILD, 0, 0, 100, 25, hWnd, (HMENU)BUTTON, hInst, NULL);
switch(msg)
{
case WM_COMMAND:
switch(LOWORD(wParam))
{
case BUTTON:
CallSomeOnClickFunction();
break;
}
break;
}
#define BUTTON 4000
CreateWindowEx(WS_EX_WINDOWEDGE, "BUTTON", "Button Text", WS_CHILD, 0, 0, 100, 25, hWnd, (HMENU)BUTTON, hInst, NULL);
switch(msg)
{
case WM_COMMAND:
switch(LOWORD(wParam))
{
case BUTTON:
CallSomeOnClickFunction();
break;
}
break;
}
Ok, but where do i put it?
It seems that with win32 you have chunks of message handling code everywhere?
If i want to create a complicated window do i just have to do lots and lots of these, in objects.
ace
It seems that with win32 you have chunks of message handling code everywhere?
If i want to create a complicated window do i just have to do lots and lots of these, in objects.
ace
You could put it in WM_CREATE or just before you start your message loop. You have to make a control if you want to create them at runtime. Or if you just want a predifined form you have to make a dialog in visual studio, you just make a resource then you can drag buttons etc. onto the form, then you could make a complicated form.
LoadDialogEx or something like that.
Buy Pretzold's book if you want a good Win32 primer.
Buy Pretzold's book if you want a good Win32 primer.
If you want to tear apart an app, you can tear apart the examples on http://www.codeproject.com/library/DWinLib.asp. There is also a little about what is needed to objectivize capturing a button click in the writeup. Specifically, look into the WinButton.cpp file. The message handling for the button clicks begins in the WinBaseO::wCommand function, which handles the WM_COMMAND message, as hinted at above.
David
David
As far as a dialog taking the place of the client area, I've never played with that. I've simply created the form I wanted, with the inputs and objects I wanted, where I've wanted them, and done any other drawing necessary.
David
David
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement