Jump to content

Fun With VB Controls


xroot
 Share

Recommended Posts

Playing around with VB controls trying to expose them to Au3 having bunch of fun.

Did not want to spend alot of time and code in doing this so I came up with

7 methods and 5 properties thats it.(see examples)

METHODS

$ObjPtr=$obj.SetWindow("title",width,height,

,[top])

$ObjPtr=$obj.SetControl($ObjPtr,

,[top],[width],[height],["title"])

$obj.SetMethod($ObjPtr,"Method Name",[var1],[var2],[var3],[var4],[var5])

$Prop =$obj.GetProperty($ObjPtr,"Property Name",[var1],[var2])

$obj.SetProperty($ObjPtr,"Property Name",[var1],[var2],[var3],[var4])

$obj.SetObject($ObjPtr,"Object Name Like "Icon" or "Picture","Filename of Object")

$obj.CloseIt($hWnd)

PROPERTIES

$hWnd =$obj.ShowIt Returns Handle to the Window

$ObjPtr=$obj.Click Returns Object Pointer to the Control

$win =$obj.DllActive Returns Number of Windows Open

$hDC =$obj.hDC Returns Handle to the Device Context

b$obj.SetWindowBorderStyle=0 None,1 Fixed Single,2 Sizable,3 Fixed Dialog,4 Fixed ToolWindow,

5 Sizable ToolWindow (*Must be set before SetWindow()*)

The "CommandButton","Image", and "PictureBox" controls can set the "Tag" property like

$obj.SetProperty($ObjPtr,"Tag","1") this will set the mouseover effect.

The 5 examples show how to use the controls to get you started.

Look in the Post with examples, file size was to large to include.

This site can help in properties and methods for each control.

http://msdn.microsoft.com/en-us/library/aa294929(v=office.11).aspx

http://msdn.microsoft.com/en-us/library/aa733701(v=VS.60).aspx

The controls are from the following files:

PictureBox=Intrinsic

Timer=Intrinsic

DriveListBox=Intrinsic

DirListBox=intrinsic

FileListBox=intrinsic

Frame=Intrinsic

Line=intrinsic

Shape=intrinsic

App=intrinsic

Screen=intrinsic

CommandButton=FM20 http://www.dll-files.com/dllindex/dll-files.shtml?fm20

Label=FM20

ListBox=FM20

TextBox=FM20

ComboBox=FM20

OptionButton=FM20

CheckBox=FM20

ScrollBar=FM20

Image=FM20

SpinButton=FM20

ToggleButton=FM20

MonthView=MSComCt2

DTPicker=MSComCt2

StatusBar=MSComCtl

ProgressBar=MSComCtl

MsFlexGrid=MSFLXGRD

SSTab=TABCTL32

If you don't have these activex files, they can be download from Inet.

WinObjs.zip

Edited by xroot
Link to comment
Share on other sites

Here are 3 examples 1,3,and 4

And 2 more.

#OnAutoItStartRegister "Reg_DLL"

Func Reg_DLL()
    RunWait(@SystemDir&"\regsvr32 /s "&@ScriptDir&"\WinObjs.dll") ;Register DLL
EndFunc

Func ObjErrFunc()
    Msgbox(0,"*COM ERROR*",$ObjErr.description&@LF& _
                           hex($ObjErr.number,8)&@LF& _
                           $ObjErr.windescription&@LF&$ObjErr.scriptline)
Endfunc

$ObjErr=ObjEvent("AutoIt.Error","ObjErrFunc")

Local $W=400,$H=320,$CenterX=(@DesktopWidth-$W)/2,$CenterY=(@DesktopHeight-$H)/2

$WW=ObjCreate("WinObjs.WinObjC")

$WW.SetWindowBorderStyle=3
$SW=$WW.SetWindow("Au3Gui From VB Objects",$W,$H,$CenterX,$CenterY)
$WW.SetObject($SW,"Icon",@ScriptDir&"\crapper.ico")
;$WW.SetProperty($SW,"BackColor",$Color)

$CB1=$WW.SetControl("CommandButton",310,80,60,35,"Exit")
;$WW.SetProperty($CB1,"AutoSize",True)
$WW.SetProperty($CB1,"BackColor",0xFFFF00)
;$WW.SetProperty($CB1,"BackStyle",0)
$WW.SetProperty($CB1,"FontName","Arial")
$WW.SetProperty($CB1,"FontBold",True)
$WW.SetProperty($CB1,"FontSize",12)
$WW.SetProperty($CB1,"FontUnderline",True)
;$WW.SetProperty($CB1,"Tag","1")  ;MouseOver

$SS=$WW.SetControl("Shape",304,75,70,45)
$WW.SetProperty($SS,"Shape",4)
$WW.SetProperty($SS,"BorderWidth",2)
$WW.SetProperty($SS,"BorderColor",0x0000FF)
$WW.SetProperty($SS,"FillStyle",0) ;Solid
$WW.SetProperty($SS,"FillColor",0x0000FF)

$CB2=$WW.SetControl("CommandButton",300,10,90,45,"Get ComboBox")
;$WW.SetProperty($CB2,"AutoSize",True)
$WW.SetProperty($CB2,"BackStyle",0)
;$WW.SetProperty($CB2,"BackColor",0x00FF00)
$WW.SetProperty($CB2,"FontBold",True)
$WW.SetProperty($CB2,"FontSize",10)
;$WW.SetProperty($CB2,"FontUnderline",True)

$COB=$WW.SetControl("ComboBox",10,10,285,30)
;$WW.SetProperty($COB,"AutoSize",True)
;$WW.SetProperty($COB,"AutoTab",True)
$WW.SetProperty($COB,"BackStyle",0)
$WW.SetMethod($COB,"AddItem","Item 1")
$WW.SetMethod($COB,"AddItem","Item 2")
$WW.SetMethod($COB,"AddItem","Item 3")
$WW.SetMethod($COB,"AddItem","Item 4")
$WW.SetProperty($COB,"ListIndex",0)
$WW.SetProperty($COB,"FontBold",True)
$WW.SetProperty($COB,"FontSize",14)
$WW.SetProperty($COB,"ToolTipText","ComboBox Control")

$IM=$WW.SetControl("Image",10,50,169,68)
;$WW.SetProperty($IM,"AutoSize",True)
;$WW.SetProperty($IM,"Stretch",True)
;$WW.SetProperty($IM,"BorderStyle",1)
$WW.SetObject($IM,"Picture",@ScriptDir&"\logo4.gif")
$WW.SetProperty($IM,"ToolTipText","Image Control")
;$WW.SetProperty($IM,"Tag","1")   ;MouseOver

$SS=$WW.SetControl("Shape",190,55,95,75)
$WW.SetProperty($SS,"Shape",3)  ; Circle
$WW.SetProperty($SS,"BorderWidth",5)
$WW.SetProperty($SS,"BorderColor",0x00FF00) ;Green
$WW.SetProperty($SS,"FillStyle",0) ;Solid
$WW.SetProperty($SS,"FillColor",0xFF0000) ;Red

$Line=$WW.SetControl("Line",10,375,150,150)
$WW.SetProperty($Line,"BorderWidth",5)
$WW.SetProperty($Line,"BorderColor",0xFF00FF)

$CKBX=$WW.SetControl("CheckBox",20,170,105,30,"CheckBox")
;$WW.SetProperty($CKBX,"AutoSize",True)
$WW.SetProperty($CKBX,"BackStyle",0)
$WW.SetProperty($CKBX,"FontBold",True)
$WW.SetProperty($CKBX,"FontSize",12)
;$WW.SetProperty($CKBX,"GroupName","CheckBox")
;$WW.SetProperty($CKBX,"BackColor",$Color)

$OB=$WW.SetControl("OptionButton",205,170,145,30,"OptionButton")
;$WW.SetProperty($OB,"AutoSize",True)
$WW.SetProperty($OB,"BackStyle",0)
$WW.SetProperty($OB,"FontBold",True)
$WW.SetProperty($OB,"FontSize",12)
;$WW.SetProperty($OB,"GroupName","OptionButton")
;$WW.SetProperty($OB,"BackColor",$Color)

$SS=$WW.SetControl("Shape",10,165,350,45)
$WW.SetProperty($SS,"Shape",4)
$WW.SetProperty($SS,"BorderWidth",4)
;$WW.SetProperty($SS,"BorderColor",0xFFFF00)
;$WW.SetProperty($SS,"FillStyle",0) ;Solid
;$WW.SetProperty($SS,"FillColor",0x00FFFF)

$TB=$WW.SetControl("TextBox",10,225,200,30)
;$WW.SetProperty($TB,"AutoSize",True)
$WW.SetProperty($TB,"BackStyle",0)
$WW.SetProperty($TB,"FontBold",True)
$WW.SetProperty($TB,"FontSize",14)
;$WW.SetProperty($TB,"Text","Hi, From a TextBox")
;$WW.SetProperty($TB,"BorderStyle",0)
;$WW.SetProperty($TB,"BackColor",$Color)
$WW.SetProperty($TB,"ToolTipText","TextBox Control")

$LL=$WW.SetControl("Label",220,230,170,20,"<--DblClick TextBox")
;$WW.SetProperty($LL,"AutoSize",True)
$WW.SetProperty($LL,"BackStyle",0)
$WW.SetProperty($LL,"FontBold",True)
$WW.SetProperty($LL,"FontSize",12)
$WW.SetProperty($LL,"FontUnderLine",True)
;$WW.SetProperty($LL,"ForeColor",0x0000FF)
;$WW.SetProperty($LL,"BackColor",$Color)
$WW.SetProperty($LL,"ToolTipText","Label Control")

$HSB=$WW.SetControl("ScrollBar",10,260,200,20)
$WW.SetProperty($HSB,"Min",1)
$WW.SetProperty($HSB,"Max",100)
;$WW.SetProperty($HSB,"ForeColor",0xFFFF00)
$WW.SetProperty($HSB,"BackColor",0x00FFFF)
$WW.SetProperty($HSB,"ToolTipText","ScrollBar Control")

$IM2=$WW.SetControl("Image",0,0,$W,$H)
$WW.SetProperty($IM2,"PictureTiling",True)
$WW.SetObject($IM2,"Picture",@ScriptDir&"\Mac4.bmp")

$TM=$WW.SetControl("Timer",1000)

$hWnd=$WW.ShowIt

While $WW.DllActive
    Switch $WW.Click
        Case $TM
            If $WW.GetProperty($Line,"Visible") Then
                $WW.SetProperty($Line,"Visible",False)
            Else
                $WW.SetProperty($Line,"Visible",True)
            EndIf
        Case $CB1
            $WW.CloseIt($hWnd)
        Case $CB2
            MsgBox(0,"ComboBox ",$WW.GetProperty($COB,"Text"),1)
        Case $TB
            MsgBox(0,"TextBox",$WW.GetProperty($TB,"Text"),1)
        Case $CKBX
            If $WW.GetProperty($CKBX,"Value") Then
                MsgBox(0,"CheckBox","Checked",1)
            Else
                MsgBox(0,"CheckBox","UnChecked",1)
            EndIf
        Case $IM
                MsgBox(0,"Image","Hi, Clicked Image Control",1)
        Case $OB
           If $WW.GetProperty($OB,"Value") Then
                MsgBox(0,"OptionButton","True",1)
            Else
                MsgBox(0,"OptionButton","False",1)
            EndIf
        Case $HSB
            $WW.SetProperty($TB,"Text","HScrollBar @"&$WW.GetProperty($HSB,"Value"))
    EndSwitch
    Sleep(1)
WEnd
$WW=0

#OnAutoItStartRegister "Reg_DLL"

Func Reg_DLL()
    RunWait(@SystemDir&"\regsvr32 /s "&@ScriptDir&"\WinObjs.dll") ;Register DLL
EndFunc

Func ObjErrFunc()
    Msgbox(0,"*COM ERROR*",$ObjErr.description&@LF& _
                           hex($ObjErr.number,8)&@LF& _
                           $ObjErr.windescription&"Line "&$ObjErr.scriptline)
Endfunc

$ObjErr=ObjEvent("AutoIt.Error","ObjErrFunc")

Local $W=800,$H=600,$CenterX=(@DesktopWidth-$W)/2,$CenterY=(@DesktopHeight-$H)/2
Local $pCom[14],$HR="",$IO="",$AmPm=""
Local $Tabs=6,$Panel[$Tabs]=["ComboBox","PickDate","Toggle","Spin","Frame",""]
Local $gName[$Tabs]=["Amanda","Bill","Michael","Susan","Wendy","James"]
Local $gAddr[$Tabs]=["1028 Vernal Ave","1176 Willow St","1663 Savannah Court","3039 Parsons Ave", _
                     "1400 Marguerite St","895 San Andreas Court"]
Local $gPhone[$Tabs]=["722-2385","201-7914","384-3936","631-9955","723-7942","723-8851"]
Local $Stat[$Tabs]=["1","2","3","4","5",""]
Local $Head="|<Name|<Address|<Phone;|1|2|3|4|5|6|7|8|9|10|11|12"

$WW=ObjCreate("WinObjs.WinObjC")

$WW.SetWindowBorderStyle=1
$pWW=$WW.SetWindow("Au3Gui From VB Objects",$W,$H,$CenterX,$CenterY)
$WW.SetObject($pWW,"Icon",@ScriptDir&"\crapper.ico")

$SB=$WW.SetControl("StatusBar",-1,0,-1,35)  ;-1 Dummy Can't Change Left&Width
$Font=$WW.GetProperty($SB,"Font")  ;Get Font Object
$WW.SetProperty($Font,"Size",12)
$WW.SetProperty($Font,"Bold",True)
$Pan=$WW.GetProperty($SB,"Panels") ;Get Panels Object
$WW.SetMethod($Pan,"Clear")
For $I=1 To $Tabs
    $WW.SetMethod($Pan,"Add",$I,"",$Stat[$I-1])
    $WW.SetProperty($Pan,"Panel",$I,"AutoSize",2)
    $WW.SetProperty($Pan,"Panel",$I,"Alignment",1) ;Center
Next
$WW.SetProperty($Pan,"Panel",2,"Text","Any Caption")
$WW.SetProperty($Pan,"Panel",5,"Style",5) ;Time
$WW.SetProperty($Pan,"Panel",6,"AutoSize",0)
$WW.SetProperty($Pan,"Panel",6,"MinWidth",840)
$WW.SetProperty($Pan,"Panel",6,"Picture",@ScriptDir&"\exit.bmp")

$pCom[0]=$WW.SetControl("CommandButton",190,60);,55,55)
$WW.SetProperty($pCom[0],"AutoSize",True)
$WW.SetObject($pCom[0],"Picture",@ScriptDir&"\exit.bmp")

$Pos=0
For $I=1 To 13
    $pCom[$I]=$WW.SetControl("CommandButton",$Pos,0,61,30,$I)
    If Mod($I,2) Then
       $WW.SetProperty($pCom[$I],"BackColor",0xFFE4C4)
    Else
       $WW.SetProperty($pCom[$I],"BackColor",0xDEB887)
    EndIf
    $WW.SetProperty($pCom[$I],"FontSize",12)
    $WW.SetProperty($pCom[$I],"FontBold",True)
    $Pos+=61
Next

$TB=$WW.SetControl("ToggleButton",150,60,100,40,"Add Date To StatusBar")
$WW.SetProperty($TB,"ForeColor",0x0000FF)
$WW.SetProperty($TB,"AutoSize",True)
$WW.SetProperty($TB,"FontSize",10)
$WW.SetProperty($TB,"FontBold",True)

$SB2=$WW.SetControl("SpinButton",120,90,100,30)
$WW.SetProperty($SB2,"Min",1)
$WW.SetProperty($SB2,"Max",100)

$CB=$WW.SetControl("ComboBox",15,70,250,30)
For $I=0 To $Tabs-1
    $WW.SetMethod($CB,"AddItem",$gName[$I])
    $WW.SetMethod($CB,"AddItem",$gAddr[$I])
    $WW.SetMethod($CB,"AddItem",$gPhone[$I])
Next
$WW.SetProperty($CB,"ListIndex",0)
$WW.SetProperty($CB,"FontSize",12)
$WW.SetProperty($CB,"FontBold",True)

$DP=$WW.SetControl("DTPicker",15,70,255,25)
$WW.SetProperty($DP,"Format",0)
$Font=$WW.GetProperty($DP,"Font")
$WW.SetProperty($Font,"Size",10)
$WW.SetProperty($Font,"Bold",True)

$PB=$WW.SetControl("ProgressBar",10,60,260,20)
$WW.SetProperty($PB,"Scrolling",1)

$TX=$WW.SetControl("TextBox",60,90);,30,30)
$WW.SetProperty($TX,"AutoSize",True)
$WW.SetProperty($TX,"BackStyle",0) ;Transparent
;$WW.SetProperty($TX,"BorderStyle",0) ;None
$WW.SetProperty($TX,"SpecialEffect",0) ;Flat
$WW.SetProperty($TX,"FontBold",True)
$WW.SetProperty($TX,"FontSize",14)
$WW.SetProperty($TX,"ForeColor",0xFF00FF)

$FR=$WW.SetControl("Frame",10,45,260,95,"Frame Control")
$WW.SetProperty($FR,"FontBold",True)

$ST=$WW.SetControl("SSTab",30,50,290,150)
$WW.SetProperty($ST,"ForeColor",0xFF0000)
;$WW.SetProperty($ST,"BackColor",0xFFFFFF)
;$WW.SetProperty($ST,"Style",1)
$Font=$WW.GetProperty($ST,"Font")
$WW.SetProperty($Font,"Size",12)
$WW.SetProperty($Font,"Bold",True)
$WW.SetProperty($ST,"Tabs",$Tabs)
$WW.SetProperty($ST,"TabsPerRow",$Tabs/2)
For $I=0 To $Tabs-1
    $WW.SetProperty($ST,"TabCaption",$I,$Panel[$I])
Next
$WW.SetProperty($CB,"Container",$ST)  ;ComboBox
$WW.SetProperty($ST,"Tab",1)
$WW.SetProperty($DP,"Container",$ST)  ;DatePicker
$WW.SetProperty($ST,"Tab",2)
$WW.SetProperty($TB,"Container",$ST)  ;ToggleButton
$WW.SetProperty($ST,"Tab",3)
$WW.SetProperty($SB2,"Container",$ST) ;SpinButtons
$WW.SetProperty($PB,"Container",$ST)  ;ProgressBar
$WW.SetProperty($TX,"Container",$ST)  ;TextBox
$WW.SetProperty($ST,"Tab",4)
$WW.SetProperty($FR,"Container",$ST)  ;Frame
$WW.SetProperty($ST,"Tab",5)
$WW.SetProperty($ST,"Caption","Exit")
$WW.SetProperty($pCom[0],"Container",$ST) ;CommandButton
$WW.SetProperty($ST,"Tab",0)

$MV=$WW.SetControl("MonthView",360,50)
$WW.SetProperty($MV,"MonthColumns",2)
$WW.SetProperty($MV,"MonthRows",3)
$WW.SetProperty($MV,"TitleBackColor",0x0000FF)
$WW.SetProperty($MV,"TitleForeColor",0xFFFF00)
$WW.SetProperty($MV,"ForeColor",0x0000FF)
$WW.SetProperty($MV,"MonthBackColor",0xFFFF00)
$Font=$WW.GetProperty($MV,"Font")
$WW.SetProperty($Font,"Bold",True)

$FG=$WW.SetControl("MsFlexGrid",30,220,295,290)
;$WW.SetProperty($FG,"AllowUserResizing",3)
;$WW.SetProperty($FG,"Rows",12)
;$WW.SetProperty($FG,"Cols",4)
$Font=$WW.GetProperty($FG,"Font")
$WW.SetProperty($Font,"Size",12)
$WW.SetProperty($Font,"Bold",True)
$WW.SetProperty($FG,"FormatString",$Head)
;$WW.SetProperty($FG,"ColAlignment",2,1)
;$WW.SetProperty($FG,"ColAlignment",3,1)
$WW.SetProperty($FG,"ColWidth",1,72)
$WW.SetProperty($FG,"ColWidth",2,200)
$WW.SetProperty($FG,"ColWidth",3,85)
For $I=1 To $Tabs
    $WW.SetProperty($FG,"TextMatrix",$I,1,$gName[$I-1])
    $WW.SetProperty($FG,"TextMatrix",$I,2,$gAddr[$I-1])
    $WW.SetProperty($FG,"TextMatrix",$I,3,$gPhone[$I-1])
Next

$IM=$WW.SetControl("Image",0,0,$W,$H)
$WW.SetProperty($IM,"PictureTiling",True)
$WW.SetObject($IM,"Picture",@ScriptDir&"\Mac4.bmp")

$hWnd=$WW.ShowIt

While $WW.DllActive
    $IO=$WW.Click
    Switch $IO
        Case $pCom[0]
            $WW.CloseIt($hWnd)
        Case $DP
            MsgBox(4096,"Date Changed",$WW.GetProperty($DP,"Value"),1)
        Case $MV
            MsgBox(4096,"Date Click",$WW.GetProperty($MV,"Value"),1)
        Case $SB
            Switch $WW.GetProperty($Pan,"Panel","Index")
                Case 5
                    Switch @HOUR
                        Case 0
                            $HR=12
                            $AmPm="AM"
                        Case 1 To 11
                            $HR=@HOUR
                            $AmPm="AM"
                        Case 12
                            $HR=@HOUR
                            $AmPm="PM"
                        Case 13 To 23
                            $HR=@HOUR-12
                            $AmPm="PM"
                    EndSwitch
                    Msgbox(0,"StatusBar",StringFormat("%s:%s %s",$HR,@MIN,$AmPm),1)
                Case 6
                    $WW.CloseIt($hWnd)
                Case 7
                    Msgbox(0,"StatusBar",@MON&"/"&@MDAY&"/"&@YEAR,1)
                Case Else
                    Msgbox(0,"StatusBar",$WW.GetProperty($Pan,"Panel","Text"),1)
            EndSwitch
        Case $FG
            $IO=InputBox("MSFlexGrid","Row="&$WW.GetProperty($FG,"Row")&@LF&"Column="& _
                         $WW.GetProperty($FG,"Col"),$WW.GetProperty($FG,"Text"))
            If @error<>1 Then $WW.SetProperty($FG,"Text",$IO)
        Case $SB2
            $WW.SetProperty($PB,"Value",$WW.GetProperty($SB2,"Value"))
            $WW.SetProperty($TX,"Value",$WW.GetProperty($SB2,"Value"))
        Case $CB
            If $WW.GetProperty($CB,"SelText") Then MsgBox(4096,"ComboBox",$WW.GetProperty($CB,"Text"),1)
        Case $TB
            If $WW.GetProperty($TB,"Value") Then
                $WW.SetMethod($Pan,"Add")
                $WW.SetProperty($Pan,"Panel",$WW.GetProperty($Pan,"Count"),"Style",6)
            Else
                $WW.SetMethod($Pan,"Remove",$WW.GetProperty($Pan,"Count"))
            EndIf
        Case Else
            If $IO Then
                For $I=1 To 13
                    If $IO=$pCom[$I] Then
                        MsgBox(0,"Click","Clicked Button "&$I,1)
                        ExitLoop
                    EndIf
                Next
            EndIf
    EndSwitch
    Sleep(1)
WEnd
$WW=0

examples.zip

Edited by xroot
Link to comment
Share on other sites

Fantastic!

Thank you very much for your work on this.

That solves also the "from time to time" question,

how MSFlexGrid can be used with au3. Now we have the answer.

Can MSHFlexGrid also used with this method?

If it is not to much work an example (by time) would be great.

best regards, Reinhard

PS: Where is the five stars button?

Link to comment
Share on other sites

Mmmh,

regarding FLEXGRID it seems the most import properties I was looking for (RowHeight, FixedRows, FixedCols) are only available in MSHFLEXGRID.

Can you bind that into the dll?

best regards, Reinhard

Link to comment
Share on other sites

I get:

800401F3
Invalid class string
Line 17

in example 4. and similar errors in the other 2.

this line is always failing: $WW=ObjCreate("WinObjs.WinObjC")

I found the error to be the same old command line error of not knowing that its a file. This is the solution:

RunWait(@SystemDir & "\regsvr32 /s "& FileGetShortName(@ScriptDir & "\WinObjs.dll"))

even then I get a lot of messages about missing msflex.ocx:

Component 'MSFLXGRD.OCX' or one of its dependencies not correctly registered: a file is missing or invalid
80020009
Line 21

The easiest way to fix it is look at this page here.

Link to comment
Share on other sites

Mmmh,

regarding FLEXGRID it seems the most import properties I was looking for (RowHeight, FixedRows, FixedCols) are only available in MSHFLEXGRID.

Can you bind that into the dll?

best regards, Reinhard

Remember that FixedCols must be at least one less than Cols value and FixedRows must be at least one less than Rows value.

I forgot to ajust the Twips for RowHeight, it now works.

Thanks

Link to comment
Share on other sites

Great!

Now it works (see quick example based on your example5 - I think)

Maybe my fault that FixedRows/-Cols didn't work.

I interpreted the title Row/Col as header(0) and set FixedRows/-Cols to 1, with set to 2 it works.

Now I will play a little bit with it.

Thanks very much,

Reinhard

#OnAutoItStartRegister "Reg_DLL"

Func Reg_DLL()
    RunWait(@SystemDir&"\regsvr32 /s "&@ScriptDir&"\WinObjs.dll") ;Register DLL
EndFunc


$WW=ObjCreate("WinObjs.WinObjC")
if not isobj($WW) Then
    msgBox(0,"","Coudn't create Object"&@lf&"TryNew")
    Exit
endif

$ObjErr=ObjEvent("AutoIt.Error","ObjErrFunc")
Func ObjErrFunc()
    Msgbox(0,"*COM ERROR*",$ObjErr.description&@LF& _
                           hex($ObjErr.number,8)&@LF& _
                           $ObjErr.windescription&"Line "&$ObjErr.scriptline)
Endfunc



Local $W=800,$H=600,$CenterX=(@DesktopWidth-$W)/2,$CenterY=(@DesktopHeight-$H)/2
Local $pCom[14],$HR="",$IO="",$AmPm=""
Local $Tabs=6,$Panel[$Tabs]=["ComboBox","PickDate","Toggle","Spin","Frame",""]
Local $gName[$Tabs]=["Amanda","Bill","Michael","Susan","Wendy","James"]
Local $gAddr[$Tabs]=["1028 Vernal Ave","1176 Willow St","1663 Savannah Court","3039 Parsons Ave", _
                     "1400 Marguerite St","895 San Andreas Court"]
Local $gPhone[$Tabs]=["722-2385","201-7914","384-3936","631-9955","723-7942","723-8851"]
Local $Stat[$Tabs]=["1","2","3","4","5",""]
Local $Head="|<Name|<Address|<Phone;|1|2|3|4|5|6|7|8|9|10|11|12"



$WW.SetWindowBorderStyle=1
$pWW=$WW.SetWindow("Au3Gui From VB Objects",$W,$H,$CenterX,$CenterY)
$WW.SetObject($pWW,"Icon",@ScriptDir&"\crapper.ico")

$SB=$WW.SetControl("StatusBar",-1,0,-1,35)  ;-1 Dummy Can't Change Left&Width
$Font=$WW.GetProperty($SB,"Font")  ;Get Font Object
$WW.SetProperty($Font,"Size",12)
$WW.SetProperty($Font,"Bold",True)
$Pan=$WW.GetProperty($SB,"Panels") ;Get Panels Object
$WW.SetMethod($Pan,"Clear")
For $I=1 To $Tabs
    $WW.SetMethod($Pan,"Add",$I,"",$Stat[$I-1])
    $WW.SetProperty($Pan,"Panel",$I,"AutoSize",2)
    $WW.SetProperty($Pan,"Panel",$I,"Alignment",1) ;Center
Next
$WW.SetProperty($Pan,"Panel",2,"Text","Any Caption")
$WW.SetProperty($Pan,"Panel",5,"Style",5) ;Time
$WW.SetProperty($Pan,"Panel",6,"AutoSize",0)
$WW.SetProperty($Pan,"Panel",6,"MinWidth",840)
$WW.SetProperty($Pan,"Panel",6,"Picture",@ScriptDir&"\exit.bmp")

$pCom[0]=$WW.SetControl("CommandButton",190,60);,55,55)
$WW.SetProperty($pCom[0],"AutoSize",True)
$WW.SetObject($pCom[0],"Picture",@ScriptDir&"\exit.bmp")

$Pos=0
For $I=1 To 13
    $pCom[$I]=$WW.SetControl("CommandButton",$Pos,0,61,30,$I)
    If Mod($I,2) Then
       $WW.SetProperty($pCom[$I],"BackColor",0xFFE4C4)
    Else
       $WW.SetProperty($pCom[$I],"BackColor",0xDEB887)
    EndIf
    $WW.SetProperty($pCom[$I],"FontSize",12)
    $WW.SetProperty($pCom[$I],"FontBold",True)
    $Pos+=61
Next

$TB=$WW.SetControl("ToggleButton",150,60,100,40,"Add Date To StatusBar")
$WW.SetProperty($TB,"ForeColor",0x0000FF)
$WW.SetProperty($TB,"AutoSize",True)
$WW.SetProperty($TB,"FontSize",10)
$WW.SetProperty($TB,"FontBold",True)

$SB2=$WW.SetControl("SpinButton",120,90,100,30)
$WW.SetProperty($SB2,"Min",1)
$WW.SetProperty($SB2,"Max",100)

$CB=$WW.SetControl("ComboBox",15,70,250,30)
For $I=0 To $Tabs-1
    $WW.SetMethod($CB,"AddItem",$gName[$I])
    $WW.SetMethod($CB,"AddItem",$gAddr[$I])
    $WW.SetMethod($CB,"AddItem",$gPhone[$I])
Next
$WW.SetProperty($CB,"ListIndex",0)
$WW.SetProperty($CB,"FontSize",12)
$WW.SetProperty($CB,"FontBold",True)

$DP=$WW.SetControl("DTPicker",15,70,55,25)
$WW.SetProperty($DP,"Format",0)
$Font=$WW.GetProperty($DP,"Font")
$WW.SetProperty($Font,"Size",10)
$WW.SetProperty($Font,"Bold",True)

$PB=$WW.SetControl("ProgressBar",10,60,260,20)
$WW.SetProperty($PB,"Scrolling",1)

$TX=$WW.SetControl("TextBox",60,90);,30,30)
$WW.SetProperty($TX,"AutoSize",True)
$WW.SetProperty($TX,"BackStyle",0) ;Transparent
;$WW.SetProperty($TX,"BorderStyle",0) ;None
$WW.SetProperty($TX,"SpecialEffect",0) ;Flat
$WW.SetProperty($TX,"FontBold",True)
$WW.SetProperty($TX,"FontSize",14)
$WW.SetProperty($TX,"ForeColor",0xFF00FF)

$FR=$WW.SetControl("Frame",10,45,160,95,"Frame Control")
$WW.SetProperty($FR,"FontBold",True)

$ST=$WW.SetControl("SSTab",30,50,290,150)
$WW.SetProperty($ST,"ForeColor",0xFF0000)
;$WW.SetProperty($ST,"BackColor",0xFFFFFF)
;$WW.SetProperty($ST,"Style",1)
$Font=$WW.GetProperty($ST,"Font")
$WW.SetProperty($Font,"Size",12)
$WW.SetProperty($Font,"Bold",True)
$WW.SetProperty($ST,"Tabs",$Tabs)
$WW.SetProperty($ST,"TabsPerRow",$Tabs/2)
For $I=0 To $Tabs-1
    $WW.SetProperty($ST,"TabCaption",$I,$Panel[$I])
Next
$WW.SetProperty($CB,"Container",$ST)  ;ComboBox
$WW.SetProperty($ST,"Tab",1)
$WW.SetProperty($DP,"Container",$ST)  ;DatePicker
$WW.SetProperty($ST,"Tab",2)
$WW.SetProperty($TB,"Container",$ST)  ;ToggleButton
$WW.SetProperty($ST,"Tab",3)
$WW.SetProperty($SB2,"Container",$ST) ;SpinButtons
$WW.SetProperty($PB,"Container",$ST)  ;ProgressBar
$WW.SetProperty($TX,"Container",$ST)  ;TextBox
$WW.SetProperty($ST,"Tab",4)
$WW.SetProperty($FR,"Container",$ST)  ;Frame
$WW.SetProperty($ST,"Tab",5)
$WW.SetProperty($ST,"Caption","Exit")
$WW.SetProperty($pCom[0],"Container",$ST) ;CommandButton
$WW.SetProperty($ST,"Tab",0)

$MV=$WW.SetControl("MonthView",360,50)
$WW.SetProperty($MV,"MonthColumns",2)
$WW.SetProperty($MV,"MonthRows",1)
$WW.SetProperty($MV,"TitleBackColor",0x0000FF)
$WW.SetProperty($MV,"TitleForeColor",0xFFFF00)
$WW.SetProperty($MV,"ForeColor",0x0000FF)
$WW.SetProperty($MV,"MonthBackColor",0xFFFF00)
$Font=$WW.GetProperty($MV,"Font")
$WW.SetProperty($Font,"Bold",True)

$FG=$WW.SetControl("MsFlexGrid",30,220,295+400,290)
$WW.SetProperty($FG,"AllowUserResizing",3)
;$WW.SetProperty($FG,"Rows",12)
$WW.SetProperty($FG,"Cols",8)
$Font=$WW.GetProperty($FG,"Font")
$WW.SetProperty($Font,"Size",12)
$WW.SetProperty($Font,"Bold",True)
$WW.SetProperty($FG,"FormatString",$Head)
;$WW.SetProperty($FG,"ColAlignment",2,1)
;$WW.SetProperty($FG,"ColAlignment",3,1)
$WW.SetProperty($FG,"ColWidth",1,72)
$WW.SetProperty($FG,"ColWidth",2,200)
$WW.SetProperty($FG,"ColWidth",3,85)

$WW.SetProperty($FG,"FixedCols",2)
$WW.SetProperty($FG,"FixedRows",2)
$WW.SetProperty($FG,"BackColor",0x0000FF)

For $I=1 To $Tabs
    $WW.SetProperty($FG,"TextMatrix",$I,1,$gName[$I-1])
    $WW.SetProperty($FG,"TextMatrix",$I,2,$gAddr[$I-1])
    $WW.SetProperty($FG,"TextMatrix",$I,3,$gPhone[$I-1])
Next


$IM=$WW.SetControl("Image",0,0,$W,$H)
$WW.SetProperty($IM,"PictureTiling",True)
$WW.SetObject($IM,"Picture",@ScriptDir&"\Mac4.bmp")

$hWnd=$WW.ShowIt

While $WW.DllActive
    $IO=$WW.Click
    Switch $IO
        Case $pCom[0]
            $WW.CloseIt($hWnd)
        Case $DP
            MsgBox(4096,"Date Changed",$WW.GetProperty($DP,"Value"),1)
        Case $MV
            MsgBox(4096,"Date Click",$WW.GetProperty($MV,"Value"),1)
        Case $SB
            Switch $WW.GetProperty($Pan,"Panel","Index")
                Case 5
                    Switch @HOUR
                        Case 0
                            $HR=12
                            $AmPm="AM"
                        Case 1 To 11
                            $HR=@HOUR
                            $AmPm="AM"
                        Case 12
                            $HR=@HOUR
                            $AmPm="PM"
                        Case 13 To 23
                            $HR=@HOUR-12
                            $AmPm="PM"
                    EndSwitch
                    Msgbox(0,"StatusBar",StringFormat("%s:%s %s",$HR,@MIN,$AmPm),1)
                Case 6
                    $WW.CloseIt($hWnd)
                Case 7
                    Msgbox(0,"StatusBar",@MON&"/"&@MDAY&"/"&@YEAR,1)
                Case Else
                    Msgbox(0,"StatusBar",$WW.GetProperty($Pan,"Panel","Text"),1)
            EndSwitch
        Case $FG
            $IO=InputBox("MSFlexGrid","Row="&$WW.GetProperty($FG,"Row")&@LF&"Column="& _
                         $WW.GetProperty($FG,"Col"),$WW.GetProperty($FG,"Text"))
            If @error<>1 Then $WW.SetProperty($FG,"Text",$IO)
        Case $SB2
            $WW.SetProperty($PB,"Value",$WW.GetProperty($SB2,"Value"))
            $WW.SetProperty($TX,"Value",$WW.GetProperty($SB2,"Value"))
        Case $CB
            If $WW.GetProperty($CB,"SelText") Then MsgBox(4096,"ComboBox",$WW.GetProperty($CB,"Text"),1)
        Case $TB
            If $WW.GetProperty($TB,"Value") Then
                $WW.SetMethod($Pan,"Add")
                $WW.SetProperty($Pan,"Panel",$WW.GetProperty($Pan,"Count"),"Style",6)
            Else
                $WW.SetMethod($Pan,"Remove",$WW.GetProperty($Pan,"Count"))
            EndIf
        Case Else
            If $IO Then
                For $I=1 To 13
                    If $IO=$pCom[$I] Then
                        MsgBox(0,"Click","Clicked Button "&$I,1)
                        ExitLoop
                    EndIf
                Next
            EndIf
    EndSwitch
    Sleep(1)
WEnd
$WW=0
Edited by ReFran
Link to comment
Share on other sites

  • 4 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...