;Autor: Danilo ;http://www.purebasic.fr/english/viewtopic.php?p=397363#p397363 EnableExplicit Define Event #OLECMDID_OPTICAL_ZOOM = 63 #OLECMDEXECOPT_DONTPROMPTUSER = 2 Procedure WebGadget_GetZoom(webgadget) Protected WebObject.IWebBrowser2, zoom.VARIANT WebObject = GetWindowLongPtr_(GadgetID(webgadget), #GWL_USERDATA) If WebObject WebObject\ExecWB(#OLECMDID_OPTICAL_ZOOM, #OLECMDEXECOPT_DONTPROMPTUSER, 0, @zoom) ; get current zoom level in percent ProcedureReturn zoom\iVal EndIf EndProcedure Procedure WebGadget_SetZoom(webgadget, percent) Protected WebObject.IWebBrowser2, zoom.VARIANT WebObject = GetWindowLongPtr_(GadgetID(webgadget), #GWL_USERDATA) If WebObject If percent < 10 : percent = 10 : EndIf If percent > 1000 : percent = 1000 : EndIf zoom\vt = 3 zoom\iVal = percent WebObject\ExecWB(#OLECMDID_OPTICAL_ZOOM, #OLECMDEXECOPT_DONTPROMPTUSER, @zoom, 0) ; set new zoom level in percent (10 - 1000) EndIf EndProcedure Procedure WebGadget_IncreaseZoom(webgadget,percent=20) Protected WebObject.IWebBrowser2, zoom.VARIANT WebObject = GetWindowLongPtr_(GadgetID(webgadget), #GWL_USERDATA) If WebObject WebObject\ExecWB(#OLECMDID_OPTICAL_ZOOM, #OLECMDEXECOPT_DONTPROMPTUSER, 0, @zoom) ; get current zoom level in percent zoom\iVal + percent If zoom\iVal > 1000 : zoom\iVal = 1000 : EndIf WebObject\ExecWB(#OLECMDID_OPTICAL_ZOOM, #OLECMDEXECOPT_DONTPROMPTUSER, @zoom, 0) ; set zoom level EndIf EndProcedure Procedure WebGadget_DecreaseZoom(webgadget,percent=20) Protected WebObject.IWebBrowser2, zoom.VARIANT WebObject = GetWindowLongPtr_(GadgetID(webgadget), #GWL_USERDATA) If WebObject WebObject\ExecWB(#OLECMDID_OPTICAL_ZOOM, #OLECMDEXECOPT_DONTPROMPTUSER, 0, @zoom) ; get current zoom level in percent zoom\iVal - percent If zoom\iVal < 10 : zoom\iVal = 10 : EndIf WebObject\ExecWB(#OLECMDID_OPTICAL_ZOOM, #OLECMDEXECOPT_DONTPROMPTUSER, @zoom, 0) ; set zoom level EndIf EndProcedure #win0_flags = #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget|#PB_Window_Maximize If OpenWindow(0, 0, 0, 800, 600, "WebGadget Zoom", #win0_flags) WebGadget(0, 10, 10,WindowWidth(0)-20, WindowHeight(0)-50, "http://www.purebasic.com") ;SetGadgetItemText(0,#PB_Web_HtmlCode,"

PureBasic

PureBasic") ButtonGadget(1,10,WindowHeight(0)-30,20,20,"-") TrackBarGadget(2,30,WindowHeight(0)-30,300,20,10,1000,#PB_TrackBar_Ticks) ButtonGadget(3,330,WindowHeight(0)-30,20,20,"+") ComboBoxGadget(4,360,WindowHeight(0)-30,100,20) AddGadgetItem(4,-1,"10 %") AddGadgetItem(4,-1,"50 %") AddGadgetItem(4,-1,"75 %") AddGadgetItem(4,-1,"100 %") AddGadgetItem(4,-1,"125 %") AddGadgetItem(4,-1,"150 %") AddGadgetItem(4,-1,"200 %") AddGadgetItem(4,-1,"300 %") AddGadgetItem(4,-1,"500 %") AddGadgetItem(4,-1,"750 %") AddGadgetItem(4,-1,"1000 %") SetGadgetState(4,3) ; Combobox Item 3 = 100% SetGadgetState(2,WebGadget_GetZoom(0)) Repeat Event = WaitWindowEvent() If Event = #PB_Event_Gadget Select EventGadget() Case 1 WebGadget_DecreaseZoom(0) SetGadgetState(2,WebGadget_GetZoom(0)) Case 2 WebGadget_SetZoom(0,GetGadgetState(2)) Case 3 WebGadget_IncreaseZoom(0) SetGadgetState(2,WebGadget_GetZoom(0)) Case 4 WebGadget_SetZoom(0,Val(GetGadgetText(4))) SetGadgetState(2,Val(GetGadgetText(4))) EndSelect ElseIf Event = #PB_Event_SizeWindow ResizeGadget(0, 10, 10,WindowWidth(0)-20, WindowHeight(0)-50) ResizeGadget(1, 10,WindowHeight(0)-30, 20,20) ResizeGadget(2, 30,WindowHeight(0)-30,300,20) ResizeGadget(3,330,WindowHeight(0)-30, 20,20) ResizeGadget(4,360,WindowHeight(0)-30,100,20) ElseIf Event = #WM_MOUSEWHEEL If EventType() = -1 And GetAsyncKeyState_(#VK_CONTROL) & (1<<15) If (EventwParam()>0) : WebGadget_IncreaseZoom(0) : EndIf If (EventwParam()<0) : WebGadget_DecreaseZoom(0) : EndIf SetGadgetState(2,WebGadget_GetZoom(0)) EndIf EndIf Until Event = #PB_Event_CloseWindow EndIf ; IDE Options = PureBasic 5.31 (Windows - x64) ; CursorPosition = 2 ; Folding = - ; EnableUnicode ; EnableXP ; EnableUser ; EnableCompileCount = 0 ; EnableBuildCount = 0