[Lazarus] Win32 API replacement calls

A.J. Venter aj at outkastsolutions.co.za
Thu Jun 12 09:14:35 CEST 2008


On Thu, Jun 12, 2008 at 4:43 AM, SteveG <steveg at nevets.com.au> wrote:
> I have a program written for Windows being converted to Linux, and have
> hit a few win api calls I need to replace.
> Mostly they are to do with window control
> eg ShowWindow, SetWindowPos, MoveWindow etc etc
> These are used to control windows outside of the program itself, not
> internal forms.
>
> Would anybody know where I could find a listing / source that I could
> track equivalents to suit Linux ?
>
> Really appreciated - Thanks
This is actually quite a bit trickier than you think - the reason
being that under Linux there is no single way that windows are
controlled nor a single API for doing it with. Various window managers
and widgetsets behave in different ways.
All of them are implemented (somewhere along the line at least) using
xlib and I think if you use xlib you could do the things you are
trying to do - though this is a very low-level way to code (fpc can
use xlib though just put xlib in your uses clause).
You could also check the gtk docs (and add gtk itself to your uses
clause) and see if it has an equivalent (I don't THINK so but it's
worth looking) - if you can do it with GTK it will be easier and
simpler code than with xlib because gtk is much more high level.

What all the above do is to send hints to the window manager ASKING it
to please do an action (the window manager won't always honour it
especially as some may not even be ABLE to honour the request) but
usually programs ask this on their OWN behalf. It is definitely
possible to send window manager hints for OTHER windows, but it isn't
straight-forward to do - you'll need to read up a bit about wm_hints
to figure out the details.
Xlib is probably your most guaranteed way to make this work, of course
if you wanted to be nice you could write wrapper functions that are
compatible in their calls to the win32 API calls you were using but
use xlib instead (advantage it isn't tied to any particular linux
widgetset - GTK calls won't play nice for people with QT apps) to
implement them, and then put them all in a unit which other people
could add on to and which people porting from delphi could use to
replace win32 calls with minimum fuss ?

Either way, I hope I at least helped you know how to find the right FM to R. :)


Ciao
A.J.
-- 
A.J. Venter
Chief Executive Officer
Tel.: +27 21 554 5059
Fax: +27 11 252 9197
Outkast Solutions IT
www.outkastsolutions.co.za
A division of Global Pact Trading Pty Ltd.

www.silentcoder.co.za - Blog
scartoonz.silentcoder.co.za - ScarToonz webcomic



More information about the Lazarus mailing list