Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Controls
  New Posts New Posts RSS Feed - UpDown Control: How do I determine whick button wa
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

UpDown Control: How do I determine whick button wa

 Post Reply Post Reply
Author
Message
Norika View Drop Down
Groupie
Groupie
Avatar

Joined: 30 November 2006
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote Norika Quote  Post ReplyReply Direct Link To This Post Topic: UpDown Control: How do I determine whick button wa
    Posted: 30 August 2011 at 10:43pm

Hi,

I cannot determine which button was clicked of a UpDown control,  "Up" button was clicked or "Down" was clicked?

I use its Change event becaluse I want to change the value continuously. 
But my sample code was running oposit direction when I clicked the first time.

 
Please help me!
Best regards

Product: Xtreme SuitePro (ActiveX) version 15.1.2
Platform: Windows XP (32bit) - SP 3
Language: Visual Basic 6.0 - SP6

Back to Top
Norika View Drop Down
Groupie
Groupie
Avatar

Joined: 30 November 2006
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote Norika Quote  Post ReplyReply Direct Link To This Post Posted: 31 August 2011 at 5:25am

Hi,

I try a detour path.
Thank you.
 
Private Declare Function SetCursorPos Lib "user32" _
    (ByVal x As Long, ByVal y As Long) As Long
Private Type POINTAPI
        x As Long
        y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" _
    (lpPoint As POINTAPI) As Long
   
Private Declare Function ScreenToClient Lib "user32" _
    (ByVal hWnd As Long, lpPoint As POINTAPI) As Long
   
Private P As POINTAPI
Private Sub UpDown1_Change()
    Dim intPixel_UpDown_ClientTop As Integer
    Dim intPixel_UpDown_Height As Integer
   
    intPixel_UpDown_ClientTop = Me.UpDown1.Top / Screen.TwipsPerPixelY
    intPixel_UpDown_Height = Me.UpDown1.Height / Screen.TwipsPerPixelY
   
    GetCursorPos P
    Call ScreenToClient(Me.hWnd, P)
    If P.y < intPixel_UpDown_ClientTop + intPixel_UpDown_Height / 2 Then
        Me.txt_Time.Text = Me.txt_Time.Text + 1
    Else
        Me.txt_Time.Text = Me.txt_Time.Text - 1
    End If
End Sub
 
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1355
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 31 August 2011 at 9:17am
I think you can use the SyncBuddy property to accomplish your goal:


Private Sub Form_Load()
   With Me.UpDown1
      .SyncBuddy = True
      .Min = -100
      .Max = 100
      .Increment = 1
   End With
End Sub


Will automatically increment/decrement  the value in the control by 1 when the up/down button is held down. It will also limit the values to between -100 and 100.


Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6

Back to Top
Norika View Drop Down
Groupie
Groupie
Avatar

Joined: 30 November 2006
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote Norika Quote  Post ReplyReply Direct Link To This Post Posted: 05 September 2011 at 8:10pm

Dear jpbro,

Thank you for your advice.
I can Increment/Decrement correctly.

Product: Xtreme SuitePro (ActiveX) version 15.1.2
Platform: Windows Vista with SP2

Language: Visual Basic 6.0 - SP6
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.188 seconds.