Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2003-06

Bug in lcl resizing code and patch for win32

16 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Karl Brandt

Sometime ago i sent a patch fixing the forms sizes under win32 and got surprised to see that things were messed.
So i did the job again!

Attached is a patch that makes the form sizes correct. But when we move or resize the window, strange effects occurs. This happens because the LCL in TWinControl.InitializeWnd, sends a LM_SETSIZE message with the Width and Height parameters (which the interface expect) while in TWinControl.RealizeBounds it sends the same message with the Bottom-Right coordinates.

I hope someone fix this.

BTW. During the last months, i didn't worked with lcl/win32 because of lack of time. Now i want to spend some time with it :-)

karl

-------------- next part --------------
A non-text attachment was scrubbed...
Name: bin00038.bin
Type: application/octet-stream
Size: 779 bytes
Desc: "size2diff.zip"
Url : http://localhost/pipermail/lazarus/attachments/20030628/c30489a6/bin00038.bin

Reply by email

Micha Nelissen
to Karl Brandt
Karl Brandt wrote 5 lines
Sometime ago i sent a patch fixing the forms sizes under win32 and got surprised to see that things were messed. So i did the job again! Attached is a patch that makes the form sizes correct.

What was wrong? Those messages should send the same information as you retrieve via GetClientRect/GetWindowRect.

Are the form sizes really correct for you? If I move the form the size is usually Left+Width instead of Width, etc.

Show quoted text 7 lines
But when we move or resize the window, strange effects occurs. This happens because the LCL in TWinControl.InitializeWnd, sends a LM_SETSIZE message with the Width and Height parameters (which the interface expect) while in TWinControl.RealizeBounds it sends the same message with the Bottom-Right coordinates. I hope someone fix this.

Yes...this is the problem I'm having too (and trying to fix).

Regards,

Micha.

Reply by email

Mattias Gaertner
to Karl Brandt: Sometime ago i sent a patch fixing the forms sizes under win32 and got surprised to see…
Show quoted text 10 lines
Sometime ago i sent a patch fixing the forms sizes under win32 and got surprised to see that things were messed. So i did the job again! Attached is a patch that makes the form sizes correct. But when we move or resize the window, strange effects occurs. This happens because the LCL in TWinControl.InitializeWnd, sends a LM_SETSIZE message with the Width and Height parameters (which the interface expect) while in TWinControl.RealizeBounds it sends the same message with the Bottom-Right coordinates.

?
Both creates the rectangle with Bounds(Left,Top,Width,Height). So both should be right,bottom.
I applied the patch.

I hope someone fix this. BTW. During the last months, i didn't worked with lcl/win32 because of lack of time. Now i want to spend some time with it :-)

Mattias

Reply by email

Micha Nelissen
to Karl Brandt: Sometime ago i sent a patch fixing the forms sizes under win32 and got surprised to see…
Mattias Gaertner wrote 33 lines
On Sat, 28 Jun 2003 21:45:04 +0200 "Micha Nelissen" wrote: > Karl Brandt wrote: >> Micha Nelissen wrote: >> >>> Karl Brandt wrote: >>> >>> >>>> Sometime ago i sent a patch fixing the forms sizes under win32 and >>>> got surprised to see that things were messed. >>>> So i did the job again! >>>> >>>> Attached is a patch that makes the form sizes correct. >>>> >>>> >>> >>> What was wrong? Those messages should send the same information as >>> you retrieve via GetClientRect/GetWindowRect. >>> >>> >> In LCL, WindowSize = ClientSize while windows and VCL expect/returns >> diferent sizes, so is needed some adjustments. > > That does not explain the WM_MOVE change. The WM_SIZE is defined as > such: > > nWidth = LOWORD(lParam); // width of client area > nHeight = HIWORD(lParam); // height of client area Ehh. At the moment the LCL thinks that WM_SIZE contains the bounds of a control. The ClientArea can be smaller (TGroupBox, TForm with a menu) or in some cases bigger (TScrollBox).

?? In TControl.WMSize it tries to do SetBounds with the Width and Height parameters...SetBounds in the LCL is defined as clientwidth and height, no?

Where and how is the difference made between ClientHeight and Height and ClientWidth and Width?

Micha.

Reply by email

Karl Brandt
to Karl Brandt: Sometime ago i sent a patch fixing the forms sizes under win32 and got surprised to see…
Mattias Gaertner wrote 48 lines
On Sat, 28 Jun 2003 21:45:04 +0200 "Micha Nelissen" wrote: >Karl Brandt wrote: > > >>Micha Nelissen wrote: >> >> >> >>>Karl Brandt wrote: >>> >>> >>> >>> >>>>Sometime ago i sent a patch fixing the forms sizes under win32 and >>>>got surprised to see that things were messed. >>>>So i did the job again! >>>> >>>>Attached is a patch that makes the form sizes correct. >>>> >>>> >>>> >>>> >>>What was wrong? Those messages should send the same information as >>>you retrieve via GetClientRect/GetWindowRect. >>> >>> >>> >>> >>In LCL, WindowSize = ClientSize while windows and VCL expect/returns >>diferent sizes, so is needed some adjustments. >> >> >That does not explain the WM_MOVE change. The WM_SIZE is defined as such: > >nWidth = LOWORD(lParam); // width of client area >nHeight = HIWORD(lParam); // height of client area > > Ehh. At the moment the LCL thinks that WM_SIZE contains the bounds of a control. The ClientArea can be smaller (TGroupBox, TForm with a menu) or in some cases bigger (TScrollBox).

These cases are handled in LM_SETSIZE processing

Show quoted text 7 lines
>Testing shows that those changes provide the same functionality, only >slower. > >

karl

Reply by email

Karl Brandt
to Karl Brandt: Sometime ago i sent a patch fixing the forms sizes under win32 and got surprised to see…
Micha Nelissen wrote 41 lines
Karl Brandt wrote: >Micha Nelissen wrote: > > > >>Karl Brandt wrote: >> >> >> >> >>>Sometime ago i sent a patch fixing the forms sizes under win32 and >>>got surprised to see that things were messed. >>>So i did the job again! >>> >>>Attached is a patch that makes the form sizes correct. >>> >>> >>> >>> >>What was wrong? Those messages should send the same information as >>you retrieve via GetClientRect/GetWindowRect. >> >> >> >> >In LCL, WindowSize = ClientSize while windows and VCL expect/returns >diferent sizes, so is needed some adjustments. > > That does not explain the WM_MOVE change. The WM_SIZE is defined as such: nWidth = LOWORD(lParam); // width of client area nHeight = HIWORD(lParam); // height of client area Testing shows that those changes provide the same functionality, only slower.

The LParam returns the client Top/Left coordinates that are diferent of window coordinates.
Try to debug this.
LCL expects the window coordinates.
For example: when a control is created with top,left =(0,0) the MoveWindow proc (ResizeChild) fires WM_SIZE, WM_MOVE messages that are passed in windowproc.
If you send the client coordinates, that will be a greater than (0,0) let's say (4,24) the LCL will think that you moved the control (the top,left coordinates in LCL are 0,0) and will ask the Interface to move the control, creating that effect we see when we move the form. The same occurs with WM_SIZE, but this time you must pass the Client coordinates.
See yourself: try to pass the WM_SIZE parameters directly to LCL, make breakpoints in LM_SETSIZE , Tcontrol.WMSize and WM_SIZE process and inspect the size values

karl

Reply by email

Micha Nelissen
to Karl Brandt: Sometime ago i sent a patch fixing the forms sizes under win32 and got surprised to see…
Karl Brandt wrote 19 lines
Micha Nelissen wrote: > Karl Brandt wrote: > > >> Sometime ago i sent a patch fixing the forms sizes under win32 and >> got surprised to see that things were messed. >> So i did the job again! >> >> Attached is a patch that makes the form sizes correct. >> >> > > What was wrong? Those messages should send the same information as > you retrieve via GetClientRect/GetWindowRect. > > In LCL, WindowSize = ClientSize while windows and VCL expect/returns diferent sizes, so is needed some adjustments.

That does not explain the WM_MOVE change. The WM_SIZE is defined as such:

nWidth = LOWORD(lParam);  // width of client area
nHeight = HIWORD(lParam); // height of client area

Testing shows that those changes provide the same functionality, only slower.

Regards,

Micha.

Reply by email

Mattias Gaertner
to Karl Brandt: Sometime ago i sent a patch fixing the forms sizes under win32 and got surprised to see…
Show quoted text 38 lines
Mattias Gaertner wrote: > On Sat, 28 Jun 2003 21:45:04 +0200 > "Micha Nelissen" wrote: > >> Karl Brandt wrote: >>> Micha Nelissen wrote: >>> >>>> Karl Brandt wrote: >>>> >>>> >>>>> Sometime ago i sent a patch fixing the forms sizes under win32 and >>>>> got surprised to see that things were messed. >>>>> So i did the job again! >>>>> >>>>> Attached is a patch that makes the form sizes correct. >>>>> >>>>> >>>> >>>> What was wrong? Those messages should send the same information as >>>> you retrieve via GetClientRect/GetWindowRect. >>>> >>>> >>> In LCL, WindowSize = ClientSize while windows and VCL expect/returns >>> diferent sizes, so is needed some adjustments. >> >> That does not explain the WM_MOVE change. The WM_SIZE is defined as >> such: >> >> nWidth = LOWORD(lParam); // width of client area >> nHeight = HIWORD(lParam); // height of client area > > Ehh. At the moment the LCL thinks that WM_SIZE contains the bounds of > a control. The ClientArea can be smaller (TGroupBox, TForm with a > menu) or in some cases bigger (TScrollBox). ?? In TControl.WMSize it tries to do SetBounds with the Width and Height parameters...SetBounds in the LCL is defined as clientwidth and height, no?

No. SetBounds sets the bounds.

Where and how is the difference made between ClientHeight and Height and ClientWidth and Width?

There is a big difference and it is even bigger in the gtk-interface. The clientarea is the area for the childs. In most cases this corresponds to the bounds minus the frame and the scrollbars. A TControl has no childs and so it defines the clientarea = bounds. TWinControl redefines the client area.
The VCL does not always distinguish cleanly between clientarea and bounds. But under gtk a control can consist of several widgets and so the LCL must distinguish between them more carefully.

I'm now able to cross compile for win32 and started to improve the IDE for cross development. Cross 'Find Declaration' and code completion already works. The next step is remote debugging.

Mattias

Reply by email

Mattias Gaertner
to Karl Brandt: Sometime ago i sent a patch fixing the forms sizes under win32 and got surprised to see…
Show quoted text 24 lines
Mattias Gaertner wrote: > On Sat, 28 Jun 2003 01:33:43 -0300 > Karl Brandt wrote: > >> Attached is a patch that makes the form sizes correct. >> But when we move or resize the window, strange effects occurs. >> This happens because the LCL in TWinControl.InitializeWnd, sends a >> LM_SETSIZE message with the Width and Height parameters (which the >> interface expect) while in TWinControl.RealizeBounds it sends the >> same message with the Bottom-Right coordinates. > > ? > Both creates the rectangle with Bounds(Left,Top,Width,Height). So both > should be right,bottom. Can you fix TWinControl.InitializeWnd in that case? Instead of: R:= Rect(Left, Top, Width, Height); also: R:= Bounds(Left, Top, Width, Height); ?

Ehh, the R was unneeded. Fixed.

Mattias

Reply by email

Micha Nelissen
to Karl Brandt: Sometime ago i sent a patch fixing the forms sizes under win32 and got surprised to see…
Mattias Gaertner wrote 13 lines
On Sat, 28 Jun 2003 01:33:43 -0300 Karl Brandt wrote: > Attached is a patch that makes the form sizes correct. > But when we move or resize the window, strange effects occurs. > This happens because the LCL in TWinControl.InitializeWnd, sends a > LM_SETSIZE message with the Width and Height parameters (which the > interface expect) while in TWinControl.RealizeBounds it sends the > same message with the Bottom-Right coordinates. ? Both creates the rectangle with Bounds(Left,Top,Width,Height). So both should be right,bottom.

Can you fix TWinControl.InitializeWnd in that case? Instead of:

  R:= Rect(Left, Top, Width, Height);

also:

  R:= Bounds(Left, Top, Width, Height);

?

Thanks,

Micha.

Reply by email

Mattias Gaertner
to Karl Brandt: Sometime ago i sent a patch fixing the forms sizes under win32 and got surprised to see…
Show quoted text 36 lines
On Sat, 28 Jun 2003 17:54:25 -0300 Karl Brandt wrote: > >That does not explain the WM_MOVE change. The WM_SIZE is defined as > >such: > > > >nWidth = LOWORD(lParam); // width of client area > >nHeight = HIWORD(lParam); // height of client area > > > >Testing shows that those changes provide the same functionality, only > >slower. > > > > > The LParam returns the client Top/Left coordinates that are diferent of > window coordinates. > Try to debug this. > LCL expects the window coordinates. > For example: when a control is created with top,left =(0,0) the > MoveWindow proc (ResizeChild) fires WM_SIZE, WM_MOVE messages that are > passed in windowproc. > If you send the client coordinates, that will be a greater than (0,0) > let's say (4,24) the LCL will think that you moved the control (the > top,left coordinates in LCL are 0,0) and will ask the Interface to move > the control, creating that effect we see when we move the form. > The same occurs with WM_SIZE, but this time you must pass the Client > coordinates. > See yourself: try to pass the WM_SIZE parameters directly to LCL, > make breakpoints in LM_SETSIZE , Tcontrol.WMSize and WM_SIZE process and > > inspect the size values Right. TCustomForm bounds are the bounds around the client area including the menu. The menu as a non TControl is *not* on the client area of the form. The Left, Top of a form is in contrary to Delphi the Left, Top inner edge of the form border.

Sorry. I ment Width, Height are not the same as under Delphi. Delphi defines Width/Height for forms including the borders.
The Left, Top of a form is tricky. Under most windowmanagers the Left, Top of a form is the outer edge. So, this is the same as under Delphi.

Mattias

Reply by email

Mattias Gaertner
to Karl Brandt: Sometime ago i sent a patch fixing the forms sizes under win32 and got surprised to see…
Show quoted text 25 lines
>That does not explain the WM_MOVE change. The WM_SIZE is defined as such: > >nWidth = LOWORD(lParam); // width of client area >nHeight = HIWORD(lParam); // height of client area > >Testing shows that those changes provide the same functionality, only >slower. > > The LParam returns the client Top/Left coordinates that are diferent of window coordinates. Try to debug this. LCL expects the window coordinates. For example: when a control is created with top,left =(0,0) the MoveWindow proc (ResizeChild) fires WM_SIZE, WM_MOVE messages that are passed in windowproc. If you send the client coordinates, that will be a greater than (0,0) let's say (4,24) the LCL will think that you moved the control (the top,left coordinates in LCL are 0,0) and will ask the Interface to move the control, creating that effect we see when we move the form. The same occurs with WM_SIZE, but this time you must pass the Client coordinates. See yourself: try to pass the WM_SIZE parameters directly to LCL, make breakpoints in LM_SETSIZE , Tcontrol.WMSize and WM_SIZE process and inspect the size values

Right.
TCustomForm bounds are the bounds around the client area including the menu. The menu as a non TControl is *not* on the client area of the form. The Left, Top of a form is in contrary to Delphi the Left, Top inner edge of the form border.

Mattias

Reply by email

Karl Brandt
to Karl Brandt: Sometime ago i sent a patch fixing the forms sizes under win32 and got surprised to see…
Mattias Gaertner wrote 22 lines
On Sat, 28 Jun 2003 01:33:43 -0300 Karl Brandt wrote: >Sometime ago i sent a patch fixing the forms sizes under win32 and got >surprised to see that things were messed. >So i did the job again! > >Attached is a patch that makes the form sizes correct. >But when we move or resize the window, strange effects occurs. >This happens because the LCL in TWinControl.InitializeWnd, sends a >LM_SETSIZE message with the Width and Height parameters (which the >interface expect) while in TWinControl.RealizeBounds it sends the same >message with the Bottom-Right coordinates. > > ? Both creates the rectangle with Bounds(Left,Top,Width,Height). So both should be right,bottom.

Before the last patch InitializeWnd was sendind Width,Height ;-)

I applied the patch.

Thanks

Reply by email

Mattias Gaertner
to Karl Brandt: Sometime ago i sent a patch fixing the forms sizes under win32 and got surprised to see…
Show quoted text 25 lines
Karl Brandt wrote: > Micha Nelissen wrote: > >> Karl Brandt wrote: >> >> >>> Sometime ago i sent a patch fixing the forms sizes under win32 and >>> got surprised to see that things were messed. >>> So i did the job again! >>> >>> Attached is a patch that makes the form sizes correct. >>> >>> >> >> What was wrong? Those messages should send the same information as >> you retrieve via GetClientRect/GetWindowRect. >> >> > In LCL, WindowSize = ClientSize while windows and VCL expect/returns > diferent sizes, so is needed some adjustments. That does not explain the WM_MOVE change. The WM_SIZE is defined as such: nWidth = LOWORD(lParam); // width of client area nHeight = HIWORD(lParam); // height of client area

Ehh. At the moment the LCL thinks that WM_SIZE contains the bounds of a control. The ClientArea can be smaller (TGroupBox, TForm with a menu) or in some cases bigger (TScrollBox).

Testing shows that those changes provide the same functionality, only slower.

Mattias

Reply by email

Karl Brandt
to Karl Brandt: Sometime ago i sent a patch fixing the forms sizes under win32 and got surprised to see…
Micha Nelissen wrote 15 lines
Karl Brandt wrote: >Sometime ago i sent a patch fixing the forms sizes under win32 and got >surprised to see that things were messed. >So i did the job again! > >Attached is a patch that makes the form sizes correct. > > What was wrong? Those messages should send the same information as you retrieve via GetClientRect/GetWindowRect.

In LCL, WindowSize = ClientSize while windows and VCL expect/returns diferent sizes, so is needed some adjustments.

Are the form sizes really correct for you? If I move the form the size is usually Left+Width instead of Width, etc.

I didn't tested after the recent changes, but when i fixed the first time it was OK.
I did a small prog to test the sizes of forms in win32. If interest you i can send it.

Show quoted text 25 lines
>But when we move or resize the window, strange effects occurs. >This happens because the LCL in TWinControl.InitializeWnd, sends a >LM_SETSIZE message with the Width and Height parameters (which the >interface expect) while in TWinControl.RealizeBounds it sends the same >message with the Bottom-Right coordinates. > >I hope someone fix this. > > Yes...this is the problem I'm having too (and trying to fix). Regards, Micha. _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives

Reply by email

Micha Nelissen
to Karl Brandt: Sometime ago i sent a patch fixing the forms sizes under win32 and got surprised to see…
Karl Brandt wrote 15 lines
Micha Nelissen wrote: > Karl Brandt wrote: > > > Are the form sizes really correct for you? If I move the form the > size is usually Left+Width instead of Width, etc. > > I didn't tested after the recent changes, but when i fixed the first time it was OK. I did a small prog to test the sizes of forms in win32. If interest you i can send it.

Yes, please, send it to me. Can't have too many tests :).

Regards,

Micha.

Reply by email