Jump to content

Make on event help button


FireFox
 Share

Recommended Posts

Hi,

Ive made gui with help button |?| and Ive looked In GUIConstantsEx and found nothing about make it on event...

Ive searched in forum but I always found words split like "help" and after "button" ...

Thanks for anyhelp.

Cheers, FireFox.

Link to comment
Share on other sites

You need WM_HELP (no good example, but the concept should be clear:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StructureConstants.au3>
Global Const $tagHELPINFO = _
    "UINT cbSize;" & _
    "int iContextType;" & _
    "int iCtrlId;" & _
    "HWND hItemHandle;" & _
    "DWORD dwContextId;" & _
    "int MousePos[2];"

Opt('MustDeclareVars', 1)

Example1()

; example 1
Func Example1()
    Local $msg

    GUICreate("My GUI",400,400,-1,-1,0x00C00000+0x00080000,$WS_EX_CONTEXTHELP) ; will create a dialog box that when displayed is centered
    GUISetState(@SW_SHOW) ; will display an empty dialog box
    GUISetHelp("C:\Programme\AutoIt3\AutoIt3Help.exe")
    GUICtrlCreateButton("jkjk",10,10)
    Local $dwContextHelpId = 1234
    DllCall("user32.dll","int","SetWindowContextHelpId","hWnd",GUICtrlGetHandle(-1),"dword",$dwContextHelpId)
    GUIRegisterMsg($WM_HELP,"WM_HELP")
    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()

        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    GUIDelete()
EndFunc   ;==>Example1

Func WM_HELP($hWnd,$uMsg,$wParm,$lParam)
    Local $HELPINFO = DllStructCreate($tagHELPINFO,$lParam)
    ConsoleWrite("----------------------------" & @CRLF)
    ConsoleWrite(DllStructGetData($HELPINFO,"iContextType") & @CRLF)
    ConsoleWrite(DllStructGetData($HELPINFO,"dwContextId") & @CRLF)
EndFunc

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

@ProgAndy

Thanks but after I click on help button I have to click on anycontrol to have my function...

What I want is like when I click on help button I have my function on event without click anywhere...

Example :

GuiSetOnEvent($GUI_EVENT_HELP, "_Help")

Thanks for anyhelp.

Cheers, FireFox.

Link to comment
Share on other sites

@ProgAndy

Thanks but after I click on help button I have to click on anycontrol to have my function...

What I want is like when I click on help button I have my function on event without click anywhere...

Example :

GuiSetOnEvent($GUI_EVENT_HELP, "_Help")

Thanks for anyhelp.

Cheers, FireFox.

@FireFox

ProgAndy's example is for the proper context sensitive help usage of that button.

you need to block the mouse capture of that mode and call your own function using WM_SYSCOMMAND message.

if you want to use this button you lose the minimize maximize buttons.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StructureConstants.au3>

Global Const $SC_CONTEXTHELP = 0xF180

Opt('MustDeclareVars', 1)
Opt("GUIOnEventMode", 1)

Global $SysMenuDummy
Example1()

; example 1
Func Example1()
    Local $msg
    GUICreate("My GUI", 400, 400, -1, -1, BitOR($WS_CAPTION, $WS_SYSMENU), $WS_EX_CONTEXTHELP);$WS_EX_CONTEXTHELP Cannot be used with the WS_MAXIMIZEBOX or WS_MINIMIZEBOX
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Events")
    $SysMenuDummy = GUICtrlCreateDummy()
    GUICtrlSetOnEvent(-1, "_Events")
    GUISetState(@SW_SHOW)
    GUIRegisterMsg($WM_SYSCOMMAND, "_WM_SYSCOMMAND")

    While 1
        Sleep(1000)
        $msg = GUIGetMsg()
    WEnd
    
EndFunc  ;==>Example1

Func _Events()
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            GUIDelete()
            Exit
        Case $SysMenuDummy
            MsgBox(262144, "Help", "Yes?, How can I help you?")
    EndSwitch
EndFunc  ;==>_Events

Func _WM_SYSCOMMAND($hWnd, $msg, $wParam, $lParam)
    #forceref $hWnd, $Msg, $wParam, $lParam
    $wParam = Number($wParam)
    If $wParam = $SC_CONTEXTHELP Then
        GUICtrlSendToDummy($SysMenuDummy, $wParam)
        Return ""
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc  ;==>_WM_SYSCOMMAND

I see fascists...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...