Mat Posted March 27, 2009 Posted March 27, 2009 (edited) I've looked up and down the forum couse I'm sure someone must have tried to do this before... There are 2 parts to my question, both on the GUI below. The firsrt is concerning tooltips. how can I have a tooltip appearing over a GUI with no other control there i.e. blank space? I've tried the simple thing - using the GUI control Id for GUICtrlsettip, and other stuff such as -1, 0 and 1 no result. Part 2 is whether I can have the SAME context menu refferring to 2 different controls / a control and blank space? I've tried and + +=, none of which work. I'be also tried doing: $GUI_Context = GUICtrlCreateContextMenu ($Label) $GUI_Context = GUICtrlCreateContextMenu (-1) GUICtrlCreateMenuItem ("Label Or GUI", $GUI_Context) But that doesn't work either. My final GUI will have considerably longer Context menus, so If possible I'd prefer to have 2 controls pointing to 1 context menu. Oh and... They should have different tips too, if that complicates things at all. Yes, I am well aware copy and paste is a great function and that It works, but that's my back up plan if I don't get any answers now. My GUI, showing space label and button. #include <guiconstantsex.au3> $GUI = GUICreate ("Context Menu Test", 340, 120) GUISetState () $Label = GUICtrlCreateLabel ("lol, This needs to have the same context menu, but not the same tooltip as the blank GUI space on the left!" & @CRLF & "<==========", 120, 10, 100, 100) $Button = GUICtrlCreateButton ("Button, needs to have a completely seperate context menu to both of the things on the left!", 230, 10, 100, 100) GUICtrlSetTip ($GUI, "GUI"); seperate to below!!!! GUICtrlSetTip ($Label, "Label") GUICtrlSetTip ($Button, "Button") $GUI_Context = GUICtrlCreateContextMenu (-1 and $Label); doesn't work, but an idea of what I want to do. GUICtrlCreateMenuItem ("Label Or GUI", $GUI_Context) $Button_Context = GUICtrlCreateContextMenu ($Button) GUICtrlCreateMenuItem ("Button", $Button_Context) While 1 $msg = GuiGetMsg() Select Case $Msg = $GUI_EVENT_CLOSE Exit EndSelect Wend Thanks MDiesel edit: whats happening to the subtitle thing? i've edited it to try and say "space". at the end, but I get "Space&# edit2: should probably be in GUI forum instead... Edited March 27, 2009 by mdiesel AutoIt Project Listing
TerarinK Posted March 27, 2009 Posted March 27, 2009 You should try to create a dummy outlining the whole thing or if you want to the box 100,100 in this example, that will simulate the click of a blank screen. ;#include <GuiConstantsEx.au3> Global Const $GUI_EVENT_CLOSE = -3 $hGUI = GUICreate("Context Menu Test", 340, 120) GUISetState() $vDummy = GUICtrlCreateLabel("", 10 , 10, 100, 100) GUICtrlSetTip(-1, "Gui") $vLabel = GUICtrlCreateLabel("lol, This needs to have the same context menu, but not the same tooltip as the blank GUI space on the left!" & @CRLF & "<==========", 120, 10, 100, 100) GUICtrlSetTip(-1, "Label") $vButton = GUICtrlCreateButton("Button", 230, 10, 100, 100) GUICtrlSetTip(-1, "Button") $vGUI_Context = GUICtrlCreateContextMenu($vDummy) GUICtrlCreateMenuItem("GUI", $vGUI_Context) $vLabel_Context = GUICtrlCreateContextMenu($vLabel) GUICtrlCreateMenuItem("Label", $vLabel_Context) $vButton_Context = GUICtrlCreateContextMenu($vButton) GUICtrlCreateMenuItem("Button", $vButton_Context) While 1 $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE Exit EndSelect WEnd I did a few changes as the first change will be comment out the #include and just add the GUI_EVENT_CLOSE button saves the total size of the application. Secondly I add GUICtrlCreateLabel as dummy wouldn't work because it doesn't have a set size I could go off of unless you remotely change it, also note that I left it blank as you don't want anything showing. Then I added the context_menu to it and you have the finished product If you want the whole thing, you will have to go into a functions, user defined they will offer you more control of you GUI_ functions. 0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E
TerarinK Posted March 28, 2009 Posted March 28, 2009 (edited) #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("Context Menu Test", 340, 120) ;$aiCoord = WinGetClientSize($hGUI) ;$vDummy = GUICtrlCreateLabel("", 0, 0, $aiCoord[0], $aiCoord[1]) ;GUICtrlSetTip(-1, "Gui") $vLabel = GUICtrlCreateLabel("lol, This needs to have the same context menu, but not the same tooltip as the blank GUI space on the left!" & @CRLF & "<==========", 120, 10, 100, 100) GUICtrlSetTip(-1, "Label") $vButton = GUICtrlCreateButton("Button", 230, 10, 100, 100) GUICtrlSetTip(-1, "Button") $vGUI_Context = GUICtrlCreateContextMenu(-1) GUICtrlCreateMenuItem("GUI", $vGUI_Context) GUISetStyle(BitOr($WS_OVERLAPPEDWINDOW, $WS_EX_LAYERED)) $vLabel_Context = GUICtrlCreateContextMenu($vLabel) GUICtrlCreateMenuItem("Label", $vLabel_Context) $vButton_Context = GUICtrlCreateContextMenu($vButton) GUICtrlCreateMenuItem("Button", $vButton_Context) GUISetState() While 1 $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE Exit EndSelect WEnd This is as close as I can figure it. still can't get the ToolTip to work on the GUICreate, thinking you'll have to open a DLL call on this one, I read up on "Controls behind Controls" but that didn't work regardless you whatever I tried. I'm surprised no one here has come up with a block to call zOrdering into play Edited March 28, 2009 by TerarinK 0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E
Mat Posted March 28, 2009 Author Posted March 28, 2009 wow, thats the last thing I was expecting! another reply. thanks for the free bump! still no clue as how to have the 2 controls using the same context menu though. looks like it's going to be making the 2 different contexts then Thanks TerarinK AutoIt Project Listing
ResNullius Posted March 28, 2009 Posted March 28, 2009 wow, thats the last thing I was expecting! another reply. thanks for the free bump!still no clue as how to have the 2 controls using the same context menu though. looks like it's going to be making the 2 different contexts then Thanks TerarinKCheck out _GUICtrlMenu_CreatePopup() (and maybe _GUICtrlMenu_TrackPopupMenu())
Mat Posted March 28, 2009 Author Posted March 28, 2009 Check out _GUICtrlMenu_CreatePopup() (and maybe _GUICtrlMenu_TrackPopupMenu()) that works but... now that same context menu applies to the button too... I need a seperate one for that, and create popup applies to everything, even when I create a context menu for the button! edited from helpfile example: expandcollapse popup#include <GuiMenu.au3> #include <GuiConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Global Enum $idOpen = 1000, $idSave, $idInfo _Main() Func _Main() Local $hGUI, $Button, $button_CXT, $button_CXTOpt ; Create GUI $hGUI = GUICreate("Menu", 400, 300) GUISetState() $Button = GUICtrlCreateButton ("lol", -1, -1, 100, 100) $button_CXT = GUICtrlCreateContextMenu ($Button) $button_CXTOpt = GUICtrlCreateMenuItem ("Button", $button_CXT) ; Register message handlers GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUIRegisterMsg($WM_CONTEXTMENU, "WM_CONTEXTMENU") ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>_Main ; Handle WM_COMMAND messages Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) Switch $iwParam Case $idOpen _WinAPI_ShowMsg ("Open") Case $idSave _WinAPI_ShowMsg ("Save") Case $idInfo _WinAPI_ShowMsg ("Info") EndSwitch EndFunc ;==>WM_COMMAND ; Handle WM_CONTEXTMENU messages Func WM_CONTEXTMENU($hWnd, $iMsg, $iwParam, $ilParam) Local $hMenu $hMenu = _GUICtrlMenu_CreatePopup () _GUICtrlMenu_InsertMenuItem ($hMenu, 0, "Open", $idOpen) _GUICtrlMenu_InsertMenuItem ($hMenu, 1, "Save", $idSave) _GUICtrlMenu_InsertMenuItem ($hMenu, 3, "", 0) _GUICtrlMenu_InsertMenuItem ($hMenu, 3, "Info", $idInfo) _GUICtrlMenu_TrackPopupMenu ($hMenu, $iwParam) _GUICtrlMenu_DestroyMenu ($hMenu) Return True EndFunc ;==>WM_CONTEXTMENU AutoIt Project Listing
Authenticity Posted March 28, 2009 Posted March 28, 2009 (edited) expandcollapse popup#include <Constants.au3> #include <GuiMenu.au3> #include <GuiConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Global Enum $idOpen = 1000, $idSave, $idInfo Global $hWndProc, $hFunc _Main() Func _Main() Local $hGUI, $Button, $button_CXT, $button_CXTOpt ; Create GUI $hGUI = GUICreate("Menu", 400, 300) GUISetState() $Button = GUICtrlCreateButton("lol", -1, -1, 100, 100) $hWndProc = _WinAPI_GetWindowLong(GUICtrlGetHandle($Button), $GWL_WNDPROC) $hFunc = DllCallbackRegister('Button_WindowProcefure', 'long', 'hwnd;uint;wparam;lparam') _WinAPI_SetWindowLong(GUICtrlGetHandle($Button), $GWL_WNDPROC, DllCallbackGetPtr($hFunc)) $button_CXT = GUICtrlCreateContextMenu($Button) $button_CXTOpt = GUICtrlCreateMenuItem("Button", $button_CXT) ; Register message handlers GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUIRegisterMsg($WM_CONTEXTMENU, "WM_CONTEXTMENU") ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() DllCallbackFree($hFunc) EndFunc ;==>_Main ; Handle WM_COMMAND messages Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) Switch $iwParam Case $idOpen _WinAPI_ShowMsg("Parent Open") Case $idSave _WinAPI_ShowMsg("Parent Save") Case $idInfo _WinAPI_ShowMsg("Parent Info") EndSwitch EndFunc ;==>WM_COMMAND ; Handle WM_CONTEXTMENU messages Func WM_CONTEXTMENU($hWnd, $iMsg, $iwParam, $ilParam) Local $hMenu $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Open", $idOpen) _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Save", $idSave) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "", 0) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "Info", $idInfo) _GUICtrlMenu_TrackPopupMenu($hMenu, $iwParam) _GUICtrlMenu_DestroyMenu($hMenu) Return True EndFunc ;==>WM_CONTEXTMENU Func Button_WindowProcefure($hWnd, $iMsg, $iwParam, $ilParam) If $iMsg = $WM_COMMAND Then Switch _WinAPI_LoWord($iwParam) Case $idOpen _WinAPI_ShowMsg("Child Open") Case $idSave _WinAPI_ShowMsg("Child Save") Case $idInfo _WinAPI_ShowMsg("Child Info") EndSwitch EndIf Return _WinAPI_CallWindowProc($hWndProc, $hWnd, $iMsg, $iwParam, $ilParam) EndFunc ;==>Button_WindowProcefure Edited March 29, 2009 by Authenticity
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