Private oWGui 'object API GUI Private oWsm 'object SendMessage (syntax different) Private oWaw 'object ANSI -> UNICODE conversion
Private MSG 'structure MSG from API Private hIns 'instance handle Private hWsh 'main window WScript handle (hidden) Private hWF 'form handle
Private Sub Class_Initialize 'Constructor Const GWL_HINSTANCE=-6 Set oWGui=CreateObject("DynamicWrapper") Set oWsm=CreateObject("DynamicWrapper") Set oWaw=CreateObject("DynamicWrapper") With oWGui .Register "user32.dll","FindWindowA","f=s","i=ss","r=l" .Register "user32.dll","CreateWindowExA","f=s","i=lsslllllllll","r=l" .Register "user32.dll","SetWindowPos","f=s","i=lllllll","r=l" .Register "user32.dll","GetMessageA","f=s","i=llll","r=l" .Register "user32.dll","DispatchMessageA","f=s","i=l","r=l" .Register "user32.dll","TranslateMessage","i=l","f=s","r=l" .Register "user32.dll","GetWindowLongA","f=s","i=ll","r=l" .Register "user32.dll","SendMessageA","f=s","i=llll","r=l" .Register "user32.dll","SetWindowLongA","f=s","i=lll","r=l" .Register "user32.dll","GetWindowLongA","f=s","i=ll","r=l" .Register "user32.dll","IsDialogMessageA","f=s","i=ll","r=l" .Register "user32.dll","DestroyWindow","f=s","i=l","r=l" .Register "user32.dll","GetFocus","f=s","r=l" .Register "user32.dll","GetWindowTextA","f=s","i=lll","r=l" .Register "user32.dll","GetWindowTextLengthA","f=s","i=l","r=l" .Register "user32.dll","GetClassLongA","f=s","i=ll","r=l" .Register "gdi32.dll","GetStockObject","f=s","i=l","r=l" End With oWsm.Register "user32.dll","SendMessageA","f=s","i=llls","r=l" 'di oWaw.Register "kernel32.dll","MultiByteToWideChar","f=s","i=llllll","r=l" Set MSG=New Struct With MSG .Add "hwnd","HWND",0 .Add "message","UINT",0 .Add "wParam","WPARAM",0 .Add "lParam","LPARAM",0 .Add "time","DWORD",0 .Add "ptx","POINTX",0 .Add "pty","POINTY",0 End With Set dFrmData=CreateObject("Scripting.Dictionary") hWsh=oWGui.FindWindowA("WSH-Timer",chr(0)) hIns=oWGui.GetWindowLongA(hWsh,GWL_HINSTANCE) End Sub Private Function GetBSTRCtrl(hdW) ' Return handle hdW control content as string BSTR Const CP_ACP=0 Dim sBuf,sBufW sBuf=String(oWGui.GetWindowTextLengthA(hdW),Chr(0)) sBufW=String(oWGui.GetWindowTextA(hdW,MSG.GetBSTRPtr(sBuf),oWGui.GetWindowTextLengthA(hdW)+1),Chr(0)) oWaw.MultiByteToWideChar CP_ACP,0,MSG.GetBSTRPtr(sBuf),-1,MSG.GetBSTRPtr(sBufW),LenB(sBufW) GetBSTRCtrl=sBufW End Function End Class
'************************************************************************* DialogBox SAMPLE
Dim oFrm Set oFrm=New XGui oFrm.CreateForm "DialogBox by omen999",150,300,480,300,-1 ' modeless form oFrm.AddControl "label1","static","&Last Name :",10,8,60,16 oFrm.AddControl "edit1","edit","",10,26,120,20 oFrm.AddControl "label2","static","&First Name :",10,50,60,16 oFrm.AddControl "edit2","edit","",10,68,120,20 oFrm.AddControl "label3","static","A&ddress :",10,94,100,16 oFrm.AddControl "edit3","edit","",10,112,150,20 oFrm.AddControl "label4","static","&City :",10,136,100,20 oFrm.AddControl "edit4","edit","",10,152,100,20 oFrm.AddControl "gbox1","groupbox"," Sex ",6,178,84,72 oFrm.AddControl "rdbox1","radiobutton","&Male",10,194,68,18 oFrm.AddControl "rdbox2k","radiobutton","&Female",10,212,68,18 'this control will be checked oFrm.AddControl "rdbox3","radiobutton","&Don't know",10,230,74,18 oFrm.AddControl "label5","static","&Status :",146,8,40,16 oFrm.AddControl "cbox1","combobox","single|married|divorcee",146,26,150,80 oFrm.AddControl "label6","static","&Type :",310,8,40,16 oFrm.AddControl "lbox1","listbox","anorexic|very thin|thin|normal|fat|obese|dead",310,28,150,80 oFrm.AddControl "ckbox1k","checkbox","Mem&ber",310,90,68,20 'this control will be checked oFrm.AddControl "button1","button","&OK",392,240,70,24 oFrm.AddControl "button2","button","&Cancel",312,240,70,24 oFrm.ShowForm False oFrm.RunForm 'messages pump
'display the dialogbox final content MsgBox oFrm.dFrmData.Item("label1") & vbLf &_ oFrm.dFrmData.Item("edit1") & vbLf &_ oFrm.dFrmData.Item("label2") & vbLf &_ oFrm.dFrmData.Item("edit2") & vbLf &_ oFrm.dFrmData.Item("label3") & vbLf &_ oFrm.dFrmData.Item("edit3") & vbLf &_ oFrm.dFrmData.Item("label4") & vbLf &_ oFrm.dFrmData.Item("edit4") & vbLf &_ oFrm.dFrmData.Item("gbox1") & vbLf &_ oFrm.dFrmData.Item("rdbox1") & vbLf &_ oFrm.dFrmData.Item("rdbox2k") & vbLf &_ oFrm.dFrmData.Item("rdbox3") & vbLf &_ oFrm.dFrmData.Item("label5") & vbLf &_ oFrm.dFrmData.Item("cbox1") & vbLf &_ oFrm.dFrmData.Item("label6") & vbLf &_ oFrm.dFrmData.Item("lbox1") & vbLf &_ oFrm.dFrmData.Item("ckbox1k") & vbLf &_ oFrm.dFrmData.Item("button1") & vbLf &_ oFrm.dFrmData.Item("button2")
|