?
Solved

Create an Edit box using CreateWindow

Posted on 2003-03-23
10
Medium Priority
?
1,606 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
7 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
Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

 

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

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

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

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
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…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

571 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