[lazarus] Win32 bug: tcontrol's painting themselves in tgroupboxes
Micha Nelissen
M.Nelissen at student.tue.nl
Mon Sep 1 07:48:58 EDT 2003
Mattias Gaertner wrote:
> On Sun, 31 Aug 2003 20:59:49 +0200
> Micha Nelissen <M.Nelissen at student.tue.nl> wrote:
>
>
>>Mattias Gaertner wrote:
>>
>>
>>>On Sun, 31 Aug 2003 18:54:50 +0200
>>>Mattias Gaertner <nc-gaertnma at netcologne.de> wrote:
>>>
>>>
>>>
>>>>On Sun, 31 Aug 2003 16:58:18 +0200
>>>>Micha Nelissen <M.Nelissen at student.tue.nl> wrote:
>>>>
>>>>
>>>>
>>>>>Hi,
>>>>>
>>>>>The problem is the following: if a tcontrol paints itself to it's
>>>
>>>parent>>
>>>
>>>>>DC, and the parent's clientrect is different than the origin, the
>>>>>tcontrol's will paint themselves to the wrong position, namely the
>>>>>parent.topleft, not the topleft of the clientrect. This happens with
>>>>>TColorButton's in TGroupboxes for example. How do we solve this?
>>>>>
>>>>>FYI: Delphi has not solved this, a control at position (0,0) in a
>>>>>tgroupbox is painted on top of the caption, while we want it in the
>>>>>clientrect.
>>>>
>>>>Right.
>>>>An additional problem is, that the gtk paints before and the win32 paint
>>>>during message handling and they both uses different DC origins. There
>>>
>>>are>plenty of possibilities, where the origin can be moved to fix this. I
>>>will>also look into this ...
>>>
>>>
>>>Maybe I find a solution.
>>
>>Hmm, not quite :(. The groupbox caption is not drawn anymore. It seems
>>the window rect has stayed in the same position, but the whole box has
>>moved up. Difference in top position of tcontrols and twincontrols has
>>stayed the same.
>
>
> Hmm. It works for me. I have to test more examples...
Well, what did you try? Can you try attached example? It is a modified
groupbox example.
> BTW, GetCLientBounds was not implemented and so I started it. It is not
> complete yet.
To what extent can it be blamed?
Regards,
Micha.
{ $Id: groupbox.pp,v 1.6 2003/08/12 16:04:22 mattias Exp $ }
{
/***************************************************************************
Initial Revision : Sun Mar 28 23:15:32 CST 1999
***************************************************************************/
***************************************************************************
* *
* This source is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This code is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* General Public License for more details. *
* *
* A copy of the GNU General Public License is available on the World *
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
* obtain it by writing to the Free Software Foundation, *
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
***************************************************************************
}
program GroupBox;
{$mode objfpc}{$H+}
uses
Interfaces, Classes, StdCtrls, Forms, Buttons, Menus, ComCtrls, SysUtils,
Dialogs;
type
TForm1 = class(TFORM)
public
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
grpTst : TGroupBox;
mnuFile: TMainMenu;
itmFileQuit: TMenuItem;
CheckBox1: TCheckBox;
clrBtn: TColorButton;
constructor Create(AOwner: TComponent); override;
procedure LoadMainMenu;
procedure mnuQuitClicked(Sender : TObject);
protected
procedure Button1CLick(Sender : TObject);
procedure Button2CLick(Sender : TObject);
procedure Button3CLick(Sender : TObject);
procedure Button4CLick(Sender : TObject);
end;
var Form1 : TForm1;
constructor TForm1.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Caption := 'Groubox Demo v0.1';
LoadMainMenu;
end;
procedure TForm1.Button1Click(Sender : TObject);
Begin
if assigned (grpTst) then grpTst.Height := grpTst.Height + 10;
End;
procedure TForm1.Button2Click(Sender : TObject);
Begin
if assigned (grpTst) then begin
grpTst.Width := grpTst.Width + 10;
grpTst.Show;
end;
End;
procedure TForm1.Button3Click(Sender : TObject);
Begin
if assigned (grpTst) then begin
grpTst.Show;
end;
End;
procedure TForm1.Button4Click(Sender : TObject);
Begin
if assigned (grpTst) then begin
grpTst.Hide;
end;
End;
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
procedure TForm1.LoadMainMenu;
begin
{ set the height and width }
Height := 350;
Width := 700;
{ Create a groupbox }
grpTst := TGroupBox.Create(Self);
with grpTst do begin
Name:='grpTst';
Parent := self;
top := 70;
left := 10;
Height := 200;
Width := 300;
Caption := 'Groupbox with 2 Buttons';
end;
clrBtn := TColorButton.Create(Self);
with clrBtn do begin
Parent := grpTst;
SetBounds(10,10,25,25);
end;
CheckBox1 := TCheckBox.Create(Self);
with CheckBox1 do begin
Parent := grpTst;
SetBounds(40,10,100,20);
Caption := 'checkbox';
end;
mnuFile := TMainMenu.Create(Self);
itmFileQuit := TMenuItem.Create(Self);
itmFileQuit.Caption := 'Quit';
itmFileQuit.OnClick := @mnuQuitClicked;
mnuFile.Items.Add(itmFileQuit);
end;
{------------------------------------------------------------------------------}
procedure TForm1.mnuQuitClicked(Sender : TObject);
begin
Close;
end;
{------------------------------------------------------------------------------}
begin
Application.Initialize; { calls InitProcedure which starts up GTK }
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
More information about the Lazarus
mailing list