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

Boxes Functions
plus
plus

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

BoxesUp Width Limitation

 Keywords: Box BoxesUp Width Coordinate Limitation title bar 

Question:

I'm writing a program to monitor the status of an application. I'm trying to create a tall-thin (vertical bar) on the left side of the screen. This vertical bar will change color from green to red and back as the application's status changes.

The problem I'm having is creating the bar to be "thin". Even though I'm coding the X,Y coordinate pairs as (0,0,10,1000), which I would expect to create a box that is 10 units wide, what I get is a window that is about 25% of the screen width.

Here's the code:

; set my status window location as a small vertical bar on the left side of the screen
BoxMapmode(1,@OFF)
BoxesUp("0,0,10,1000",@NORMAL)
BoxCaption(1,"Monitor")
BoxNew(2,"0,0,1000,1000",0)
; indicate process control is ready by setting box color to green
BoxColor(2,"0,255,0",0)
BoxDrawRect(2,"0,0,1000,1000",2)

TimeDelay(1.5)
; indicate process control is NOT ready by setting box color to red
BoxColor(2,"255,0,0",0)
BoxDrawRect(2,"0,0,1000,1000",2)
TimeDelay(3)
Exit
BTW, this is Winbatch 2008B running on Vista SP2.

Answer:

Looks like BoxesUp is not allowing you to specify less than x units wide. I suspect this is due to the window title bar, forcing the limitiation. Which is confirmed by the following code sample:
; set my status window location as a small vertical bar on the left side of the screen
 BoxTitle("Monitor")

;Hide Title Bar, set to noswap/nomove
DlgName=DllHwnd("Monitor")
WS_CAPTION=12582912 ;12582912 Hex 00C00000 (Search MSDN for Q111011 for more parameter values)
GWL_STYLE=-16
User32=StrCat(DirWindows(1),"USER32.DLL")
OldStyle=DllCall(User32, long:"GetWindowLongA", long:DlgName, long:GWL_STYLE)
NewStyle=OldStyle & ~WS_CAPTION
DllCall(User32, long:"SetWindowLongA", long:DlgName, long:GWL_STYLE, long:NewStyle)

BoxesUp("0,0,10,1000",@NORMAL)

TimeDelay(3)
Exit

Here is the complete code revised to first remove the title bar then display the box with each color:

; set my status window location as a small vertical bar on the left side of the screen

; Change title of existing hidden box window
BoxTitle("Monitor")

; Remove Title Bar
DlgName=DllHwnd("Monitor")
WS_CAPTION=12582912 ;12582912 Hex 00C00000 (Search MSDN for Q111011 for more parameter values)
GWL_STYLE=-16
User32=StrCat(DirWindows(1),"USER32.DLL")
OldStyle=DllCall(User32, long:"GetWindowLongA", long:DlgName, long:GWL_STYLE)
NewStyle=OldStyle & ~WS_CAPTION
DllCall(User32, long:"SetWindowLongA", long:DlgName, long:GWL_STYLE, long:NewStyle)

; color - Green
BoxColor(1,"0,255,0",0)
BoxDrawRect(1,"0,0,1000,1000",2)

; Display tall thin box
BoxesUp("0,0,10,1000",@NORMAL)

TimeDelay(3)

; color - Red
BoxColor(1,"255,0,0",0)
BoxDrawRect(1,"0,0,1000,1000",2)

TimeDelay(3)
Exit

Article ID:   W17683
Filename:   BoxesUp Width Limitation.txt
File Created: 2010:12:09:11:54:12
Last Updated: 2010:12:09:11:54:12