Pelles C forum

Pelles C => General discussions => Topic started by: skirby on May 04, 2007, 02:17:55 pm

Title: Multiline Text control and Flat EditBox with border
Post by: skirby 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?
(http://img185.imageshack.us/img185/5589/multilinepi5.th.png) (http://img185.imageshack.us/my.php?image=multilinepi5.png)

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?
(http://img95.imageshack.us/img95/674/flatborderwc1.th.png) (http://img95.imageshack.us/my.php?image=flatborderwc1.png)

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


Thanks in advance and have a nice day.
Title: Re: Multiline Text control and Flat EditBox with border
Post by: JohnF 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?
(http://img185.imageshack.us/img185/5589/multilinepi5.th.png) (http://img185.imageshack.us/my.php?image=multilinepi5.png)

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?
(http://img95.imageshack.us/img95/674/flatborderwc1.th.png) (http://img95.imageshack.us/my.php?image=flatborderwc1.png)

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

Title: Re: Multiline Text control and Flat EditBox with border
Post by: skirby 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.
Title: Re: Multiline Text control and Flat EditBox with border
Post by: JohnF 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

Title: Re: Multiline Text control and Flat EditBox with border
Post by: skirby 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.
(http://img156.imageshack.us/img156/4436/stylesbu2.th.png) (http://img156.imageshack.us/my.php?image=stylesbu2.png)
Title: Re: Multiline Text control and Flat EditBox with border
Post by: JohnF 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
Title: Re: Multiline Text control and Flat EditBox with border
Post by: TimoVJL on May 19, 2007, 11:26:25 am
Create window dynamically with CreateWindow.

Title: Re: Multiline Text control and Flat EditBox with border
Post by: DMac 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
Title: Re: Multiline Text control and Flat EditBox with border
Post by: skirby 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?
Title: Re: Multiline Text control and Flat EditBox with border
Post by: TimoVJL 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);
Title: Re: Multiline Text control and Flat EditBox with border
Post by: skirby 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.
Title: Re: Multiline Text control and Flat EditBox with border
Post by: DMac 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