I didn't want to fill up a thread with a bunch of code, but I couldn't find a way to attach a file to an e-mail using this site's "send a message" system. I would have inserted the .CPP file.
This is a basic windows program to run tests on what started out to be two problems I had. Comrade Ogilvy solved one of them for me and my large program now is displaying the mouse position in my status bar the way I wanted. I've cleaned out all the unneeded code so only the "CreateMenu" problem code is left. I stepped through SofeIce to try to see what is happening but when SI gets to "SysEnter", if I single step through, my box blue screens. I've had that happen to me before in other programs when the program tries to step through "SysEnter". I don't know why. If you compile and run this you will get a "Get System Error" stating "The system cannot find the file specified." Why not? Isn't CreateMenu suppose to return a new handle?
#include <windows.h>
HINSTANCE hInstance;
HWND hwndMain;
HMENU hMenu;
char szBuff3[128]="TEST";
MSG msg;
WNDCLASS wc;
WPARAM wParam;
LPARAM lParam;
//***** START Prototypes
int WINAPI WinMain (HINSTANCE hInstance , HINSTANCE hPrevInstance , LPSTR lpCmdLine , int nCmdShow);
LRESULT CALLBACK MainWndProc(HWND hwndMain, UINT uMsg , WPARAM wParam , LPARAM lParam);
//HMENU NewMenu(HMENU hMenu);
//*******END Prototypes
int WINAPI WinMain( HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow)
{
(void)UNREFERENCED_PARAMETER(hPrevInstance);
(void)UNREFERENCED_PARAMETER(lpCmdLine);
(void)UNREFERENCED_PARAMETER(nCmdShow);
wc.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS;
wc.lpfnWndProc = (WNDPROC)MainWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "szClassName";
if (!RegisterClass(&wc))
return FALSE;
hwndMain = CreateWindow("szClassName","szAppName", WS_OVERLAPPEDWINDOW,
0,0,740,480,NULL,NULL,hInstance,NULL );
ShowWindow(hwndMain,SW_SHOW);
UpdateWindow(hwndMain);
while (GetMessage(&msg, NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (msg.wParam);
}
LRESULT WINAPI MainWndProc (HWND hwndMain, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_CREATE:
HMENU CreateMenu(void);
LPTSTR lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,GetLastError(),MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)(&lpMsgBuf),0,NULL);
MessageBox( NULL, lpMsgBuf, "GetLastError", MB_OK|MB_ICONINFORMATION );
LocalFree( lpMsgBuf );
IsMenu(hMenu);
if(hMenu == NULL)
MessageBox(hwndMain,"No Menu","MBOX",MB_OK);
else
MessageBox(hwndMain,"Have Menu","MBOX",MB_OK);
SetMenu(hwndMain,hMenu);
AppendMenu(hMenu,MF_ENABLED | MF_STRING,1,szBuff3);
DrawMenuBar(hwndMain);
UpdateWindow(hwndMain);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return (DefWindowProc(hwndMain, message, wParam, lParam));
}
}