Jump to content
Sign in to follow this  
Hypertrophy

getting handle of window code included

Recommended Posts

Hypertrophy

hi i have many little child window on main window. then on the child windows i have a context menu with options. when i click for example set tooltip on one of the windows context menus in theory, how can i get the handle of the window that i just clicked its context menu so i can set a tooltip on it?

dont have any code but i am preparing to start but need an answer.

Share this post


Link to post
Share on other sites
SmOke_N

hi i have many little child window on main window. then on the child windows i have a context menu with options. when i click for example set tooltip on one of the windows context menus in theory, how can i get the handle of the window that i just clicked its context menu so i can set a tooltip on it?

dont have any code but i am preparing to start but need an answer.

No idea on earth what you're really asking. But if you just clicked on the window, then it's active... so WinGetHandle("") or WinGetHandle("[ACTIVE]") would give it to you.

If by child window you mean controls, then the API calls for WindowFromPoint and or ChildWindowFromPoint could help you as well.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Hypertrophy

lets say i have 3 child window on a big one. if i were right click on first child window and select "set tooltip" in context menu, at that point how would i know which of the child windows to set tooltip on?

Edited by coder09

Share this post


Link to post
Share on other sites
SmOke_N

lets say i have 3 child window on a big one. if i were right click on first child window and select "set tooltip" in context menu, at that point how would i know which of the child windows to set tooltip on?

You need to stop here. Write some code, then post the code. And explain in detail what you need or want. This forum isn't for making other guess on how the hell to help you.

Edit:

This topic has been closed until you produce code demonstrating the issue you are having. If you create another topic on the issue without said code, you will not be a part of this forum any longer.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Hypertrophy

hi code is here with question. i place comment on line 93 meaning i need help how to put code there so it will set tooltip on exact edit that was clicked to set tooltip on.

#include <GuiConstantsEx.au3>
#include <GuiEdit.au3>
#include <WindowsConstants.au3>
#include <GUIMenu.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <EditConstants.au3>
#include <WinAPI.au3>

Dim $hInput_GUI[6], $Input[6], $wProcsOld[6], $InputMenu[6]

Global $lastdragIP = -1
Global Enum $idOpen = 1000, $idSetTooltip, $idInfo

$GUI = GUICreate("Test", 300, 300)

$button5 = GUICtrlCreateButton("", 100, 200, 40, 25)
GUICtrlSetState(-1, $GUI_DEFBUTTON)

GUISetState()

$wProcHandle = DllCallbackRegister("_WindowProc", "ptr", "hwnd;uint;wparam;lparam")


While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $button5
            If $lastdragIP < 5 Then
                $lastdragIP += 1
                createNextdragIP($lastdragIP)
            EndIf
        Case $msg = $GUI_EVENT_PRIMARYDOWN
            $aMouse_Pos = MouseGetPos()
            $sel = -1

        For $n = 0 To $lastdragIP
            GUISwitch($hInput_GUI[$n])
            $aCursorInfo = GUIGetCursorInfo()

            If Not IsArray($aCursorInfo) Then ContinueLoop
            If $aCursorInfo[4] = $Input[$n] Then
                $sel = $n
                ExitLoop
            EndIf
        Next

        If $sel = -1 Then ContinueLoop
        $aInputGUI_Pos = WinGetPos($hInput_GUI[$sel])

        While IsArray($aCursorInfo) And $aCursorInfo[2] = 1
            $aCursorInfo = GUIGetCursorInfo()
            $aCurrent_Mouse_Pos = MouseGetPos()

            WinMove($hInput_GUI[$sel], "", _
            $aInputGUI_Pos[0] - $aMouse_Pos[0] + $aCurrent_Mouse_Pos[0], _
            $aInputGUI_Pos[1] - $aMouse_Pos[1] + $aCurrent_Mouse_Pos[1])
        WEnd
    EndSelect
WEnd

Func createNextdragIP($nw)
$start = WinGetPos($GUI)
$hInput_GUI[$nw] = GUICreate("", 120, 22, $start[0]+30, $start[1]+200, $WS_POPUP, $WS_EX_TOOLWINDOW)
$Input[$nw] = GUICtrlCreateEdit("", 0, 0, 120, 22, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN))


$hMenu = _GUICtrlMenu_CreatePopup()
$InputMenu[$nw] = $hMenu
_GUICtrlMenu_AddMenuItem($hMenu, "Delete", $idOpen)
_GUICtrlMenu_AddMenuItem($hMenu, "Set tooltip", $idSetTooltip)
_GUICtrlMenu_AddMenuItem($hMenu, "Info", $idInfo)
$wProcsOld[$nw] = _WinAPI_SetWindowLong(GUICtrlGetHandle($Input[$nw]), $GWL_WNDPROC, DllCallbackGetPtr($wProcHandle))
GUISetState()
WinSetOnTop($hInput_GUI[$nw], "", 1)
EndFunc ;==>createNextdragIP

Func _WindowProc($hWnd, $Msg, $wParam, $lParam)
    Local $wProcOld
    For $i = 0 To UBound($Input)-1
        If GUICtrlGetHandle($Input[$i]) = $hWnd Then
            Switch $Msg
                Case $WM_CONTEXTMENU
                    _GUICtrlMenu_TrackPopupMenu($InputMenu[$i], $wParam)
                    Return 0
                Case $WM_COMMAND
                    Switch $wParam
                        Case $idOpen
                            GUICtrlDelete($Input[$i])
                        Case $idSetTooltip
                            ; this is where i need help on how to set a tooltip on edit window
                        Case $idInfo
                            ConsoleWrite("-> Info" & @LF)
                    EndSwitch
            EndSwitch
            $wProcOld = $wProcsOld[$i]
            ExitLoop
        EndIf
    Next

    Local $aRet = DllCall("user32.dll", "int", "CallWindowProc", "ptr", $wProcOld, _
    "hwnd", $hWnd, "uint", $Msg, "wparam", $wParam, "lparam", $lParam)
    Return $aRet[0]
EndFunc

Share this post


Link to post
Share on other sites
SmOke_N

http://www.autoitscript.com/forum/index.ph...st&p=590283

I don't suggest you continue pushing the fence post, you'll undoubtedly trip over and hurt yourself.

I told you to produce code you've attempted to try at.

Do a forum search for ToolTip in the Titles section, preferably in the examples forum.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×