[Lazarus] Unmoveable forms?

Kostas Michalopoulos badsector at slashstone.com
Fri Jun 27 01:57:18 CEST 2008


Thats a hack, but it will probably work:
1. Save the size/position in a TRect when onShow event occurs
2. Put a timer that periodically (say, every 50ms or so) checks if the size 
or position changed and restore it if so

A 50ms timer won't create any kind of resource waste (ok, it might eat 
000000025% of your CPU :-P), but the dragging back to the original place 
will be visible. But that shouldn't be a problem i think.

Kostas

----- Original Message ----- 
From: "Luca Olivetti" <luca at wetron.es>
To: "General mailing list" <lazarus at lazarus.freepascal.org>
Sent: Thursday, June 26, 2008 5:43 PM
Subject: Re: [Lazarus] Unmoveable forms?


En/na Luca Olivetti ha escrit:
> En/na Felipe Monteiro de Carvalho ha escrit:
>> On Wed, Apr 16, 2008 at 11:12 AM, Luca Olivetti <luca at wetron.es> wrote:
>>> With delphi I used a trick involving windows messages to make a form
>>>  unmoveable:
>> I don't think this is implementable in a cross-platform way. On X11
>> the conection with the window manager is loose, and it may ignore any
>> request you make.
>
> Well, I just need it under windows right now, it would just be nice if
> it could be done in a cross platform way, but it's not a strict 
> requirement
>
>> If you don't want the user to move the form and set the borderstyle to
>> bsNone. You can paint your own title if you really need one.
>
> Oh, but I like the system-drawn title bar with the application icon and
> the big X to close the form ;-)
>
>> Having said that, I can't imagine why one would wish to do this.
>
> My main reason is that the layout of the screeen(s) has to be fixed,
> besides avoiding the dragging of the form avoids freezing threads
> waiting on a Synchronize (though dragging a scrollbar will freeze them
> anyway, and that's really bad for my application).
> I'm not the only one with such a need (i.e. unmoveable forms), since I
> found that trick somewhere in the internet many years ago.

I'm sorry to revive this old thread, but I'm going to need it, at least
under windows.
Any other suggestion (besides BorderStyle:=bsNone)?

As a remainder, with delphi I used to to this:

    procedure WMNCHitTest(var Msg: TWMNCHitTest);message WM_NCHitTest;
    procedure WMInitMenuPopup(var Msg: TWMInitMenuPopUp);message
WM_INITMENUPOPUP;


procedure TMainFrm.WMNCHitTest(var Msg: TWMNCHitTest);
begin
      inherited;
      if Msg.Result=Windows.HTCAPTION then
      begin
        Msg.Result:= Windows.HTCLIENT
      end;
end;

procedure TMainFrm.WMInitMenuPopup(var Msg: TWMInitMenuPopup);
begin
      inherited;
      if Msg.SystemMenu then
         EnableMenuItem(Msg.MenuPopup, SC_MOVE, MF_BYCOMMAND or MF_GRAYED)
end;


Bye
-- 
Luca Olivetti
Wetron Automatización S.A. http://www.wetron.es/
Tel. +34 93 5883004      Fax +34 93 5883007
_______________________________________________
Lazarus mailing list
Lazarus at lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus 




More information about the Lazarus mailing list