Click here to Skip to main content
15,868,292 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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.
Posted

You just need to change the window styles. You can set the styles with the CreateWindow or change them with the SetWindowLong function or SetWindowLongPtr.

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.
 
Share this answer
 
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
);

Use the help manual for the edit control styles (ES_...).
Good luck.
 
Share this answer
 
<><a href=""></a><a href=""></a>[<a href="" target="_blank"></a>]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900