ON KEY F12 does not work in HMG 3.3.1

Moderator: Rathinagiri

trmpluym
Posts: 303
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands

ON KEY F12 does not work in HMG 3.3.1

Post by trmpluym »

F1 to F11 works just fine, CONTROL+F12 does work but F12 does not work

For example (see attachment)

ON KEY F12 OF Win_1 ACTION MsgDebug('TEST F12')
Attachments
F12_bug_test.zip
(1.29 MiB) Downloaded 288 times
tiampei
Posts: 12
Joined: Tue Jun 24, 2014 2:47 am

ON KEY F12 does not work in HMG 3.3.1

Post by tiampei »

May be not a bug in HMG.

I think MS Windows just not allow hotkey for F12.

http://msdn.microsoft.com/en-us/library ... s.85).aspx
The F12 key is reserved for use by the debugger at all times, so it should not be registered as a hot key. Even when you are not debugging an application, F12 is reserved in case a kernel-mode debugger or a just-in-time debugger is resident.
User avatar
tonton2
Posts: 455
Joined: Sat Jun 29, 2013 1:26 pm
Location: Algerie
Contact:

Re: ON KEY F12 does not work in HMG 3.3.1

Post by tonton2 »

trmpluym wrote:F1 to F11 works just fine, CONTROL+F12 does work but F12 does not work

For example (see attachment)

ON KEY F12 OF Win_1 ACTION MsgDebug('TEST F12')
Bonsoir,please don't send file in .exe
Thanks
L'Algerie vous salut
Y.TABET
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

ON KEY F12 does not work in HMG 3.3.1

Post by Pablo César »

URL tag was added and link re-composed to tiampei message.

Please next time, use URL tags for links.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
tiampei
Posts: 12
Joined: Tue Jun 24, 2014 2:47 am

Re: ON KEY F12 does not work in HMG 3.3.1

Post by tiampei »

Pablo César wrote:URL tag was added and link re-composed to tiampei message.

Please next time, use URL tags for links.
Oic, :oops:

Thank you for remind me and re-composed the post.
trmpluym
Posts: 303
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands

Re: ON KEY F12 does not work in HMG 3.3.1

Post by trmpluym »

Also a lot of other programs make use of the F12 key. For example Microsoft Word 2010 uses F12 (save as) . When it was a Windows limitation the F12 key also would not work in other programs.

I also use xHarbour. In xHarbour i can also use the F12 in my xBase 32 bits executables.
trmpluym
Posts: 303
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands

Re: ON KEY F12 does not work in HMG 3.3.1

Post by trmpluym »

A lot of other programs make use of the F12 key. For example Microsoft Word 2010 uses F12 (save as) . When it was a Windows limitation the F12 key also would not work in other programs.

I also use xHarbour. In xHarbour i can also use the F12 in my xBase 32 bits executables.
trmpluym
Posts: 303
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands

Re: ON KEY F12 does not work in HMG 3.3.1

Post by trmpluym »

A lot of other programs make use of the F12 key. For example Microsoft Word 2010 uses F12 (save as) . When it was a Windows limitation the F12 key also would not work in other programs.

I also use xHarbour. In xHarbour i can also use the F12 in my xBase 32 bits executables.

So why not HMG ?
tiampei
Posts: 12
Joined: Tue Jun 24, 2014 2:47 am

Re: ON KEY F12 does not work in HMG 3.3.1

Post by tiampei »

I have try using 3 compilers. HMG, FreeBasic and Dev-c, all not support for hotkey F12. Or I missing something :?:

Here I post the source I test in separated posts.

For HMG, I have bypass the standard function and direct into low API function to see the problem.

HMG code:

Code: Select all

#include "hmg.ch"

#pragma BEGINDUMP
#include <windows.h>

/*
HB_FUNC ( INITHOTKEY )
{
	RegisterHotKey(
	    (HWND) hb_parnl(1 )	, // window to receive hot-key notification
	    hb_parni(4)		, // identifier of hot key
	    hb_parni(2) ,	// key-modifier flags
	    hb_parni(3)		// virtual-key code
	   );
}

HB_FUNC ( RELEASEHOTKEY )
{
	UnregisterHotKey(
		(HWND) hb_parnl(1),	// window associated with hot key
		hb_parni(2)	// identifier of hot key
   );
}
*/

HB_FUNC ( REGISTERHOTKEY )
{
   int iRet =
   RegisterHotKey(
      (HWND) hb_parnl(1)	, // window to receive hot-key notification
      hb_parni(2)		, // identifier of hot key
      hb_parni(3) ,	// key-modifier flags
      hb_parni(4)		// virtual-key code
	   );
   hb_retl(iRet); // Return boolean
}

#pragma ENDDUMP

PROCEDURE Main
   Local hWnd, nID1, nID2, nID3

   DEFINE WINDOW Win_1 AT 157 , 162 WIDTH 550 HEIGHT 350 TITLE "Press F10 and F12 function keys to test" MAIN NOMAXIMIZE NOMINIMIZE
      // On Key F10 of Win_1 Action MsgInfo('Test F10')
      // ON KEY F11 OF Win_1 ACTION MsgInfo('TEST F11') 
      // ON KEY F12 OF Win_1 ACTION MsgInfo('TEST F12') 
   END WINDOW

   /* nID1 := _GetId()
   nID2 := _GetId()
   nID3 := _GetId() */
   nID1 := 320
   nID2 := 321
   nID3 := 322
   hWnd := GetFormHandle("Win_1")

   /*
   MsgInfo(hb_ValToStr(InitHotkey(hWnd, 0, VK_F10, nID1)))
   MsgInfo(hb_ValToStr(InitHotkey(hWnd, 0, VK_F11, nID2)))
   MsgInfo(hb_ValToStr(InitHotkey(hWnd, 0, VK_F12, nID3)))
   */

   MsgInfo("Register hotkey is: " + hb_ValToStr(RegisterHotkey(hWnd, nID1, 0, VK_F10)))
   MsgInfo("Register hotkey is: " + hb_ValToStr(RegisterHotkey(hWnd, nID2, 0, VK_F11)))
   MsgInfo("Register hotkey is: " + hb_ValToStr(RegisterHotkey(hWnd, nID3, 0, VK_F12)))

   InstallEventHandler("HotkeyProc")

   ACTIVATE WINDOW Win_1

   ReleaseHotkey(hWnd, nID1)
   ReleaseHotkey(hWnd, nID2)
   ReleaseHotkey(hWnd, nID3)
Return

Procedure HotkeyProc(hWnd, nMsg, wParam, lParam)
   Local nRet := Nil , WM_HOTKEY := 786

   If nMsg = WM_HOTKEY
      MsgInfo("Hotkey Is Press", "Catch hotkey")
      nRet := 1 // Return non Nil value
   EndIf
Return nRet
Attachments
TestHotkeyHMG.zip
(1.28 KiB) Downloaded 244 times
tiampei
Posts: 12
Joined: Tue Jun 24, 2014 2:47 am

Re: ON KEY F12 does not work in HMG 3.3.1

Post by tiampei »

FreeBasic sources

Code: Select all


#include once "windows.bi"

declare function WinMain ( byval hInstance as HINSTANCE, _
                           byval hPrevInstance as HINSTANCE, _
                           byval szCmdLine as string, _
                           byval iCmdShow as integer ) as integer

end WinMain( GetModuleHandle( null ), null, Command( ), SW_NORMAL )

'':::::
function WndProc ( byval hWnd as HWND, _
                   byval wMsg as UINT, _
                   byval wParam as WPARAM, _
                   byval lParam as LPARAM ) as LRESULT
    
    function = 0
    
    select case( wMsg )
    
      CASE WM_HOTKEY
         MessageBox( null, "Hotkey is press", "Hotkey!!!", MB_ICONINFORMATION )
    
        case WM_CREATE            
            exit function

        case WM_PAINT
    		dim rct as RECT
    		dim pnt as PAINTSTRUCT
    		dim hDC as HDC
          
            hDC = BeginPaint( hWnd, @pnt )
            GetClientRect( hWnd, @rct )
            
            DrawText( hDC, _
            		  "Hello, World!", _
            		  -1, _
                      @rct, _
                      DT_SINGLELINE or DT_CENTER or DT_VCENTER )
            
            EndPaint( hWnd, @pnt )
            
            exit function            
        
		case WM_KEYDOWN
			if( lobyte( wParam ) = 27 ) then
				PostMessage( hWnd, WM_CLOSE, 0, 0 )
			end if

    	case WM_DESTROY
            PostQuitMessage( 0 )
            exit function
    end select
    
    function = DefWindowProc( hWnd, wMsg, wParam, lParam )    
    
end function

'':::::
function WinMain ( byval hInstance as HINSTANCE, _
                   byval hPrevInstance as HINSTANCE, _
                   byval szCmdLine as string, _
                   byval iCmdShow as integer ) as integer    
     
    dim wMsg as MSG
    dim wcls as WNDCLASS     
    dim hWnd as HWND
    
   Dim nID1 As Integer
   Dim nID2 As Integer
   Dim nID3 As Integer

   'Dim iRet As Long

   nID1 = 33000
   nID2 = 33001
   nID3 = 33002

    function = 0
     
    with wcls
    	.style         = CS_HREDRAW or CS_VREDRAW
    	.lpfnWndProc   = @WndProc
    	.cbClsExtra    = 0
    	.cbWndExtra    = 0
    	.hInstance     = hInstance
    	.hIcon         = LoadIcon( NULL, IDI_APPLICATION )
    	.hCursor       = LoadCursor( NULL, IDC_ARROW )
    	.hbrBackground = GetStockObject( WHITE_BRUSH )
    	.lpszMenuName  = NULL
    	.lpszClassName = @"HelloWin"
    end with
          
    if( RegisterClass( @wcls ) = FALSE ) then
       MessageBox( null, "Failed to register wcls", "Error", MB_ICONERROR )
       exit function
    end if
    
    hWnd = CreateWindowEx( 0, _
    			 		   @"HelloWin", _
                           "Press F10 to F12 to the hotkey", _
                           WS_OVERLAPPEDWINDOW, _
                           CW_USEDEFAULT, _
                           CW_USEDEFAULT, _
                           CW_USEDEFAULT, _
                           CW_USEDEFAULT, _
                           NULL, _
                           NULL, _
                           hInstance, _
                           NULL )

   'iRet = RegisterHotKey(hWnd, nID1, 0, VK_F10)
   'If iRet = 0 Then
   If RegisterHotKey(hWnd, nID1, 0, VK_F10) = 0 Then
      MessageBox(null, "RegisterHotKey F10 fail!!", "Fail", MB_ICONERROR)
   End If

   'iRet = RegisterHotKey(hWnd, nID2, 0, VK_F11)
   'If iRet = 0 Then
   If RegisterHotKey(hWnd, nID2, 0, VK_F11) = 0 Then
      MessageBox(null, "RegisterHotKey F11 fail!!", "Fail", MB_ICONERROR)
   End If

   'iRet = RegisterHotKey(hWnd, nID3, 0, VK_F12)
   'If iRet = 0 Then
   If RegisterHotKey(hWnd, nID3, 0, VK_F12) = 0 Then
      MessageBox(null, "RegisterHotKey F12 fail!!", "Fail", MB_ICONERROR)
   End If

    ShowWindow( hWnd, iCmdShow )
    UpdateWindow( hWnd )
     
    while( GetMessage( @wMsg, NULL, 0, 0 ) <> FALSE )    
        TranslateMessage( @wMsg )
        DispatchMessage( @wMsg )
    wend
    
UnregisterHotKey(hWnd, nID1)
UnregisterHotKey(hWnd, nID2)
UnregisterHotKey(hWnd, nID3)

    function = wMsg.wParam

end function
Attachments
TestHotkeyFB.zip
(8.86 KiB) Downloaded 220 times
Post Reply