Jump to content

Adding context menu on edit control (RESOLVED)


Recommended Posts

  • 3 weeks later...

So, I tried to make it. You have to create Array and set the Window Proc for each Input:

CODE
#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, $idSave, $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, "Save", $idSave)

_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 $idSave

ConsoleWrite("-> Save" & @LF)

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

*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

Link to comment
Share on other sites

I tried and deleted all , but it didn't crash. Yes, you can't create new ones, but thats because of the creating and deletion logic :) Also, the GUIs of the Edits arent deleted.

But a crash didn't occur.

*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

I don't think this will be of much use but when I did a beta run after it crashed here's all that was there:

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /beta /ErrorStdOut /in "*\*" /autoit3dir "C:\Program Files\AutoIt3\beta" /UserParams   
+>14:55:24 Starting AutoIt3Wrapper v.1.9.2
>Running AU3Check (1.54.13.0)  from:C:\Program Files\AutoIt3\beta
+>14:55:24 AU3Check ended.rc:0
>Running:(3.2.11.5):C:\Program Files\AutoIt3\beta\autoit3.exe "*"   
-> Save
-> Save
!>14:56:08 AutoIT3.exe ended.rc:-1073741819
+>14:56:09 AutoIt3Wrapper Finished
>Exit code: -1073741819 Time: 45.539
Link to comment
Share on other sites

Hello,

It appears you have found your answer to your question.

Please take the time to edit your thread title with [RESOLVED] so others know that is it resolved.

You can do this by scrolling to the top of your thread, clicking EDIT and then Full Edit and adding: "[RESOLVED]"

to the front of your thread title.

Thanks for your cooperation.

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...