CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2000
    Location
    india
    Posts
    191

    Disabled controls

    Hi All,

    In my project, I need to execute some messages, when user clicks on the disabled control. For example, if user clicks on the disabled combo box, he/she should get the message to do something else to enable the combo box. But, disabled control cannot execute click event. How to make this requirement possible?

    Thanks in advance.


  2. #2
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: Disabled controls

    Disabled controls do receive messages but being disabled they don't pass them on to VB to raise events with.

    You will either have to subclass the controls to intercept these messages and pass them on to your application (see http://www.merrioncomputing.com/OnlineIssue2.htm for information about subclassing - what it is and how to do it ) or you will have to use the SetCapture API call to make all mouse messages go to the form instead of the controls and pass them on if the control is not disabled.

    hope this helps,
    Duncan

    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  3. #3
    Join Date
    Aug 2000
    Location
    india
    Posts
    191

    Re: Disabled controls

    Thank you for the reply. Can you please eloberate on the usage of SetCapture API? If you are specific to an example, like the coding for disabled command button, it will help a lot.



  4. #4
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: Disabled controls

    FAQs - How to capture the mouse input.

    You need to use the SetCapture API call.

    '\\ Mouse message capture
    private Declare Function SetCaptureApi Lib "user32" Alias "SetCapture" (byval hwnd as Long) as Long
    private Declare Function GetCaptureApi Lib "user32" Alias "GetCapture" () as Long




    Now say you want mouse events from a control to go to a form instead....

    If GetCapture() = cmbOK.hwnd then
    Call SetCapture(me.Hwnd)
    End If






    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  5. #5
    Join Date
    Aug 2000
    Location
    india
    Posts
    191

    Re: Disabled controls

    That's fine Duncan and thanks again. But how to proceed after this? Let me be specific to my project. There is a combobox (disabled) in a form. It will remain disabled until another checkbox is unchecked. When user clicks on the disabled combobox, a message should come saying that the checkbox should be unchecked first to enable the combobox.

    Thanks in advance.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured