Home » U++ Library support » U++ Widgets - General questions or Mixed problems » Using InstallKeyHook
Using InstallKeyHook [message #10378] |
Wed, 04 July 2007 19:27 |
malaugh
Messages: 7 Registered: June 2007
|
Promising Member |
|
|
I am trying to disable an entry field if the user types in another entry field. If the user enters data in the EditVakue control editVendData, then the EditValue control editVendLength, should be disabled. I thought I could do this with the Installkeyhook function. My basic logic is
1) Capture the key input for the application
2) In the key handler, if a key is hit when the user is in the editVendData, then disable editVendLength.
I have tried numerous methods, this is one of my attempts.
In the class
friend bool VendDataKeyHook(Ctrl *ctrl, dword key, int count);
In the constructor
InstallKeyHook(VendDataKeyHook);
The function
bool VendDataKeyHook(Ctrl *ctrl, dword key, int count)
{
USBConsole *panel = (USBConsole *)ctrl;
if(ctrl->GetFocusCtrl() == (Ctrl *)(&(panel->editVendData)))
{
panel->editVendLength.Disable();
}
return(FALSE);
}
The if statement is always FALSE, so editVendLength is never disabled. Also if I move the disable statement outside the if, the program crashes. What am I doing wrong?
I could not find any examples that use InstallKeyHook, is there one?
|
|
|
|
|
Re: Using InstallKeyHook [message #10389 is a reply to message #10384] |
Thu, 05 July 2007 11:39 |
mrjt
Messages: 705 Registered: March 2007 Location: London
|
Contributor |
|
|
Something like this?
In window contructor
editVendData <<= THISBACK(SyncFields); // Sets WhenAction callback
Sync function:
SyncFields()
{
if (editVendData.GetLength())
// Disable length field and set data to length of data field
editVendLength.Enable(false) <<= editVendData.GetLength();
else
editVendLength.Enable(true);
}
James
[Updated on: Thu, 05 July 2007 11:39] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Thu Apr 25 15:08:29 CEST 2024
Total time taken to generate the page: 0.02266 seconds
|