首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >稍后运行程序后菜单消失

稍后运行程序后菜单消失
EN

Stack Overflow用户
提问于 2010-06-23 23:17:10
回答 1查看 241关注 0票数 0

好的,一开始当我运行我的win32程序时,菜单运行得很好,但是当我第二天或类似的时候打开应用程序时,菜单就消失了,但是代码从来没有改变。我正在用一个.rc文件制作菜单。这是推荐的方式吗?

resource.rc

代码语言:javascript
复制
#include "resource.h"



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

resource.h

代码语言:javascript
复制
#define IDR_MYMENU 101
#define IDI_MYICON 201


#define ID_FILE_EXIT 9001
#define ID_STUFF_GO 9002

main.cpp

代码语言:javascript
复制
#include "resource.h"
wincl.lpszMenuName = MAKEINTRESOURCE(IDR_MYMENU);   

我还注意到MSVC++有一个非常非常复杂的窗口模板,而不是血腥。我是不是应该放弃流血事件而使用MSVC++呢?我习惯了失血,但当我最终学会这些东西的时候,我想要有一个优势?

代码语言:javascript
复制
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 */
       );
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-06-23 23:29:08

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3102991

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档