NO

Author Topic: Multiline Text control and Flat EditBox with border  (Read 7298 times)

skirby

  • Guest
Multiline Text control and Flat EditBox with border
« on: May 04, 2007, 02:17:55 PM »
Hello,

Do you know if there is a way to make a multiline Text control from dialog editor?


I believed that \r\n in the Text property of a Text/Label control should work.


Also, is it possible to create a flat EditBox control with border like ResED (a ressource editor from KetilO) does?


I am only able to get 3D-look control with Pelles C dialog editor.


Thanks in advance and have a nice day.
« Last Edit: May 04, 2007, 03:02:16 PM by skirby »

JohnF

  • Guest
Re: Multiline Text control and Flat EditBox with border
« Reply #1 on: May 04, 2007, 04:39:41 PM »
Hello,

Do you know if there is a way to make a multiline Text control from dialog editor?


I believed that \r\n in the Text property of a Text/Label control should work.


Also, is it possible to create a flat EditBox control with border like ResED (a ressource editor from KetilO) does?


I am only able to get 3D-look control with Pelles C dialog editor.


Thanks in advance and have a nice day.

1. Select Multiline in one of the properties.

2. \r\n works ok.

3. You can experiment with all the styles by looking up the Edit control on MSDN and entering these styles by hand in the .RC file.

John


skirby

  • Guest
Re: Multiline Text control and Flat EditBox with border
« Reply #2 on: May 17, 2007, 10:53:31 PM »
Hello JohnF,

Sorry for the delay.

Quote
1. Select Multiline in one of the properties.

2. \r\n works ok.
It does not work for me  ???

I have written a simple example.
You can find it here in attached file.

It would be nice if you could modify it in order to make it works  :)

Quote
3. You can experiment with all the styles by looking up the Edit control on MSDN and entering these styles by hand in the .RC file.
I have done a test with GCC and a dialog box created with ResED and I have the same result with Pelles C  :'(
So, what is the way to have a flat EditBox control ?
What window style should I use to have a flat control with a thin black border like on the picture below?

Thanks and have a nice day.

JohnF

  • Guest
Re: Multiline Text control and Flat EditBox with border
« Reply #3 on: May 18, 2007, 06:42:34 AM »
You are using

CONTROL "Hello.\\r\\nHow are you\?"

Try

CONTROL "Hello.\r\nHow are you\?"

Does ResED show you the window styles?

John


skirby

  • Guest
Re: Multiline Text control and Flat EditBox with border
« Reply #4 on: May 18, 2007, 09:28:16 PM »
You are using

CONTROL "Hello.\\r\\nHow are you\?"

Try

CONTROL "Hello.\r\nHow are you\?"

I am using \\r\\n because Pelles C add \ character.
I have used \r\n in the resource editor but when I save the file, Pelles C add a character \ itself.

I don't know if it is a bug but I have to modify the .rc file manually in order to make a carriage return in my edit control.

Does ResED show you the window styles?
Yes as you can see.
But I don't know what style I have to use in order to make a flat control with a thin black border.

JohnF

  • Guest
Re: Multiline Text control and Flat EditBox with border
« Reply #5 on: May 18, 2007, 10:52:58 PM »
Just adjust that string manually.

If ResEd is showing the correct styles to create the border you want you can use the styles shown, if it doesn't work then ResEd is doing something strange.

I've not been able to create the border you want either.

John
« Last Edit: May 18, 2007, 11:02:23 PM by JohnF »

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: Multiline Text control and Flat EditBox with border
« Reply #6 on: May 19, 2007, 11:26:25 AM »
Create window dynamically with CreateWindow.

May the source be with you

Offline DMac

  • Member
  • *
  • Posts: 272
Re: Multiline Text control and Flat EditBox with border
« Reply #7 on: May 21, 2007, 01:37:34 AM »
Hello Skirby,

I have put together a small demo that I think answers all of the questions here.

Before compiling the project and running it please have a look at the dialog in the resource editor.  You will see two static text controls and one edit box.  Next, run the project and notice the difference.  After this, have a look at the code.  Notice the difference between the text appended to the static versus the edit box.  The Method MakeFlat() illustrates how to modify the appearance of any control by subclassing and handling the paint event.

Regards,
David MacDermot
No one cares how much you know,
until they know how much you care.

skirby

  • Guest
Re: Multiline Text control and Flat EditBox with border
« Reply #8 on: May 23, 2007, 11:48:34 PM »
Hello DMac,

Your example works very well but in order to create a simple Windows control, it is rather complicated.

Does somebody know why the static windows style in a dialog box is bordered?

Otherwise, I have written another example (see attached file)
In this example, I have created a Window static child control with CreateWIndow.
It works very well but the font size and style of the control is defined by Windows and I have to create a font, ...
So, I have tried to change the window style with SetWindowLong but without success.

Is it possible to change the style of a window if this window is already created?

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: Multiline Text control and Flat EditBox with border
« Reply #9 on: May 24, 2007, 07:06:47 AM »
For that font:
Code: [Select]
HFONT hFont = GetStockObject(DEFAULT_GUI_FONT);
SendMessage(hwnd, WM_SETFONT, (WPARAM)hFont, TRUE);
May the source be with you

skirby

  • Guest
Re: Multiline Text control and Flat EditBox with border
« Reply #10 on: May 30, 2007, 01:52:30 PM »
Thanks a lot timovjl for font informations.

After several tests, I can modify the style of any window created with CreateWindow/CreateWindowEx and created from a resource file.

Now, I would like to do two things:
1./ give a flat black border to a window created from resource file
2./ give a Edit box style to a window create from CreateWindow function

You can find my project in attached file

To finish, what is the way to remove the ? from system menu on my dialog box?

I hope you could help me.

Thanks and have a nice day.

Offline DMac

  • Member
  • *
  • Posts: 272
Re: Multiline Text control and Flat EditBox with border
« Reply #11 on: May 30, 2007, 09:40:26 PM »
Hello Skirby,

Quote
Your example works very well but in order to create a simple Windows control, it is rather complicated.

It is true that the method initially is a bit more technical.  However, As you see in the example, the application is quite simple.  Just add the code module to your project, include the header and use the function MakeFlat() wherever you need to modify these controls. 8)

I am not sure why dialog components created from resources do not respond well to SetWindowLong(),  I have only been successfull utilizing GWL_USERDATA, and GWL_WINDPROC, and oring SS_NOTIFY to the style property.  It may be that they are initially created by a process running on a seperate thread. :-\

I downloaded your example code and modified it to do the things that you wanted it to do.  I took a queue from the microsoft sdk dialog editor.  It does not give you the option to put a border arround a static label instead you must draw a border around it using a rectangle.

In the example I placed a bitmap over the label and configured it to be a black rectangle.  I default the visibility to FALSE, pressing the dialog button toggles the "border" on and off.  There is a little more work with this method getting the border placed so that the text of the label does not touch the rectangle.  Also if there is any moving / sizing going on you will have to handle both objects in your size proc.

Regards,
DMac
No one cares how much you know,
until they know how much you care.