Thanks so much for your reply... If I wish to use this window class or the visual C++ template, how do I then interface it with whatever code I have written?
Depends on what the code does and how you want to inteface with it. Usually, programs respond to user events so you need to extend the message handling switch statement to handle different events. Menu item clicks for example get handled by WM_COMMAND message:
switch(uMsg) {
case WM_DESTROY:
PostQuitMessage(0); // close app
break;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case CM_SOME_MENUITEM_YOU_DEFINE:
YourFunctionCall();
break;
case CM_YOUR_MENU_EXIT_OPTION:
DestroyWindow(hWnd);
break;
}
break;
In this example you would first need to create a menu, which means you need to create a resource in VC++ which you add to your project. The menu needs to have items which have ids corresponding to the values above. i.e. CM_SOME_MENUITEM_YOU_DEFINE is the id of one of the items in your menu.
Alternately if you want a GUI of some kind (say with buttons) then you need to create it, either as a dialog resource you embed into the client area of the main window or manually by creating each button with CreateWindow(). Then, messages from each button are handled, again within the WM_COMMAND message, using the high word of the wParam to get the button-clicked notification and the low word to get the id of the button:
case WM_COMMAND:
switch(HIWORD(wParam))
{
case BN_CLICKED:
switch(LOWORD(wParam))
{
case IDC_SOMEBTN:
SomeFunction();
break;
case IDC_SOMEOTHERBTN:
SomeOtherFunction();
break;
}
break;
}
break;
This is all a pretty manual approach, which doesn't bother me, but a lot of people use MFC which wraps a lot of this kind of stuff into more manageable C++ classes.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.