2010-06-23 147 views
0

好的,所以起初当我运行我的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++有一个非常非常复杂的窗口模板,VS流血。我应该放弃流血并使用MSVC++吗?我用于blooshed,但我想有一个优势,当我终于学会了这个东西?

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

向我们显示创建菜单的代码。 – Max 2010-06-23 15:27:49

+0

你在那里,对不起试图不要因为太多的信息而被斥责 – TimothyTech 2010-06-23 15:38:15

回答

1

RC文件的内容看起来不错,所以我不认为问题在那里。我怀疑问题出在Bloodshhed上 - 虽然我并不是特别喜欢Dev-C++,但我怀疑这是造成这种情况的原因。这会使应用程序的代码成为导致问题的最可能的罪魁祸首。不幸的是,你甚至没有足够的证据来猜测问题的可能来源。

+0

那么源代码是通过流血创建的,我在这里因为显示太多代码而被骂。你有什么需要看到的吗?或者我应该把整个源代码? – TimothyTech 2010-06-23 15:34:26

+0

您的编辑已经添加了看起来像代码的正确部分 - 不幸的是,我没有看到任何明显的问题。 – 2010-06-23 16:08:40

+0

从底部看第4行看起来像它的问题,NULL,/ *没有菜单* /。是否有假设而不是NULL?我不知道该放什么。或者那是最初不是问题? – TimothyTech 2010-06-23 16:13:39