KeyState

KeyState

Postby Gilbert » Tue Feb 20, 2007 4: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
Gilbert
 
Posts: 74
Joined: Thu Oct 20, 2005 4:30 pm
Location: Canada

Re: KeyState

Postby wmormar » Tue Feb 20, 2007 5: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
User avatar
wmormar
 
Posts: 1074
Joined: Fri Oct 07, 2005 10:41 pm
Location: México

Postby James Bott » Tue Feb 20, 2007 5:31 pm

Glibert,

Try VK_MENU

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Gilbert » Tue Feb 20, 2007 5:54 pm

Hi,

Thanks for the hint it partly solved my problem.

But there`s something that I don`t 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
Gilbert
 
Posts: 74
Joined: Thu Oct 20, 2005 4:30 pm
Location: Canada

Postby James Bott » Tue Feb 20, 2007 6: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Gilbert » Tue Feb 20, 2007 7: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
Gilbert
 
Posts: 74
Joined: Thu Oct 20, 2005 4:30 pm
Location: Canada

Postby James Bott » Tue Feb 20, 2007 8: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for CA-Clipper

Who is online

Users browsing this forum: No registered users and 8 guests