| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 608 人关注过本帖
标题:为什么编译同不过?
只看楼主 加入收藏
fcc1234
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2005-3-30
收藏
 问题点数:0 回复次数:0 
为什么编译同不过?

#include<windows.h> #include"resource.h"

#define ID_TIEMR 1

LRESULT CALLBACK WndProc(HWND,UINT, WPARAM, LPARAM);

TCHAR szAppName[]= TEXT("MenuDemo");

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { HWND hwnd; MSG msg; WNDCLASS wndclass;

wndclass.style =CS_HREDRAW|CS_VREDRAW; wndclass.lpfnWndProc =WndProc; wndclass.cbClsExtra =0; wndclass.cbWndExtra =0; wndclass.hInstance =hInstance; wndclass.hIcon =LoadIcon(NULL, IDI_APPLICATION); wndclass.hCursor =LoadCursor(NULL, IDC_ARROW); wndclass.hbrBackground =(HBRUSH)GetStockObject(WHITE_BRUSH); wndclass.lpszMenuName =szAppName; wndclass.lpszClassName =szAppName;

if(!RegisterClass(&wndclass)) { MessageBox(NULL, TEXT("This program requires Windows NT!"), szAppName,MB_ICONERROR); return 0; }

hwnd=CreateWindow(szAppName, TEXT("Menu Demonstration"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,CW_USEDEFAULT, CW_USEDEFAULT,CW_USEDEFAULT, NULL, NULL,hInstance,NULL); ShowWindow(hwnd,iCmdShow); UpdateWindow(hwnd);

while(GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; }

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static int iColor[5]={WHITE_BRUSH, LTGRAY_BRUSH, GRAY_BRUSH, DKGRAY_BRUSH, BLACK_BRUSH};

static int iSelection= IDM_BKGND_WHITE; HMENU hMenu;

switch(message) { case WM_COMMAND: hMenu=GetMenu(hwnd);

switch(LOWORD(wParam)) { case IDM_FILE_NEW: case IDM_FILE_OPEN: case IDM_FILE_SAVE: case IDM_FILE_SAVE_AS: MessageBeep(0); return 0;

case IDM_APP_EXIT: SendMessage(hwnd, WM_CLOSE,0, 0); return 0;

case IDM_EDIT_UND case IDM_EDIT_CUT: case IDM_EDIT_COPY: case IDM_EDIT_PASTE: case IDM_EDIT_CLEAR: MessageBeep(0); return 0;

case IDM_BKGND_WHITE: case IDM_BKGND_LTGRAY: case IDM_BKGND_GRAY: case IDM_BKGND_DKGRAY: case IDN_BKGND_BLACK:

CheckMenuItem(hMenu,iSelection, MF_UNCHECKED); iSelection = LOWORD(wParam); ChenkMenuItem(hMenu, iSelection, MF_UNCHECKED);

SetClassLong(hwnd, GCL_HBRBACKGROUND,(LONG) GetStockObject (idColor[LOWORD(wParam)-IDM_BKGND_WHITE]));

InvalidateRect(hwnd,NULL,TRUE); return 0;

case IDM_TIMER_START: if(SetTimer(hwnd,ID_TIMER,1000, NULL) { EnableMenuItem(hMenu, IDM_TIMER_START, MF_GRAYED); EnableMenuItem(hMenu, IDM_TIMER_STOP, MF_ENABLED); } return 0;

case IDM_TIMER_STOP: KillTimer(hwnd, ID_TIMER); EnableMenuItem(hMenu, IDM_TIMER_STOP, MF_ENABLED); EnableMenuItem(hMenu, IDM_TIMER_STOP, MF_GRAYED); return 0;

case IDM_APP_ABOUT: MessageBox(hwnd,TEXT("Menu Demonstrstion Program\n") TEXT("(c) Charles Petzold, 1998"), szAppName,MB_ICONEXCLAMATION|ME_OK); return 0; case IDM_APP_HELP: MessageBox(hend, TEXT("Help not yet implemented"), szAppName,MB_ICONEXCLAMATION|ME_OK); return 0; } break;

case WM_TIMER: MessageBeep(0); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hwnd, message, wParam, lParam); }

搜索更多相关主题的帖子: 编译 
2005-07-30 23:40
快速回复:为什么编译同不过?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022623 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved