Jump to content

Recommended Posts

Posted (edited)

; #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"

Global Const $MB_HELP = 0x4000

Opt("GUIOnEventMode", 1)

Global $Toggle = False

#Region Help GUI
Global $hGuiHelp = GUICreate("Help-GUI", 220, 100, -1, -1, 0x80880000, 0x00000088)
GUISetBkColor(0xFFFFE1) ;tooltip color
GUICtrlCreateLabel("Help for abort button", 10, 10)
GUICtrlCreateLabel("Help for retry button", 10, 30)
GUICtrlCreateLabel("Help for ignore button", 10, 50)
#EndRegion Help GUI

Global $hGui = GUICreate("Main Application")
GUISetOnEvent(-3, "_Exit")
GUIRegisterMsg(0x0053, "_Help") ;WM_HELP

Global $Button = GUICtrlCreateButton("Show MsgBox", 50, 50)
GUICtrlSetOnEvent(-1, "_Show_MsgBox")

GUISetState()

While 1
 Sleep(20000)
WEnd

Func _Help($hWnd, $Msg, $wParam, $lParam)
 Local $tInfo, $ContextType, $CtrlID, $ItemHandle, $ContextID, $X, $Y
 
 $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")
 
 ConsoleWrite("ContextType: " & $ContextType & @CR)
 ConsoleWrite("CtrlID:  " & $CtrlID & @CR)
 ConsoleWrite("ItemHandle: " & $ItemHandle & @CR)
 ConsoleWrite("ContextID: " & $ContextID & @CR)
 ConsoleWrite("PointX:  " & $X & @CR)
 ConsoleWrite("PointY:  " & $Y & @CR & @CR)

 Local $aPos = ControlGetPos($ItemHandle, "", $CtrlID)
 
 $Toggle = Not $Toggle
 If $Toggle Then
  _ClientToScreen($ItemHandle, $aPos[0], $aPos[1])
  WinMove($hGuiHelp, "", $aPos[0], $aPos[1] + $aPos[3])
  GUISetState(@SW_SHOW, $hGuiHelp)
  Switch StringRight(@OSLang, 2)
   Case "07" ;german
    ControlSetText($ItemHandle, "", $CtrlID, "Schließe Hilfe")
   Case "09" ;english
    ControlSetText($ItemHandle, "", $CtrlID, "Close Help")   
  EndSwitch
 Else
  GUISetState(@SW_HIDE, $hGuiHelp)
  Switch StringRight(@OSLang, 2)
   Case "07" ;german
    ControlSetText($ItemHandle, "", $CtrlID, "Hilfe")
   Case "09" ;english
    ControlSetText($ItemHandle, "", $CtrlID, "Help")   
  EndSwitch
 EndIf 
EndFunc

Func _Show_MsgBox()
 Local $ret = MsgBox($MB_HELP + 2 + 48, "Hello","What do you want to do?", 0, $hGui)
 ConsoleWrite($ret & @cr)
 GUISetState(@SW_HIDE, $hGuiHelp)
 $Toggle = False
EndFunc

; Convert the client (GUI) coordinates to screen (desktop) coordinates
Func _ClientToScreen($hWnd, ByRef $x, ByRef $y)
    Local $stPoint = DllStructCreate("int;int")
    
    DllStructSetData($stPoint, 1, $x)
    DllStructSetData($stPoint, 2, $y)

    DllCall("user32.dll", "int", "ClientToScreen", "hwnd", $hWnd, "ptr", DllStructGetPtr($stPoint))
    
    $x = DllStructGetData($stPoint, 1)
    $y = DllStructGetData($stPoint, 2)
    ; release Struct not really needed as it is a local
    $stPoint = 0
EndFunc   ;==>_ClientToScreen

Func _Exit()
 Exit
EndFunc

I hope someone can need this.

Edited by funkey

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Posted

Very nice. I didn't even know Help was available in MessageBoxes

My contributions:

  Reveal hidden contents

Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFsProcess CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen)Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery

Wrappers/Modifications of others' contributions:

_DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity)

UDF's added support/programming to:

_ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne)

(All personal code/wrappers centrally located at Ascend4nt's AutoIT Code)

Posted

  On 8/26/2010 at 7:19 AM, 'wakillon said:

Can be usefull but GUICtrlSetTip can give help and is more simple to use Posted Image

But you can not use GUICtrlSetTip for MsgBox.

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Posted

  On 8/26/2010 at 8:22 AM, 'funkey said:

But you can not use GUICtrlSetTip for MsgBox.

Yes, you are right, but in this case your msgbox is based on a gui ! Posted Image

And your strange avatar gives me a headache ! Posted Image

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

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
  • Recently Browsing   0 members

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