[Closed] WebBrowser in Rcmenu,possible?
Hi,I recently have a project need a webBrowser in Rcmenu,like example below,but I did not find any codes can do it,does anyone know?Thanks in advanced.
Rcmenu Common_tool
(
menuitem test_01 "Test_01"
menuitem test_02 "Test_02"
menuitem test_03 "Test_03"
--webBrowser goes here
)
rollout test_rcmenus "Test" width:190
(
button test_rcmenus_tool "Test Url" width:90 height:19 pos:[50,40]
on test_rcmenus_tool pressed do
(
popupmenu Common_tool
)
)
CreateDialog test_rcmenus 200 150
why not create a separate form with the browser and then just show and align it to opened rcmenu?
Thanks for help,it’s a good idea,but how can I align the opened remenu?Like below,each time I pressed the Test Url button,the menu shows is not the same position,how can I get the red point’s position?
You can use dialogMonitorOps to get the rcmenu hwnd (or even get the last child hwnd) and then windows.getWindowPos to get its size and position.
How can I get rcmenu position and size before creating a webb dialog?
try (destroydialog X ) catch ()
rollout X "" (
button btn "-------------------------"
local rcm, webb, rcdata
fn catchRCMENU = (
local hwnd = DialogMonitorOPS.GetWindowHandle()
if hwnd != undefined do (
local data = windows.getHWNDData hwnd
if data[4] == "#32768" do (
rcdata = windows.getWindowPos data[1]
SetDialogPos webb [ rcdata.x, rcdata.y + rcdata.h ]
)
)
true
)
on x open do (
RCMenu rcm (
menuitem mnu "menuitem"
)
rollout webb "" (
label l "webbrowser"
)
)
on btn rightclick do (
DialogMonitorOPS.Enabled = true
DialogMonitorOPS.RegisterNotification catchRCMENU id:#showHWND
CreateDialog webb style:#(#style_border) pos:mouse.screenpos
PopupMenu rcm
DestroyDialog webb
DialogMonitorOPS.Enabled = false
DialogMonitorOPS.UnRegisterNotification id:#showHWND
)
)
createDialog X pos:[100,100]
Thanks for great help,I tried your code,but the script threw an error:
– Error occurred in catchRCMENU();
Actually,I found some codes and put them together after searched forum topic,it seems can align the menu now,but not finish,I need to press the WebBrowser and let it hide when mouse pressed ‘webBrowser item’,but how can I do that?Also,when mouse move out to menu zone, how can I let the WebBrowser visible?That mean,at position 1 or posistion 2, press mouse ,then ,let WebBrowser hide.
global webbrowser_rollout
arrFavtmp = #("menu_01", "menu_02", "menu_03")
Fn Display_or_hide_ad_now shows_type=
(
if shows_type==1 then SetDialogPos webbrowser_rollout [300,600]
)
Fn going_item sender args =
(
Display_or_hide_ad_now 1
)
rollout webbrowser_rollout "Web Test" width:250 height:125
(
dotNetControl wb "System.Windows.forms.WebBrowser" pos:[0,0] width:250 height:125
on webbrowser_rollout open do
(
wb.url = dotNetObject "System.Uri" "http://www.autodesk.com"
)
on webbrowser_rollout lbuttondown the_pos do Display_or_hide_ad_now 1
)
createdialog webbrowser_rollout
rollout roll_type "" width:131 height:29
(
button btn "Test web url"
local contextMenu = dotNetObject "System.Windows.Forms.ContextMenu"
on btn pressed do
(
Vcoors= GetDialogPos roll_type
VSz = GetDialogSize roll_type
contextMenu = dotNetObject "System.Windows.Forms.ContextMenuStrip"
contextMenu.ImageScalingSize = dotNetObject "System.Drawing.Size" (width = 164) (height = 164)
contextMenu.ShowImageMargin = true
for i =1 to arrFavtmp.count do dotnet.addeventhandler (contextMenu.Items.Add(arrFavtmp[i])) "Click" going_item
SetDialogPos webbrowser_rollout [Vcoors[1]+60-2,Vcoors[2]+100]
contextmenu.Show (Vcoors[1]+60) (Vcoors[2]+30)
)
)
createdialog roll_type
cui.RegisterDialogBar roll_type --style:#(#cui_handles, #cui_max_sized)
cui.DockDialogBar roll_type #cui_dock_top
Maybe that has something to do with the max version. Max 2014 works fine for me