Page 1 of 1

Unhide window and make it active

Posted: Fri Sep 18, 2009 2:58 pm
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!

Re: Unhide window and make it active

Posted: Fri Sep 18, 2009 4:14 pm
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) 

Re: Unhide window and make it active

Posted: Fri Sep 18, 2009 9:47 pm
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.

Re: Unhide window and make it active

Posted: Sat Sep 19, 2009 3:43 pm
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.