Chris, Semen, thanks for your reply.
I'm gonna try using only WM_HSCROLL and WM_VSCROLL Chris.
Meanwhile Semen's routine does the job too. I did add the %UDS_WRAP
style to let the UD value wrap.
Kind regards
Eddy
------------------
[email protected]
Announcement
Collapse
No announcement yet.
strange updown control...
Collapse
X
-
Eddy --
Up-down works as expected:
1) it tests min/max.
2) UDS_WRAP
I modified a sample, which is located in the same message, as Lance's sample.
Code:#Compile Exe #Dim All #Include "WIN32API.INC" #Include "COMMCTRL.INC" %ID_UPDOWN = 101 CallBack Function DlgProc Static ii1 As Integer, ii2 As Integer Dim lpNmh As NMHDR Ptr, lpNMUPDOWN As NM_UPDOWN Ptr, UDACCEL As UDACCEL Select Case CbMsg Case %WM_INITDIALOG InitCommonControls %MAX_SPIN = 100 %MIN_SPIN = -100 %STEP_SPIN = 5 %INI_SPIN = 50 Control Add "msctls_updown32", CbHndl, %ID_UPDOWN, "", 10, 10, 0, 0, %WS_CHILD Or %WS_VISIBLE Control Send CbHndl, %ID_UPDOWN, %UDM_SETRANGE, 0&, MakLng(%MAX_SPIN, %MIN_SPIN) Control Set Size CbHndl, %ID_UPDOWN, 110, 50 UDACCEL.nInc = %STEP_SPIN Control Send CbHndl, %ID_UPDOWN, %UDM_SETACCEL, 1, VarPtr(UDACCEL) Control Send CbHndl, %ID_UPDOWN, %UDM_SETPOS, 0, %INI_SPIN ii1 = %INI_SPIN: PostMessage CbHndl, %WM_VSCROLL, MakDwd(0, ii1), GetDlgItem(CbHndl, %ID_UPDOWN) Case %WM_NOTIFY lpNmh = CbLparam If @lpNmh.Code = %UDN_DELTAPOS Then If (@lpNmh.idFrom = %ID_UPDOWN) Then lpNMUPDOWN = CbLparam ii1 = Max(Min(@lpNMUPDOWN.iPos + @lpNMUPDOWN.iDelta, %MAX_SPIN), %MIN_SPIN) End If End If Case %WM_VSCROLL If GetDlgCtrlID(CbLparam) = %ID_UPDOWN Then ii2 = HiWrd(CbWparam) SetWindowText CbHndl, " Shown " + Format$(ii2) + " Expected " + Str$(ii1) End If End Select End Function Function PbMain Dim hDlg As Long Dialog New 0, "DDT Up-Down demo",,, 130, 70, %WS_CAPTION Or %WS_SYSMENU To hDlg Dialog Show Modal hDlg Call DlgProc End Function
------------------
E-MAIL: [email protected]
Leave a comment:
-
Eddy;
The Up-Down control should produce the
WM_VSCROLL and WM_HSCROLL messages !
In those messages, you should be able to retreive the current
position using :
Code:ActualPos&=LOWRD(SendMessage(hUpDown&, %UDM_GETPOS,0,0))
Note: Trackbars also use the WM_VSCROLL and WM_HSCROLL messages !
You can get the current position of a trackbar using :
Code:ActualPos&=SendMessage(hTrackBar&, %TBM_GETPOS,0,0)
------------------
Leave a comment:
-
strange updown control...
Hi all,
this is an old(?) demo of Lance I believe regarding updown controls.
It was originally a buddy control but I wanted a stand-alone updown control,
so I commented out a few lines.
Because of
%MAX_SPIN = 10
%MIN_SPIN = 1
I would expect a return value between 1 and 10.
Strange thing is that when clicking "up" continuously, return value goes
from 2 to 11. Clicking "down" continuously returns a value from 9 to 0..
Any suggestions?
Kind regards
Eddy
Code:#COMPILE EXE #DIM ALL #INCLUDE "WIN32API.INC" #INCLUDE "COMMCTRL.INC" %ID_LABEL = 100 %ID_BUDDY = 101 %ID_UPDOWN = 102 %MAX_SPIN = 10 %MIN_SPIN = 1 DECLARE CALLBACK FUNCTION DlgCallback() FUNCTION PBMAIN DIM hDlg AS LONG CALL InitCommonControls DIALOG NEW 0, "DDT Up-Down demo",,, 230, 150, %WS_SYSMENU TO hDlg CONTROL ADD LABEL, hDlg, %ID_LABEL, "How Many Lines?", 55, 14, 58, 14 'CONTROL ADD TEXTBOX, hDlg, %ID_BUDDY, "1", 77, 12, 26, 12, %ES_AUTOHSCROLL OR %ES_LEFT, %WS_EX_CLIENTEDGE CONTROL ADD BUTTON, hDlg, %IDOK, "&OK", 13, 41, 40, 14, %BS_DEFAULT OR %WS_TABSTOP CONTROL ADD BUTTON, hDlg, %IDCANCEL, "Cancel", 76, 41, 40, 14 CONTROL ADD "msctls_updown32", hDlg, %ID_UPDOWN, "", 0, 0, 8, 8, %WS_CHILD OR _ %WS_BORDER OR %WS_VISIBLE OR %UDS_WRAP OR %UDS_ARROWKEYS OR _ %UDS_ALIGNRIGHT 'OR %UDS_SETBUDDYINT 'CONTROL SEND hDlg, %ID_UPDOWN, %UDM_SETBUDDY, GetDlgItem(hDlg, %ID_BUDDY), 0& CONTROL SEND hDlg, %ID_UPDOWN, %UDM_SETRANGE, 0&, MAKLNG(%MAX_SPIN, %MIN_SPIN) CONTROL SET SIZE hDlg, %ID_UPDOWN,30,30 DIALOG SHOW MODAL hDlg CALL DlgCallback END FUNCTION CALLBACK FUNCTION DlgCallback() IF CBMSG = %WM_INITDIALOG THEN CONTROL SET FOCUS CBHNDL, %IDOK FUNCTION = 1 ELSEIF CBMSG = %WM_COMMAND THEN IF CBCTL = %IDOK OR CBCTL = %IDCANCEL THEN DIALOG END CBHNDL, (CBCTL = %IDOK) END IF ELSEIF CBMSG = %WM_NOTIFY THEN DIM pNmUpDown AS NM_UPDOWN PTR pNmUpDown = CBLPARAM IF @pNmUpDown.hdr.code = %UDN_DELTAPOS THEN SetWindowText CBHNDL, "Preview value =" + STR$(@pNmUpDown.iPos + @pNmUpDown.iDelta) END IF END IF END FUNCTION
[email protected]
[This message has been edited by Eddy Van Esch (edited June 15, 2001).]Tags: None
Leave a comment: