$ filename "UpDown.exe"
'uses rtl32
'uses rtl64
uses WinUtil
sys hInstance=inst
% UDM_SETRANGE=1125
% UDM_SETBUDDY=1129
% UDM_GETBUDDY=1130
% UDM_SETPOS32=1137
% UDS_SETBUDDYINT=2
% UDS_ALIGNRIGHT=4
% UDS_ARROWKEYS=32
macro makelong(lo,hi) { ( (lo) or ( (hi)<<16 ) ) }
function createControl(string ctlclass, string Text, sys hwnd, int id, x,y,w,h, int Style, optional ExStyle=0) as sys
sys hCtrl
hCtrl=CreateWindowEx(ExStyle, ctlclass, Text, Style, x,y,w,h, hWnd, id, hInstance, null)
if hCtrl=null then mbox "Error: Cannot create " ctlclass
return hCtrl
end function
% ID_Button = 1000
% ID_Buddy = 1001 'Edit as buddy
% ID_UpDown = 1002
' Initialize common controls.
INITCOMMONCONTROLSEXt icex
icex.dwSize = sizeof(INITCOMMONCONTROLSEXt)
icex.dwICC = 0xffff
InitCommonControlsEx(&icex)
MainWindow 500,300,WS_OVERLAPPEDWINDOW
function WndProc(sys hwnd, uint uMsg, sys wParam, lParam) as sys callback
sys hButton, hEdit, hUpDown
select uMsg
case WM_CREATE
SetWindowText(hwnd, "UpDown Example in OxygenBasic")
hButton = CreateControl("Button", "Info", hwnd, ID_Button, 250, 100, 100, 30, WS_CHILD or WS_VISIBLE )
hEdit = CreateControl("Edit", "", hwnd, ID_Buddy, 100, 100, 60, 30,
WS_CHILD or WS_VISIBLE or WS_TABSTOP or ES_NUMBER or ES_LEFT or ES_AUTOHSCROLL,
WS_EX_CLIENTEDGE )
hUpDown = CreateControl("MSCTLS_UPDOWN32", "", hwnd, ID_UpDown, 160, 100, 30, 30,
WS_CHILD or WS_VISIBLE or WS_TABSTOP or WS_BORDER or
UDS_ARROWKEYS or UDS_SETBUDDYINT or UDS_ALIGNRIGHT)
'Set Edit control as Buddy Window
SendMessage(hUpDown, UDM_SETBUDDY, hEdit, 0)
'Set Range
SendMessage(hUpDown, UDM_SETRANGE, 0, makelong(20,-20))
'Set initial value
SendMessage(hUpDown, UDM_SETPOS32, 0,1)
case WM_COMMAND
int id = loword(wParam)
if id =ID_Button then
sys hBuddy = SendMessage(GetDlgItem(hwnd,ID_UpDown), UDM_GETBUDDY, 0,0)
string text=nuls 32
GetWindowText(hBuddy, text, 32)
mbox text
end if
case WM_CLOSE
DestroyWindow(hwnd)
case WM_DESTROY
PostQuitMessage(0)
case else
return DefWindowProc(hwnd, uMsg, wParam, lParam)
end select
return 0
end function