FlashWindow_() How to "unflash"?

Just starting out? Need help? Post your questions and find answers here.
novablue
Enthusiast
Enthusiast
Posts: 165
Joined: Sun Nov 27, 2016 6:38 am

FlashWindow_() How to "unflash"?

Post by novablue »

Hello, i am using FlashWindow_() and then after a couple of seconds i want it to go back to its original state. I tried "FlashWindowEx_() with #FLASHW_STOP which makes the window stop pulsing but how can i remove the orange highlight on the taskbar without giving the window focus?
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: FlashWindow_() How to "unflash"?

Post by RASHAD »

Hi
Any workable snippet ?
Egypt my love
novablue
Enthusiast
Enthusiast
Posts: 165
Joined: Sun Nov 27, 2016 6:38 am

Re: FlashWindow_() How to "unflash"?

Post by novablue »

Example:

Code: Select all

EnableExplicit

Define Window.i, WindowEvent.i, Timer.i

Window = OpenWindow(#PB_Any, 0, 0, 500, 500, "Window", #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)

SetWindowState(Window, #PB_Window_Minimize)

FlashWindow_(WindowID(Window), #True)

Timer = ElapsedMilliseconds()
Repeat 
    WindowEvent = WaitWindowEvent(10)
    
    If (Timer <> -1 And ElapsedMilliseconds() - Timer > 2000) 
        Timer = -1
        FlashWindow_(WindowID(Window), #False) ; But window remains orange in taskbar
        Debug "stop"
	EndIf
ForEver
But the window remains highlighted orange in the taskbar until it is activated. I want to undo the highlight without giving the window focus.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: FlashWindow_() How to "unflash"?

Post by RASHAD »

Adapt it for your needs

Code: Select all


#FLASHW_STOP = 0
#FLASHW_CAPTION = 1
#FLASHW_TRAY = 2
#FLASHW_ALL = 3
#FLASHW_TIMER = 4
#FLASHW_TIMERNOFG = 12
  
Procedure FlashWindow(hwnd,count,timeout,flags)
  Info.FLASHWINFO
  Info\cbSize = SizeOf(FLASHWINFO)
  Info\hwnd   = hwnd  
  Info\dwFlags= flags
  Info\uCount = count
  Info\dwTimeout = timeout 
  FlashWindowEx_(Info)
EndProcedure

hwnd = OpenWindow(0,0,0,200,200,"Flash Window",#PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_MinimizeGadget)

AddWindowTimer(0,125,100)
Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Quit = 1
    Case #PB_Event_MinimizeWindow
      FlashWindow(hwnd,10,100,#FLASHW_ALL)
      
    Case #PB_Event_RestoreWindow
      FlashWindow(hwnd,0,0,#FLASHW_STOP)

    Case #PB_Event_Timer
;       FlashWindow(hwnd,10,100,#FLASHW_ALL)
;       Delay(5000)
;       FlashWindow(hwnd,0,0,#FLASHW_STOP)
  EndSelect
Until Quit = 1

Using your example :

Code: Select all

#FLASHW_STOP = 0
#FLASHW_CAPTION = 1
#FLASHW_TRAY = 2
#FLASHW_ALL = 3
#FLASHW_TIMER = 4
#FLASHW_TIMERNOFG = 12
  
Procedure FlashWindow(hwnd,count,timeout,flags)
  Info.FLASHWINFO
  Info\cbSize = SizeOf(FLASHWINFO)
  Info\hwnd   = hwnd  
  Info\dwFlags= flags
  Info\uCount = count
  Info\dwTimeout = timeout 
  FlashWindowEx_(Info)
EndProcedure

Define Window.i, WindowEvent.i, Timer.i

Window = OpenWindow(#PB_Any, 0, 0, 500, 500, "Window", #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)

SetWindowState(Window, #PB_Window_Minimize)

FlashWindow(WindowID(window),10,100,#FLASHW_ALL)

Timer = ElapsedMilliseconds()
Repeat 
    WindowEvent = WaitWindowEvent(10)
    
    If (Timer <> -1 And ElapsedMilliseconds() - Timer > 2000) 
        Timer = -1
        FlashWindow(WindowID(window),0,0,#FLASHW_STOP)
        Debug "stop"
	  EndIf
ForEver
Egypt my love
novablue
Enthusiast
Enthusiast
Posts: 165
Joined: Sun Nov 27, 2016 6:38 am

Re: FlashWindow_() How to "unflash"?

Post by novablue »

Thanks but when i use your example nothing happens. It does not start to flash at all. I am using Windows 10.
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: FlashWindow_() How to "unflash"?

Post by BarryG »

Minimize the window to start the flashing.
novablue
Enthusiast
Enthusiast
Posts: 165
Joined: Sun Nov 27, 2016 6:38 am

Re: FlashWindow_() How to "unflash"?

Post by novablue »

BarryG wrote: Wed Dec 08, 2021 8:37 am Minimize the window to start the flashing.
I know, FlashWindow_() seems to work here but FlashWindowEX_() does nothing, i am not sure why.

I think i will use this instead to highlight / de-highlight the window in the taskbar, it's not exactly meant for it but it has 4 states with multiple colors (green, yellow, red) which makes it even better.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: FlashWindow_() How to "unflash"?

Post by RASHAD »

I don't have windows 10 anymore
But try the 2 example with

Code: Select all

Window = OpenWindow(#PB_Any, 0, 0, 500, 500, "Window", #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)

SetWindowState(Window, #PB_Window_Minimize)
FlashWindow_(WindowID(Window), #True)
;FlashWindow(WindowID(window),10,100,#FLASHW_ALL)

Timer = ElapsedMilliseconds()
Egypt my love
Post Reply