UpDown Control

Started by Martin Francom, December 10, 2009, 11:46:31 PM

Previous topic - Next topic

Martin Francom

I am a bit confused about the up/down control.

How do I detect if the Up Arrow of the control was clicked or whether the Down Arrow was clicked?

Roger Garstang

#1
It is a Buddy control.  You link it to another control with a message (UDM_SETBUDDY) or Auto-Buddy to link by Tab Order.  Usually links to a Text/Edit Box to make a spinner to cycle through numbers.  Most of what it does is automatic.  Looks like for manual usage you need WM_NOTIFY and UDN_DELTAPOS...never used it like that before myself though.

Martin Francom

Thanks Roger.  I was hoping to be able to detect which direction was clicked.

Roger Garstang

iDelta is signed in the notification message and would indicate direction by negative or positive I'd guess.  Or, iPos could be stored and compared to what is in the next message for direction.  The control has a range of numbers too, so it would wrap...probably best to use iDelta then...unless it wraps too.

Rolf Brandt

Hi Marty,

it is implemented in the AdBook example. Here is a piece of code I had found on this forum. Put this into the custom function of the form on which the UpDown control resides.


   Local pUpDown As NM_UPDOWN Ptr
   
   Select Case wMsg
      Case %WM_NOTIFY
         pUpDown = lParam
         If @pUpDown.hdr.idFrom = IDC_FRMCREATETBL_UPDOWN1 Then
            If @pUpDown.hdr.Code = %UDN_DELTAPOS Then
               If @pUpDown.iDelta = -1 Then 'Down
                  MsgBox "DOWN"
               Else   'Up
                  MsgBox "UP"
               End If                     
            End If                           
         End If   
      Case Else                             
   End Select                                     

Rolf Brandt
http://www.rbsoft.eu
http://www.taxifreeware.com
I cook with wine, sometimes I even add it to the food.
(W. C. Fields)

Roger Garstang

#5
While we are on the subject of Up/Down...I just started a new project using them as a buddy control and they seem to behave differently than in FF2.  The behavior seems to be more WYSIWYG than before, just wondering if it was meant to be or not.

FF2- Auto-Buddy to Textbox and really you could place it anywhere on the form and any size and at runtime it would position itself and be where it is supposed to be.

FF3- Where you place it is where it is during runtime even though it is linked to the box fine.  The textbox does size itself like it did in FF2 though, so it looks really weird.  Usually I place the Up/Dn right next to the textbox sort of how it will look since if placed on top it is hard to select it.  This doesn't work now though and I need to place it on top with right edges aligned.  Back to hard to select again, but how it looks in IDE is how it looks when running.

Edit:  The way FF3 is placing the controls if I align right edges is still 1 pixel too far to the right on my text boxes, so it appears this would be a bug that needs fixed another way to behave like FF2 did.

Martin Francom

Rolf,
   Thanks.  I saw that.  I was trying to use more than 2 of thoughs controls and was getting tangle up in the logic.  I was hoping that their might an easier less complicated way of detecting an up or down click.
   I may use a couple of command buttons longated to resemble the up/down control. 
   Is there a way to place a Chr$(30)  and Chr$(31) in the caption of a command button?