What's up with this webgadget attribute?

Just starting out? Need help? Post your questions and find answers here.
mrjiles
Enthusiast
Enthusiast
Posts: 238
Joined: Fri Aug 18, 2006 7:21 pm
Location: IL

What's up with this webgadget attribute?

Post by mrjiles »

I'm not posting this in the bugs category cause I'm not sure if it's linked to my system or PB. Enable XP themes on this and look at the Google search buttons (it's like this for all HTML buttons)...


Code: Select all

If OpenWindow(1, 0, 0, 500, 500, "WebGadget Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered ) And CreateGadgetList(WindowID(1))

	WebGadget(2, 10, 10, 480, 240, "google.com")
	WebGadget(3, 10, 260, 480, 240, "google.com")

	; only settings the #PB_Web_BlockPopupMenu for the top WebGadget
	SetGadgetAttribute(2, #PB_Web_BlockPopupMenu, 1)
	
EndIf


Repeat
	Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
End

Edit: I meant skin support
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post by Derek »

On my system the second window draws all the gadgets without using the xp-skin so I guess it's not just your system.
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

I get the same results as well.

To tell you the truth, I never noticed the fact that even with XP skins enabled, the WebGadget still displays controls in the classic, non-XP theme.

At least now, with your discovery, we know how to enable XP skins for the WebGadget. 8)
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Post by Edwin Knoppert »

So far it's via ATL only possible to embed a theme meta statement in the HEAD and having theming enabled.

Though.. since you also browse websites not being your own, you'll be out of luck.
I don't know how to solve this myself.
If you are able to insert the statement in the document before rendering...?

It has to do the way the webcontrol is used, in this case via atl.
Even VB and .NET suffer from this.
mrjiles
Enthusiast
Enthusiast
Posts: 238
Joined: Fri Aug 18, 2006 7:21 pm
Location: IL

Post by mrjiles »

Wahoo! I contributed something useful!!
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post by Derek »

mrjiles wrote:Wahoo! I contributed something useful!!
:lol: :lol:
Nearly 2 years in and your first useful contribution, nah, I don't believe you. :wink:
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Edwin Knoppert wrote:I don't know how to solve this myself.
It's over my head but Google for IDocHostUIHandler GetHostInfo DOCHOSTUIFLAG_THEME.

Here's some help with IDocHostUIHandler http://www.purebasic.fr/english/viewtop ... 415#227415

Bug or not, I gotta say that mrjiles method of activating themes sure looks a whole lot easier. :wink:
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Post by Edwin Knoppert »

It works!

You have to use (PowerBASIC code):

Code: Select all

Function IDocHostUIHandler_GetHostInfo (ByVal pthis As Dword Ptr, ByRef pInfo As DOCHOSTUIINFO) As Long

    pInfo.dwFlags = pInfo.dwFlags Or %DOCHOSTUIFLAG_THEME

   Function = %S_OK
End Function
Here is the topic:

http://www.powerbasic.com/support/pbfor ... tUIHandler
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

This enables the popup menu and skins at the same time:

Code: Select all

   SetGadgetAttribute(2, #PB_Web_BlockPopupMenu, 1)
   SetGadgetAttribute(2, #PB_Web_BlockPopupMenu, 0)
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Post by Edwin Knoppert »

But how is this internally done?
Nico
Enthusiast
Enthusiast
Posts: 274
Joined: Sun Jan 11, 2004 11:34 am
Location: France

Post by Nico »

Work very well, thanks for the tips :)

An example with PureBasic:




Enumeration 0
    #OLECMDEXECOPT_DODEFAULT
    #OLECMDEXECOPT_PROMPTUSER
    #OLECMDEXECOPT_DONTPROMPTUSER
    #OLECMDEXECOPT_SHOWHELP
EndEnumeration

Enumeration 1
    #OLECMDID_OPEN
    #OLECMDID_NEW
    #OLECMDID_SAVE
    #OLECMDID_SAVEAS
    #OLECMDID_SAVECOPYAS
    #OLECMDID_PRINT
    #OLECMDID_PRINTPREVIEW
    #OLECMDID_PAGESETUP
    #OLECMDID_SPELL
    #OLECMDID_PROPERTIES
    #OLECMDID_CUT
    #OLECMDID_COPY
    #OLECMDID_PASTE
    #OLECMDID_PASTESPECIAL
    #OLECMDID_UNDO
    #OLECMDID_REDO
    #OLECMDID_SELECTALL
    #OLECMDID_CLEARSELECTION
    #OLECMDID_ZOOM
    #OLECMDID_GETZOOMRANGE
    #OLECMDID_UPDATECOMMANDS
    #OLECMDID_REFRESH
    #OLECMDID_STOP
    #OLECMDID_HIDETOOLBARS
    #OLECMDID_SETPROGRESSMAX
    #OLECMDID_SETPROGRESSPOS
    #OLECMDID_SETPROGRESSTEXT
    #OLECMDID_SETTITLE
    #OLECMDID_SETDOWNLOADSTATE
    #OLECMDID_STOPDOWNLOAD
EndEnumeration


#TPM_RETURNCMD =$100
#TPM_NONOTIFY =$80

#DOCHOSTUIFLAG_THEME = $40000

Structure DOCHOSTUIINFO
    cbSize.l
    dwFlags.l
    dwDoubleClick.l
    *pchHostCss.l
    *pchHostNS.l
EndStructure

;Window
Enumeration
    #Main
EndEnumeration

;Gadget
Enumeration
    #Web
EndEnumeration

;Popup
Enumeration
    #Popup
    #PureBasic
EndEnumeration

Structure IDocHost
  *IDocHostUIHandler.IDocHostUIHandler
  ObjectCount.l
EndStructure

Global NewList IDocHost.IDocHost()

Procedure AddRef(*THIS.IDocHost)
  *THIS\ObjectCount + 1
    ProcedureReturn *THIS\ObjectCount
EndProcedure

Procedure QueryInterface(*THIS.IDocHost, *iid.GUID, *Object.LONG)
    If CompareMemory (*iid, ?IID_IUnknown, SizeOf (GUID)) Or CompareMemory (*iid, ?IID_IDocHostUIHandler, SizeOf (GUID))
    *Object\l = *THIS
    AddRef(*THIS.IDocHost)
      ProcedureReturn #S_OK
    Else
    *Object\l = 0
      ProcedureReturn #E_NOINTERFACE
    EndIf
EndProcedure

Procedure.l Release(*THIS.IDocHost)
  *THIS\ObjectCount - 1
    ProcedureReturn *THIS\ObjectCount
EndProcedure

Procedure ShowContextMenu(*THIS.IDocHost, dwID.l, *ppt.POINT, *pcmdtReserved.IUnknown, *pdispReserved.IDispatch)
  Protected bstr.l,iSelection.l,pElem.IHTMLElement,parent.IHTMLElement
  
    Select dwID
      Case 0
        Debug "CONTEXT_MENU_DEFAULT"
      
      Case 1
        Debug "CONTEXT_MENU_IMAGE"
      
      Case 2
        Debug "CONTEXT_MENU_CONTROL"
        ;Pour avoir plus de renseignement sur l'objet
        If *pdispReserved\QueryInterface(?IID_IHTMLElement, @pElem.IHTMLElement)= #S_OK
          If pElem
          
          pElem\get_tagName(@bstr)
            If bstr
              Debug PeekS (bstr, 200, #PB_Unicode )
            EndIf
          
          pElem\get_outerHTML(@bstr)
            If bstr
              Debug PeekS (bstr, 200, #PB_Unicode )
            EndIf
          
          pElem\get_parentElement(@parent.IHTMLElement)
          parent\get_outerHTML(@bstr)
          parent\Release()
            If bstr
              Debug PeekS (bstr, 200, #PB_Unicode )
            EndIf
          
          pElem\Release()
            Debug SysFreeString_ (@bstr)
          EndIf
        EndIf
      iSelection = TrackPopupMenu_ ( MenuID ( #Popup ), #TPM_LEFTALIGN | #TPM_RIGHTBUTTON | #TPM_RETURNCMD ,*ppt\x,*ppt\y,0, GadgetID ( #Web ), #Null )
        If iSelection <> 0
          PostMessage_ ( WindowID ( #Main ), #WM_COMMAND , iSelection, #Null )
          ProcedureReturn #False ;0 pour interdire le menu par défaut
        EndIf
      
      
      Case 3
        Debug "CONTEXT_MENU_TABLE"
      
      Case 4
        Debug "CONTEXT_MENU_TEXTSELECT"
      
      Case 5
        Debug "CONTEXT_MENU_ANCHOR"
      
      Case 6
        Debug "CONTEXT_MENU_UNKNOWN"
    EndSelect
  
    ProcedureReturn #True ;1 pour autoriser le menu par défaut
EndProcedure

Procedure GetHostInfo(*THIS.IDocHost, *pInfo.DOCHOSTUIINFO)
   *pInfo\dwFlags = *pInfo\dwFlags | #DOCHOSTUIFLAG_THEME
    ProcedureReturn #S_OK
EndProcedure
  
Procedure ShowUI(*THIS.IDocHost, dwID.l, *pActiveObject.l, *pCommandTarget.l, *pFrame.l, *pDoc.l)
    ProcedureReturn #S_OK
EndProcedure
  
Procedure HideUI(*THIS.IDocHost)
    ProcedureReturn #S_OK
EndProcedure
  
Procedure UpdateUI(*THIS.IDocHost)
    ProcedureReturn #S_OK
EndProcedure
  
Procedure EnableModeless(*THIS.IDocHost, fEnable.l)
    ProcedureReturn #S_OK
EndProcedure
  
Procedure OnDocWindowActivate(*THIS.IDocHost, fActivate.l)
    ProcedureReturn #S_OK
EndProcedure
  
Procedure OnFrameWindowActivate(*THIS.IDocHost, fActivate.l)
    ProcedureReturn #S_OK
EndProcedure
  
Procedure ResizeBorder(*THIS.IDocHost, *prcBorder.l, *pUIWindow.l, fFrameWindow.l)
    ProcedureReturn #S_OK
EndProcedure
  
Procedure TranslateAccelerator(*THIS.IDocHost, *lpMsg.MSG, *pguidCmdGroup.GUID, nCmdID.l)
    ProcedureReturn #S_OK
EndProcedure
  
Procedure GetOptionKeyPath(*THIS.IDocHost, *pchKey.l, dw.l)
    ProcedureReturn #S_OK
EndProcedure
  
Procedure GetDropTarget(*THIS.IDocHost, *pDropTarget.l, *ppDropTarget.l)
  *ppDropTarget= #Null
    ProcedureReturn #E_NOTIMPL
EndProcedure
  
Procedure GetExternal(*THIS.IDocHost, *ppDispatch.LONG)
  *ppDispatch\l = *THIS
    ProcedureReturn #S_OK
EndProcedure
  
Procedure TranslateUrl(*THIS.IDocHost, dwTranslate.l, *pchURLIn.l, *ppchURLOut.l)
    ProcedureReturn #S_FALSE
EndProcedure
  
Procedure FilterDataObject(*THIS.IDocHost, *pDO.IDataObject, *ppDORet.IDataObject)
  *ppDORet = #Null
    ProcedureReturn #S_FALSE
EndProcedure
  
If OpenWindow ( #Main ,0,0,600,300, "WebGadget" , #PB_Window_SystemMenu|#PB_Window_ScreenCentered )
    CreateGadgetList ( WindowID ( #Main ))
    WebGadget ( #Web ,10,10,580,280, "http://www.google.fr/" )
  
    If CreatePopupMenu ( #Popup )
      MenuItem ( #PureBasic , "Pure Basic" )
    EndIf
  
    AddElement (IDocHost())
  IDocHost()\IDocHostUIHandler=?IDocHostUIHandler
  
  webBrowser.IWebBrowser2 = GetWindowLong_ ( GadgetID ( #Web ), #GWL_USERDATA )
    If webBrowser\get_Document(@pDisp.IDispatch)= #S_OK
      If pDisp\QueryInterface(?IID_ICustomDoc, @pDoc.ICustomDoc)= #S_OK
      pdoc\SetUIHandler(@IDocHost()\IDocHostUIHandler)
      pDoc\Release()
      EndIf
    pDisp\Release()
    EndIf
  
    Repeat
    event= WaitWindowEvent ()
      ;ViewEvent(event2)
      Select event
        Case #PB_Event_Menu
          Select EventMenu ()
            Case #PureBasic
              SetClipboardText ( "PureBasic" )
            webBrowser\ExecWB( #OLECMDID_PASTE , #OLECMDEXECOPT_DONTPROMPTUSER , 0, 0)
          EndSelect
        Case #WM_CLOSE
        Quit=1
      EndSelect
    Until Quit = 1
EndIf
  
  
DataSection
  IDocHostUIHandler:
    Data.l @QueryInterface()
    Data.l @AddRef()
    Data.l @Release()
    Data.l @ShowContextMenu()
    Data.l @GetHostInfo()
    Data.l @ShowUI()
    Data.l @HideUI()
    Data.l @UpdateUI()
    Data.l @EnableModeless()
    Data.l @OnDocWindowActivate()
    Data.l @OnFrameWindowActivate()
    Data.l @ResizeBorder()
    Data.l @TranslateAccelerator()
    Data.l @GetOptionKeyPath()
    Data.l @GetDropTarget()
    Data.l @GetExternal()
    Data.l @TranslateUrl()
    Data.l @FilterDataObject()
  
  IID_IDocHostUIHandler:
    Data.l $BD3F23C0
    Data.w $D43E, $11CF
    Data.b $89, $3B, $00, $AA, $00, $BD, $CE, $1A
  
  IID_ICustomDoc:
    Data.l $3050F3F0
    Data.w $98B5, $11CF
    Data.b $BB, $82, $00, $AA, $00, $BD, $CE, $0B
  
  IID_IHTMLElement:
    Data.l $3050F1FF
    Data.w $98B5, $11CF
    Data.b $BB, $82, $00, $AA, $00, $BD, $CE, $0B
  
  IID_IUnknown:
    Data.l $00000000
    Data.w $0000, $0000
    Data.b $C0, $00, $00, $00, $00, $00, $00, $46
EndDataSection


Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Post by Edwin Knoppert »

That's what i thought, internally this same interface seems being used by pb.
Only.. somehow the toggle is awkward isn't?
mrjiles
Enthusiast
Enthusiast
Posts: 238
Joined: Fri Aug 18, 2006 7:21 pm
Location: IL

Post by mrjiles »

Let's stop talking about it before the "bug" is fixed :)

Edit: Ignore my above comment, maybe this can be turned into an available flag for the webgadget.
Post Reply