hi all
The problem is when I click an arrow up or down on my spin control I want to increment or decrement
a real number value,something like this:
0.25 is for one click so:
arrow up: 00.00--->00.25--->00.50--->00.75 etc
I know how to do it with integer values but with real one I have no idea...
thx for replies...
Post what you have done so far or make a demo of what you want to do.
Regards, P1 :8)
invoke GetDlgItem,hWin,IDC_EDT1
mov hEditb1,eax ;getting handle of editbox ( IDC_EDT1 )
invoke SendDlgItemMessage,hWin,IDC_UDN1,UDM_SETBUDDY,hEditb1,0 ; setting buddy of updown control ( IDC_UDN1 )
mov dx,1 ;min value
ror edx,16
mov dx,31 ;max value
invoke SendDlgItemMessage,hWin,IDC_UDN1,UDM_SETRANGE,0,edx ;range
.
.
.
and then when I click arrow ( up or down ) I have increment or decrement of 1...
The automatic "buddy" with up/down controls only process sequential integers.
If you want to display other types of values (i.e. non-sequential, floats, etc.), you will have to avoid the "buddy", process the up/down control notification messages yourself, and then display yourself whatever you prefer in the edit control.
Raymond
@reymond
if I dont use UDM_SETBUDDY to assign a buddy window to an updown control they
will not look like single control ( spinner control ) ...
You can always position the EDIT and the UP/DOWN controls in such a way that they would appear as a single control.
If you insist on using the UDM_SETBUDDY for that purpose, you will still have to process the UDN_DELTAPOS notification message and return TRUE to prevent Windows from making any changes to the EDIT control after you have made your own changes.
Raymond
@reymond
dont understand
How can I prevent or allow return values to be TRUE or FALSE ?
maybe something like this :
.
.
.elseif eax==WM_NOTIFY
mov eax,lParam
.if [eax].NMHDR.code==UDN_DELTAPOS
.
.
.endif
.
.elseif eax==WM_NOTIFY
mov eax,lParam
.if [eax].NMHDR.code==UDN_DELTAPOS
;The lParam of the message is a pointer to an NM_UPDOWN structure
;Get the info and adjust the EDIT control as required
.....
.....
return TRUE ;to prevent Windows from processing the same message
.endif
(Look at the description of the UDN_DELTAPOS message in the Win32 Programmer's Reference.)
Raymond
Dancho,
The simple and right way is to create subclassed control for UpDownCtrl.
Read MSDN and you understand me (and windows too :bg).
I done this in VB. Multiply the integer part by .250 and you will have a resultant steps of a quarter increment.
Regards, P1 :8)
thx all for yours time and replies...
:U
well it seems that I cant get it right , or I miss something again ...
elseif eax==WM_NOTIFY
mov edx,lParam
mov eax,[edx].NMHDR.hwndFrom
.if eax==hUpd9;handle of UpDown control
.if [edx].NMHDR.code==UDN_DELTAPOS
mov eax,lParam
mov [eax].NM_UPDOWN.iPos,0
mov [eax].NM_UPDOWN.iDelta,3
return TRUE
.endif
.endif
program is working , but ( there is always atleast one but ) if I click up or down arrow numbers always going up to max number in range
like there is no down arrow at all...
so from 0 to 3,6,9,12 etc...max number
any help will be appriciate
Quoteif I click up or down arrow numbers always going up to max number in range
like there is no down arrow at all...
Obviously. With the
mov [eax].NM_UPDOWN.iDelta,3, you are telling it to increase the number by 3 all the time regardless of the UP or DOWN arrow having been clicked. The message is telling you that the information is located in the
iDelta component. Check whether it is negative or positive before overwriting it.
Raymond
@reymond
thx , it is working now ...
QuoteThe iDelta member of the structure is a signed integer that contains the proposed change in position. If the user has clicked on the up button, this is a positive value. If the user has clicked on the down button, this is a negative value.
It seems that I didnt understand this explanation,I thought that up or down button gives + or - sign to the iDelta no matter what sign previuse iDelta was...
.elseif eax==WM_NOTIFY
mov edx,lParam
mov eax,[edx].NMHDR.hwndFrom
.if eax==hUpd9;handle of UpDown control
.if [edx].NMHDR.code==UDN_DELTAPOS
mov edx,lParam
mov eax,[edx].NM_UPDOWN.iDelta
.if eax==1
invoke SendDlgItemMessage,hWin,IDC_EDT12,WM_GETTEXT,sizeof ipos_buff_9,addr ipos_buff_9
invoke FpuAtoFL,addr ipos_buff_9,addr ipos_real9,DEST_MEM ; decimal string to real
invoke FpuAdd,addr ipos_real9,addr icdc,addr ipos_sum9,SRC1_REAL or SRC2_REAL or DEST_MEM ; adding 0.250
invoke FpuFLtoA,addr ipos_sum9,2,addr outpos_buff_9,SRC1_REAL or SRC2_DIMM ; writing back to decimal string
.elseif eax==-1
invoke SendDlgItemMessage,hWin,IDC_EDT12,WM_GETTEXT,sizeof ipos_buff_9,addr ipos_buff_9
invoke FpuAtoFL,addr ipos_buff_9,addr ipos_real9,DEST_MEM
invoke FpuSub,addr ipos_real9,addr icdc,addr ipos_sum9,SRC1_REAL or SRC2_REAL or DEST_MEM
invoke FpuFLtoA,addr ipos_sum9,2,addr outpos_buff_9,SRC1_REAL or SRC2_DIMM
.endif
return TRUE
.endif
.endif
.elseif eax==WM_VSCROLL
invoke SendDlgItemMessage,hWin,IDC_EDT12,WM_SETTEXT,0,addr outpos_buff_9
like I said program is working , values in spinner control are going up or down by 0.250 , but :dazzled:
the problem is when I add second spin control(same code like this) and new line for that control in WM_VSCROLL , like this
.elseif eax==WM_VSCROLL
invoke SendDlgItemMessage,hWin,IDC_EDT12,WM_SETTEXT,0,addr outpos_buff_9
invoke SendDlgItemMessage,hWin,IDC_EDT13,WM_SETTEXT,0,addr outpos_buff_10
when user click up or down arrow on one control ,
other control is automaticly empty...
I know thats because other control buff is empty ( there wasnt any clicking yet),
my question is how I can control that...
btw both controls getting their default values like this:
.if eax==WM_INITDIALOG
invoke SendDlgItemMessage,hWin,IDC_EDT12,WM_SETTEXT,0,addr df_spin12
invoke SendDlgItemMessage,hWin,IDC_EDT13,WM_SETTEXT,0,addr df_spin13
thx
Quotelike I said program is working , values in spinner control are going up or down by 0.250
Glad to hear that. (Also nice to see some use for the Fpulib.)
Quotemy question is how I can control that...
That is quasi-impossible to answer without seeing most of the code you used. Zip it up, including the resource file, and I will have a look at it.
Raymond
I find FpuLib very very helpful...
:U
this is download link for small program that shows exactly what is the problem,
btw I put all RadAsm project in it ( 8kb )...
Your Download-Link: http://rapidshare.de/files/22851628/SpinControl.7z.html
Please, what must I use to access the information inside that .7z file????? :dazzled: :dazzled: :dazzled:
Raymond
www.7-zip.org (http://www.7-zip.org)
I just notice some strange behavior of spin control in this program,
when you click up or down arrow ( I mean no clicking but one click and keep it press ) values want go
for their max or min but only for 3.75 points ( + or - , depends if you click up or down ) and it will
stop...
I dont see any limitations in program that can cause that ...!
@raymond
sry...
I'm using 7-Zip for a long time and I thought that newest versions of WinRar and WinZip
can open *.7z file...
If you have trouble with it I will post link with *.rar or *.zip file...
thx
Tedd:
Thanks for the link.
dancho:
Quotewhen user click up or down arrow on one control ,
other control is automaticly empty...
I know thats because other control buff is empty ( there wasnt any clicking yet),
my question is how I can control that...
Initialize your outpos_buff buffers with the default values when processing the WM_INITDIALOG message.
QuoteI just notice some strange behavior of spin control in this program,
when you click up or down arrow ( I mean no clicking but one click and keep it press ) values want go
for their max or min but only for 3.75 points ( + or - , depends if you click up or down ) and it will
stop...
I dont see any limitations in program that can cause that ...!
Instead of checking if EAX=1 or -1, try checking if EAX is positive or negative instead.
test eax,eax
.if !SIGN? ;if positive
....
.else ;if negative
....
.endif
I would also suggest you increase the size of the edit boxes so that the entire number can be displayed.
Raymond
@raymond
thy very much....
:U