uses console
#Def abc Printl
abc "Hello myWorld" ' ok
#Def defg Printl
defg "Hello yourWorld" ' ok
#Def zorro abc
zorro "Hello ZorrosWorld" ' ok
#Def batman zorro
batman "Hello Batman+ZorrosWorld" ' ok
'batman "1" zorro "2"
batman "Batman without zorro" ' ok
batman "1" zorro "1" ' ok ' 1 11
wait
printl "print key to continue"
' demo test2 GO for combobox, sdk modus, by frank bruebach
' oxygenbasic, 23-07-2024
'
$ filename "t.exe"
uses Winutil
#lookahead ' for procedures
%IDB_BUTTON=1001
%IDB_COMBO=1002
%cbs_sort= 256i32
%CBS_DROPDOWN= 2i32
%CBS_SIMPLE= dword 0x0001
' pub const %cbs_sort i32 = 256i32 commctrl.h
' cbs_simple dword = 0x0001
' cbs_dropdown i32 = 2i32
'
'=========
'MAIN CODE
'=========
dim cmdline as asciiz ptr, inst as sys
@cmdline=GetCommandLine
inst=GetModuleHandle 0
'
'WINDOWS START
'=============
'
WinMain inst,0,cmdline,SW_NORMAL
end
function combobox_addstring(byval hwndcombo as dword , byval ltext as string ) as string
function=sendMessage(hwndcombo,CB_ADDSTRING, 0, ltext ) 'strptr(ltext)
end function
sub combobox_setcursel(byval hwndcombo as dword , byval index as long )
sendMessage(hwndcombo,CB_SETCURSEL, index,0 )
end sub
'--------------------------------------------------------------------
Function WinMain(sys inst, prevInst, asciiz*cmdline, sys show) as sys
'====================================================================
WndClass wc
MSG wm
sys hwnd, wwd, wht, wtx, wty, tax
with wc
.style = CS_HREDRAW or CS_VREDRAW
.lpfnWndProc = @WndProc
.cbClsExtra =0
.cbWndExtra =0
.hInstance =inst
.hIcon=LoadIcon 0, IDI_APPLICATION
.hCursor=LoadCursor 0,IDC_ARROW
.hbrBackground = GetStockObject WHITE_BRUSH
.lpszMenuName =null
.lpszClassName = strptr "Demo"
end with
sys r=RegisterClass (@wc)
Wwd = 420 : Wht = 300
Tax = GetSystemMetrics SM_CXSCREEN
Wtx = (Tax - Wwd) /2
Tax = GetSystemMetrics SM_CYSCREEN
Wty = (Tax - Wht) /2
'
hwnd = CreateWindowEx 0,wc.lpszClassName,"OXYGEN BASIC",WS_OVERLAPPEDWINDOW,Wtx,Wty,Wwd,Wht,0,0,inst,0
if not hwnd
mbox "Unable to create window"
exit function
end if
'
ShowWindow hwnd,SW_SHOW
UpdateWindow hwnd
'
sys bRet
'
do while bRet := GetMessage (@wm, 0, 0, 0)
if bRet = -1 then
'show an error message
else
TranslateMessage @wm
DispatchMessage @wm
end if
wend
End Function
'#recordof winmain
'#recordof wndproc
dim as rect crect 'for WndProc and TimerProc
'------------------------------------------------------------------
function WndProc ( sys hWnd, wMsg, wParam, lparam ) as sys callback
'==================================================================
static as sys hdc
static as String txt
static as PaintStruct Paintst
'sys hfont as long
'==========
select wMsg
'==========
'--------------
case WM_CREATE
'=============
SetWindowText(hwnd, "Button and Combobox")
sys hInstance = GetWindowLongPtr(hWnd, GWL_HINSTANCE)
sys hWndStdButton = CreateWindowEx(
0,
"BUTTON",
"test button",
WS_VISIBLE or WS_CHILD,
10, 10,
120, 24,
hWnd,
IDB_BUTTON,
hInstance,
NULL)
' sys hfont
' SendMessage(hWndStdCombo, WM_SETFONT, hFont, TRUE)
sys hWndStdCombo = CreateWindowEx(
0,
"Combobox",
"Test",
WS_CHILD or WS_VISIBLE or WS_BORDER or ES_AUTOHSCROLL or WS_HSCROLL or WS_VSCROLL _
OR ES_MULTILINE OR WS_TABSTOP OR CBS_SIMPLE OR CBS_SORT, ''_ '%CBS_DROPDOWNLIST,
10, 130,
120, 124,
hWnd,
IDB_COMBO,
hInstance, 'GetWindowLongPtr(hWnd, GWL_HINSTANCE),
NULL)
'---------------------------- 1. way ------------------------------------------------------------- //
' Add items to the combobox
Dim combItem As String
combItem = "Ironman" : SendMessage(hWndStdCombo, CB_ADDSTRING, 0, STRPtr(combItem))
combItem = "Thor" : SendMessage(hWndStdCombo, CB_ADDSTRING, 0, STRPtr(combItem))
combItem = "Spiderman" : SendMessage(hWndStdCombo, CB_ADDSTRING, 0, STRPtr(combItem))
combItem = "Black Widow" : SendMessage(hWndStdCombo, CB_ADDSTRING, 0, STRPtr(combItem))
combItem = "Batman" : SendMessage(hWndStdCombo, CB_ADDSTRING, 0, STRPtr(combItem))
combItem = "Captain America" : SendMessage(hWndStdCombo, CB_ADDSTRING, 0, STRPtr(combItem))
combItem = "Captain Marvel" : SendMessage(hWndStdCombo, CB_ADDSTRING, 0, STRPtr(combItem))
' Set the current selection
SendMessage(hWndStdCombo, CB_SETCURSEL, 1, 0)
SendMessage(hWndStdCombo, WM_SETREDRAW, true, 0) 'important
'---------------------------- 2. way ------------------------------------------------------------- //
' // Fill the control with some data
' Add items to the combobox using a loop
'Dim wszText As String
DIM wszText[80] AS STRING
int i
For i = 1 To 9
wszText = "Marvel " + Right("00" + Str(i), 2)
SendMessage(hWndStdCombo, CB_ADDSTRING, 0, STRPtr(wszText))
Next
' Set the current selection
SendMessage(hWndStdCombo, CB_SETCURSEL, 1, 0)
SendMessage(hWndStdCombo, WM_SETREDRAW, true, 0) 'important
case WM_COMMAND
select case loword(wParam)
case IDB_BUTTON
select case hiword(wParam)
case BN_CLICKED
MessageBox(NULL, "Selected Button", "testmy Button", MB_OK or MB_ICONINFORMATION)
end select
end select
'--------------
case WM_DESTROY
'===============
PostQuitMessage 0
'------------
case WM_PAINT
'============
'TEXT
'http://msdn.microsoft.com/en-us/library/dd144821(v=VS.85).aspx
'DRAWING AND PAINTING
'http://msdn.microsoft.com/en-us/library/dd162760(v=VS.85).aspx
GetClientRect hWnd,&cRect
hDC=BeginPaint hWnd,&Paintst
'style
'0x20 DT_SINGLELINE
'0x04 DT_VCENTER
'0x01 DT_CENTER
'0x25
SetBkColor hdc,yellow
SetTextColor hdc,red
DrawText hDC,"Hello World!",-1,&cRect,0x25
EndPaint hWnd,&Paintst
'--------------
case WM_KEYDOWN
'==============
'============
Select wParam
'============
Case 27 : SendMessage hwnd, WM_CLOSE, 0, 0 'ESCAPE
End Select
'--------
case else
'========
function=DefWindowProc hWnd,wMsg,wParam,lParam
end select
end function
WS_CHILD or WS_VISIBLE or WS_BORDER or ES_AUTOHSCROLL or WS_HSCROLL or WS_VSCROLL, '*** ok
'WS_CHILD or WS_VISIBLE or WS_BORDER or ES_AUTOHSCROLL or WS_HSCROLL or WS_VSCROLL _
'OR ES_MULTILINE OR WS_TABSTOP OR CBS_SIMPLE OR CBS_SORT, ''_ '%CBS_DROPDOWNLIST,
' demo test for combobox, sdk modus, by frank bruebach
' oxygenbasic, 23-07-2024
'
$ filename "t.exe"
uses Winutil
#lookahead ' for procedures
%IDB_BUTTON=1001
%IDB_COMBO=1002
%CBS_SIMPLE=23456
%CBS_SORT=24567
%CBS_NOINTEGRALHEIGHT=24678
%CBS_DROPDOWNLIST=24679
'=========
'MAIN CODE
'=========
dim cmdline as asciiz ptr, inst as sys
@cmdline=GetCommandLine
inst=GetModuleHandle 0
'
'WINDOWS START
'=============
'
WinMain inst,0,cmdline,SW_NORMAL
end
function combobox_addstring(byval hwndcombo as dword , byval ltext as string ) as string
function=sendMessage(hwndcombo,CB_ADDSTRING, 0, ltext ) 'strptr(ltext)
end function
sub combobox_setcursel(byval hwndcombo as dword , byval index as long )
sendMessage(hwndcombo,CB_SETCURSEL, index,0 )
end sub
'--------------------------------------------------------------------
Function WinMain(sys inst, prevInst, asciiz*cmdline, sys show) as sys
'====================================================================
WndClass wc
MSG wm
sys hwnd, wwd, wht, wtx, wty, tax
with wc
.style = CS_HREDRAW or CS_VREDRAW
.lpfnWndProc = @WndProc
.cbClsExtra =0
.cbWndExtra =0
.hInstance =inst
.hIcon=LoadIcon 0, IDI_APPLICATION
.hCursor=LoadCursor 0,IDC_ARROW
.hbrBackground = GetStockObject WHITE_BRUSH
.lpszMenuName =null
.lpszClassName = strptr "Demo"
end with
sys r=RegisterClass (@wc)
Wwd = 420 : Wht = 300
Tax = GetSystemMetrics SM_CXSCREEN
Wtx = (Tax - Wwd) /2
Tax = GetSystemMetrics SM_CYSCREEN
Wty = (Tax - Wht) /2
'
hwnd = CreateWindowEx 0,wc.lpszClassName,"OXYGEN BASIC",WS_OVERLAPPEDWINDOW,Wtx,Wty,Wwd,Wht,0,0,inst,0
if not hwnd
mbox "Unable to create window"
exit function
end if
'
ShowWindow hwnd,SW_SHOW
UpdateWindow hwnd
'
sys bRet
'
do while bRet := GetMessage (@wm, 0, 0, 0)
if bRet = -1 then
'show an error message
else
TranslateMessage @wm
DispatchMessage @wm
end if
wend
End Function
'#recordof winmain
'#recordof wndproc
dim as rect crect 'for WndProc and TimerProc
'------------------------------------------------------------------
function WndProc ( sys hWnd, wMsg, wParam, lparam ) as sys callback
'==================================================================
static as sys hdc
static as String txt
static as PaintStruct Paintst
'sys hfont as long
'==========
select wMsg
'==========
'--------------
case WM_CREATE
'=============
SetWindowText(hwnd, "Button and Combobox")
sys hInstance = GetWindowLongPtr(hWnd, GWL_HINSTANCE)
sys hWndStdButton = CreateWindowEx(
0,
"BUTTON",
"test button",
WS_VISIBLE or WS_CHILD,
10, 10,
120, 24,
hWnd,
IDB_BUTTON,
hInstance,
NULL)
' sys hfont
' SendMessage(hWndStdCombo, WM_SETFONT, hFont, TRUE)
sys hWndStdCombo = CreateWindowEx(
0,
"Combobox",
"Test",
WS_CHILD or WS_VISIBLE or WS_BORDER or ES_AUTOHSCROLL or WS_HSCROLL or WS_VSCROLL _
OR ES_MULTILINE OR WS_TABSTOP OR CBS_SIMPLE OR CBS_SORT, ''_ '%CBS_DROPDOWNLIST,
10, 130,
120, 124,
hWnd,
IDB_COMBO,
hInstance, 'GetWindowLongPtr(hWnd, GWL_HINSTANCE),
NULL)
'---------------------------- 1. way ------------------------------------------------------------- //
' Add items to the combobox
Dim combItem As String
combItem = "Ironman" : SendMessage(hWndStdCombo, CB_ADDSTRING, 0, STRPtr(combItem))
combItem = "Thor" : SendMessage(hWndStdCombo, CB_ADDSTRING, 0, STRPtr(combItem))
combItem = "Spiderman" : SendMessage(hWndStdCombo, CB_ADDSTRING, 0, STRPtr(combItem))
combItem = "Black Widow" : SendMessage(hWndStdCombo, CB_ADDSTRING, 0, STRPtr(combItem))
combItem = "Batman" : SendMessage(hWndStdCombo, CB_ADDSTRING, 0, STRPtr(combItem))
combItem = "Captain America" : SendMessage(hWndStdCombo, CB_ADDSTRING, 0, STRPtr(combItem))
combItem = "Captain Marvel" : SendMessage(hWndStdCombo, CB_ADDSTRING, 0, STRPtr(combItem))
' Set the current selection
SendMessage(hWndStdCombo, CB_SETCURSEL, 1, 0)
SendMessage(hWndStdCombo, WM_SETREDRAW, true, 0) 'important
'---------------------------- 2. way ------------------------------------------------------------- //
' // Fill the control with some data
' Add items to the combobox using a loop
'Dim wszText As String
DIM wszText[80] AS STRING
int i
For i = 1 To 9
wszText = "Marvel " + Right("00" + Str(i), 2)
SendMessage(hWndStdCombo, CB_ADDSTRING, 0, STRPtr(wszText))
Next
' Set the current selection
SendMessage(hWndStdCombo, CB_SETCURSEL, 1, 0)
SendMessage(hWndStdCombo, WM_SETREDRAW, true, 0) 'important
case WM_COMMAND
select case loword(wParam)
case IDB_BUTTON
select case hiword(wParam)
case BN_CLICKED
MessageBox(NULL, "Selected Button", "testmy Button", MB_OK or MB_ICONINFORMATION)
end select
end select
'--------------
case WM_DESTROY
'===============
PostQuitMessage 0
'------------
case WM_PAINT
'============
'TEXT
'http://msdn.microsoft.com/en-us/library/dd144821(v=VS.85).aspx
'DRAWING AND PAINTING
'http://msdn.microsoft.com/en-us/library/dd162760(v=VS.85).aspx
GetClientRect hWnd,&cRect
hDC=BeginPaint hWnd,&Paintst
'style
'0x20 DT_SINGLELINE
'0x04 DT_VCENTER
'0x01 DT_CENTER
'0x25
SetBkColor hdc,yellow
SetTextColor hdc,red
DrawText hDC,"Hello World!",-1,&cRect,0x25
EndPaint hWnd,&Paintst
'--------------
case WM_KEYDOWN
'==============
'============
Select wParam
'============
Case 27 : SendMessage hwnd, WM_CLOSE, 0, 0 'ESCAPE
End Select
'--------
case else
'========
function=DefWindowProc hWnd,wMsg,wParam,lParam
end select
end function
uses console
' it's possible to create a macro with three params in one line?
' macro PRINT_THREE_PARAMS(p1, p2, p3) Print p1, p2, p3
'
macro Print3( a,b,c )
Print a
Print " "
Print b
Print " "
Print c
print "!"
end macro
Print3( "Hello", "Dianas ", "World " )
wait
printl "press key to continue"
macro PRINT_THREE_PARAMS(p1, p2, p3)
Print p1
print p2
print p3
end macro
PRINT_THREE_PARAMS( " Hello2 ", " Dianas2 ", " World2 " )
wait
printl "press key to continue"
'' CodeSelect
def listitem print "%1" + chr(9) + "%2" + chr(13,10)
'
listitem shoes 1
listitem socks 2
listitem hat 3
wait
printl "press key to continue"
def listitem2 print "%1" + chr(9) + "%2" + chr(13,10) + "%3" +chr(13,10) 'print "%3" '+chr(13,10)
'
listitem2 shoes legs 1
listitem2 socks feet 2
listitem2 hat head 3
wait
printl "press key to continue"
'-------------------------------- //
'
' ---> freebasic: this example works well below
'' #define PRINT_THREE_PARAMS(p1, p2, p3) Print p1, p2, p3
' test program
'' PRINT_THREE_PARAMS("hello ", "Dianas ", " world")
'' Wait for user to press a key
'' Print "Press any key to continue..."
'' Sleep
Page created in 0.762 seconds with 10 queries.