Date: 02-16-2022
Return to Index
created by gbSnippets
'Property "position" changes when Up/down arrows are clicked.
'Buddy Window: You can specify that an up-down control automatically
'position itself next to its buddy window and that it automatically
'set the caption of the buddy window to its current position
Control Send hDlg, %IDC_UpDown, %UDM_SetBuddy, GetDlgItem(hDlg, %IDC_TextBox), 0
Style = %UDS_SetBuddyInt
NOtification
UDN_DeltaPOS
arrowkeys, horz, wrap
getrange/setrange - min/max
getpos/setpos - set position within min/max range
getbase/setbase - hex or dec
getaccel/setaccel - time interval + delta increment
'Credit: Lance Edmonds
http://msdn.microsoft.com/en-us/library/bb759918%28v=vs.85%29.aspx
http://www.powerbasic.com/support/pbforums/showthread.php?t=22826
http://www.powerbasic.com/support/pbforums/showthread.php?t=7566&highlight=spinner+control
'Compilable Example: (Jose Includes)
#Compiler PBWin 10
#Compile Exe
#Dim All
%Unicode=1
#Include "Win32API.inc"
'#Include "commctrl.inc" '<--- include to work in PBWin9
%IDC_TextBox = 500
%IDC_UpDown = 501
Global hDlg As Dword
Function PBMain() As Long
Dialog New Pixels, 0, "Up-Down Control",300,300,240,75, %WS_OverlappedWindow To hDlg
Control Add TextBox, hDlg, %IDC_TextBox, "0", 50,20,150,20
Control Add "msctls_updown32", hDlg, %IDC_UpDown, "", 0, 0, 8, 8, %WS_Child Or %WS_Border _
Or %WS_Visible Or %UDS_ArrowKeys Or %UDS_AlignRight Or %UDS_SetBuddyInt
Control Send hDlg, %IDC_UpDown, %UDM_SetBuddy, GetDlgItem(hDlg, %IDC_TextBox), 0
Control Send hDlg, %IDC_UpDown, %UDM_SetRange, 0, Mak(Long,20,0) 'Max,Min
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local temp$
Select Case Cb.Msg
Case %WM_Notify
Select Case Cb.NmId
Case %IDC_UpDown
Select Case Cb.NmCode
Case %UDN_DeltaPOS
Local UPD As NMUPDOWN Ptr
UPD = Cb.LParam
'old value will be @upd.iPos
'change (delta) to old value will be @upd.iDelta
End Select
End Select
Case %WM_VScroll
'when click on Up arrow or Down arrow
'use Send Control hDlg, %IDC_UpDown, %UDM_GetPos, 0,0 to get new position
'use Control Get Text hDlg, %IDC_TextBox To temp$ to get new position if style include %UDS_SetBuddyInt
End Select
End Function
'gbs_01155
'Date: 03-14-2012
'Compilable Example: (Jose Includes)
#Compiler PBWin 10
#Compile Exe
#Dim All
%Unicode=1
#Include "Win32API.inc"
%IDC_TextBox = 500
%IDC_UpDown = 501
%IDC_Button = 502
Global hDlg As Dword
Function PBMain() As Long
Dialog New Pixels, 0, "Up-Down Control",300,300,240,75, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, %IDC_Button, "Set Value", 20,10,100,20
Control Add TextBox, hDlg, %IDC_TextBox, "0", 20,40,150,20
Control Add "msctls_updown32", hDlg, %IDC_UpDown, "", 0, 0, 8, 8, %WS_Child Or %WS_Border _
Or %WS_Visible Or %UDS_ArrowKeys Or %UDS_AlignRight Or %UDS_SetBuddyInt
Control Send hDlg, %IDC_UpDown, %UDM_SetBuddy, GetDlgItem(hDlg, %IDC_TextBox), 0
Control Send hDlg, %IDC_UpDown, %UDM_SetRange, 0, Mak(Long,20,1) 'Max,Min
Control Set Text hDlg, %IDC_TextBox, "12"
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local temp$, UPD As NMUpDown Ptr, iResult As Long
Select Case Cb.Msg
Case %WM_Command
Select Case Cb.Ctl
Case %IDC_Button
Control Set Text hDlg, %IDC_TextBox, "5"
Case %IDC_TextBox
If Cb.CtlMsg = %EN_Change Then
iResult = SendMessage(GetDlgItem(hDlg, %IDC_Updown), %UDM_GetPos, 0, 0)
Dialog Set Text hDlg, Str$(iResult)
End If
End Select
End Select
End Function
http://www.garybeene.com/sw/gbsnippets.htm