c语言程序设计基础
char *hello="你好,这里是窗口演示程序!"; HDC hdc; // 说明设备描述句柄 PAINTSTRUCT ps; //说明用来绘制用户程序客户区所需信息的结构 //多分支结构用来根据消息的不同值进行相应的处理 switch(message) { 完整的源程序清单 case WM_PAINT: //此消息要在用户的客户区进行绘图输出 hdc=BeginPaint(hWnd,&ps); TextOut(hdc,120,100,hello,lstrlen(hello)); EndPaint(hWnd,&ps); break; case WM_DESTROY: //此消息要结束窗口过程 PostQuitMessage(0); break; default: // 默认情况下,系统处理余下的消息 return (DefWindowProc(hWnd,message,wParam,lParam)); } UpdateWindow发出 WM_PAINT An application sends the WM_PAINT message when the system or another application makes a request to paint a portion of an application's window. The message is sent when the UpdateWindow or RedrawWindow function is called, or by the DispatchMessage function when the application obtains a WM_PAINT message by using the GetMessage or PeekMessage function. WM_PAINT hdc = (HDC) wParam; // the device context to draw in Parameters hdc Handle to the device context to draw in. If this parameter is NULL, use the default device context. This parameter is used by some common controls to enable drawing in a device context other than the default device context. Other windows can safely ignore this parameter. Return Values An application returns zero if it processes this message. wcex.style =CS_HREDRAW|CS_VREDRAW; // 窗口风格 wcex.lpfnWndProc=(WNDPROC)MainWndProc; // 窗口函数过程 wcex.cbClsExtra =0; // 类变量占用的附属存储空间 wcex.cbWndExtra =0; // 实例变量占用的附属存储空间 wcex.hInstance =hInstance; // 模块句柄,用于系统操作本程序 wcex.hIcon =LoadIcon(NULL, IDI_APPLICATION); // 图标对象句柄 wcex.hCursor =LoadCursor(NULL,IDC_ARROW); // 光标对象句柄 wcex.hbrBackground =GetStockObject(WHITE_BRUSH); // 刷子对象 wcex.lpszMenuName = NULL; // 菜章对象字符串 wcex.lpszClassName ="DemoWClass"; // 标识类名字的串 ”DIALOGMENU” 将菜单标识符在定义窗口类时挂上 ”DIALOGMENU” ABOUTBOX DIALOG DISCARDABLE 20, 25, 124, 77 STYLE DS_MODALFRAME | DS_3DLOOK | DS_CONTRO