Difference between mouse and keyboard

Post Reply
User avatar
MarcoBoschi
Posts: 925
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy
Contact:

Difference between mouse and keyboard

Post by MarcoBoschi »

Hi,
please compile this little sample program.

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    LOCAL cVar := SPACE(10)

    CGETFILE( "*.*", "Select a file" )

    DEFINE DIALOG oDlg

    @ 1, 1 GET cVar

    @ 2, 1 BUTTON "Button1"
    @ 3, 1 BUTTON "Button2"

    ACTIVATE DIALOG oDlg

    RETURN NIL
First time use keyboard to select file into CGETFILE dialog ( you can use mouse and press keyboard just one time)

When you return to dialog oDlg and you change focus into Button1 everything works fine.

Image

Second time use only mouse (please do not touch keyboard)
When Button1 gets focus it does not appear in the right way
Image

Any suggestions?
Marco
Marco Boschi
info@marcoboschi.it
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Difference between mouse and keyboard

Post by Antonio Linares »

Marco,

If you press "Alt" then the dotted line will appear.

Somehow, Windows seems not to show it if only using the mouse.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
MarcoBoschi
Posts: 925
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy
Contact:

Re: Difference between mouse and keyboard

Post by MarcoBoschi »

Antonio,
the solution is to simulate an "Alt" press?
Thanks
Marco Boschi
info@marcoboschi.it
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Difference between mouse and keyboard

Post by Antonio Linares »

Marco,

The problem is that we can not simulate an "Alt" key :(

We are trying many different ways, but no success. We just need a simple "Alt" simulation there...

Code: Select all

#include "Fivewin.ch"

#define WM_SYSCOMMAND   0x0112
#define SC_KEYMENU       61696

FUNCTION MAIN()

    LOCAL oDlg, oBtn
    LOCAL cVar := SPACE(10), oGet

    DEFINE DIALOG oDlg

    @ 1, 1 GET oGet VAR cVar

    @ 2, 1 BUTTON oBtn PROMPT "Button1"
    oBtn:bGotFocus = { || oBtn:PostMsg( WM_SYSCOMMAND, SC_KEYMENU ) }
    
    @ 3, 1 BUTTON "Button2"

    ACTIVATE DIALOG oDlg CENTER

    RETURN NIL
 

Code: Select all

#include "Fivewin.ch"

FUNCTION MAIN()

    LOCAL oDlg, oBtn
    LOCAL cVar := SPACE(10), oGet

    DEFINE DIALOG oDlg

    @ 1, 1 GET oGet VAR cVar

    @ 2, 1 BUTTON oBtn PROMPT "Button1"
    oBtn:bGotFocus = { || __KeyBoard( Chr( ... ) ) }
    
    @ 3, 1 BUTTON "Button2"

    ACTIVATE DIALOG oDlg CENTER

    RETURN NIL
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
Rossine
Posts: 343
Joined: Tue Oct 11, 2005 11:33 am

Re: Difference between mouse and keyboard

Post by Rossine »

Hi,

See if this works to you :

Code: Select all

#include "Fivewin.ch"

#define VK_LMENU  164
#define VK_A       65

FUNCTION MAIN()

    LOCAL oDlg

    LOCAL cVar := SPACE(10)

    CGETFILE( "*.*", "Select a file" )

    DEFINE DIALOG oDlg

    @ 1, 1 GET cVar

    @ 2, 1 BUTTON oBtn PROMPT "Button1"
    oBtn:bGotFocus = { || SetStateKey( VK_LMENU, .T. ), ;
                          SetStateKey( VK_A, .T. ), ;
                          SetStateKey( VK_LMENU, .F. ) }
   
    @ 3, 1 BUTTON "Button2"

    ACTIVATE DIALOG oDlg

RETURN NIL

#pragma begindump

#include <windows.h>
#include <hbapi.h>

HB_FUNC( SETSTATEKEY )
{
  if( hb_parl(2) )
      keybd_event( hb_parvnl(1), 0x45, KEYEVENTF_EXTENDEDKEY | 0, 0 );
  else
      keybd_event( hb_parvnl(1), 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
}

#pragma enddump

 
Obrigado, Regards, Saludos

Rossine.

xHarbour comercial (xAcc) -> Testando harbour + bcc / msvc
fwh 9.05
Windows XP SP2
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Difference between mouse and keyboard

Post by Antonio Linares »

Rossine,

Very good! :-)

many thanks!
regards, saludos

Antonio Linares
www.fivetechsoft.com
hua
Posts: 861
Joined: Fri Oct 28, 2005 2:27 am

Re: Difference between mouse and keyboard

Post by hua »

When compiled, I got an error message Unresolved external '_hb_parvnl'. What lib am I missing?
FWH 11.08/FWH 19.03
xHarbour 1.2.1 (Rev 6406) + BCC
Harbour 3.1 (Rev 17062) + BCC
Harbour 3.2.0dev (r1904111533) + BCC
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Difference between mouse and keyboard

Post by Antonio Linares »

Hua,

Please change hb_parvnl() with hb_parnl() calls
regards, saludos

Antonio Linares
www.fivetechsoft.com
hua
Posts: 861
Joined: Fri Oct 28, 2005 2:27 am

Re: Difference between mouse and keyboard

Post by hua »

Antonio Linares wrote:Please change hb_parvnl() with hb_parnl() calls
It worked. Thanks.
FWH 11.08/FWH 19.03
xHarbour 1.2.1 (Rev 6406) + BCC
Harbour 3.1 (Rev 17062) + BCC
Harbour 3.2.0dev (r1904111533) + BCC
User avatar
MarcoBoschi
Posts: 925
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy
Contact:

Re: Difference between mouse and keyboard

Post by MarcoBoschi »

Hello,
just now I read your answers.
Thanks a lot.
I've tried it but if I press return key in the field it does not work.
It works only if I press TAB button to exit get field.
Anyway, thanks a lot

marco
Marco Boschi
info@marcoboschi.it
Post Reply