第一次编译连接正常无错误,就是运行时没有效果
第二次 编译,连接时
Linking...
LINK : fatal error LNK1168: cannot open Debug/5.exe for writing
Error executing link.exe.
5.exe - 1 error(s), 0 warning(s)
这是什么错误呢?
(windows编程)
建立的工程是Win32 Application
三个文件,分别是:
//-----------------------5_2.h-------------------
#define IDM_NEW 10
#define IDM_OPEN 11
#define IDM_CLOSE 12
#define IDM_SAVE 13
#define IDM_SAVEAS 14
#define IDM_ADDPRINTMENU 15
#define IDM_DELPRINTMENU 16
#define IDM_EXIT 17
#define IDM_CUT 18
#define IDM_COPY 19
#define IDM_PASTE 20
#define IDM_DELETE 21
#define IDM_HELP 22
#define IDM_LINE 23
#define IDM_RECT 24
#define IDM_RRECT 25
#define IDM_ELLIP 26
//-----------------------52.rc--------------------------
#include <windows.h>
#include "5_2.h"
MENU MENU DISCARDABLE
BEGIN
POPUP "文件(&F)"
BEGIN
MENUITEM "新建(&N)\t Ctrl+N", IDM_NEW
MENUITEM " 打开(&0)\T Ctrl+O", IDM_OPEN
MENUITEM " 关闭(&C)", IDM_CLOSE
MENUITEM SEPARATOR
MENUITEM "保存(&S)\t Ctrl+S", IDM_SAVE
MENUITEM "另存为(&A)", IDM_SAVEAS
MENUITEM SEPARATOR
MENUITEM "创建统计计算彩单项(&P)\T Ctrl+P", IDM_ADDPRINTMENU
MENUITEM "删除统计计算彩单项(&D)\T Ctrl+D", IDM_DELPRINTMENU,GRAYED
MENUITEM SEPARATOR
MENUITEM "退出(&X)", IDM_EXIT
END
POPUP "编辑(&E)"
BEGIN
MENUITEM "剪切(&T)\t Ctrl+X", IDM_CUT
MENUITEM "复制(&C)\t Ctrl+C", IDM_COPY
MENUITEM "粘贴(&P)\t Ctrl+V", IDM_PASTE
MENUITEM "删除(&D)\T Del", IDM_DELETE
END
MENUITEM "帮助(&H)", IDM_HELP
END
MENU ACCELERATORS MOVEABLE PURE
BEGIN
"^N", IDM_NEW, ASCII
"^O", IDM_OPEN, ASCII
"^S", IDM_SAVE, ASCII
"^P", IDM_ADDPRINTMENU, ASCII
"^D", IDM_DELPRINTMENU, ASCII
"^X", IDM_CUT, ASCII
"^C", IDM_COPY , ASCII
"^V", IDM_PASTE , ASCII
VK_DELETE, IDM_DELETE, VIRTKEY
END
//-----------------------5.cpp-------------------------
#include <windows.h>
#include <stdlib.h>
#include <string.h>
#include "5_2.h"
HMENU hmenu,hprintmenu;
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevstance,LPSTR lpCmdLine,int nCmdShow)
...........................
帮忙一下,大虾们
早上又重新试了一下,又是没看到运行结果
//------------------5.CPP--------------
#include <windows.h>
#include <stdlib.h>
#include <string.h>
#include "5_2.h"
HMENU hmenu,hprintmenu;
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevstance,LPSTR lpCmdLine,int nCmdShow)
{
HWND hwnd;
MSG Msg;
HACCEL hAccel;
WNDCLASS WndClass;
char lpszMenuName[] = "Menu";
char lpszClassName[] = "彩单";
char lpszTitle[] = "My_Menu_Example";
WndClass.style = 0;
WndClass.cbClsExtra = 0;
WndClass.cbWndExtra = 0;
WndClass.hbrBackground = (HBRUSH)(GetStockObject(WHITE_BRUSH));
WndClass.hCursor = LoadCursor(NULL,IDC_ARROW);
WndClass.hIcon = LoadIcon(NULL,IDI_APPLICATION);
WndClass.hInstance = hInstance;
WndClass.lpfnWndProc = WndProc;
WndClass.lpszClassName = lpszClassName;
WndClass.lpszMenuName = lpszMenuName;
if(!RegisterClass(&WndClass))
{
MessageBeep(0);
return FALSE;
}
hwnd = CreateWindow("5_1",
lpszTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
0,
CW_USEDEFAULT,
0,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
hAccel = LoadAccelerators(hInstance,lpszMenuName);
while(GetMessage(&Msg,NULL,0,0))
{
if(!TranslateAccelerator(hwnd,hAccel,&Msg))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
}
return Msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDM_NEW: break;
case IDM_OPEN: break;
case IDM_SAVE: break;
case IDM_SAVEAS: break;
case IDM_CLOSE :break;
case IDM_ADDPRINTMENU:
hmenu = GetMenu(hwnd);
hprintmenu = CreateMenu();
AppendMenu(hprintmenu,MF_ENABLED,IDM_LINE,"求和");
AppendMenu(hprintmenu,MF_ENABLED,IDM_RECT,"方差");
AppendMenu(hprintmenu,MF_ENABLED,IDM_RRECT,"平均值");
AppendMenu(hprintmenu,MF_ENABLED,IDM_ELLIP,"均方根");
InsertMenu(hmenu,2,MF_POPUP|MF_BYPOSITION,(UINT)hprintmenu,"统计计算(&C)");
EnableMenuItem(hmenu,IDM_ADDPRINTMENU,MF_GRAYED);
EnableMenuItem(hmenu,IDM_DELPRINTMENU,MF_ENABLED);
DrawMenuBar(hwnd);
break;
case IDM_DELPRINTMENU:
DeleteMenu(hmenu,2,MF_BYPOSITION);
EnableMenuItem(hmenu,IDM_ADDPRINTMENU,MF_ENABLED);
EnableMenuItem(hmenu,IDM_DELPRINTMENU,MF_GRAYED);
DrawMenuBar(hwnd);
break;
case IDM_EXIT:
SendMessage(hwnd,WM_DESTROY,0,0);
break;
case IDM_CUT: break;
case IDM_COPY: break;
case IDM_PASTE: break;
case IDM_DELETE: break;
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
return 0;
}
帮我看看吧