论坛: 编程破解 标题: 找一个VC++的程序错误 复制本贴地址    
作者: suphen [suphen]       登录
#include <windows.h>
#include <stdio.h>

//窗口过程涵数的申明
LRESULT CALLBACK WinPinkeProc(
  HWND hwnd,
  UINT uMsg,
  WPARAM wParam,
  LPARAM lParam
);

//WinMain涵数
int WinMain(
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nCmdShow
)
{
          //创建窗口类
WNDCLASS wndcls;
wndcls.cbClsExtra=0;
wndcls.cbWndExtra=0;
wndcls.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
wndcls.hCursor=LoadCursor(NULL,IDC_CROSS);
wndcls.hIcon=LoadIcon(NULL,IDI_ERROR);
wndcls.hInstance=hInstance;
wndcls.lpfnWndProc=WinPinkeProc;
wndcls.lpszClassName="FPK2003";
wndcls.lpszMenuName=NULL;
wndcls.style=CS_HREDRAW | CS_VREDRAW;
          //注册窗口类
RegisterClass(&wndcls);

HWND hwnd;
hwnd=CreateWindow("FPK2003","My Fiest VC++",WS_OVERLAPPEDWINDOW,100,100,400,200,
NULL,NULL,hInstance,NULL);
          //显示和更新窗口
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);
          //消息循环
MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}

LRESULT CALLBACK WinPinkeProc(
  HWND hwnd,
  UINT uMsg,
  WPARAM wParam,
  LPARAM lParam
)
{
switch(uMsg)
{
case WM_CHAR:
char szChar[20];
sprintf(szChar,"char is %d",wParam);
MessageBox(hwnd,szChar,"Pinke",0);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"LEFT BUTTONDOWN","Pinek",0);
HDC hdc;
hdc=GetDC(hwnd);
TextOut(hdc,10,10,"My First VC++ Program!",strlen("My First VC++ Program!"));
ReleaseDC(hwnd,hdc);
break;
case WM_PAINT:
HDC hDC;
PAINTSTRUCT ps;
hDC=BeginPaint(hwnd,&ps);
TextOut(hDC,10,50,"VC++",strlen("VC++"));
EndPaint(hwnd,&ps);
break;
case WM_CLOSE:
if(IDYES==MessageBox(hwnd,"是否真的要退出?","Pinke",MB_YESNO));
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}

在VC++的WIN32 Application 下的    修改过了
可以正常运行~~~


[此贴被 suphen(suphen) 在 07月19日15时01分 编辑过]

地主 发表时间: 05-07-18 17:41

回复: windflower [windflower]   论坛用户   登录
你把调试错误信息帖上来
我估计是回调函数在使用时,参数不必再加上类型在前
LRESULT CALLBACK WinPinkeProc(
  HWND hwnd,
  UINT uMsg,
  WPARAM wParam,
  LPARAM lParam
)
而是
LRESULT CALLBACK WinPinkeProc( hwnd, uMsg, wParam, lParam )


B1层 发表时间: 05-07-18 20:30

回复: suphen [suphen]      登录
Compiling...
1.cpp
D:\我的音乐\Lesson1\1\1.cpp(19) : error C2731: 'WinMain' : function cannot be overloaded
        D:\我的音乐\Lesson1\1\1.cpp(13) : see declaration of 'WinMain'
D:\我的音乐\Lesson1\1\1.cpp(81) : warning C4390: ';' : empty controlled statement found; is this the intent?
Error executing cl.exe.

1.obj - 1 error(s), 1 warning(s)

[此贴被 suphen(suphen) 在 07月19日01时08分 编辑过]

B2层 发表时间: 05-07-19 00:05

回复: suphen [suphen]      登录
WinMain涵数到底怎么回事呀 

B3层 发表时间: 05-07-19 01:03

回复: suphen [suphen]      登录
int WinMain(
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nCmdShow
)

定义问题 已解决~~

B4层 发表时间: 05-07-19 14:56

论坛: 编程破解

20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon

粤ICP备05087286号