gtkD window centering message up and no app on taskbar

Johnson Jones via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 9 14:54:24 PDT 2017


On Wednesday, 9 August 2017 at 15:10:46 UTC, Mike Wey wrote:
> On 09-08-17 01:00, Johnson Jones wrote:
>> But, finally, this does seem to work:
>> 
>> 
>> // Fixup missing taskbar icon
>> void SetTaskBarIcon(gtk.ApplicationWindow window)
>> {
>> 
>>      version(Windows)
>>          version(X86)
>>          {
>>              import core.sys.windows.winuser, gdk.Window;
>>              auto handle = 
>> cast(core.sys.windows.winuser.HANDLE)gdk_win32_window_get_handle(gtk.gtk_widget_get_window(window.getWidgetStruct()));
>> 
>>              ShowWindow(handle, SW_HIDE);
>> //            SetParent(handle, null);
>>              SetWindowLong(handle, GWL_EXSTYLE, 
>> GetWindowLong(handle, GWL_EXSTYLE) | WS_EX_APPWINDOW);
>>              ShowWindow(handle, SW_SHOW);
>>          }
>>      return;
>> }
>> 
>> Of course, along with this:
>> 
>> 
>> MainWindow.addOnShow((Widget widget) { 
>> MainWindow.SetTaskBarIcon(); });
>
> `gdk_win32_window_get_handle` I spend way to much time looking 
> for a function like this, before giving up and doing the 
> pointer arithmetic.
>
> This should do it for getting the function:
> ```
> import gtkd.Loader;
> import gdk.c.functions; //Still at gtkc.gdk for 3.6.
>
> __gshared extern(C) HANDLE function(GdkWindow*) 
> gdk_win32_window_get_handle;
> Linker.link(gdk_win32_window_get_handle, 
> "gdk_win32_window_get_handle", LIBRARY_GDK);
> ```
>
> I did find out that gdk set the Desktop window as the parent 
> window and doesn't set `WS_EX_APPWINDOW` i should try if 
> setting it for top level windows would fix this from within gdk.


Ok, I added

	import core.sys.windows.winuser;
	__gshared extern(C) core.sys.windows.winuser.HANDLE 
function(GdkWindow*) gdk_win32_window_get_handle;
	Linker.link(gdk_win32_window_get_handle, 
"gdk_win32_window_get_handle", LIBRARY_GDK);

to GtkD\generated\gtkd\gdk\c\functions.d

and rebuilt and it seems to work. Hopefully that is the right 
place so in the future when I replace GtkD with it won't show up 
as a bug in my code somewhere. I assume master will be updated 
with this at some point?


More information about the Digitalmars-d-learn mailing list