Gtk window object lazarus / 8-Other ---------------------------------------------------------------------- Spike · 2006-08-03 15:43 In porting my (windows) project to gtk2, I need a little bit of focus- magic and for that I'm using xlib. The only problem is that right now, in order to obtain the window id of one of my forms, I'm using a really unreliable "XGetInputFocus" while praying that the returned window is the one I'm looking for. So I've tried to take a peek into the gtk2 interface sources, but that code is way too "spagetti" for me to handle right now. All that I know is that the code that's supposed to switch focus has a "//TO DO: Implement me" comment within. I went on and looked at the gtk2 docs and found a really nifty method that puts my window on top, gives it focus and takes care of any unwanted side effects, but that requires a GtkWindow object reference as a parameter. So I was back at square one, trying to figure out by myself where is that handle stored, but like I said, the pure spagettiness (that's most likely not a word) of the LCL pushed me away. Now this post is getting longer than I wanted, so I'm just gonna cut this short: Who do I have to kill to get that object reference, or even better, a window ID to use the XLib functions (so that I don't have to do this again should I want qt compatibility later on) ---------------------------------------------------------------------- felipemdc · 2006-08-03 17:03 Take a look here: http://wiki.lazarus.freepascal.org/index.php/Accessi ng_the_Interfaces_directly under gtk a Handle is often a PGtkWidget You need to use the Handle property of your window (or other control) to get access to a GtkWindow. Then you can use that value to access Gtk functions directly. Some Gtk functions will give you access to a X11 Handle. I don´t remember them from memory, but just look at how TTrayIcon component was implemented. It´s located at lazarus/components/trayicon on your local Lazarus install. Specifically take a look at the Gtk2 file from trayicon. > so that I don't have to do this again should I want qt compatibility later on You will have to put platform dependent code to get support for qt and gtk. Even if it´s just 2 lines, because LCL gives access to a Handle of the widgetset it´s using, not a Handle to the Windowing system being utilized. ---------------------------------------------------------------------- Spike · 2006-08-03 17:20 Thanks for the post. I knew that under windows, the Handle property is a hwnd, but I wasn't sure on what it represented on other widgetsets. ---------------------------------------------------------------------- Marc · 2006-08-09 09:00 Please be aware that this might change in the future.