Sign in Join

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

Mailing lists / lazarus / 2003-09

BitButton in Win32

6 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

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

Martin Smat

Hi,
I tried to implement the bitmap buttons under win32 interface to show correctly the image and the button caption (now the caption is not displayed - it's because the button is defined with flag BS_BITMAP). It should be defined with flag BS_OWNERDRAW and painted in processing WM_DRAWITEM message.
In WM_DRAWITEM I filled the TLMDrawItems structure. The LM_DRAWITEM message is processed in procedure TCustomForm.WndProc but only for ODT_MENU. Can this procedure be extended about processing ODT_BUTTON? I think something like this:
...
if CtlType = ODT_BUTTON then
begin
CNSendMessage(LM_DRAWITEM, TObject(GetProp(hwndItem ,'WinControl')), Pointer(TheMessage.LParam)); { or calling an interface function - what would be better? }
end;
...

When processing ODT_BUTTON will be there I will make the rest and send a patch.

Martin Smat.

Reply by email

Mattias Gaertner
to Martin Smat
Show quoted text 6 lines
Hi, I tried to implement the bitmap buttons under win32 interface to show correctly the image and the button caption (now the caption is not displayed - it's because the button is defined with flag BS_BITMAP). It should be defined with flag BS_OWNERDRAW and painted in processing WM_DRAWITEM message.

This is win32 specific. Under gtk you don't need to draw it yourself, you can simply insert a pixmap into a button. Every used custom draw function in the LCL should be avoided to get theme dependent controls. Can we delegate the bitmap drawing to the win32 interface?

Mattias

Show quoted text 22 lines
In WM_DRAWITEM I filled the TLMDrawItems structure. The LM_DRAWITEM message is processed in procedure TCustomForm.WndProc but only for ODT_MENU. Can this procedure be extended about processing ODT_BUTTON? I think something like this: ... if CtlType = ODT_BUTTON then begin CNSendMessage(LM_DRAWITEM, TObject(GetProp(hwndItem ,'WinControl')), Pointer(TheMessage.LParam)); { or calling an interface function - what would be better? } end; ... When processing ODT_BUTTON will be there I will make the rest and send a patch. Martin Smat. _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives

Reply by email

Prof. Roberto A. Berrospe Machin
to Martin Smat: I tried to implement the bitmap buttons under win32 interface to show correctly the image…

Why Timers in Win32 dont work?
I try use, TTimer and TIdleTimer, but no work.
The app compiles fine, but timer not work.

This is part of my code.

Procedure TESTTIMER_ONTIMER();
Begin
    MAINFORM.TIMELABEL.Caption := 'Test';
    Application.MessageBox('Test','test',1)
End;
Constructor MAINFORMCLASS.Create(AOwner: TComponent);
Begin
     Inherited Create(AOwner);
     Caption  := 'Timer Test';
     Width  := 120;
     Height  := 100;
    TESTTIMER := TIdleTimer.Create(Self);
    TESTTIMER.Interval  := 1000;
    TESTTIMER.OnTimer  := @TESTTIMER_ONTIMER;
End;
destructor MAINFORMCLASS.Destroy;
begin
     inherited Destroy;
end;

Reply by email

Vincent Snijders
to Martin Smat: I tried to implement the bitmap buttons under win32 interface to show correctly the image…

On Fri, 5 Sep 2003 16:52:22 -0300
"Prof. Roberto A. Berrospe Machin"

Why Timers in Win32 dont work? I try use, TTimer and TIdleTimer, but no work.

I have no problems with TTimer, I didn't TIdleTimer.

The app compiles fine, but timer not work.

This surprises me. It shouldn't compiler.

Show quoted text 17 lines
This is part of my code. Procedure TESTTIMER_ONTIMER(); Begin MAINFORM.TIMELABEL.Caption := 'Test'; Application.MessageBox('Test','test',1) End; Constructor MAINFORMCLASS.Create(AOwner: TComponent); Begin Inherited Create(AOwner); Caption := 'Timer Test'; Width := 120; Height := 100; TESTTIMER := TIdleTimer.Create(Self); TESTTIMER.Interval := 1000; TESTTIMER.OnTimer := @TESTTIMER_ONTIMER;

It should give an error on this line. The signature of TESTTIMER_ONTIMER is wrong.
Either this is NOT your code, or you are using an old fpc compiler.

Show quoted text 6 lines
End; destructor MAINFORMCLASS.Destroy; begin inherited Destroy; end;

Reply by email

Martin Smat
to Martin Smat: I tried to implement the bitmap buttons under win32 interface to show correctly the image…
Mattias Gaertner wrote 17 lines
On Fri, 05 Sep 2003 18:37:40 +0200 Martin Smat wrote: >Hi, > I tried to implement the bitmap buttons under win32 interface to show >correctly the image and the button caption (now the caption is not >displayed - it's because the button is defined with flag BS_BITMAP). It >should be defined with flag BS_OWNERDRAW and painted in processing >WM_DRAWITEM message. This is win32 specific. Under gtk you don't need to draw it yourself, you can simply insert a pixmap into a button. Every used custom draw function in the LCL should be avoided to get theme dependent controls. Can we delegate the bitmap drawing to the win32 interface?

Under win32 it is possible to insert the pixmap in a simple way too. But only when the button is created with the flag BS_BITMAP and in this case the button can contain *only* the pixmap, nothing more (text caption). Can I add drawing the custom button directly into win32 interface (into WindowProc add processing WM_DRAWITEM message)?

Martin Smat.

Reply by email

Mattias Gaertner
to Martin Smat: I tried to implement the bitmap buttons under win32 interface to show correctly the image…
Show quoted text 24 lines
Mattias Gaertner wrote: > On Fri, 05 Sep 2003 18:37:40 +0200 > Martin Smat wrote: > > >>Hi, >> I tried to implement the bitmap buttons under win32 interface to show > >>correctly the image and the button caption (now the caption is not >>displayed - it's because the button is defined with flag BS_BITMAP). It >>should be defined with flag BS_OWNERDRAW and painted in processing >>WM_DRAWITEM message. > > > This is win32 specific. Under gtk you don't need to draw it yourself, > you can simply insert a pixmap into a button. Every used custom draw > function in the LCL should be avoided to get theme dependent controls. > Can we delegate the bitmap drawing to the win32 interface? > Under win32 it is possible to insert the pixmap in a simple way too. But only when the button is created with the flag BS_BITMAP and in this case the button can contain *only* the pixmap, nothing more (text caption). Can I add drawing the custom button directly into win32 interface (into WindowProc add processing WM_DRAWITEM message)?

Sure.

Mattias

Reply by email