Windows API程序设计(窗口创建)
学习目的
1.了解Windows操作系统应用程序的基本概念,win32API函数、消息与事件驱动;
2.掌握WinMain函数的基本框架,窗口定义、窗口创建、消息循环及窗口过程函数;
学习内容
动手写第一个基于windows API 的基于窗体、消息循环、事件驱动的 Windows C语言风格的Windows 程序。
代码
# 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(BLACK_BRUSH);
wndcls.hCursor=LoadCursor