FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for CA-Clipper KeyState
Posts: 74
Joined: Thu Oct 20, 2005 04:30 PM
KeyState
Posted: Tue Feb 20, 2007 04:33 PM

Hi,

Is there a way to test the state of ALT Key just like CONTROL and SHIFT key.

In VKEY.CH I can find VK_CONTROL, VK_SHIFT but not VK_ALT

Regards

Gilbert Vaillancourt
turbolog@videotron.ca
Posts: 1076
Joined: Fri Oct 07, 2005 10:41 PM
Re: KeyState
Posted: Tue Feb 20, 2007 05:29 PM
Gilbert wrote:Hi,

Is there a way to test the state of ALT Key just like CONTROL and SHIFT key.

In VKEY.CH I can find VK_CONTROL, VK_SHIFT but not VK_ALT

Regards


is: VK_MENU

regards
William, Morales

Saludos



méxico.sureste
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
KeyState
Posted: Tue Feb 20, 2007 05:31 PM

Glibert,

Try VK_MENU

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 74
Joined: Thu Oct 20, 2005 04:30 PM
KeyState
Posted: Tue Feb 20, 2007 05:54 PM

Hi,

Thanks for the hint it partly solved my problem.

But theres something that I dont understand.

If VK_MENU test the ALT key, Why VK_CONTROL test the CTRL and ALT keys.

I wrote this small piece of code for testing:

if GetKeyState(VK_MENU)
MsgInfo(ALT key has been pressed)
endif

if GetKeyState(VK_CONTROL)
MsgInfo(CTRL key has been pressed)
endif

If I press CTRL + 2 Message displayed is CTRL key has been pressed
If I press ALT + 2 Message displayed is ALT key has been pressed followed by CTRL key has been pressed

Why is VK_CONTROL also test the ALT key ?
Sould`nt it be testing the CTRL key only ?

Regards

Gilbert

Gilbert Vaillancourt
turbolog@videotron.ca
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
KeyState
Posted: Tue Feb 20, 2007 06:05 PM

Gilbert,

As I remember there are some strange things going on with the Alt key, probably since it is a Windows reserved key to trigger hotkeys.

Perhaps if you tell us exactly what you are trying to accomplish someone can come up with a solution.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 74
Joined: Thu Oct 20, 2005 04:30 PM
KeyState
Posted: Tue Feb 20, 2007 07:01 PM

Hi James,

I`m implementing new picture clause in the TGet. So far it works ok exept for one situation.

One picture clause I create allows the user to use FastLogin by using CTLR-G or whatever. (All 26 alpha key are available). Of course this FastLogin key has been configured in a User managament module where the user can create new users and define a FastLogin key.

So far, so good it works nicely. The only problem that this is causing me is whenever I have to capture an E-Mail address in a get field I cannot capture the @. TGet crashes. I figured out that it was because whenever the ALT Key is used it goes through the same routine that I added to the TGET that captures the FastLogin.

The strange thing about this is that the FastLogin should only work with CTRL Key. But I found out that using GetKeyState(VK_CONTROL) wich test the CTRL key also test the ALT Key. Because of this TGet crashes.

Finaly, I was able to work around the problem by doing the following:

do case
case GetKeyState(VK_MENU)
// Do Nothing
case GetKeyState(VK_CONTROL)
...
...
...
endcase

By testing VK_MENU (ALT key) first I eliminate the fact that using the ALT key GetKeyState(VK_CONTROL) processes the ALT + whaterver key may be used. This work around is quite weird but it works.

Regard,

Gilbert

Gilbert Vaillancourt
turbolog@videotron.ca
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
KeyState
Posted: Tue Feb 20, 2007 08:16 PM

Gilbert,

>This work around is quite weird but it works.

Glad to hear you got it working. As I mentioned the Alt key is special. It probably doesn't get trapped because it has to be available to call up the menu or a hotkey at any time.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10

Continue the discussion