Assembly code snippets
Details
Title | Making a Spin Control |
---|---|
Author | NaN |
Submitted by: | NaN |
Date added: | 2002-03-30 09:23:30 |
Date modified: | 2002-03-30 09:23:30 |
Comments
This snippet will show the method how to create a Spin Control, where an UP/DOWN control manages a small Editbox (This combination is termed a SPIN control). Good for setting and quickly changing setting/numbers with your mouse (or mouse wheel).
Snippet
; ----------------------------------------------------------------------
; Things to NOTE:
; The styles flags of the Control is very important to getting the
; BUDDY (edit window) to work.
;
; Refer to MSDN: for styles at :
;
; http://msdn.microsoft.com/library/default.asp?url=/library/
; en-us/shellcc/platform/CommCtls/UpDown/Styles.asp/
;
; When BUDDIED, the height of the EDIT BOX controls the hieght
; of the Up Down Control. Hence the overall height here is 25!
; To my knowledge the no position param's of the UP/DOWN control
; reallu is valid at this point.
;
; Messages are UDM_xxxxx's, and '2000' is the UDM control ID chosen
; The UDS_SETBUDDYINT is the most important style setting for getting
; the EDIT box to properly buddy and 'communicate' between each other
; ----------------------------------------------------------------------
invoke CreateWindowEx,WS_EX_CLIENTEDGE,ADDR szEDITCls,NULL,\
WS_CHILD or WS_BORDER or WS_VISIBLE,\
120,20,80,25,hWin,NULL,\
hInstance,NULL
mov hBuddyEdit,eax
invoke CreateUpDownControl, WS_CHILDWINDOW or WS_BORDER or WS_VISIBLE or \
UDS_SETBUDDYINT or UDS_ALIGNRIGHT or UDS_WRAP \
or UDS_ARROWKEYS,\
140, 20, 60, 30, hWin, 2000, hInstance,
hBuddyEdit, 99, 0, 0
mov hSpinControl, eax
; Set to 10 for base 10!
invoke SendMessage, hSpinControl, UDM_SETBASE, 16, NULL
There you go! Hope you can use it..
Enjoy.
NaN
; Things to NOTE:
; The styles flags of the Control is very important to getting the
; BUDDY (edit window) to work.
;
; Refer to MSDN: for styles at :
;
; http://msdn.microsoft.com/library/default.asp?url=/library/
; en-us/shellcc/platform/CommCtls/UpDown/Styles.asp/
;
; When BUDDIED, the height of the EDIT BOX controls the hieght
; of the Up Down Control. Hence the overall height here is 25!
; To my knowledge the no position param's of the UP/DOWN control
; reallu is valid at this point.
;
; Messages are UDM_xxxxx's, and '2000' is the UDM control ID chosen
; The UDS_SETBUDDYINT is the most important style setting for getting
; the EDIT box to properly buddy and 'communicate' between each other
; ----------------------------------------------------------------------
invoke CreateWindowEx,WS_EX_CLIENTEDGE,ADDR szEDITCls,NULL,\
WS_CHILD or WS_BORDER or WS_VISIBLE,\
120,20,80,25,hWin,NULL,\
hInstance,NULL
mov hBuddyEdit,eax
invoke CreateUpDownControl, WS_CHILDWINDOW or WS_BORDER or WS_VISIBLE or \
UDS_SETBUDDYINT or UDS_ALIGNRIGHT or UDS_WRAP \
or UDS_ARROWKEYS,\
140, 20, 60, 30, hWin, 2000, hInstance,
hBuddyEdit, 99, 0, 0
mov hSpinControl, eax
; Set to 10 for base 10!
invoke SendMessage, hSpinControl, UDM_SETBASE, 16, NULL
There you go! Hope you can use it..
Enjoy.
NaN