Post by Ronnie on Jul 11, 2018 12:44:02 GMT -5
Hi - I am testing a program with 3 tabs and tried two methods to create an executable file. The first approach was Liberty Basic, it create a file that was 1,200,000 bites (plus the dlls) and the second approach used LB Boost that compiled a file that was only 110,000 bites. My question is how can I get the Liberty Basic program to compile smaller executable files?
One thing to note the LB Boost code flickers when running, so I can not use the exe. Thank You...
If anyone is interested the follow is the code:
'<cursorpos> 4120
'tab control demo
'use dialog_popup windows to hold controls
'set parent of popups to be main program window
'when tab is clicked, use MoveWindow to move popups on and off
'if a graphicbox is used, use GetParent on popup
'if graphicbox is used, restore parent of popup at close
'doesn't work properly with type window_popup
nomainwin
'constants:
TCIF.TEXT = 1
TCIF.IMAGE =2
TCS.MULTILINE = 512
TCM.INSERTITEMA = 4871
TCM.GETCURSEL = 4875
TCM.SETCURSEL = 4876
tabID = 1 'current tab
oldTab = 0 'previously selected tab
struct TCITEM,_
mask as ulong,_
dwState as ulong,_
dwStateMask as ulong,_
pszText$ as ptr,_
txtMax as long,_
iImage as long,_
lParam as long
'initialize DLL
calldll #comctl32, "InitCommonControls", ret as void
WindowWidth=700:WindowHeight=410
UpperLeftX=int((DisplayWidth-WindowWidth)/2)
UpperLeftY=int((DisplayHeight-WindowHeight)/2)
BackgroundColor$ = "darkblue"
ForegroundColor$ = "red"
'example controls:
'first page
'Branch Label Event Handler
' Sample program. Pick a contact status
options$(0) = "Cold Contact Phone Call"
options$(1) = "Send Literature"
options$(2) = "Follow Up Call"
options$(3) = "Send Promotional"
options$(4) = "Final Call"
listbox #tab1.lb, options$(), [selectionMade], 20, 30, 200, 330
textbox #tab1.tx, 224, 30, 410, 330
Button #tab1.b1, "Button 1", [buttonOne], UL, 395, 370, 90, 24
open "" for window_popup as #tab1
print #tab1.lb, "font Ariel 12" ' font text box
print #tab1.tx, "!font Ariel 18" ' font text box
#tab1.lb "singleclickselect [selectionMade]"
'second page
Textbox #tab2.t2, 40, 40, 180, 30
Button #tab2.b2, "Button 2", [buttonTwo], UL, 40, 80, 85, 24
open "" for window_popup as #tab2
'third page
graphicbox #tab3.g, 0, 0, 350, 210
open "" for window_popup as #tab3
'main program window
WindowWidth = 700:WindowHeight = 500 ' whole window
open "Tab Demo" for window_nf as #1
print #1, "trapclose [quit]"
print #1, "font ms_sans_serif 12"
#tab2.t2 "Second Tab Page!"
print #tab3.g, "down; fill blue; color white"
print #tab3.g, "backcolor blue"
print #tab3.g, "place 30 50;\Third page!\Click Me!"
print #tab3.g, "flush"
print #tab3.g, "setfocus; when leftButtonDown [mouseClick]"
hwndParent = hwnd(#1) 'retrieve window handle
hTab1=hwnd(#tab1):hTab2=hwnd(#tab2):hTab3=hwnd(#tab3)
dim winTab(3) 'hold tab window handles in array
winTab(0)=hTab1
winTab(1)=hTab2
winTab(2)=hTab3
'because of graphicbox, get parent on third tab window for use later
hTab3Parent=GetParent(hTab3)
'set popups to be children of main program window
for i = 0 to 2
call SetParent hwndParent,winTab(i)
next
'move child windows
gosub [clear]
call MoveWindow hTab1, 20,40,650,410 ' first set up
CallDLL #user32, "GetWindowLongA",_
hwndParent As ulong,_ 'parent window handle
_GWL_HINSTANCE As long,_'flag to retrieve instance handle
hInstance As ulong 'instance handle
' Create control
style = _WS_CHILD or _WS_CLIPSIBLINGS or _WS_VISIBLE _
or TCS.MULTILINE
calldll #user32, "CreateWindowExA",_
0 As long,_ ' extended style
"SysTabControl32" as ptr,_ ' class name
"" as ptr,_
style as long,_ ' style
10 as long,_ ' left x
10 as long,_ ' top y
675 as long,_ ' width internal fram
450 as long,_ ' height
hwndParent as ulong,_ ' parent hWnd
0 as long,_
hInstance as ulong,_ ' hInstance
"" as ptr,_
hwndTab as ulong ' tab control handle
'set mask and fill struct members:
TCITEM.mask.struct = TCIF.TEXT or TCIF.IMAGE
TCITEM.iImage.struct = -1 'no image
TCITEM.pszText$.struct = "Introduction"
'TCITEM.txtMax.struct=len("First Tab")+1 'used when retrieving text, not needed here
'add first tab:
calldll #user32, "SendMessageA",_
hwndTab as ulong,_
TCM.INSERTITEMA as long,_
0 as long,_ 'zero-based, so 0=first tab
TCITEM as struct,_
ret as long
'add second tab:
TCITEM.pszText$.struct = "Second Tab"
'TCITEM.txtMax.struct=len("Second Tab")+1 'used when retrieving text, not needed here
calldll #user32, "SendMessageA",_
hwndTab as ulong,_
TCM.INSERTITEMA as long,_
1 as long,_ 'zero-based, so 1=second tab
TCITEM as struct,_
ret as long
'add third tab:
TCITEM.pszText$.struct = "Third Tab"
'TCITEM.txtMax.struct=len("Third Tab")+1 'used when retrieving text, not needed here
calldll #user32, "SendMessageA",_
hwndTab as ulong,_
TCM.INSERTITEMA as long,_
2 as long,_ 'zero-based, so 2=third tab
TCITEM as struct,_
ret as long
calldll #gdi32, "GetStockObject",_
_DEFAULT_GUI_FONT as long, hFont as ulong
'set the font to the control:
CallDLL #user32, "SendMessageA",_
hwndTab As ulong,_ 'tab control handle
_WM_SETFONT As long,_ 'message
hFont As ulong,_ 'handle of font
1 As long,_ 'repaint flag
ret As long
timer 300, [checkForTab]
calldll #user32, "SetFocus",hwndParent as ulong,re as ulong
wait
[quit]
timer 0
'because of graphicbox, restore parent to third tab window
call SetParent hTab3Parent, hTab3
close #1:close #tab1:close #tab2:close #tab3:end
[checkForTab] 'see if selected tab is the same
'as previously selected tab and
'change controls if tab has changed
timer 0 'turn off timer
'get the current tab ID
calldll #user32, "SendMessageA",_
hwndTab as ulong,_ 'tab control handle
TCM.GETCURSEL as long,_ 'message to get current selection
0 as long, 0 as long,_ 'always 0's
tabID as long 'returns selected tab ID
if tabID <> oldTab then 'change page displayed
oldTab = tabID 'for next check of selected tab
gosub [clear]
call MoveWindow winTab(tabID), 20,40,650,410
end if
print #1, "refresh"
timer 300, [checkForTab] 'reactivate timer
wait
[buttonOne]
timer 0
notice "First page."
timer 300, [checkForTab]
wait
[buttonTwo]
timer 0
#tab2.t2 "!contents? txt$"
notice "Textbox contents: ";txt$
timer 300, [checkForTab]
wait
[mouseClick]
timer 0
notice "Mouse clicked on third page."
timer 300, [checkForTab]
wait
[clear] 'hide all windows
for i = 0 to 2
call MoveWindow winTab(i), 3000,3000,550,410
next
return
[selectionMade]
print #tab1.lb, "selectionindex? xVar"
SELECT CASE xVar
CASE 1
c$ = "one"
CASE 2
c$ = "two"
CASE 3
c$ = "three"
CASE else
c$ = "none of the above"
'basic code
'goes here
END SELECT
print #tab1.tx, c$ 'str$(c)
wait
Function GetParent(hWnd)
calldll #user32, "GetParent",hWnd as ulong,_
GetParent as ulong
End Function
Sub SetParent hWnd,hWndChild
CallDLL #user32, "SetParent", hWndChild As uLong,_
hWnd As uLong, result As uLong
style = _WS_CHILD or _WS_VISIBLE
CallDLL #user32, "SetWindowLongA",_
hWndChild As ulong, _GWL_STYLE As long,_
style As Long, r As long
End Sub
Sub MoveWindow hWnd,x,y,w,h
CallDLL #user32, "MoveWindow",hWnd As uLong,_
x As Long, y As Long,w As Long, h As Long,_
1 As Boolean, r As Boolean
End Sub
One thing to note the LB Boost code flickers when running, so I can not use the exe. Thank You...
If anyone is interested the follow is the code:
'<cursorpos> 4120
'tab control demo
'use dialog_popup windows to hold controls
'set parent of popups to be main program window
'when tab is clicked, use MoveWindow to move popups on and off
'if a graphicbox is used, use GetParent on popup
'if graphicbox is used, restore parent of popup at close
'doesn't work properly with type window_popup
nomainwin
'constants:
TCIF.TEXT = 1
TCIF.IMAGE =2
TCS.MULTILINE = 512
TCM.INSERTITEMA = 4871
TCM.GETCURSEL = 4875
TCM.SETCURSEL = 4876
tabID = 1 'current tab
oldTab = 0 'previously selected tab
struct TCITEM,_
mask as ulong,_
dwState as ulong,_
dwStateMask as ulong,_
pszText$ as ptr,_
txtMax as long,_
iImage as long,_
lParam as long
'initialize DLL
calldll #comctl32, "InitCommonControls", ret as void
WindowWidth=700:WindowHeight=410
UpperLeftX=int((DisplayWidth-WindowWidth)/2)
UpperLeftY=int((DisplayHeight-WindowHeight)/2)
BackgroundColor$ = "darkblue"
ForegroundColor$ = "red"
'example controls:
'first page
'Branch Label Event Handler
' Sample program. Pick a contact status
options$(0) = "Cold Contact Phone Call"
options$(1) = "Send Literature"
options$(2) = "Follow Up Call"
options$(3) = "Send Promotional"
options$(4) = "Final Call"
listbox #tab1.lb, options$(), [selectionMade], 20, 30, 200, 330
textbox #tab1.tx, 224, 30, 410, 330
Button #tab1.b1, "Button 1", [buttonOne], UL, 395, 370, 90, 24
open "" for window_popup as #tab1
print #tab1.lb, "font Ariel 12" ' font text box
print #tab1.tx, "!font Ariel 18" ' font text box
#tab1.lb "singleclickselect [selectionMade]"
'second page
Textbox #tab2.t2, 40, 40, 180, 30
Button #tab2.b2, "Button 2", [buttonTwo], UL, 40, 80, 85, 24
open "" for window_popup as #tab2
'third page
graphicbox #tab3.g, 0, 0, 350, 210
open "" for window_popup as #tab3
'main program window
WindowWidth = 700:WindowHeight = 500 ' whole window
open "Tab Demo" for window_nf as #1
print #1, "trapclose [quit]"
print #1, "font ms_sans_serif 12"
#tab2.t2 "Second Tab Page!"
print #tab3.g, "down; fill blue; color white"
print #tab3.g, "backcolor blue"
print #tab3.g, "place 30 50;\Third page!\Click Me!"
print #tab3.g, "flush"
print #tab3.g, "setfocus; when leftButtonDown [mouseClick]"
hwndParent = hwnd(#1) 'retrieve window handle
hTab1=hwnd(#tab1):hTab2=hwnd(#tab2):hTab3=hwnd(#tab3)
dim winTab(3) 'hold tab window handles in array
winTab(0)=hTab1
winTab(1)=hTab2
winTab(2)=hTab3
'because of graphicbox, get parent on third tab window for use later
hTab3Parent=GetParent(hTab3)
'set popups to be children of main program window
for i = 0 to 2
call SetParent hwndParent,winTab(i)
next
'move child windows
gosub [clear]
call MoveWindow hTab1, 20,40,650,410 ' first set up
CallDLL #user32, "GetWindowLongA",_
hwndParent As ulong,_ 'parent window handle
_GWL_HINSTANCE As long,_'flag to retrieve instance handle
hInstance As ulong 'instance handle
' Create control
style = _WS_CHILD or _WS_CLIPSIBLINGS or _WS_VISIBLE _
or TCS.MULTILINE
calldll #user32, "CreateWindowExA",_
0 As long,_ ' extended style
"SysTabControl32" as ptr,_ ' class name
"" as ptr,_
style as long,_ ' style
10 as long,_ ' left x
10 as long,_ ' top y
675 as long,_ ' width internal fram
450 as long,_ ' height
hwndParent as ulong,_ ' parent hWnd
0 as long,_
hInstance as ulong,_ ' hInstance
"" as ptr,_
hwndTab as ulong ' tab control handle
'set mask and fill struct members:
TCITEM.mask.struct = TCIF.TEXT or TCIF.IMAGE
TCITEM.iImage.struct = -1 'no image
TCITEM.pszText$.struct = "Introduction"
'TCITEM.txtMax.struct=len("First Tab")+1 'used when retrieving text, not needed here
'add first tab:
calldll #user32, "SendMessageA",_
hwndTab as ulong,_
TCM.INSERTITEMA as long,_
0 as long,_ 'zero-based, so 0=first tab
TCITEM as struct,_
ret as long
'add second tab:
TCITEM.pszText$.struct = "Second Tab"
'TCITEM.txtMax.struct=len("Second Tab")+1 'used when retrieving text, not needed here
calldll #user32, "SendMessageA",_
hwndTab as ulong,_
TCM.INSERTITEMA as long,_
1 as long,_ 'zero-based, so 1=second tab
TCITEM as struct,_
ret as long
'add third tab:
TCITEM.pszText$.struct = "Third Tab"
'TCITEM.txtMax.struct=len("Third Tab")+1 'used when retrieving text, not needed here
calldll #user32, "SendMessageA",_
hwndTab as ulong,_
TCM.INSERTITEMA as long,_
2 as long,_ 'zero-based, so 2=third tab
TCITEM as struct,_
ret as long
calldll #gdi32, "GetStockObject",_
_DEFAULT_GUI_FONT as long, hFont as ulong
'set the font to the control:
CallDLL #user32, "SendMessageA",_
hwndTab As ulong,_ 'tab control handle
_WM_SETFONT As long,_ 'message
hFont As ulong,_ 'handle of font
1 As long,_ 'repaint flag
ret As long
timer 300, [checkForTab]
calldll #user32, "SetFocus",hwndParent as ulong,re as ulong
wait
[quit]
timer 0
'because of graphicbox, restore parent to third tab window
call SetParent hTab3Parent, hTab3
close #1:close #tab1:close #tab2:close #tab3:end
[checkForTab] 'see if selected tab is the same
'as previously selected tab and
'change controls if tab has changed
timer 0 'turn off timer
'get the current tab ID
calldll #user32, "SendMessageA",_
hwndTab as ulong,_ 'tab control handle
TCM.GETCURSEL as long,_ 'message to get current selection
0 as long, 0 as long,_ 'always 0's
tabID as long 'returns selected tab ID
if tabID <> oldTab then 'change page displayed
oldTab = tabID 'for next check of selected tab
gosub [clear]
call MoveWindow winTab(tabID), 20,40,650,410
end if
print #1, "refresh"
timer 300, [checkForTab] 'reactivate timer
wait
[buttonOne]
timer 0
notice "First page."
timer 300, [checkForTab]
wait
[buttonTwo]
timer 0
#tab2.t2 "!contents? txt$"
notice "Textbox contents: ";txt$
timer 300, [checkForTab]
wait
[mouseClick]
timer 0
notice "Mouse clicked on third page."
timer 300, [checkForTab]
wait
[clear] 'hide all windows
for i = 0 to 2
call MoveWindow winTab(i), 3000,3000,550,410
next
return
[selectionMade]
print #tab1.lb, "selectionindex? xVar"
SELECT CASE xVar
CASE 1
c$ = "one"
CASE 2
c$ = "two"
CASE 3
c$ = "three"
CASE else
c$ = "none of the above"
'basic code
'goes here
END SELECT
print #tab1.tx, c$ 'str$(c)
wait
Function GetParent(hWnd)
calldll #user32, "GetParent",hWnd as ulong,_
GetParent as ulong
End Function
Sub SetParent hWnd,hWndChild
CallDLL #user32, "SetParent", hWndChild As uLong,_
hWnd As uLong, result As uLong
style = _WS_CHILD or _WS_VISIBLE
CallDLL #user32, "SetWindowLongA",_
hWndChild As ulong, _GWL_STYLE As long,_
style As Long, r As long
End Sub
Sub MoveWindow hWnd,x,y,w,h
CallDLL #user32, "MoveWindow",hWnd As uLong,_
x As Long, y As Long,w As Long, h As Long,_
1 As Boolean, r As Boolean
End Sub