WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Samples from Users
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Flashing Window Title Example

Keywords: 	   flash

I have recently been experimenting with Windows API functions, and I came across the FlashWindow function.

Flashing is where the title bar of the window is switched from an active to inactive look (or vice versa) to get the user’s attention. Normally this is done multiple times, instead of just once. When you are done flashing, the window’s look is returned to the state it was in before flashing.

Below are 2 scripts to demonstrate this function. I use flashing in a program to warn the user of the possibility of impending doom.

SCRIPT #1:

	;FlashDemo.wbt
	;We will call Flash.wbt then display a message with a specific title.
	; A variation of this script can be added to your program.
	RunHide ("Flash.wbt","")
	Message ("WARNING - Demo", "Demonstration of %@CRLF%Flashing Titlebar.")
	;End FlashDemo.wbt
SCRIPT #2:
	;Flash.wbt - This is the program that does the flashing.

	Delay (1) ;Delay long enough for the window to show up.
	;I'm not sure if this is necessary but it seems like a good idea.

	;It expects the window with the specified title to already exist
	;if it does not then we terminate.
	if WinExist("WARNING -") == @FALSE
		Message("Flash","Run FlashDemo.wbt")
		exit
	endif

	;Setup our variables, we will need user32.dll and the appropriate window.
	User32=strcat (dirwindows (1),"user32.DLL")
	WinFlash = DllHwnd ("WARNING -")

	;Now we will do the flashing.
	;Flash 100 times or until the window is deactivated.
	For x = 1 to 100
		;Switch the title bar from an active to inactive look (or vice versa).
		DllCall (User32, long:"FlashWindow", long:WinFlash, long:1)
		Delay (1)
		;Stop flashing if Window is deactivated.
		if WinExist ("WARNING -") == @FALSE then x = 100
	next

	;Restore the window to its normal look.
	DllCall (User32, long:"FlashWindow", long:WinFlash, long:0)
	;End Flash.wbt


Article ID:   W13780
Filename:   Flashing Window Title Example.txt
File Created: 1999:04:15:16:56:20
Last Updated: 1999:04:15:16:56:20