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

Process ID

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

Ticker Sample Code


Its been a while since I posted any code but here is a nice little script that I have been using to keep managment happy. Its a small rolling ticker that will sit on top and show 3 lines of text. I use it to display a number of sales stats that are retrieved from a database. But this example is just reads the lines from a text file. Have fun.
; Ticker
; by Iain (iain@caverock.com)
; 26 July 2004
;AddExtender("wwctl34i.dll")
;Addextender("wproc34I.dll")
AddExtender("wwctl44i.dll")
AddExtender("wwprc44i.dll")

;counterstring=tBrowseCntrs (0,0,0,0,0)


;============================================================
#DefineSubroutine MyDialogCallbackProc(MyDialog_Handle,MyDialog_Message,MyDialog_ID,rsvd1,rsvd2)
   ;DialogprocOptions Constants
   MSG_INIT=0                ; The one-time initilization
   MSG_TIMER=1        ; Pushbutton or Picturebutton
   MSG_BUTTONPUSHED=2        ; Pushbutton or Picturebutton
   TRANSPARENT=1
   switch MyDialog_Message
      case MSG_INIT
         ; Windows constants
         WS_CAPTION=12582912  ; Hex 00C00000  (Search MSDN for Q111011 for more parameter values)
         WS_EX_TOOLWINDOW = 128
         GWL_STYLE=-16
         GWL_EXSTYLE=-20
         ; Window Z-Order constants
         HWND_TOP = 0
         HWND_BOTTOM = 1
         HWND_TOPMOST = -1
         HWND_NOTOPMOST = -2
         WS_EX_TOPMOST = 8
         ;Window API Constants
         SWP_NOSIZE = 1
         SWP_NOMOVE = 2
         SWP_NOZORDER = 4
         SWP_NOACTIVATE = 16
         SWP_SHOWWINDOW = 64
         SWP_HIDEWINDOW = 128
         GWL_STYLE=-16
         WS_CAPTION=12582912
         HTCAPTION=2
         WM_NCLBUTTONDOWN=161

         ; Setup timer
         DialogProcOptions(MyDialog_Handle,MSG_TIMER,100)
         ;DialogProcOptions(MyDialog_Handle,MSG_BUTTONPUSHED,1)
         x = WinItemChild("")
         ; Load lines from text file
         array = ArrayFileGet(datafile)
         total_lines = ArrInfo(array,1)
         ; Setup array to hold window handles for lines and starting text
         line = ArrDimension(3,3)
         line[0,0] = cWndByName(MyDialog_Handle,"line1")
         line[1,0] = cWndByName(MyDialog_Handle,"line2")
         line[2,0] = cWndByName(MyDialog_Handle,"line3")
         line[0,2] = "Current CPU use: ~CPU~%%"
         line[1,2] = "Memory (in use/total): ~MEM_INUSE~Mb/~MEM_TOTAL~Mb"
         line[2,2] = "Disk free: ~DISK_FREE|'C'~Mb"
         For li = 0 to 2
            s = line[li,2]
            While StrIndex(s,"~",1,@FWDSCAN)
               cmd_line = ItemExtract(2,s,"~")
               param = ItemExtract(2,cmd_line,"|")
               cmd = ItemExtract(1,cmd_line,"|")
               s = StrReplace(s,StrCat("~",cmd_line,"~"),Display_%cmd%(%param%))
            EndWhile
            line[li,1] = s
         next s
         ; Set the starting text for the lines
         DialogControlSet(MyDialog_Handle, 1, 4, line[0,1])
         DialogControlSet(MyDialog_Handle, 2, 4, line[1,1])
         DialogControlSet(MyDialog_Handle, 3, 4, line[2,1])
         ; Make sure the lines are in the right places
         y = ArrDimension(3)
         y[0] = 0
         y[1] = 20
         y[2] = 40
         SetWindowPos(line[0,0],4,y[0],198*2,18,0,0)
         SetWindowPos(line[1,0],4,y[1],198*2,18,0,0)
         SetWindowPos(line[2,0],4,y[2],198*2,18,0,0)
         p = 50
         ; Setup the dialog (code from Guido)
         user32=strcat(dirwindows(1),"user32.dll")
         gdi32=strcat(dirwindows(1),"gdi32.dll")
         dlgid=WinIdGet("")
         RECT=binaryalloc(16)
         ;remove caption
         os=dllcall(user32,long:"GetWindowLongA",long:MyDialog_Handle,long:GWL_STYLE)
         dllcall(user32,long:"SetWindowLongA",long:MyDialog_Handle,long:GWL_STYLE,long:os & ~WS_CAPTION)
         ;create region
         dllcall(user32,long:"GetClientRect",long:MyDialog_Handle,lpbinary:RECT)
         hrgn=dllcall(gdi32,long:"CreateRoundRectRgn",long:0,long:0,long:binarypeek4(RECT,8),long:binarypeek4(RECT,12),long:10,long:10)
         dllcall(user32,long:"SetWindowRgn",long:MyDialog_Handle,long:hrgn,long:@true)
         binaryfree(RECT)
         NewStyle=WS_EX_TOOLWINDOW
         ;   DllCall(User32, long:"SetWindowLongA", long:MyDialog_Handle,long:GWL_EXSTYLE, long:NewStyle)
         SetWindowPos(MyDialog_Handle,0,0,0,0,HWND_TOPMOST,SWP_NOSIZE|SWP_NOACTIVATE|SWP_NOMOVE)
         break
   case MSG_TIMER
      ; If left mouse button is pushed
      if MouseInfo(8)==4
         ; And is over this windows then move the window to follow pointer
         if MouseInfo(9)== dlgid then dllcall(user32,long:"SendMessageA",long:MyDialog_Handle,long:WM_NCLBUTTONDOWN,long:HTCAPTION,lpnull)
      endif
      ; p is used to make the system pause to display the line for a bit
      If p == 0 then
         ; loop round and move each line
         for li = 0 to 2
            if y[li] == -20 then
               ; line is at the top, load some new text and move it to the bottom
               y[li] = 40
               s = line[li,2]
               ; find all 'tags' and call the function
               While StrIndex(s,"~",1,@FWDSCAN)
                  cmd_line = ItemExtract(2,s,"~")
                  param = ItemExtract(2,cmd_line,"|")
                  cmd = ItemExtract(1,cmd_line,"|")
                  s = StrReplace(s,StrCat("~",cmd_line,"~"),Display_%cmd%(%param%))
               EndWhile
               line[li,1] = s
               DialogControlSet(MyDialog_Handle, li+1, 4, line[li,1])
               p = 50
            else
               ; move the line up
               y[li] = y[li] - 1
            endif
            SetWindowPos(line[li,0],4,y[li],198*2,18,0,0)
         next
      else
         p = p - 1
      EndIf
   break
   endswitch       ; MyDialog_Message
;   dllcall(user32,long:"UpdateWindow",long:MyDialog_Handle)
   return(-1)      ;  Do default processing
#EndSubroutine       ;End of Dialog Callback MyDialogCallbackProc

;============================================================
;============================================================
;============================================================

#DefineFunction SetWindowPos(handle,xpos,ypos,width,height,after,style)
   user32=strcat(dirwindows(1),"user32.dll")
   val = dllcall(user32,long:"SetWindowPos",long:handle,long:after,long:xpos,long:ypos,long:width,long:height,long:style)
   Return val
#EndFunction

#DefineFunction Display_CPU()
   Return tGetData("\\STELLA\Processor(_Total)\%% Processor Time",1)
#EndFunction

#DefineFunction Display_MEM_INUSE()
   Return tGetData("\\STELLA\Memory\Committed Bytes",0)/1024/1024
#EndFunction

#DefineFunction Display_MEM_TOTAL()
   Return tGetData("\\STELLA\Memory\Commit Limit",0)/1024/1024
#EndFunction

#DefineFunction Display_DISK_FREE(disk)
   Return DiskFree(disk)/1024/1024
#EndFunction

MyDialogFormat=`WWWDLGED,6.1`

MyDialogCaption=`Ticker`
MyDialogX=100
MyDialogY=0
MyDialogWidth=202
MyDialogHeight=0013
MyDialogNumControls=004
MyDialogProcedure=`MyDialogCallbackProc`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,200|200|200`
MyDialogConfig=2

MyDialog001=`004,000,200,009,VARYTEXT,line1,"line1",DEFAULT,3,DEFAULT,"Arial|7680|40|34","0|0|0",DEFAULT`
MyDialog002=`004,000,200,009,VARYTEXT,line2,"line2",DEFAULT,2,DEFAULT,"Arial|7680|40|34","0|0|0",DEFAULT`
MyDialog003=`004,000,200,009,VARYTEXT,line3,"line3",DEFAULT,2,DEFAULT,"Arial|7680|40|34","0|0|0",DEFAULT`
MyDialog004=`083,103,036,012,PUSHBUTTON,DEFAULT,"Cancel",0,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("MyDialog",0) ; WinBatch will not display this dialog.


;IntControl(72,1, 0, 0, 0)
IntControl (1002, 0, 0, 0, 0)
IntControl (49, 1, 0, 0, 0)

ButtonPushed=Dialog("MyDialog",1)

Article ID:   W16359
File Created: 2017:07:28:13:58:39
Last Updated: 2013:04:01:09:13:30