An unusal issue with SPIN BUTTON


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 9 of 9

Thread: An unusal issue with SPIN BUTTON

  1. #1
    Join Date
    Nov 2006
    Posts
    3

    Question An unusal issue with SPIN BUTTON

    Hi,

    I'm facing an unusual issue with spin button. In my project i'm using
    Microsoft Forms 2.0 Object library. In one of the forms i have a couple of
    frames. A large Frame and within that another one.

    In the small frame which is within the large frame, i have a textbox and a
    spin button. then outside of this frame within the large frame i have a
    command button. The tab order is TextBox (0). Spin Button(1) and Command
    Button(2).

    I'm using the spin button to increase/decrease the value in the text box. I
    have written the code in SpinUp and SpinDown events and it works perfectly.
    I have written some code in the click event of the command button.

    The issue i'm facing is, if the focus is on the spin button and then if i
    click the command button, the command button click event never fires. I have
    to click a second time to get the event fired.

    Can somebody help me on this?.

    Is this a problem with spinbutton control or do i have to set some
    properties for the spin button?

  2. #2
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    I saw the same behavior, it is very possible that this is an issue with the Form 2.0 controls (that Miscrosoft does not support anymore)
    Just an idea: use the comand button mouse down event, and check if the spinbutton control had the focus, if yes set a flag, and in the mouse up event fire the Click event.
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  3. #3
    Join Date
    Nov 2006
    Posts
    3
    Hi,

    Tnx for the reply. i'll try this out. but how do i find out if the focus was on spin button?. is there any direct way to do it?

  4. #4
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    not that I know, but a couple of flags should help:

    Code:
    Private m_spinHasFocus As Boolean
    Private m_bSendClick As Boolean
    
    Private Sub Command1_Click()
        Debug.Print "Command1_Click"
    End Sub
    
    Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        m_bSendClick = m_spinHasFocus
    End Sub
    
    Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
        '' check if X and Y are in the button
        If m_bSendClick Then
            Command1_Click
        End If
        m_bSendClick = False
    End Sub
    
    Private Sub SpinButton1_GotFocus()
        m_spinHasFocus = True
    End Sub
    
    Private Sub SpinButton1_LostFocus()
        m_spinHasFocus = False
    End Sub
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  5. #5
    Join Date
    Nov 2006
    Posts
    3
    Hi mstraf,

    Thanks for the reply. I'll try this out.

  6. #6
    Join Date
    Oct 2005
    Location
    Staffordshire, England
    Posts
    101
    As I said in M2k you can use Spin32.ocx to do the same thing. You can also use ScrollBars to spin up and down. You can also use the up, down button as well.

    If your using Microsoft Forms 2.0 Object Library (Fm20.dll) then you can't distribute your app will this dll.
    I've been programming with VB for 15 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

    Martin2k

  7. #7
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    Quote Originally Posted by Keithuk
    ..If your using Microsoft Forms 2.0 Object Library (Fm20.dll) then you can't distribute your app will this dll.
    interesting... I never used the Forms 2.0 library, why is that it cannot be distributed?
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  8. #8
    Join Date
    Oct 2005
    Location
    Staffordshire, England
    Posts
    101
    Quote Originally Posted by mstraf
    interesting... I never used the Forms 2.0 library, why is that it cannot be distributed?
    The Fm20.dll is NOT redistributable. You must have an application such as Microsoft Office 97 on the target system that installs Fm20.dll as part of its setup. (Fm20.dll is included with the OSR2 and OSR2.5 releases of Windows 95.) You can also find this file on the Visual Basic 5.0 CD under the \TOOLS\DataTool\Datatool\Msdesign folder. This will be installed only if you run the setup for the Visual Database Tools. In any case, you may not distribute the Fm20.dll as part of your setup, even if you purchase the Microsoft Office Developer Edition product.

    As an alternative to having your end users install Microsoft Office, you can have them freely download and install the Microsoft ActiveX Control Pad, which also installs the Fm20.dll. For more information, see the following Microsoft Developer Network (MSDN) Web site:

    Microsoft ActiveX Control Pad
    http://msdn.microsoft.com/library/de.../html/cpad.asp

    http://support.microsoft.com/kb/241245/EN-US/#appliesto

    NOTE: The use of these Microsoft Forms components in your own compiled applications, such as those written with Microsoft Visual C++ and Microsoft Visual Basic, is not recommended or supported. These controls were designed and tested to work exclusively within Microsoft Office and its Visual Basic for Applications environment.
    I've been programming with VB for 15 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

    Martin2k

  9. #9
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    wooah... thanks!
    I am glad I never used that control...
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

Similar Threads

  1. Replies: 7
    Last Post: 07-17-2013, 12:47 AM
  2. Need help with calculator...
    By 2eXtreme in forum Java
    Replies: 0
    Last Post: 04-05-2006, 08:38 AM
  3. Start Stop Button
    By sboothman in forum Java
    Replies: 6
    Last Post: 11-30-2005, 03:12 AM
  4. button listener not working
    By DrunkinP in forum Java
    Replies: 0
    Last Post: 03-31-2005, 10:36 AM
  5. Replies: 0
    Last Post: 11-21-2002, 12:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center