MohanRatnam Posted February 27, 2015 Posted February 27, 2015 Hello Everyone, I'm new to Autoit. I found some code to create a window with two rich edit boxes inside. I would like the richeditboxes to have contextmenus. So far I have managed to get the GUI to show with the two edit boxes but I am unable to get the contextmenus for the editboxes to show. Could someone please show me where I am going wrong. Here's the code so far. Many thanks expandcollapse popup#include <DateTimeConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiRichEdit.au3> #Include <GuiScrollBars.au3> #include <WinAPI.au3> #include <GuiMenu.au3> #include <Array.au3> Global Enum $idSeparator, $idDate Global $hGUI, $hMenu, $aCM_Edits[2][7]= [[ 0, 0, 10, 10, 280, 150, 0], _ [ 0, 0, 10, 180, 280, 150, 0]] Global $wProcHandle = DllCallbackRegister("_WindowProc", "ptr", "hwnd;uint;wparam;lparam") $hGUI = GUICreate("_SetEditContextMenu", 300, 350) For $x = 0 To UBound($aCM_Edits)-1;B1 $aCM_Edits[$x][0] = _GUICtrlRichEdit_Create($hGUI, "", $aCM_Edits[$x][2], $aCM_Edits[$x][3], $aCM_Edits[$x][4], $aCM_Edits[$x][5], BitOR($ES_WANTRETURN, $ES_MULTILINE, $WS_VSCROLL, 8192)) GUICtrlSetState(-1, $GUI_DROPACCEPTED) _GUIScrollBars_ShowScrollBar($aCM_Edits[$x][0], $SB_VERT, True) $aCM_Edits[$x][6] = GUICtrlGetHandle($aCM_Edits[$x][0]) Local $wProcOld = _WinAPI_SetWindowLong($aCM_Edits[$x][0], $GWL_WNDPROC, DllCallbackGetPtr($wProcHandle)) $aCM_Edits[$x][1] = $wProcOld Next;E1 $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_AddMenuItem($hMenu, "Separator", $idSeparator) _GUICtrlMenu_AddMenuItem($hMenu, "Date", $idDate) For $x = 1 to UBound($aCM_Edits) -1;B2 ControlShow($hGUI, "", $aCM_Edits[$x][0]) Next;E2 GUISetState() While 1;B3 $msg = GUIGetMsg() Switch $msg;B4 Case $GUI_EVENT_CLOSE ExitLoop EndSwitch;E4 WEnd;E3 GUIDelete($hGui) DllCallbackFree($wProcHandle) ;************************************************************************************************** Func _WindowProc($hWnd, $nMsg, $wParam, $lParam) Local $wProcOld, $aRet For $i = 0 To UBound($aCM_Edits)-1;B1 If $hWnd = $aCM_Edits[$i][0] Then;B2 Switch $nMsg;B3 Case $WM_CONTEXTMENU _GUICtrlMenu_TrackPopupMenu($hMenu, $wParam) Return 0 Case $WM_COMMAND Switch $wParam;B4 Case $idSeparatort _GUICtrlRichEdit_InsertText($hWnd, @CRLF & "--------------------------------------------------------------------------------") Case $idDate _GUICtrlRichEdit_InsertText($hWnd, " " & @YEAR &"/"& @MON &"/"& @MDAY) EndSwitch;E4 EndSwitch;E3 $wProcOld = $aCM_Edits[$i][1] ExitLoop EndIf;E2 Next;E1 If $wProcOld Then;B5 $aRet = DllCall("user32.dll", "int", "CallWindowProc", "ptr", $wProcOld, _ "hwnd", $hWnd, "uint", $nMsg, "wparam", $wParam, "lparam", $lParam) Return $aRet[0] EndIf;E5 EndFunc
orbs Posted February 27, 2015 Posted February 27, 2015 perhaps this will be useful: '?do=embed' frameborder='0' data-embedContent>> Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now