Unhide window and make it active

Just starting out? Need help? Post your questions and find answers here.
yabune
User
User
Posts: 65
Joined: Mon Aug 22, 2005 2:31 pm

Unhide window and make it active

Post by yabune »

Hi,

I have an application with only a systray icon, and when I click on the icon, a window should unhide.

I'm using this code to achieve that:

Code: Select all

  HideWindow(#WINDOW_1, 0)
  SetActiveWindow(#WINDOW_1)
  SetActiveGadget(#G_1)
Most of the times this works, but sometimes the window shows up minimized, I have to click on the window in the taskbar to open it.

Any tips on this? Why doesn't open always active?

Thank you!
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Unhide window and make it active

Post by Kwai chang caine »

Hello

Me for up the windows of the taskbar i use one of this API

Code: Select all

SendMessage_(Hwnd,#SW_SHOWNORMAL,0,0) 
ShowWindow_(Hwnd,#SW_RESTORE) 
ShowWindow_(Hwnd,#SW_SHOW) 
SetForegroundWindow_(Hwnd) 
ImageThe happiness is a road...
Not a destination
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Re: Unhide window and make it active

Post by Tranquil »

yabune wrote:Hi,

I have an application with only a systray icon, and when I click on the icon, a window should unhide.

I'm using this code to achieve that:

Code: Select all

  HideWindow(#WINDOW_1, 0)
  SetActiveWindow(#WINDOW_1)
  SetActiveGadget(#G_1)
Most of the times this works, but sometimes the window shows up minimized, I have to click on the window in the taskbar to open it.

Any tips on this? Why doesn't open always active?

Thank you!
Do you use Threads? I encountered this issue sometimes if I open windows in threads. The window is opened but not shown. Its only visible in the taskbar. A setactivewindow() does not work for me in this moment. It activates the window but does not bring it up. Also a SetForegoundWindow_() Call does not solve it.
Tranquil
yabune
User
User
Posts: 65
Joined: Mon Aug 22, 2005 2:31 pm

Re: Unhide window and make it active

Post by yabune »

Yes, I'm using threads. But I'm not opening the window inside the thread. The thread is running but I'm opening when there's a hotkey pressed, it's an event in the main loop of the application.

I tried Kwaï chang caïne tip and it's working now!
Thanks Kwaï!

I'm using this to show the window:

Code: Select all

  HideWindow(#WINDOW_1, 0)
  SetActiveWindow(#WINDOW_1)
  SendMessage_(WindowID(#WINDOW_1),#SW_SHOWNORMAL,0,0) 
  ShowWindow_(WindowID(#WINDOW_1),#SW_RESTORE) 
  ShowWindow_(WindowID(#WINDOW_1),#SW_SHOW) 
  SetForegroundWindow_(WindowID(#WINDOW_1))

Tranquil wrote:
yabune wrote:Hi,

I have an application with only a systray icon, and when I click on the icon, a window should unhide.

I'm using this code to achieve that:

Code: Select all

  HideWindow(#WINDOW_1, 0)
  SetActiveWindow(#WINDOW_1)
  SetActiveGadget(#G_1)
Most of the times this works, but sometimes the window shows up minimized, I have to click on the window in the taskbar to open it.

Any tips on this? Why doesn't open always active?

Thank you!
Do you use Threads? I encountered this issue sometimes if I open windows in threads. The window is opened but not shown. Its only visible in the taskbar. A setactivewindow() does not work for me in this moment. It activates the window but does not bring it up. Also a SetForegoundWindow_() Call does not solve it.
Post Reply