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

Systray Icon Questions

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

Systray Icon Dialog


 ; dialog and UDS to handle systray icons and window hiding
 ; dick elleray
 ;
 ; 04Jun03
 ; learn the lesson that window id's are relative
 ; added mywid = cWinIdConvert(dDialogHandle) on deanad's advice
 ;
 ;
#DefineSubRoutine  TimerProc(dDialogHandle,eventc,dDialogControlID,param4,param5)
Switch (eventc)

	Case 0  ; initialisation
		 ;enable 1 second timer events
		 DialogProcOptions(dDialogHandle, 1, 1000)
		 clock=10 ;set clock to 10secs
		 temp=IntControl(1007,2,0,0,0) ;clear icon from systray
		 toolbarmsg="Desktop (click to hide)"
		 temp=IntControl(1007,1,1,toolbarmsg,"") ;show icon
		 AddExtender("wwctl44i.dll");Updated WWW
		 Break

	Case 1 ; timer counter
		;Convert Windows handle to Window ID
		
		 mywid = cWinIdConvert(dDialogHandle)
		 Clock=Clock-1
		 If Clock==0  ; timedout
		    clock= 10  ;reset clock to 10 sec
		    goto iconme ; put me away
		 EndIf

		; update clock
		 DialogControlSet(dDialogHandle, 3, 4, clock)

		; check for mouseclick
		 trayclick=IntControl(1007,0,"","","")
		 If trayclick==0 then break ; no clicks

		;left click means open

		 If trayclick==1
		    DialogControlSet(dDialogHandle, 3, 4, "leftclicked")
		    DialogProcOptions(dDialogHandle,1000,0) ; redisplay dialog also seems to fix wbt icon reappearing  ;<<<<<<<<<<<
		    WinActivate(mywid)  ;<<<<<<<<<<<
		    temp=IntControl(1007,2,0,0,0);clear icon from systray
		    toolbarmsg="Desktop (click to hide again)"
		    temp=IntControl(1007,1,1,toolbarmsg,"") ;show icon and message
		 EndIf

		; right click means hide

		 If trayclick==2
		    temp=IntControl(1007,2,0,0,0);clear icon
		    ;DialogProcOptions(dDialogHandle,1000,1) ; hide dialog
		    DialogControlSet(dDialogHandle, 3, 4, "rightclicked")
		     winiconize(mywid)  ;or
		    ;winhide(mywid) ;
		    toolbarmsg="Desktop (click to open up)"
		    temp=IntControl(1007,1,1,toolbarmsg,"");show icon and message
		 EndIf
		 Return (-1) ; return to normal dialog
		 Break

EndSwitch
Return (-1)  ; return to normal dialog
;
;------------------
:iconme
;-----------------
;
; iconises current dialog to sys tray
;
DialogControlSet(dDialogHandle, 3, 4, "timer trigger")
temp=IntControl(1007,2,0,0,0);clear icon and message
;DialogProcOptions(dDialogHandle,1000,2) ; dim dialog
;beep
winiconize(mywid)  ;or
;winhide(mywid) ;
toolbarmsg="Desktop (left click to open)"
temp=IntControl(1007,1,1,toolbarmsg,"");show icon and message

Return (-1)  ; return to normal dialog
#EndSubRoutine

:init
; only a maindialog

TimerFormat=`WWWDLGED,6.1`

TimerCaption=`IconMe Example`
TimerX=78
TimerY=129
TimerWidth=121
TimerHeight=117
TimerNumControls=3
TimerProcedure="TimerProc"
TimerFont=`DEFAULT`
TimerTextColor=`DEFAULT`
TimerBackground=`DEFAULT,DEFAULT`
TimerConfig=0

Timer001=`12,82,35,14,PUSHBUTTON,DEFAULT,"OK",1,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Timer002=`66,82,35,14,PUSHBUTTON,DEFAULT,"Cancel",0,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Timer003=`22,15,71,53,VARYTEXT,datafield,"Startup",DEFAULT,DEFAULT,DEFAULT,"Tahoma|8000|70|34","128|0|0",DEFAULT`

ButtonPushed=Dialog("Timer",1)

message("exited dialog",buttonpushed)
Exit
 
:CANCEL
message("cancelled dialog",buttonpushed)
Exit

Article ID:   W16220
File Created: 2007:03:09:12:45:38
Last Updated: 2007:03:09:12:45:38