好的,一开始当我运行我的win32程序时,菜单运行得很好,但是当我第二天或类似的时候打开应用程序时,菜单就消失了,但是代码从来没有改变。我正在用一个.rc文件制作菜单。这是推荐的方式吗?
resource.rc
#include "resource.h"
IDR_MYMENU MENU
BEGIN
POPUP "&File"
BEGIN
MENUITEM "E&xit", ID_FILE_EXIT
END
ENDresource.h
#define IDR_MYMENU 101
#define IDI_MYICON 201
#define ID_FILE_EXIT 9001
#define ID_STUFF_GO 9002main.cpp
#include "resource.h"
wincl.lpszMenuName = MAKEINTRESOURCE(IDR_MYMENU); 我还注意到MSVC++有一个非常非常复杂的窗口模板,而不是血腥。我是不是应该放弃流血事件而使用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 */
);发布于 2010-06-23 23:29:08
你的RC文件的内容看起来很好,所以我不认为有问题。我也怀疑这个问题是不是出了问题--虽然我不是特别喜欢Dev-C++,但我怀疑它会导致这样的事情。这使得您的应用程序代码成为最有可能导致问题的罪魁祸首。不幸的是,您还没有展示出足够的信息来猜测问题的可能来源。
https://stackoverflow.com/questions/3102991
复制相似问题