// 2.cpp : Defines the entry point for the application.
//#include "stdafx.h"
//function=prototype
LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
WNDCLASS wc;
MSG msg;
wc.style =CS_VREDRAW |CS_HREDRAW;
wc.lpfnWndProc =WndProc;
wc.cbClsExtra =wc.cbWndExtra =0;
wc.hInstance =hInstance;
wc.hIcon =NULL;
wc.hCursor =NULL;
wc.lpszMenuName =NULL;
wc.hbrBackground =NULL;
wc.lpszClassName ="demo"; HWND hWnd;
hWnd=::CreateWindow("demo","demo",WS_OVERLAPPEDWINDOW,0,0,50,50,NULL,NULL,hInstance,NULL);
if (hWnd==NULL)
{
return FALSE;
} ::RegisterClass(&wc);
::ShowWindow(hWnd,nCmdShow);
::UpdateWindow(hWnd); while(TRUE)
{
if (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
{
if (::GetMessage(&msg,NULL,0,0)==0) return (int)msg.wParam;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
::WaitMessage();
}
return 0;
}LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch (uMsg)
{
case WM_KEYDOWN:
::PostMessage(hWnd,WM_CLOSE,0,0);
return 0L;
case WM_DESTROY:
::PostQuitMessage(0);
return 0L;
}
return ::DefWindowProc(hWnd,uMsg,wParam,lParam);
}
//#include "stdafx.h"
//function=prototype
LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
WNDCLASS wc;
MSG msg;
wc.style =CS_VREDRAW |CS_HREDRAW;
wc.lpfnWndProc =WndProc;
wc.cbClsExtra =wc.cbWndExtra =0;
wc.hInstance =hInstance;
wc.hIcon =NULL;
wc.hCursor =NULL;
wc.lpszMenuName =NULL;
wc.hbrBackground =NULL;
wc.lpszClassName ="demo"; HWND hWnd;
hWnd=::CreateWindow("demo","demo",WS_OVERLAPPEDWINDOW,0,0,50,50,NULL,NULL,hInstance,NULL);
if (hWnd==NULL)
{
return FALSE;
} ::RegisterClass(&wc);
::ShowWindow(hWnd,nCmdShow);
::UpdateWindow(hWnd); while(TRUE)
{
if (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
{
if (::GetMessage(&msg,NULL,0,0)==0) return (int)msg.wParam;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
::WaitMessage();
}
return 0;
}LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch (uMsg)
{
case WM_KEYDOWN:
::PostMessage(hWnd,WM_CLOSE,0,0);
return 0L;
case WM_DESTROY:
::PostQuitMessage(0);
return 0L;
}
return ::DefWindowProc(hWnd,uMsg,wParam,lParam);
}
解决方案 »
- 用MOXA串口卡设置RS422标准接收数据,收不到,高分求助!!!
- 请教为什么在WinCE下,如下代码SetPixel总是得到同一种颜色?
- IMPLEMENT_SERIAL(class_name, base_class_name, wSchema )宏的第三个参数如何定值?
- os是win7,word2007的打开文件对话框的消息问题
- windows 下socket产生的位置对 ”动态库“产生的影响(棘手)
- 不明白为什么会出现这样的错误
- 别的不说,光是看代码编辑器,我就觉得VC不行。
- 我用MFC生成了一个单文本框的程序,如何给主界面上加上滑动条?
- 有关COM,DCOM,COM+ 的初级问题,请各位大侠指点指点
- DLL的问题,请各位高手赐教
- 请问:能通过编译,但程序不能显示结果的原因?
- 我该如何才能用CPropertSheet做个主界面?
console main wmian
windows WinMain wWinMainUNICODE & MFC wWinMainCRTStartup
::RegisterClass(&wc);
HWND hWnd;
hWnd=::CreateWindow("demo","demo",WS_OVERLAPPEDWINDOW,0,0,50,50,NULL,NULL,hInstance,NULL);
if (hWnd==NULL)
{
return FALSE;
}