?
Solved

Create an Edit box using CreateWindow

Posted on 2003-03-23
10
Medium Priority
?
1,604 Views
Last Modified: 2013-12-03
Hi,

I am trying to create an edit box on a window using the CreateWindow function and the class "Edit". However, the edit box being created is different in looks than edit boxes I create using Dialog Boxes resources. It has no border! I have looked for styles I can put when creating edit boxes but found no style for border, am I missing something? I have had the same problem for buttons, but then only the font was different, and I used a WM_SETFONT message to fix it. Now, the font is wrong too, but I can fix it with a similar message. However, I can't seem to get the border right, please help!

Here is the CreateWindow code:

m_hEditBox = CreateWindow("Edit", "", WS_VISIBLE | WS_CHILD, 5, 5, 100, 100, m_hPlayWindow, NULL, (HINSTANCE)GetWindowLong(m_hPlayWindow, GWL_HINSTANCE), NULL);

Thanks,
Idan.
0
Comment
Question by:IdanM
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 9

Accepted Solution

by:
Priyesh earned 100 total points
ID: 8191074
create using CreateWindowEx and use WS_EX_CLIENT_EDGE style in the dwExStyle member.

or after creating using CreateWindow, change style using

long lStyleEx = GetWindowLong(m_hEditBox, GWL_EX_STYLE) ;
lStyleEx |= WS_EX_CLIENT_EDGE ;
SetWindowLong(m_hEditBox, lStyleEx, GWL_EX_STYLE) ;
0
 

Author Comment

by:IdanM
ID: 8197095
I tried it, but it still doesn't look like edit boxes I create using dialog boxes resources. The border looks different, and the interior is white.
0
 
LVL 1

Expert Comment

by:Koro_das_Master
ID: 8197674
I think WS_BORDER is the style you should put
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 

Author Comment

by:IdanM
ID: 8197752
Nope, doesn't work as well... It's a different kind of border.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8205280
>>The border looks different, and the interior is white.

That's an odd statement, because the interior of ALL edit boxes is white!  (exception: the interior of read-only editboxes is gray)

Here is what you should do:  
In the dialog editor, create an edit box that looks just the way you want it to look.  Then use notepad to open the file named
      <yourProject>.RC
In that file, you will find a section that defines the dialog box and in that section you will find the line that defines the edit box.  The window styles that are displayed there are the same ones that you must use in your CreateWindow call.

-- Dan
0
 

Author Comment

by:IdanM
ID: 8212768
I tried that too, only ES_AUTOHSCROLL shows, and that doesn't do it. I'm thinking maybe it has to do with defines I am missing?
0
 
LVL 49

Assisted Solution

by:DanRollins
DanRollins earned 100 total points
ID: 8212979
Try using Spy++.  Use it to examine the styles of an edit box that you like and an edit box that you don't like.

The WS_EX_CLIENT_EDGE extended style will only be visible if the window is created on a grey background.

And please, why do you think that having the interior be white is unusual or wrong?  There is something that you are not explaining and that is making it difficult to help you.

-- Dan
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question