解决方案 »
- 如何在视频中画线或添加文字
- 浏览目录对话框,选择目录,然后在目录下新建文件,如何避免选择光驱等非法的目录????
- SDI里如何在子对话框中调用CMainFrame中的函数?
- VS2005的MFC做的ACTIVEX问题
- 如何查找注册表?
- Modem掉线与信噪比及数据传输速率的分析
- 一个很简单的调用DLL的例子,书上的源程序,但在调试的时候有问题,请帮忙看一下
- FAQ: 如何列出系统中安装的物理硬盘及其接口类型
- 请教一个初级程序的代码规范问题,见代码:
- 求美图秀秀经典Lomo算法
- vc2013+ 未能实例化activex控件 +注册控件成功
- MFC debug assertion failed在ensure(this)处中断
http://blog.csdn.net/yuvmen/article/details/5877271
//代码能运行
#include <windows.h>
#include <stdio.h>LRESULT CALLBACK WinSunProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);int WINAPI WinMain(//入口函数........
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
WNDCLASS wndcls;
wndcls.cbClsExtra=0;
wndcls.cbWndExtra=0;
wndcls.hbrBackground=(HBRUSH)GetStockObject(GRAY_BRUSH);
wndcls.hCursor=LoadCursor(NULL,IDC_ARROW);
wndcls.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndcls.hInstance=hInstance;
wndcls.lpfnWndProc=WinSunProc;
wndcls.lpszClassName="Weixin2003";
wndcls.lpszMenuName=NULL;
wndcls.style=CS_HREDRAW ;
RegisterClass(&wndcls);
HWND hwnd;
hwnd=CreateWindow("Weixin2003","北京维新科学技术培训中\
心",WS_OVERLAPPEDWINDOW &~WS_MAXIMIZEBOX ,
0,0,600,400,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 WinSunProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
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;
}
所以从main开始的写软件思路是错误的。你可以写代码的地方很多,如create消息,initdialog消息等,都可以,不同需求 写的地方不同