#include <windows.h>
#include <stdio.h>LRESULT CALLBACK WinsunProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lparam
)
int WinApi 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=winsunproc;
wndcls.lpszclassname="weixin2008";
wndcls.lpszmenuname=null;
wndcls.style=cs_hredraw | cs_vredraw;
registerclass(&wndcls);
hwnd hwnd;
hwnd=createwindow("weixin2003","维新学习",ws_overlappedwindow,0.0,600,400,null,null,hinstance,null);
showwindow(hwnd,sw_shownormall);
updatewindow(hwnd); msg msg;
while(getmessage(&msg,null,0,0))
{
Translatemessage(&msg);
dispatchmessage(&msg);
}
return 0;
}
LRESULT CALLBACK WinsunProc(
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,"weixin",0);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"mouse clicked","weixin",0);
HDC hdc;
hdc=GetDC(hwnd);
TextOut(hdc,0.50,"计算机编程语言培训",strlen("计算机编程语言培训"));
releaseDC(hwnd,hdc);
break;
case WM_PAINT:
HDC hdc;
PAINTSTRUCT ps;
hdc=BeginPaint(hwnd,&ps);
Textout(hDC,0,0,"维新培训",strlen("维新培训"));
EndPaint(hwnd,&ps);
break;
case WM_CLOSE:
if(IDYES==MessageBox(hwnd,"是否真的结束?","weixin",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefwindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
} --------------------Configuration: O1 - Win32 Debug--------------------
Compiling...
o1.cpp
E:\VCe\O1\o1.cpp(11) : warning C4518: 'int ' : storage-class or type specifier(s) unexpected here; ignored
E:\VCe\O1\o1.cpp(11) : error C2146: syntax error : missing ';' before identifier 'WinApi'
E:\VCe\O1\o1.cpp(11) : fatal error C1004: unexpected end of file found
Error executing cl.exe.O1.exe - 2 error(s), 1 warning(s)
#include <stdio.h>LRESULT CALLBACK WinsunProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lparam
)
int WinApi 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=winsunproc;
wndcls.lpszclassname="weixin2008";
wndcls.lpszmenuname=null;
wndcls.style=cs_hredraw | cs_vredraw;
registerclass(&wndcls);
hwnd hwnd;
hwnd=createwindow("weixin2003","维新学习",ws_overlappedwindow,0.0,600,400,null,null,hinstance,null);
showwindow(hwnd,sw_shownormall);
updatewindow(hwnd); msg msg;
while(getmessage(&msg,null,0,0))
{
Translatemessage(&msg);
dispatchmessage(&msg);
}
return 0;
}
LRESULT CALLBACK WinsunProc(
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,"weixin",0);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"mouse clicked","weixin",0);
HDC hdc;
hdc=GetDC(hwnd);
TextOut(hdc,0.50,"计算机编程语言培训",strlen("计算机编程语言培训"));
releaseDC(hwnd,hdc);
break;
case WM_PAINT:
HDC hdc;
PAINTSTRUCT ps;
hdc=BeginPaint(hwnd,&ps);
Textout(hDC,0,0,"维新培训",strlen("维新培训"));
EndPaint(hwnd,&ps);
break;
case WM_CLOSE:
if(IDYES==MessageBox(hwnd,"是否真的结束?","weixin",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefwindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
} --------------------Configuration: O1 - Win32 Debug--------------------
Compiling...
o1.cpp
E:\VCe\O1\o1.cpp(11) : warning C4518: 'int ' : storage-class or type specifier(s) unexpected here; ignored
E:\VCe\O1\o1.cpp(11) : error C2146: syntax error : missing ';' before identifier 'WinApi'
E:\VCe\O1\o1.cpp(11) : fatal error C1004: unexpected end of file found
Error executing cl.exe.O1.exe - 2 error(s), 1 warning(s)
解决方案 »
- 请教一个关于vc6的联机编译软件
- 如何更改Microsoft FlexGrid Control表格控件中某一单元格的字体颜色?
- 如何发消息
- 如何将彩色图片在激光打印机上打印出来(打印成灰度)?
- 如何提取一段字符串中的有用信息?最好我们能交流一下QQ17694350
- 救命!PowerDesigner中的新建的第一项business process是干什么的?
- VC 程序运行期间错误提示
- 我在有属性页类继承的对话框中怎么找不到OnChange消息影射函数
- MFC 串口通信问题!
- 基于对话框的程序,怎么使他不在任务栏显示?到底怎么回事呢?
- 试图执行系统不支持的操作??
- 树节点问题,共享一段代码(别人指点下完成的),但是有点问题
努力吧,朋友!
努力吧,朋友!
hwnd=createwindow("weixin2003","维新学习",ws_overlappedwindow,0.0,600,400,null,null,hinstance,null);
showwindow(hwnd,sw_shownormall);
updatewindow(hwnd);
"维新学习",这个逗号写错了