my window menu is crazy!

This is a discussion on my window menu is crazy! within the Windows Programming forums, part of the Platform Specific Boards category; I have been reading up on tutorials at winprog.org... I've come to this one: http://winprog.org/tutorial/dialogs.html I can't get it to ...

  1. #1
    C++ beginner
    Join Date
    Jun 2004
    Posts
    66

    my window menu is crazy!

    I have been reading up on tutorials at winprog.org...
    I've come to this one: http://winprog.org/tutorial/dialogs.html

    I can't get it to compile because it says that there is a parse error is my .rc file!

    I'm not sure how to fix it either, can you help?

    here is the sourcecode:

    simplewindow1.c:
    Code:
    #include <windows.h>
    
    #include "resource.h" 
    
    const char g_szClassName[] = "myWindowClass";
    
    BOOL CALLBACK AboutDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
    {
    	switch(Message)
    	{
    		case WM_INITDIALOG:
    
    		return TRUE;
    		case WM_COMMAND:
    			switch(LOWORD(wParam))
    			{
    				case IDOK:
    					EndDialog(hwnd, IDOK);
    				break;
    				case IDCANCEL:
    					EndDialog(hwnd, IDCANCEL);
    				break;
    			}
    		break;
    		default:
    			return FALSE;
    	}
    	return TRUE;
    }
    
    LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
    {
    	switch(Message)
    	{
    		case WM_COMMAND:
    			switch(LOWORD(wParam))
    			{
    				case ID_FILE_EXIT:
    					PostMessage(hwnd, WM_CLOSE, 0, 0);
    				break;
    				case ID_HELP_ABOUT:
    				{
    					int ret = DialogBox(GetModuleHandle(NULL), 
    						MAKEINTRESOURCE(ID_HELP_ABOUT), hwnd, AboutDlgProc);
    					if(ret == IDOK){
    						MessageBox(hwnd, "Dialog exited with IDOK.", "Notice",
    							MB_OK | MB_ICONINFORMATION);
    					}
    					else if(ret == IDCANCEL){
    						MessageBox(hwnd, "Dialog exited with IDCANCEL.", "Notice",
    							MB_OK | MB_ICONINFORMATION);
    					}
    					else if(ret == -1){
    						MessageBox(hwnd, "Dialog failed!", "Error",
    							MB_OK | MB_ICONINFORMATION);
    					}
    				}
    				break;
    			}
    		break;
    		case WM_CLOSE:
    			DestroyWindow(hwnd);
    		break;
    		case WM_DESTROY:
    			PostQuitMessage(0);
    		break;
    		default:
    			return DefWindowProc(hwnd, Message, wParam, lParam);
    	}
    	return 0;
    }
    
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    	LPSTR lpCmdLine, int nCmdShow)
    {
    	WNDCLASSEX wc;
    	HWND hwnd;
    	MSG Msg;
    
    	wc.cbSize		 = sizeof(WNDCLASSEX);
    	wc.style		 = 0;
    	wc.lpfnWndProc	 = WndProc;
    	wc.cbClsExtra	 = 0;
    	wc.cbWndExtra	 = 0;
    	wc.hInstance	 = hInstance;
    	wc.hIcon		 = LoadIcon(NULL, IDI_APPLICATION);
    	wc.hCursor		 = LoadCursor(NULL, IDC_ARROW);
    	wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
    	wc.lpszMenuName  = MAKEINTRESOURCE(IDR_MYMENU);
    	wc.lpszClassName = g_szClassName;
    	wc.hIconSm		 = LoadIcon(NULL, IDI_APPLICATION);
    
    	if(!RegisterClassEx(&wc))
    	{
    		MessageBox(NULL, "Window Registration Failed!", "Error!",
    			MB_ICONEXCLAMATION | MB_OK);
    		return 0;
    	}
    
    	hwnd = CreateWindowEx(
    		WS_EX_CLIENTEDGE,
    		g_szClassName,
    		"The title of my window",
    		WS_OVERLAPPEDWINDOW,
    		CW_USEDEFAULT, CW_USEDEFAULT, 240, 120,
    		NULL, NULL, hInstance, NULL);
    
    	if(hwnd == NULL)
    	{
    		MessageBox(NULL, "Window Creation Failed!", "Error!",
    			MB_ICONEXCLAMATION | MB_OK);
    		return 0;
    	}
    
    	ShowWindow(hwnd, nCmdShow);
    	UpdateWindow(hwnd);
    
    	while(GetMessage(&Msg, NULL, 0, 0) > 0)
    	{
    		TranslateMessage(&Msg);
    		DispatchMessage(&Msg);
    	}
    	return Msg.wParam;
    }
    resource.h:
    Code:
    #define IDR_MYMENU 101
    #define IDI_MYICON 201
    
    #define ID_FILE_EXIT 9001
    #define ID_HELP_ABOUT 9002
    and finally the menu.rc file:
    Code:
    #include "resource.h"
    
    IDR_MYMENU MENU
    BEGIN
        POPUP "&File"
        BEGIN
            MENUITEM "E&xit", ID_FILE_EXIT
        END
    
        POPUP "&Help"
        BEGIN
            MENUITEM "&About", ID_HELP_ABOUT
        END
    END
    
    IDD_ABOUT DIALOG DISCARDABLE  0, 0, 239, 66
    STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU           
    CAPTION "ABOUTXX0rS MEH!"
    FONT 8, "MS Sans Serif"
    BEGIN
        DEFPUSHBUTTON   "&OK",IDOK,174,18,50,14
        PUSHBUTTON      "&Cancel",IDCANCEL,174,35,50,14
        GROUPBOX        "About this program...",IDC_STATIC,7,7,225,52
        CTEXT           "This is basically matt trying to learn API, quite fun really.",
                        IDC_STATIC,16,18,144,33
    END
    
    IDI_MYICON ICON "favicon.ico"

    When I compile this, my menu doesn't appear. I get no warneings, or errors. What's wrong?
    Oh my goodness.

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    In menu.rc insert at the top of the file (ie. before #include "resource.h"):
    Code:
    #include <windows.h>
    #if !defined IDC_STATIC
    #define IDC_STATIC -1
    #endif
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    C++ beginner
    Join Date
    Jun 2004
    Posts
    66
    It still does not show up...

    Did it show up for you when you added that?
    Oh my goodness.

  4. #4
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    If you could post the exact error message, it would help.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  5. #5
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    You haven't defined IDD_ABOUT, IDCANCEL and IDC_STATIC.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  6. #6
    C++ beginner
    Join Date
    Jun 2004
    Posts
    66
    how do I do that?

    =/
    Oh my goodness.

  7. #7
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,804
    just add this to your resource.h file
    Code:
    #define IDD_ABOUT 103
    you don't need to define IDCANCEL it is predefined
    Woop?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  2. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 10:06 AM
  3. Linking OpenGL in Dev-C++
    By linkofazeroth in forum Game Programming
    Replies: 4
    Last Post: 09-13-2005, 10:17 AM
  4. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  5. Constructive Feed Back (Java Program)
    By xddxogm3 in forum Tech Board
    Replies: 12
    Last Post: 10-10-2004, 03:41 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21