Re: Win32 modal support
| From: | Tom Rogers | Date: | Sun, 28 Aug 2005 06:41:04 +0000 |
| Subject: | Re: Win32 modal support | ||
| References: | 1 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-6183@lists.php.net to get a copy of this message | ||
Hi,
Saturday, August 27, 2005, 5:09:50 AM, you wrote:
JB> Hello,
JB> Does anyone know of a workaround for set_modal() and set_transient_for() not
JB> working on Windows platforms?
JB> Thanks,
JB> Jeff
I have modified gdk to make this work under windows using gtk2.4 as a
base. If you are compiling your own gtk replace the function:
gdk_window_set_transient_for() in ...\gtk\gdk\win32\gdkwindow-win32.c
(which currently does nothing) with this:
gdk_window_set_transient_for (GdkWindow *window,
GdkWindow *parent)
{
HWND window_id, parent_id;
LONG style;
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
GDK_NOTE (MISC, g_print ("gdk_window_set_transient_for: %p %p\n",
GDK_DRAWABLE_XID (window),
GDK_DRAWABLE_XID (parent)));
window_id = GDK_DRAWABLE_XID (window);
parent_id = GDK_DRAWABLE_XID (parent);
if ((style = GetWindowLong (window_id, GWL_STYLE)) == 0)
WIN32_API_FAILED ("GetWindowLong");
style |= WS_CHILD;
if (!SetWindowLong (window_id, GWL_STYLE, style))
WIN32_API_FAILED ("SetWindowLong");
if (!SetParent (window_id, parent_id))
WIN32_API_FAILED ("SetParent");
if (!RedrawWindow (window_id, NULL, NULL,
RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW))
WIN32_API_FAILED ("RedrawWindow");
}
If you need a precompiled dll you can download it from:
http://kwiktemplates.com/gtk.zip
If you don't want the parent to be active you will need to combine
set_transient_for() with set_modal().
It also behaves in that it does not create a new icon on the taskbar
and will minimize if the main window minimizes.
The only thing to watch for is if you kill the parent while the dialog
is showing you will get a gdk error message. This won't happen if you
use set_modal(TRUE) of course.
--
regards,
Tom