Subj : Borland C++ 5.02 and writing Windows code To : borland.public.cpp.borlandcpp From : paulpigott Date : Thu Jul 01 2004 11:43 am Greetings, I'm pretty much a newbie to writing Window's code, though not so much to C++. I've been following the chapters in the book "Windows 2000 Programming from the Ground Up" by Herbert Schildt as I try to assimilate all this, and I've come across a problem. The book does things from the very basic level as far as the resource compiler is concerned. It doesn't take into account the Borland 5.02 IDE and the resource editor it has. As such, I've built a very simple menu (see the text layout) ===MENU BEGIN=== IDM_MENU1 MENU { POPUP "&File" { MENUITEM "&Select Drive", 101 MENUITEM "E&xit", 108 } POPUP "&Help" { MENUITEM "&About", 903 } } ===MENU END=== and a simple program to simply display a window. Additionally, I've added the code to include this menu as part of the window (see below). ===CODE BEGIN=== /* ======================================================================= Primary Documentation Windows Skeleton ======================================================================= */ #include LRESULT CALLBACK WindowFunc( HWND, UINT, WPARAM, LPARAM ); char szWinName[] = "MyWin"; // name of window class char szMenuName[] = "IDM_MENU1"; // name of menu #define IDM_SELECT 101 #define IDM_EXIT 108 #define IDM_ABOUT 903 int WINAPI WinMain( HINSTANCE hThisInst, HINSTANCE hPrevInst, LPSTR lpszArgs, int nWinMode ) { HWND hwnd; MSG msg; WNDCLASSEX wcl; // ============================================== // Define a window class // ============================================== wcl.cbSize = sizeof(WNDCLASSEX); wcl.hInstance = hThisInst; // handle to this instance wcl.lpszClassName = szWinName; // window class name wcl.lpfnWndProc = WindowFunc; // window function wcl.style = 0; // default style wcl.hIcon = LoadIcon( NULL, IDI_APPLICATION ); // large icon wcl.hIconSm = NULL; // use small version of large icon wcl.hCursor = LoadCursor( NULL, IDC_ARROW); // cursor style wcl.lpszMenuName = szMenuName; // class menu wcl.cbClsExtra = 0; // no extra memory needed wcl.cbWndExtra = 0; // ============================================== // Make the Window background white // ============================================== wcl.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); // ============================================== // Register the window class // ============================================== if ( !RegisterClassEx(&wcl) ) return 0; // ============================================== // Now that the window class has been registered, // a window can be created // ============================================== hwnd = CreateWindow( szWinName, // name of window class "DiskUse", // title WS_OVERLAPPEDWINDOW, // window style, normal CW_USEDEFAULT, // x coordinate - let Windows decide CW_USEDEFAULT, // y coordinate - let Windows decide CW_USEDEFAULT, // width - let Windows decide CW_USEDEFAULT, // height - let Windows decide NULL, // no parent window NULL, // no menu hThisInst, // instance handle NULL // no additional arguments ); // ============================================== // Display the window // ============================================== ShowWindow( hwnd, nWinMode ); UpdateWindow( hwnd ); // ============================================== // Create the message loop // ============================================== while( GetMessage( &msg, NULL, 0, 0 ) ) { TranslateMessage(&msg); // translate keyboard messages DispatchMessage(&msg); // return control to Windows } // ============================================== // Exiting the program // ============================================== return msg.wParam; } LRESULT CALLBACK WindowFunc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam ) { // int response; switch( message ) { case WM_COMMAND: switch( LOWORD(wParam) ) { case IDM_SELECT: MessageBox( hwnd, "SELECT", "FILE", MB_OK ); break; case IDM_EXIT: MessageBox( hwnd, "EXIT", "FILE", MB_OK ); PostQuitMessage(0); break; case IDM_ABOUT: MessageBox( hwnd, "ABOUT", "HELP", MB_OK ); break; } break; case WM_DESTROY: PostQuitMessage(0); break; default: // ================================================ // Windows will process any messages not specified // in the preceding switch statement. // ================================================ return DefWindowProc( hwnd, message, wParam, lParam ); } return 0; } ===CODE END=== But the menu is not showing up. Am I missing something in the Borland IDE to "turn on" this menu? Is there some additional code I need to use? Can anyone provide some direction on this? I would greatly appreciate it. TIA, Paul .