Hi,
want to switch in insert mode with
- KeyToggle( VK_INSERT ) or
- Eval( oWnd:bAction ) or
- Mouse click in the message bar on 'Ins'
but it's not working
In addition the NUMLOCK- and CAPSLOCK-LED's on the keyboard don't react, if the Buttons 'Num' or 'Caps' are mouse clicked in the message bar
With the informations out of these two threads:
viewtopic.php?f=6&t=2551
viewtopic.php?f=3&t=1577
I changed the method 'KeybOn()' in msgbar.prg as follows:
- Replaced 'KeyToggle( VK_NUMLOCK )' with 'SetNumLock( !GetNumLock() )' in ::oKeyNum
- Replaced 'KeyToggle( VK_CAPITAL )' with 'SetCapsLock( !GetCapsLock() )' in ::oKeyCaps
- Added ', Set( _SET_INSERT, ! Set( _SET_INSERT ) )' in ::oKeyIns
Here is the complete method and the C functions:
Now I can set the insert mode by mouse click or with:
And the NUMLOCK- and CAPSLOCK-LED's on the keyboard are consistent with the FiveWin settings
want to switch in insert mode with
- KeyToggle( VK_INSERT ) or
- Eval( oWnd:bAction ) or
- Mouse click in the message bar on 'Ins'
but it's not working
In addition the NUMLOCK- and CAPSLOCK-LED's on the keyboard don't react, if the Buttons 'Num' or 'Caps' are mouse clicked in the message bar
With the informations out of these two threads:
viewtopic.php?f=6&t=2551
viewtopic.php?f=3&t=1577
I changed the method 'KeybOn()' in msgbar.prg as follows:
- Replaced 'KeyToggle( VK_NUMLOCK )' with 'SetNumLock( !GetNumLock() )' in ::oKeyNum
- Replaced 'KeyToggle( VK_CAPITAL )' with 'SetCapsLock( !GetCapsLock() )' in ::oKeyCaps
- Added ', Set( _SET_INSERT, ! Set( _SET_INSERT ) )' in ::oKeyIns
Here is the complete method and the C functions:
METHOD KeybOn() CLASS TMsgBar
if ::oKeyNum == nil
// keep the ':=' below for XBase++ compatibility
::oKeyNum := TMsgItem():New( Self, "Num", ::GetWidth( "Num" ) + 12,,,, .t.,;
{ || SetNumLock( !GetNumLock() ), ::oKeyNum:Refresh() } )
::oKeyNum:lTimer = .t.
::oKeyNum:nClrDisabled = GetSysColor( COLOR_BTNSHADOW )
::oKeyNum:lActive = GetKeyToggle( VK_NUMLOCK )
::oKeyNum:bMsg = { || ::oKeyNum:lActive := GetKeyToggle( VK_NUMLOCK ), "Num" }
endif
if ::oKeyCaps == nil
// keep the ':=' below for XBase++ compatibility
::oKeyCaps := TMsgItem():New( Self, "Caps", ::GetWidth( "Caps" ) + 12,,,, .t.,;
{ || SetCapsLock( !GetCapsLock() ), ::oKeyCaps:Refresh() } )
::oKeyCaps:lTimer = .t.
::oKeyCaps:nClrDisabled = GetSysColor( COLOR_BTNSHADOW )
::oKeyCaps:lActive = GetKeyToggle( VK_CAPITAL )
::oKeyCaps:bMsg = { || ::oKeyCaps:lActive := GetKeyToggle( VK_CAPITAL ), "Caps" }
endif
if ::oKeyIns == nil
// keep the ':=' below for XBase++ compatibility
::oKeyIns := TMsgItem():New( Self, "Ins", ::GetWidth( "Ins" ) + 12,,,, .t.,;
{ || KeyToggle( VK_INSERT ), Set( _SET_INSERT, ! Set( _SET_INSERT ) ), ::oKeyIns:Refresh() } )
::oKeyIns:lTimer = .t.
::oKeyIns:nClrDisabled = GetSysColor( COLOR_BTNSHADOW )
::oKeyIns:lActive = GetKeyToggle( VK_INSERT )
::oKeyIns:bMsg = { || ::oKeyIns:lActive := GetKeyToggle( VK_INSERT ), "Ins" }
endif
::CheckTimer()
return nil
#pragma BEGINDUMP
#include <windows.h>
#include "hbapi.h"
#define TOGGLED 0x0001
void SetKeyLock( BYTE vKey, BOOL bState )
{
BOOL bCurrentState;
bCurrentState = ( GetKeyState( vKey ) & TOGGLED );
if( (bState && !bCurrentState) ||
(!bState && bCurrentState) )
{
// Simulate a key press
keybd_event( vKey,
0,
KEYEVENTF_EXTENDEDKEY | 0,
0 );
// Simulate a key release
keybd_event( vKey,
0,
KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,
0);
}
}
BOOL GetKeyLock( int vKey )
{
return ( GetKeyState( vKey ) & TOGGLED );
}
HB_FUNC( SETCAPSLOCK )
{
SetKeyLock( VK_CAPITAL, hb_parl( 1 ) );
}
HB_FUNC( SETNUMLOCK )
{
SetKeyLock( VK_NUMLOCK, hb_parl( 1 ) );
}
HB_FUNC( SETINSLOCK )
{
SetKeyLock( VK_INSERT, hb_parl( 1 ) );
}
HB_FUNC( GETCAPSLOCK )
{
hb_retl( GetKeyLock( VK_CAPITAL ) );
}
#pragma ENDDUMPNow I can set the insert mode by mouse click or with:
...
KeyToggle( VK_INSERT )
Set( _SET_INSERT, .T. )
...And the NUMLOCK- and CAPSLOCK-LED's on the keyboard are consistent with the FiveWin settings
Windows 11 Pro 22H2 22621.1848
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86