文章来源:http://blog.csdn.net/achellies/article/details/4273035
注:转载文章仅是为了方便自己保存学习来提升自我。
此为我程序中的一个类,本用于WinCE,但在桌面系统上也同样适用!
使用方法(在WM_INITDIALOG或WM_CREATE消息中加入):
CWindowAnchor::BeginControlBound(hwnd)
手动调整控件位置:
CWindowAnchor::AddControl(hwnd,IDC_STATIC1,
&
WindowAnchorInfo(WAT_LEFT
|
WAT_TOP,
2
,
8
,
4
,
10
));
CWindowAnchor::AddControl(hwnd,IDC_STATIC1,
&
WindowAnchorInfo(WAT_LEFT
|
WAT_TOP
|
WAT_RIGHT,
2
,
20
,
4
,
10
));
CWindowAnchor::AddControl(hwnd,IDC_STATIC1,
&
WindowAnchorInfo(WAT_LEFT
|
WAT_TOP,
2
,
8
,
40
,
10
));
自动调整控件位置(跟据设计时资源文件中控件的大小及位置):
CWindowAnchor::AddControl(hwnd,IDC_STATIC1,
&
WindowAnchorInfo(WAT_LEFT
|
WAT_TOP));
CWindowAnchor::AddControl(hwnd,IDC_STATIC1,
&
WindowAnchorInfo(WAT_LEFT
|
WAT_TOP
|
WAT_RIGHT));
响应WM_SIZE消息:
case
WM_SIZE:
return
HANDLE_WM_SIZE(hwndDlg,wParam,lParam,CWindowAnchor::OnSize);
响应WM_DESTROY消息:
CWindowAnchor::EndControlBound(hwnd);
代码:
#pragma once
#include