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.

Text Alignment in BoxDrawText

Keywords: 	 text alignment boxdrawtext

Question:

How do you align text with a edit or select box in winbatch box? I have tried playing with another transparent box to contain the text and spacing the text that way, to no avail. Does any one have something like that?

Here is my sample code:

box_count=3
name_list=StrCat("Username",@TAB,"Password",@TAB,"Flags")

for i = 1 to box_count
BoxColor(1,"128,128,128",0)
box_coord=StrCat('"',x+75,",",y-25,",",x+185,",",y+135,'"')
BoxDrawRect(1,%box_coord%, 2)
item=ItemExtract(i,name_list,@TAB)
BoxDrawText(1,%box_coord%,item,@TRUE, 0|1)
sDLLName = StrCat(DirWindows(1), "User32.DLL")
sEntry = StrCat("long:", '"CreateWindowExA"')
sArgs = "long:dwExStyle"
sArgs = StrCat(sArgs, ", lpstr:lpClassName")
sArgs = StrCat(sArgs, ", long:lpWindowName")
sArgs = StrCat(sArgs, ", long:dwStyle")
sArgs = StrCat(sArgs, ", long:x")
sArgs = StrCat(sArgs, ", long:y")
sArgs = StrCat(sArgs, ", long:nWidth")
sArgs = StrCat(sArgs, ", long:nHeight")
sArgs = StrCat(sArgs, ", long:hWndParent")
sArgs = StrCat(sArgs, ", long:hMenu")
sArgs = StrCat(sArgs, ", long:hInstance")
sArgs = StrCat(sArgs, ", long:lParam")
hWndEdit%i% = DLLCall(sDLLName, %sEntry%, %sArgs%)
y=y+50
next

Answer:

It is much easier to align stuff between boxes 2 thru 8 rather than trying to align stuff between box 1 and other boxes. Mostly Box 1 and the other boxes are not the same "level" while as Boxes 2 thru 8 are, so they are more identical.

When I try to run it it fails immediately. Then I tried some fixes, but no go.

Anyway in looking at it my guess is that you are fighting between the 1000x1000 virtual co-ordinates that WinBatch uses and the real screen co-ordinates that CreateWindowA uses.

Basicaly you have to scale one to the other depending on screen resolution. Use WinMetrics 0 and 1 to get screen resolution.

Map one to the other.

real to virtual:

virtualx=realx*1000/WinMetrics(0)
virtualy=realy*1000/WinMetrics(1)

virtual to real:

realx=virtualx*WinMetrics(0)/1000
realy=virtualy*WinMetrics(0)/1000
Also watch out for how the points are defined. In WinBatch the co-ordinates are usually:
upper-left-x
upper-left-y
lower-right-x
lowerright=y
However in Create Window it is more like:
upper-left-x
upperleft-y
x-width
y-height
So besides converting real to virtual, you also have to worry about the meaning of each co-ordinate.
Article ID:   W15113
File Created: 2002:09:05:13:49:44
Last Updated: 2002:09:05:13:49:44