I've been trying for a long time as well as all day today to get a menu or dialog box to work, with no luck. THe windows Programming book has led me to many problems I can't figure out. Does someone have a simple menu or dialog box step by step instructions? I just want something so i can get something to work so I get the concept down. THanks alot!!
Matt
1) Create an empty Win32 Application project (NOT console).
2) Choose Project->Add to Project->New... and add a code file (.cpp)
3) Choose Project->Add to Project->New... and add a resource script
4) Choose Insert->Resource... and add a menu resource. Use the resource editor to add menu items. Give the menu a meaningful ID (like IDM_MAINMENU, in the menu properties dialog).
5) Choose Project->Add to Project->Files... and select the file "resource.h" that was automatically created.
6) Now write the following code in your main module.
Code:
// extracts from the code, the complete file is attached
#include <windows.h>
#include "resource.h" // resource ID aliases
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, int iShowCmd)
{
MSG msg;
WNDCLASS wc;
// ...
wc.lpszClassName = "MenuDemo";
wc.lpszMenuName = MAKEINTRESOURCE(IDM_MAINMENU); // this is the most important line!
RegisterClass(&wc);
HWND hwnd = CreateWindow("MenuDemo", /* ... */);
ShowWindow(hwnd, iShowCmd);
UpdateWindow(hwnd);
while(GetMessage(&msg, NULL, 0, 0) > 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
All the buzzt CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.