稍后运行程序后菜单消失

时间:2010-06-23 15:17:10

标签: c++ menu

好吧,首先当我运行我的win32程序时,菜单工作正常,但是当我第二天晚些时候打开应用程序或者这样的菜单消失但代码永远不会改变。我用.rc文件制作菜单。这是推荐的方式吗?

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);   

我也注意到MSVC ++有一个非常复杂的Windows模板,而不是流血。我是否应该放弃流血并使用MSVC ++?我习惯于大笑,但是当我终于学到这些东西时,我想要有优势?

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 个答案:

答案 0 :(得分:1)

您的RC文件的内容看起来很好,所以我认为问题不存在。我怀疑问题出现在Bloodshed中 - 虽然我不是特别喜欢Dev-C ++,但我怀疑它是否会导致这样的事情。这使得应用程序的代码成为导致问题的最可能的罪魁祸首。不幸的是,你没有足够的证据来猜测问题的可能来源。