vc CreateWindow创建窗口控件及设置字体
2013-11-24 20:55
387 查看
vc CreateWindow创建窗口控件及设置字体
HWND hBtn, hEdit, hText, hCombBox;
hBtn = CreateWindow( //按钮创建
"button",
"创建的按钮",
WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_CENTER|BS_VCENTER,
100,100,90,28,
m_hWnd,
NULL,
AfxGetInstanceHandle(),
0);
hEdit = CreateWindow( //edit控件
"edit",
"create",
WS_VISIBLE|WS_CHILD|WS_BORDER/*|DT_CENTER*/|DT_VCENTER,
100,70,100,25,
m_hWnd,
NULL,
NULL,
NULL);
HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
::SendMessage(hEdit,WM_SETFONT,(WPARAM)hFont,1); //设置控件字体
::SendMessage(hBtn,WM_SETFONT,(WPARAM)hFont,1);
hCombBox = CreateWindow(
"combobox",
"1",
WS_CHILD|WS_VISIBLE|WS_BORDER|CBS_AUTOHSCROLL|CBS_DROPDOWNLIST,
220, 100, 100, 25,
m_hWnd,
NULL,
NULL,
NULL);
1、字体字号的问题解决方案是:
创建一个自己想要的字体,我直接获取的
HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
然后给Edit发消息
SendMessage(mhAgreementHand,WM_SETFONT,(WPARAM)hNewFont,1);
2、背景色的问题,直接在父窗口的WM_CTLCOLORSTATIC消息里返回一个黑画刷就好了
HBRUSH hbr = (HBRUSH)GetStockObject(BLACK_BRUSH);
return (LRESULT)hbr;
函数体
HWND hBtn, hEdit, hText, hCombBox;
hBtn = CreateWindow( //按钮创建
"button",
"创建的按钮",
WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_CENTER|BS_VCENTER,
100,100,90,28,
m_hWnd,
NULL,
AfxGetInstanceHandle(),
0);
hEdit = CreateWindow( //edit控件
"edit",
"create",
WS_VISIBLE|WS_CHILD|WS_BORDER/*|DT_CENTER*/|DT_VCENTER,
100,70,100,25,
m_hWnd,
NULL,
NULL,
NULL);
HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
::SendMessage(hEdit,WM_SETFONT,(WPARAM)hFont,1); //设置控件字体
::SendMessage(hBtn,WM_SETFONT,(WPARAM)hFont,1);
hCombBox = CreateWindow(
"combobox",
"1",
WS_CHILD|WS_VISIBLE|WS_BORDER|CBS_AUTOHSCROLL|CBS_DROPDOWNLIST,
220, 100, 100, 25,
m_hWnd,
NULL,
NULL,
NULL);
1、字体字号的问题解决方案是:
创建一个自己想要的字体,我直接获取的
HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
然后给Edit发消息
SendMessage(mhAgreementHand,WM_SETFONT,(WPARAM)hNewFont,1);
2、背景色的问题,直接在父窗口的WM_CTLCOLORSTATIC消息里返回一个黑画刷就好了
HBRUSH hbr = (HBRUSH)GetStockObject(BLACK_BRUSH);
return (LRESULT)hbr;
函数体
HWND CreateWindow(
LPCTSTR lpClassName, // pointer to registered class name
LPCTSTR lpWindowName, // pointer to window name
DWORD dwStyle, // window style
int x, // horizontal position of window
int y, // vertical position of window
int nWidth, // window width
int nHeight, // window height
HWND hWndParent, // handle to parent or owner window
HMENU hMenu, // handle to menu or child-window identifier
HANDLE hInstance, // handle to application instance
LPVOID lpParam // pointer to window-creation data
);
相关文章推荐
- OAuth2.0协议学习
- 简易播放器的部分实现
- oracle 10g 学习之服务器端安装(1)
- Basic Data Structures and Algorithms in the Linux kernel
- flip
- 最短路径 (Dijkstra算法)
- HDU 1299 Diophantus of Alexandria
- myeclipse中,copy项目后,访问总是404的解决办法
- cat命令
- POJ 2449Remmarguts' Date (A* 求K短路)
- java学习之路---IO类----字节流
- 诫子书--摘抄
- <转>常规测试方法
- linux下配置JAVA常用的编程环境
- SqlServer2005内存分配
- 2013-2014集训之DP
- cookie带来的致命危险
- 昂达V971四核测评
- 各类 HTTP 返回状态代码详解
- IBM 服务器硬盘只亮黄灯解决方法