As it seams that we are on the GUI festival, and tonight i was bored, i decide to make my own Visual Basic form (.frm) to Pure Basic.
I know there are some other (and better ones) outthere, but i was bored.
I hope someone want to continue with me this code.
Maybe its horrible coded, its 3:00 a.m. here and i take only 20 minutes developing it. But the idea is here:
Code: Select all
Global File.s, Start.l, Object.l, x.l, y.l, w.l, h.l, c.s, GadgetNum.l
Procedure Parsea(Linea.s)
If FindString(Linea,"Begin",0) 0
Start.l = 1
;MessageRequester("Begin",Linea,0)
;-IDENTIFICA LOS OBJETOS
If FindString(Linea,"VB.Form",0) 0
Object = 0
ElseIf FindString(Linea,"VB.CommandButton",0) 0
Object = 1
ElseIf FindString(Linea,"VB.TextBox",0) 0
Object = 2
ElseIf FindString(Linea,"VB.Label",0) 0
Object = 3
ElseIf FindString(Linea,"VB.ListBox",0) 0
Object = 4
ElseIf FindString(Linea,"VB.ComboBox",0) 0
Object = 5
ElseIf FindString(Linea,"VB.OptionButton",0) 0
Object = 6
ElseIf FindString(Linea,"VB.CheckBox",0) 0
Object = 7
ElseIf FindString(Linea,"VB.Frame",0) 0
Object = 8
ElseIf FindString(Linea,"VB.PictureBox",0) 0
Object = 9
EndIf
ElseIf FindString(Linea,"End",0) 0 Or FindString(Linea,"StartUpPosition",0) 0
If Start = 1
Start = 0
Select Object
Case 0
UseFile(1)
WriteString("If OpenWindow(" + Str(WindowNum) + "," + Str(x) + "," + Str(y) + "," + Str(w) + "," + Str(h) + ",#PB_Window_SystemMenu" + "," + c.s + ")" + Chr(13) + Chr(10) )
WriteString(" CreateGadgetList(WindowID())" + Chr(13) + Chr(10))
UseFile(0)
WindowNum = WindowNum + 1
Case 1
UseFile(1)
WriteString(" ButtonGadget(" + Str(GadgetNum) + "," + Str(x) + "," + Str(y) + "," + Str(w) + "," + Str(h) + "," + c.s + ")" + Chr(13) + Chr(10) )
UseFile(0)
GadgetNum = GadgetNum + 1
Case 2
UseFile(1)
WriteString(" StringGadget(" + Str(GadgetNum) + "," + Str(x) + "," + Str(y) + "," + Str(w) + "," + Str(h) + "," + c.s + ")" + Chr(13) + Chr(10) )
UseFile(0)
GadgetNum = GadgetNum + 1
Case 3
UseFile(1)
WriteString(" TextGadget(" + Str(GadgetNum) + "," + Str(x) + "," + Str(y) + "," + Str(w) + "," + Str(h) + "," + c.s + ")" + Chr(13) + Chr(10) )
UseFile(0)
GadgetNum = GadgetNum + 1
Case 4
NumList = NumList + 1
UseFile(1)
WriteString(" ListViewGadget(" + Str(GadgetNum) + "," + Str(x) + "," + Str(y) + "," + Str(w) + "," + Str(h) + ")" + Chr(13) + Chr(10) )
WriteString(" AddGadgetItem(" + Str(GadgetNum) + ", 0," + Chr(34) + "List" + Str(NumList) + Chr(34) + ")" + Chr(13) + Chr(10))
UseFile(0)
GadgetNum = GadgetNum + 1
Case 5
UseFile(1)
WriteString(" ComboBoxGadget(" + Str(GadgetNum) + "," + Str(x) + "," + Str(y) + "," + Str(w) + "," + Str(h) + ")" + Chr(13) + Chr(10) )
WriteString(" AddGadgetItem(" + Str(GadgetNum) + ", 0," + c.s + ")" + Chr(13) + Chr(10))
UseFile(0)
GadgetNum = GadgetNum + 1
Case 6
UseFile(1)
WriteString(" OptionGadget(" + Str(GadgetNum) + "," + Str(x) + "," + Str(y) + "," + Str(w) + "," + Str(h) + "," + c.s + ")" + Chr(13) + Chr(10) )
UseFile(0)
GadgetNum = GadgetNum + 1
Case 7
UseFile(1)
WriteString(" CheckBoxGadget(" + Str(GadgetNum) + "," + Str(x) + "," + Str(y) + "," + Str(w) + "," + Str(h) + "," + c.s + ")" + Chr(13) + Chr(10) )
UseFile(0)
GadgetNum = GadgetNum + 1
Case 8
UseFile(1)
WriteString(" Frame3DGadget(" + Str(GadgetNum) + "," + Str(x) + "," + Str(y) + "," + Str(w) + "," + Str(h) + "," + c.s + ")" + Chr(13) + Chr(10) )
UseFile(0)
GadgetNum = GadgetNum + 1
Case 9
UseFile(1)
WriteString(" ImageGadget(" + Str(GadgetNum) + "," + Str(x) + "," + Str(y) + "," + Str(w) + "," + Str(h) + "," + c.s + ")" + Chr(13) + Chr(10) )
UseFile(0)
GadgetNum = GadgetNum + 1
EndSelect
EndIf
ElseIf FindString(Linea,"Attribute VB_Name",0) 0
UseFile(1)
WriteString(" Repeat" + Chr(13) + Chr(10))
WriteString(" EventID=WaitWindowEvent()" + Chr(13) + Chr(10))
WriteString(" Until EventID=#PB_EventCloseWindow" + Chr(13) + Chr(10))
WriteString("EndIf" + Chr(13) + Chr(10))
WriteString("End" + Chr(13) + Chr(10))
Delay(100)
MessageRequester("End","Done",0)
CloseFile(1)
CloseFile(0)
ShellExecute_(WindowID(),"open",File + ".pb","","",0)
End
Else
Pos.l = FindString(Linea,"=",1)
Valor$ = Mid(Linea,Pos+1,Len(Linea) - Pos)
If FindString(Linea,"Top ",0) 0
y = Val(Trim(Valor$))/15
;MessageRequester(Linea + " -TOP- " + Valor$,Str(Val(Trim(Valor$))/15),0)
ElseIf FindString(Linea,"Left ",0) 0
x = Val(Trim(Valor$))/15
;MessageRequester(Linea + " -LEFT- " + Valor$,Str(Val(Trim(Valor$))/15),0)
ElseIf FindString(Linea,"Height ",0) 0 And FindString(Linea,"ScaleHeight ",0) = 0
h = Val(Trim(Valor$))/15
;MessageRequester(Linea + " -HEIGHT- " + Valor$,Str(Val(Trim(Valor$))/15),0)
ElseIf FindString(Linea,"Width ",0) 0 And FindString(Linea,"ScaleWidth ",0) = 0
w = Val(Trim(Valor$))/15
;MessageRequester(Linea + " -WIDTH- " + Valor$,Str(Val(Trim(Valor$))/15),0)
ElseIf FindString(Linea,"Caption ",0) 0 Or FindString(Linea,"Text ",0)
c = Trim(Valor$)
EndIf
EndIf
EndProcedure
If OpenWindow(0,100,150,450,200,#PB_Window_SystemMenu,"VB to PB GUI converter")
CreateGadgetList(WindowID())
StringGadget(1,50,50,350,20,"")
ButtonGadget(2,200,100,50,25,"Test")
Repeat
EventID=WaitWindowEvent()
Select EventID
Case #PB_EventGadget
Select EventGadgetID()
Case 2
FileName$ = OpenFileRequester("Select a form","","*.frm",0)
SetWindowText_(WindowID(),"Vaaaaaaaaaaaa")
SetWindowText_(WindowID(),FileName$)
If FileName$
SetWindowText_(WindowID(),FileName$)
If ReadFile(0,FileName$)
DeleteFile(FileName$ + ".pb")
Delay(100)
OpenFile(1,FileName$ + ".pb")
File = FileName$
UseFile(0)
Repeat
Delay(1)
Line$ = ReadString()
SetWindowText_(WindowID(),Line$)
Parsea(Line$)
If Loc()=> FileSize(FileName$)
Final = 1
EndIf
Until Final = 1
SetWindowText_(WindowID(),"Final")
CloseFile(0)
CloseFile(1)
MessageRequester("End","",0)
EndIf
EndIf
EndSelect
EndSelect
Until EventID=#PB_EventCloseWindow
EndIf