MsgBox mit Hilfe-Button

  • Da ich bis vor 30 Minuten nicht wusste, dass es das gibt, hier ein kleines Beispiel für euch.
    Vllt kann das ja mal nützlich sein.

    Spoiler anzeigen
    [autoit]

    Global Const $MB_HELP = 0x4000
    Global $Toggle = False

    [/autoit] [autoit][/autoit] [autoit]

    $hGui = GUICreate("Application")
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    $hGuiHelp = GUICreate("Help-GUI", 200, 100, @DesktopWidth - 400, -1, 0)
    GUICtrlCreateLabel("Please press the OK button!", 10, 10)
    GUIRegisterMsg(0x0053, "_Help") ;WM_HELP

    [/autoit] [autoit][/autoit] [autoit]

    Sleep(1000)
    $ret = MsgBox($MB_HELP, "Hello","This is a test", 0, $hGui)
    GUISetState(@SW_HIDE, $hGuiHelp)
    Sleep(1000)

    [/autoit] [autoit][/autoit] [autoit]

    Func _Help($hWnd, $Msg, $wParam, $lParam)
    ConsoleWrite("Help button was pressed" & @cr)
    $Toggle = Not $Toggle
    If $Toggle Then
    GUISetState(@SW_SHOW, $hGuiHelp)
    Else
    GUISetState(@SW_HIDE, $hGuiHelp)
    EndIf
    EndFunc

    [/autoit]
  • Hab noch die passende Struktur dazu erstellt: $tagHELPINFO

    Spoiler anzeigen
    [autoit]

    Global Const $MB_HELP = 0x4000

    [/autoit] [autoit][/autoit] [autoit]

    ; #STRUCTURE# ===================================================================================================================
    ; Name...........: $tagHELPINFO
    ; Description ...: Contains information about an item for which context-sensitive Help has been requested
    ; Fields ........: Size - The structure size, in bytes
    ; ContextType - The type of context for which Help is requested. This member can be one of the following values:
    ; HELPINFO_WINDOW = 1: Help requested for a control or window.
    ; HELPINFO_MENUITEM = 2: Help requested for a menu item.
    ; CtrlID - The identifier of the window or control if ContextType is HELPINFO_WINDOW,
    ; or identifier of the menu item if ContextType is HELPINFO_MENUITEM
    ; ItemHandle - The identifier of the child window or control if ContextType is HELPINFO_WINDOW,
    ; or identifier of the associated menu if ContextType is HELPINFO_MENUITEM.
    ; ContextID - The help context identifier of the window or control.
    ; PointX - X position that of the mouse at the time the event occurred
    ; PointY - Y position that of the mouse at the time the event occurred
    ; Author ........: funkey
    ; Remarks .......:
    ; ===============================================================================================================================
    Global Const $tagHELPINFO = "uint Size;int ContextType;int CtrlID;handle ItemHandle;dword ContextID;int PointX;int PointY"

    [/autoit] [autoit][/autoit] [autoit]

    Global $Toggle = False

    [/autoit] [autoit][/autoit] [autoit]

    $hGui = GUICreate("Application")
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    $hGuiHelp = GUICreate("Help-GUI", 200, 100, -1, -1, 0x80880000, 0x00000080)
    GUICtrlCreateLabel("Please press the OK button!", 10, 10)
    GUIRegisterMsg(0x0053, "_Help") ;WM_HELP

    [/autoit] [autoit][/autoit] [autoit]

    Sleep(1000)
    $ret = MsgBox($MB_HELP, "Hello","This is a test", 0, $hGui)
    GUISetState(@SW_HIDE, $hGuiHelp)
    Sleep(1000)

    [/autoit] [autoit][/autoit] [autoit]

    Func _Help($hWnd, $Msg, $wParam, $lParam)
    Local $tInfo, $ContextType, $CtrlID, $ItemHandle, $ContextID, $X, $Y
    ; $hWnd is the parent window handle for this MsgBox

    Local $tInfo = DllStructCreate($tagHELPINFO, $lParam)
    $ContextType = DllStructGetData($tInfo, "ContextType")
    $CtrlID = DllStructGetData($tInfo, "CtrlID")
    $ItemHandle = HWnd(DllStructGetData($tInfo, "ItemHandle"))
    $ContextID = DllStructGetData($tInfo, "ContextID")
    $X = DllStructGetData($tInfo, "PointX")
    $Y = DllStructGetData($tInfo, "PointY")

    $Toggle = Not $Toggle
    If $Toggle Then
    WinMove($hGuiHelp, "", $X + 10, $Y + 10)
    GUISetState(@SW_SHOW, $hGuiHelp)
    Else
    GUISetState(@SW_HIDE, $hGuiHelp)
    EndIf
    EndFunc

    [/autoit]
  • Hi!


    Ich finde den Hilfe butten sehr Hilfreich weil viele Msg dazu genutzt werden fehler meldungen auszugeben oder auch ereignisse!
    Supper :D
    Ich bin dafür das der HilfeButton in der Hilfe aufgenommen wird ^^


    LG Kleiner