[Lazarus] DrawText function problems

Lee Jenkins lee at datatrakpos.com
Sun Apr 13 18:50:21 CEST 2008


Felipe Monteiro de Carvalho wrote:
> On Sun, Apr 13, 2008 at 10:16 AM, Lee Jenkins <lee at datatrakpos.com> wrote:
>>  BTW, in Delphi the behavior that I mentioned above is present.  Which made it a
>>  simple task to create custom buttons.  With the current behavior of Lazarus, it
>>  leave custom buttons made like this in a "visually down" state.
> 
> Ahhh ... so this is what this is about?
> 
> I would have used a TCustomControl descendent to do that.

Probably a better choice, but I have problems using with it with my limited 
experience of custom controls so a TImage descendant worked for me, except that 
it doesn't paint correctly.

> Your code works fine in gtk2, the caption is drawn as expected. The
> button doesn't go back when the mouse leaves it. Pay attention to how
> real system buttons work. It doesn't go back on MouseUp. It goes back
> when the mouse leaves the button, so I added a handler for
> OnMouseLeave:
> 

Hmm. Are you saying that OnMouseLeave is called as well when the user releases 
the mouse button after clicking down?  I didn't know this, I'll give it a try.

> procedure TDTImageButton.HandleMouseLeave(Sender: TObject);
> begin
>   HandleMouseUp(Sender, mbLeft, [], 0, 0); // Just a hack, you should
> actually have the code from you MouseUp here, and correct your MouseUp
> end;

> You would also need a handler for OnMouseEnter and some logic to see
> again when the mouse goes back to the button to put it down again.
> 
> Other hints. You don't need those ifdefs for fpc, so use mode delphi.
> 
> In Lazarus you can use LCLIntf and LCLType instead of the WIndows unit.
> 

Thanks for these tips.

>> Even when Auto drag is not set or BeginDrag is not called?
> 
> I was just pointing which events may occur with that mouse gesture.
> 

I have managed to use a TImage descendant which doesn't have the problem of not 
firing OnMouseUp when the cursor leaves, but the output of DrawText is not 
acceptable for some reason.  See me post with sample project attachment and 
screenshot of the image.

-- 

Warm Regards,

Lee

"When my company started out, we were really, really, really, really small. 
Now...we're just really small."



More information about the Lazarus mailing list