Print Page | Close Window

UpDown Control: How do I determine whick button wa

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Controls
Forum Description: Topics Related to Codejock Controls
URL: http://forum.codejock.com/forum_posts.asp?TID=18880
Printed Date: 30 November 2024 at 10:14am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: UpDown Control: How do I determine whick button wa
Posted By: Norika
Subject: UpDown Control: How do I determine whick button wa
Date 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.

https://forum.codejock.com/uploads/2548/UpDownTest_VB6.zip - uploads/2548/UpDownTest_VB6.zip
 
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




Replies:
Posted By: Norika
Date 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
 


Posted By: jpbro
Date 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



Posted By: Norika
Date 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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net