Click here to Skip to main content
11,704,509 members (55,282 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ Dev VC10.0
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 4-Apr-11 1:13am
raulz79134
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

<>[]
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 700
1 OriginalGriff 495
2 Andy Lanng 275
3 CPallini 242
4 Maciej Los 235
0 OriginalGriff 8,824
1 Sergey Alexandrovich Kryukov 8,247
2 CPallini 5,189
3 Maciej Los 4,726
4 Mika Wendelius 3,606


Advertise | Privacy | Mobile
Web02 | 2.8.150819.1 | Last Updated 13 Sep 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100