PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: John Montenigro on October 05, 2006, 02:24:37 AM

Title: Question about Up-Down control
Post by: John Montenigro on October 05, 2006, 02:24:37 AM
My application will use an UpDown control in conjunction with a listbox. I started to write my own position management code when I found information in the Win32API helpfile.

The description of the Up-Down control mentions how it can be associated with a "Buddy-Control" such as ListBox. Joined, a lot of positioning messages between the two are handled automatically. Sounds like something I'd like to use, BUT: I don't see a Property for associating a Buddy-Control on the FF Properties sheet for the UpDown control.


I found some info in CommCtrl.INC about the UPDOWN_CLASS, but I'm not sure how to use it in FF. Is this one of those situations where I have to intercept the calls to the control and put my own "wrapper" around it?

-John
Title: Re: Question about Up-Down control
Post by: John Montenigro on October 08, 2006, 11:57:22 AM
After many hours experimenting with UpDown code found in POFFS, I discovered that it's better to put my code into the FRMMAIN_UPDOWN1_WM_VSCROLL routine than in the _CUSTOM routine.   :?

Now I'm trying to figure out how to trap the right messages in order to change the cursor position in the listbox. I've been reading the Win32API Help file on UpDown controls, and I think I understand what messages to trap, but I haven't been successful yet. Again, I'm probably overlooking something pretty simple...

Well, I'll figure it out sooner or later, but I guess I really expected that the UpDown control in FF would have Properties for associating the control with a BuddyControl...  Or are they there and I'm just not seeing them?

The adventure continues,
-John
Title: Question about Up-Down control
Post by: TechSupport on October 08, 2006, 10:45:54 PM
Hi John,

FireFly does not use the Buddy Control concept. You need to update your "buddy" control manually after retrieving the value from the UpDown message.

Function FORM1_UPDOWN1_WM_VSCROLL ( _
                                 ControlIndex  As Long,  _  ' index in Control Array
                                 hWndForm      As Dword, _  ' handle of Form
                                 hWndControl   As Dword, _  ' handle of Control
                                 nScrollCode   As Long,  _  ' scroll bar value
                                 nPosition     As Long   _  ' current scroll bar position
                                 ) As Long

  Select Case nScrollCode
     Case %SB_THUMBPOSITION
        FF_Control_SetText HWND_FORM1_TEXT1, "ThumbPosition: " & Str$(nPosition)
       
     Case %SB_ENDSCROLL
        FF_Control_SetText HWND_FORM1_TEXT1, "EndScroll: " & Str$(nPosition)
 
  End Select
       
       
End Function


If you want to update your control on every value change then respond to the %SB_THUMBPOSITION. If you only want to respond to the change after the user stops pressing the arrow key then respond to the %SB_ENDSCROLL message.

Hope this helps.
Title: Question about Up-Down control
Post by: John Montenigro on October 09, 2006, 04:45:18 PM
Quote from: TechSupport

....

If you want to update your control on every value change then respond to the %SB_THUMBPOSITION. If you only want to respond to the change after the user stops pressing the arrow key then respond to the %SB_ENDSCROLL message.

Hope this helps.

Oh boy, does it ever! With all the reading I've already done, I didn't see anything about these messages or those particular equates!

That brief explanation tells volumes of what I need to do next!!

Thanks, I appreciate it!
-John
Title: Question about Up-Down control
Post by: TechSupport on October 09, 2006, 05:21:46 PM
:)   Windows can be very vast and deep and finding the right message can be difficult sometimes. I got those messages from my #1 resource book: "Win32 Programming" by Rector and Newcomer.
Title: Question about Up-Down control
Post by: John Montenigro on October 10, 2006, 03:00:53 AM
OK, so in about 25 minutes, I completely replaced all code for the UpDown control with two command buttons. Works great.

But I still wish I understood how to use the UpDown control properly...

If anyone could check those Position parameters, I'd sure like to know what you find! Thanks!

-John
Title: Question about Up-Down control
Post by: TechSupport on October 10, 2006, 08:30:22 AM
If it is the setting and retrieving of the position numbers then you can use the following functions:

%UDM_SETRANGE
SendMessage hWndControl, %UDM_SETRANGE, 0, MAKLNG( nLower, nUpper )

%UDM_SETPOS
SendMessage hWndControl, %UDM_SETPOS, 0, 1

You can also use the %UDM_GETPOS to retrieve the current position
nPos = SendMessage( hWndControl, %UDM_GETPOS, 0, 0 )
Title: Question about Up-Down control
Post by: John Montenigro on October 10, 2006, 10:06:57 AM
Well, I really didn't need to change the indexing. I had been trying to determine which arrow of the UpDown had been clicked, so I could change which line in the listbox had the cursor (highlight).

All I needed was to increase or decrease the _SetCurSel value.

I was having trouble because I could detect %SB_LINEDOWN but not %SB_LINEUP. So the selection would work downward, but not upward.

That's when I noticed that the Position param of the _UPDOWN1_VSCROLL routine was always incrementing, regardless of which arrow was clicked.

And that's where I got stuck.