Win32 API GetTopWindow() - how to call it

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
Widgets
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 534
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Win32 API GetTopWindow() - how to call it

Post by Widgets »

In my current app, I want to get the current top window in general, not the top window of my app.

When I tried to use the Win32 function GetTopWindow(), I get the wrong function returning wxWindow * instead of HWND, because wxApp also has a function with the exact same name and it takes precedence.
Running under Win 10 & MSVC 2015, wxWidgets 3.1
Environment: Win 10/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
New Pagodi
Super wx Problem Solver
Super wx Problem Solver
Posts: 469
Joined: Tue Jun 20, 2006 6:47 pm
Contact:

Re: Win32 API GetTopWindow() - how to call it

Post by New Pagodi »

You probably just need to use the scope operator. ie use ::GetTopWindow() to call the global function instead of class method with the same name.
Widgets
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 534
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Re: Win32 API GetTopWindow() - how to call it

Post by Widgets »

[edit]
After my first cut at my reply, I found the function wxWindow::GetHWND() and it looks like what I think I need, though that is still to be confirmed, but it got me further along the road.

Code: Select all

wxWindow *pWin = GetTopWindow();
HWND hWnd = pWin->GetHandle();
[/edit]
I'm, afraid, that does not do what I need. It compiles and runs, but I would need to transform the returned wxWindow * to HWND - two completely different things
Environment: Win 10/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
Post Reply