tags:

views:

22

answers:

1

Okay, so at first when i run my win32 program the menu works fine, however when i open the application later the next day or such the menu is gone but the code never changed. im making the menu with a .rc file. is this the recommended way?

resource.rc

#include "resource.h"



IDR_MYMENU MENU
BEGIN
   POPUP "&File"
      BEGIN
        MENUITEM "E&xit", ID_FILE_EXIT
      END
END

resource.h

#define IDR_MYMENU 101
#define IDI_MYICON 201


#define ID_FILE_EXIT 9001
#define ID_STUFF_GO 9002

main.cpp

#include "resource.h"
wincl.lpszMenuName = MAKEINTRESOURCE(IDR_MYMENU);   

also i noticed that MSVC++ has a very very complex windows templates, vs bloodshed. should i maybe give up on bloodshed and use MSVC++? I am use to blooshed, but i want to have an edge when i finally learn this stuff?

HWND hwnd;               /* This is the handle for our window */
MSG messages;            /* Here messages to the application are saved */
WNDCLASSEX wincl;        /* Data structure for the windowclass */

/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);

/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON));
wincl.hIconSm = (HICON) LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON), IMAGE_ICON, 16, 16 ,0);
wincl.hCursor = LoadCursor (NULL, IDC_CROSS);
wincl.lpszMenuName = MAKEINTRESOURCE(IDR_MYMENU);                 /* No menu */
wincl.cbClsExtra = 0;                                             /* No extra bytes after the window class */
wincl.cbWndExtra = 0;                                             /* structure or the window instance */
/* Use Windows's default color as the background of the window */
wincl.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);

/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
    return 0;

/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
       0,                   /* Extended possibilites for variation */
       szClassName,         /* Classname */
       "Windows App",       /* Title Text */
       WS_OVERLAPPEDWINDOW, /* default window */
       CW_USEDEFAULT,       /* Windows decides the position */
       CW_USEDEFAULT,       /* where the window ends up on the screen */
       544,                 /* The programs width */
       375,                 /* and height in pixels */
       HWND_DESKTOP,        /* The window is a child-window to desktop */
       NULL,                /* No menu */
       hThisInstance,       /* Program Instance handler */
       NULL                 /* No Window Creation data */
       );
+1  A: 

The content of your RC file looks fine, so I don't think the problem is there. I doubt the problem is in Bloodshed either -- while I'm not particularly fond of Dev-C++, I doubt it's causing anything like this. That leaves your code for the application as the most likely culprit for causing the problem. Unfortunately, you haven't shown enough of that to even guess at likely sources of the problem.

Jerry Coffin
well the source code was created by bloodshed, and i get scolded here for showing too much code. is there anything in paticular that you need to see? or should i put on the whole source code?
TimothyTech
Your edit has added what looks like the right parts of the code -- unfortunately, I don't see any obvious problems with it.
Jerry Coffin
the 4th line from the bottom looks like its the issue, NULL, /*no menu*/. is there suppose to be something rather than NULL? i dont know what to put there. or is that definitly not the issue?
TimothyTech
@TimothyTech: no, that's for setting a window menu if you want one that's different from the class menu that you set in the `WNDCLASSEX` structure you passed to `RegisterClassEx`. Using this is *quite* unusual.
Jerry Coffin