UpDown Control with real numbers increment or decrement

Started by dancho, June 02, 2006, 04:34:53 PM

Previous topic - Next topic

dancho

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...




P1

Post what you have done so far or make a demo of what you want to do.

Regards,  P1  :8)

dancho

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...

raymond

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
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

dancho

@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 ) ...

raymond

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
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

dancho

@reymond

dont understand
How can I prevent or allow return values to be TRUE or FALSE ?

dancho

maybe something like this :
.
.
.elseif eax==WM_NOTIFY
mov eax,lParam
.if [eax].NMHDR.code==UDN_DELTAPOS
.
.         
.endif
.

raymond

.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
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

KSS

Dancho,
 The simple and right way is to create subclassed control for UpDownCtrl.
Read MSDN and you understand me (and windows too  :bg).

P1

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)

dancho


dancho

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

raymond

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
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

dancho

@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...