Click to See Complete Forum and Search --> : Disabled controls
shashidharkr
August 23rd, 2001, 02:01 AM
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.
Clearcode
August 23rd, 2001, 04:02 AM
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.
shashidharkr
August 23rd, 2001, 04:50 AM
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.
Clearcode
August 23rd, 2001, 05:05 AM
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.
shashidharkr
August 23rd, 2001, 05:40 AM
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.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.