资源简介
演示了常见窗体和对话框的产生原理,演示了控件的WM_DRAWITEM消息重绘和使用窗体子类化控件重绘。
代码片段和文件信息
#include
#include “resource.h“
LRESULT CALLBACK WndProc (HWND hwnd UINT message WPARAM wParam LPARAM lParam);
BOOL CALLBACK TemplateProc(HWND hDlg UINT message WPARAM wParam LPARAM lParam);
BOOL CALLBACK CreateProc(HWND hDlg UINT message WPARAM wParam LPARAM lParam);
BOOL CALLBACK SelfDrawProc(HWND hDlg UINT message WPARAM wParam LPARAM lParam);
BOOL CALLBACK SubclassProc(HWND hDlg UINT message WPARAM wParam LPARAM lParam);
LRESULT CALLBACK BtnProc (HWND hwnd UINT message WPARAM wParam LPARAM lParam);
HWND hDlgModeless=NULL;//保存全局非模态对话框
int WINAPI WinMain (HINSTANCE hInstance HINSTANCE hPrevInstance PSTR szCmdLine int iCmdShow)
{
static TCHAR szAppName[] = TEXT (“SDKButton“);
HWND hwnd;
MSG msg;
WNDCLASSEX wndclassex = {0};
wndclassex.cbSize = sizeof(WNDCLASSEX);
wndclassex.style = CS_HREDRAW | CS_VREDRAW;
wndclassex.lpfnWndProc = WndProc;
wndclassex.cbClsExtra = 0;
wndclassex.cbWndExtra = 0;
wndclassex.hInstance = hInstance;
wndclassex.hIcon = LoadIcon (NULL IDI_APPLICATION);
wndclassex.hCursor = LoadCursor (NULL IDC_ARROW);
wndclassex.hbrBackground = (HBRUSH) GetStockobject (WHITE_BRUSH);
wndclassex.lpszMenuName = MAKEINTRESOURCE(IDR_MAINMENU);
wndclassex.lpszClassName = szAppName;
wndclassex.hIconSm = wndclassex.hIcon;
if (!RegisterClassEx (&wndclassex))
{
MessageBox (NULL TEXT (“RegisterClassEx failed!“) szAppName MB_IConerror);
return 0;
}
hwnd = CreateWindowEx (WS_EX_OVERLAPPEDWINDOW
szAppName
TEXT (“SDK Button测试“)
WS_OVERLAPPEDWINDOW
CW_USEDEFAULT
CW_USEDEFAULT
CW_USEDEFAULT
CW_USEDEFAULT
NULL
NULL
hInstance
NULL);
ShowWindow (hwnd iCmdShow);
UpdateWindow (hwnd);
while (GetMessage (&msg NULL 0 0))
{
//注意非模态对话框消息由主窗口分发
if (hDlgModeless == NULL || !IsDialogMessage(hDlgModeless &msg))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
}
return msg.wParam;
}
LRESULT CALLBACK WndProc (HWND hwnd UINT message WPARAM wParam LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
static RECT rect;
TCHAR szDrawText[] = TEXT(“欢迎访问我的博客http://blog.csdn.net/wenzhou1219“);
switch (message)
{
case WM_SIZE:
GetClientRect(hwnd &rect);
return (0);
case WM_PAINT:
hdc = BeginPaint (hwnd &ps);
DrawText(hdc szDrawText -1 &rect DT_CENTER | DT_SINGLELINE | DT_VCENTER);
EndPaint (hwnd &ps);
return (0);
case WM_COMMAND:
//分发菜单
switch (LOWORD(wParam))
{
case IDM_TEMPLATE:
DialogBox(GetWindowLong(hwnd GWL_HINSTAN
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2013-12-29 13:34 VS2008_WIN32_SDK按钮\
文件 893 2013-12-27 21:03 VS2008_WIN32_SDK按钮\20131227始_VS2008_WIN32_SDK按钮.sln
文件 14336 2013-12-29 13:33 VS2008_WIN32_SDK按钮\20131227始_VS2008_WIN32_SDK按钮.suo
目录 0 2013-12-29 13:34 VS2008_WIN32_SDK按钮\SDKButton\
文件 12915 2013-12-29 13:33 VS2008_WIN32_SDK按钮\SDKButton\Main.c
目录 0 2013-12-29 13:34 VS2008_WIN32_SDK按钮\SDKButton\res\
文件 1149 2013-12-28 11:49 VS2008_WIN32_SDK按钮\SDKButton\resource.h
文件 1398 2013-12-27 22:32 VS2008_WIN32_SDK按钮\SDKButton\res\image1d.bmp
文件 1398 2013-12-27 22:32 VS2008_WIN32_SDK按钮\SDKButton\res\image1f.bmp
文件 1398 2013-12-27 22:32 VS2008_WIN32_SDK按钮\SDKButton\res\image1u.bmp
文件 2038 2013-12-27 22:32 VS2008_WIN32_SDK按钮\SDKButton\res\image2d.bmp
文件 2038 2013-12-27 22:32 VS2008_WIN32_SDK按钮\SDKButton\res\image2f.bmp
文件 2038 2013-12-27 22:32 VS2008_WIN32_SDK按钮\SDKButton\res\image2u.bmp
文件 4487 2013-12-28 17:31 VS2008_WIN32_SDK按钮\SDKButton\SDKButton.rc
文件 4446 2013-12-27 22:35 VS2008_WIN32_SDK按钮\SDKButton\SDKButton.vcproj
文件 1417 2013-12-29 13:33 VS2008_WIN32_SDK按钮\SDKButton\SDKButton.vcproj.wenzhou-PC.wenzhou.user
- 上一篇:博客-MIL基础概念和开发步骤学习资源
- 下一篇:IR2110驱动电路的优化设计
相关资源
- 美松打印机SDK MsPrintSDK-Demo-DLL-CShare-
- S32K144 和S32K SDK开发入门培训.pdf
- 虚拟摄像头VCam开发SDK
- 整理的ModbusProtocol SDK开发包
- WinCE_6.0_中文SDK(仿真器模拟器)
- eetop.cn_eetop.cn_hfss15_win32crack
- nginx-rtmp-win32-master.rar
- silverlight4 SDK
- N76E003开发资料最新SDK参考代码
- rockchip rv1108和rk3288资料,淘宝28买的
- 海康摄像头+web3.0开发包SDK的demo
- 海康SDK delphi demo
- 海康sdk说明书 二次开发参考
- 企业微信JS-SDK调试工具
- 人脸识别开源SDK源码
- NVIDIAOpticalFlowSDK-79c6cee80a2df9a196f20afd6
- delphi百度人脸识别离线SDK demo
- sunxi-tools-win32-support_f1c100s_32M(32M fl
- 汉王人脸通sdk v3.0 delphi demo
- 汉王考勤机开发指南HANVON SDK 20141119
- 撸大师死灰复燃SDK,可常驻后台运行
- 精伦电子开发包最新开发包带网页插
- IDCardReader SDK.rar
- ipscan-win32
- 精伦电子idr210 sdk
- ffplay_win32
- 光阵通用高拍仪控件
- oaid_sdk_1.0.23.zip200578
- Nokia SDK 开发模拟器
- x86-sdk25-v89-x86-64 xp框架
评论
共有 条评论