编辑框控件问题 [英] Edit box control question
问题描述
大家好,
我有一个关于编辑"控制框的问题.是否可以在子窗口中获得这种控件,就像出现在对话框中一样? (在对话框中,编辑框具有3d边框,但是在子窗口中,它没有任何视觉效果.我希望子窗口中也使用相同的编辑框,而不使用MFC,而仅使用Win32本机代码.)
在此先感谢您.
Hi All,
I have a question regarding Edit control box. It is possible to obtain such control in a child window like it appear in a dialog box? (In a dialog box the edit box has 3d border but in a child window it does not have any visual effect. I want the same edit box also in a child window without using MFC but only Win32 native code).
Thanks in advance.
推荐答案
您只需更改窗口样式.您可以使用CreateWindow
设置样式,也可以使用SetWindowLong
函数或SetWindowLongPtr
更改样式.
例如,尝试以下操作:
You just need to change the window styles. You can set the styles with theCreateWindow
or change them with theSetWindowLong
function orSetWindowLongPtr
.
For example, try this:
//get the style
LONG_PTR style = GetWindowLongPtr(hWndEditbox, GWL_STYLE);
//use |= to add a style
style |= WS_BORDER;
//use &= ~(...) to remove a style
style &= ~(WS_BORDER);
//set the new style
SetWindowLongPtr(hWndEditBox, GWL_STYLE, style);
样式 [
Styles[^]
//get the extended style
LONG_PTR exStyle = GetWindowLongPtr(hWndEditbox, GWL_EXSTYLE);
//use |= to add a style
style |= WS_EX_CLIENTEDGE;
//use &= ~(...) to remove a style
style &= ~(WS_EX_CLIENTEDGE);
//set the new style
SetWindowLongPtr(hWndEditBox, GWL_EXSTYLE, exStyle);
扩展样式 [
Extended styles[^]
Try to remove different styles to see which one you don''t want.
您可以通过以下方式进行操作:
You can do it in this way:
HWND hed;
hed = CreateWindowEx
(
0,
__TEXT("EDIT"),
__TEXT(""),
WS_CHILD|WS_CLIPSIBLINGS|ES_AUTOHSCROLL,
rcPos.left,
rcPos.top,
rcPos.right-rcPos.left,
rcPos.bottom-rcPos.top,
hWndParent,
(HMENU)0,
(HINSTANCE)0,
0
);
将帮助手册用于编辑控件样式(ES _...).
祝你好运.
Use the help manual for the edit control styles (ES_...).
Good luck.
<><a href=""></a><a href=""></a>[<a href="" target="_blank"></a>]
这篇关于编辑框控件问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!