Set Webgadget border style?
Set Webgadget border style?
Does anyone know if you can change the border style around a webgadget? It defaults to borderless. I want a double line sunken border. I have a container gadget for the border currently.
-
- Enthusiast
- Posts: 480
- Joined: Thu Jul 27, 2006 4:06 am
Someone might be able to make a better example...
I don't know why this works, I mean... without the #WS_EX_LEFTSCROLLBAR it doesn't work!
--EDIT--
Either #WS_EX_LEFTSCROLLBAR or #WS_EX_LEFT or #WS_EX_RIGHT is needed for the border styles to work, anyone knows why?
Try #WS_EX_STATICEDGE if you want a thinner border though.
--EDIT2--
Well, this is what I have so far:
I researched on the problem and I couldn't find anything useful, it simply isn't displaying the border in my XP unless I set an RTL style!... Very, very strange.
Code: Select all
If OpenWindow(0, 0, 0, 640, 480, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
web_gadget = WebGadget(#PB_Any, 50, 50, 256, 256, "http://localhost")
web_gadget_handle = GadgetID(web_gadget)
web_gadget_exstyle = GetWindowLong_( web_gadget_handle, #GWL_EXSTYLE)
SetWindowLong_( web_gadget_handle, #GWL_EXSTYLE, web_gadget_exstyle | #WS_EX_CLIENTEDGE | #WS_EX_LEFTSCROLLBAR ) ; dont ask why this works...
UpdateWindow_( web_gadget_handle ) ; make sure it updates?
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
--EDIT--
Either #WS_EX_LEFTSCROLLBAR or #WS_EX_LEFT or #WS_EX_RIGHT is needed for the border styles to work, anyone knows why?
Try #WS_EX_STATICEDGE if you want a thinner border though.
--EDIT2--
Well, this is what I have so far:
Code: Select all
Procedure WebGadgetBorder( hWnd.l )
If (IsWindow_(hWnd))
SetWindowLong_( hWnd, #GWL_EXSTYLE, GetWindowLong_( hWnd, #GWL_EXSTYLE) | #WS_EX_CLIENTEDGE | #WS_EX_RIGHT ) ; #WS_EX_LAYOUTRTL
UpdateWindow_( hWnd ) ; make sure it updates?
EndIf
EndProcedure
If OpenWindow(0, 0, 0, 640, 480, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
web_gadget = WebGadget(#PB_Any, 50, 20, 540, 440, "http://www.google.com/search?&q=Google")
WebGadgetBorder( GadgetID(web_gadget) )
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Last edited by superadnim on Tue Apr 22, 2008 9:42 pm, edited 1 time in total.


Does this not work ?
Code: Select all
If OpenWindow(0, 0, 0, 640, 480, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
web_gadget = WebGadget(#PB_Any, 50, 50, 256, 256, "http://localhost")
hWnd = GadgetID(web_gadget)
style = GetWindowLong_(hWnd, #GWL_EXSTYLE)
SetWindowLong_(hWnd, #GWL_EXSTYLE, style|#WS_EX_CLIENTEDGE)
SetWindowPos_(hWnd,0,0,0,0,0,#SWP_NOMOVE|#SWP_NOSIZE|#SWP_NOOWNERZORDER|#SWP_DRAWFRAME)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
I may look like a mule, but I'm not a complete ass.
-
- Enthusiast
- Posts: 480
- Joined: Thu Jul 27, 2006 4:06 am
Try this for setting the focus, and I added a WS_STYLE in hopes that it works under 9X but I can't test right now, I only have XP here, sorry.
Notice, if you're browsing local files inside your WebGadget the WebGadgetSetFocus routine WILL fail, because the instance created in the embedded object is not an internet explorer object but rather a shell (explorer) object. (at least thats what I remember from previous attempts)
Code: Select all
Procedure WebGadgetSetBorder( hWnd.l )
If (IsWindow_(hWnd))
SetWindowLong_( hWnd, #GWL_STYLE, GetWindowLong_( hWnd, #GWL_STYLE) | #WS_THICKFRAME ) ; as thick as it gets
SetWindowLong_( hWnd, #GWL_EXSTYLE, GetWindowLong_( hWnd, #GWL_EXSTYLE) | #WS_EX_WINDOWEDGE | #WS_EX_CLIENTEDGE | #WS_EX_RIGHT ) ; #WS_EX_LAYOUTRTL
UpdateWindow_( hWnd ) ; make sure it updates?
EndIf
EndProcedure
Procedure.l WebGadgetSetFocus( hWnd.l )
Repeat
hWnd = GetWindow_( hWnd, #GW_CHILD )
Define.s lpClassName = Space(#MAX_PATH)
GetClassName_( hWnd, lpClassName, #MAX_PATH)
If lpClassName = "Internet Explorer_Server"
ProcedureReturn SetFocus_( hWnd )
EndIf
Until hWnd = #Null
EndProcedure
If OpenWindow(0, 0, 0, 640, 480, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
web_gadget = WebGadget(#PB_Any, 50, 20, 540, 440, "http://www.google.com/search?&q=Google")
WebGadgetSetBorder( GadgetID(web_gadget) )
WebGadgetSetFocus( GadgetID(web_gadget) )
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Last edited by superadnim on Tue Apr 22, 2008 9:58 pm, edited 1 time in total.


-
- Enthusiast
- Posts: 480
- Joined: Thu Jul 27, 2006 4:06 am
-
- Enthusiast
- Posts: 480
- Joined: Thu Jul 27, 2006 4:06 am
Final code from my side, works in XP and WinME:
I'm not too happy about the focus routine but thats the only thing I could come up with 
Perhaps, if you iterate until you can't find a child anymore, that'll give you the last child which is the one you should be sending the focus to. Either way I ignore if winapi has a function or better way to do this that's why I did it by hand.
Hope it works over there too.
--EDIT--
This is what I meant, but it doesn't work with files...
Code: Select all
Procedure WebGadgetSetBorder( hWnd.l, mode.l=#False )
If (IsWindow_(hWnd))
If (mode)
SetWindowLong_( hWnd, #GWL_STYLE, GetWindowLong_( hWnd, #GWL_STYLE) | #WS_THICKFRAME )
Else
SetWindowLong_( hWnd, #GWL_EXSTYLE, GetWindowLong_( hWnd, #GWL_EXSTYLE) | #WS_EX_CLIENTEDGE )
EndIf
SetWindowPos_(hWnd, #Null, 0,0,0,0 , #SWP_FRAMECHANGED | #SWP_NOSIZE | #SWP_NOMOVE )
EndIf
EndProcedure
Procedure.l WebGadgetSetFocus( hWnd.l )
Repeat
hWnd = GetWindow_( hWnd, #GW_CHILD )
Define.s lpClassName = Space(#MAX_PATH)
GetClassName_( hWnd, lpClassName, #MAX_PATH)
If lpClassName = "Internet Explorer_Server"
ProcedureReturn SetFocus_( hWnd )
EndIf
Until hWnd = #Null
EndProcedure
If OpenWindow(0, 0, 0, 640, 480, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
web_gadget = WebGadget(#PB_Any, 50, 20, 540, 440, "http://www.google.com/search?&q=Google")
WebGadgetSetBorder( GadgetID(web_gadget) )
WebGadgetSetFocus( GadgetID(web_gadget) )
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

Perhaps, if you iterate until you can't find a child anymore, that'll give you the last child which is the one you should be sending the focus to. Either way I ignore if winapi has a function or better way to do this that's why I did it by hand.
Hope it works over there too.
--EDIT--
This is what I meant, but it doesn't work with files...
Code: Select all
Procedure.l WebGadgetSetFocus( hWnd.l ) ; still doesn't work with webgadget while browsing files...
If (IsWindow_(hWnd))
Define.l temp
Repeat
temp = hWnd
hWnd = GetWindow_( hWnd, #GW_CHILD )
Until hWnd = #Null
If (IsWindow_(temp))
ProcedureReturn SetFocus_( temp )
EndIf
EndIf
EndProcedure


Both your setfocus functions work here superadnim, I'm using local files. Thanks, I prefer the first version, it loops 3 times so not too many. I didn't realize a webgadget is embedded. Anyway, here is what I am using now...
Code: Select all
Procedure SetWebBorder(Gadget.l)
;Double sunken border for WebGadget, by srod
Protected hWnd.l = GadgetID(Gadget)
SetWindowLong_(hWnd, #GWL_EXSTYLE, GetWindowLong_(hWnd, #GWL_EXSTYLE) | #WS_EX_CLIENTEDGE)
SetWindowPos_(hWnd, 0, 0, 0, 0, 0, #SWP_NOMOVE | #SWP_NOSIZE | #SWP_NOOWNERZORDER | #SWP_DRAWFRAME)
EndProcedure
Code: Select all
Procedure.l SetWebFocus(Gadget.l)
;Set the focus on a WebGadget, by superadnim
Protected lpClassName$, hWnd.l = GadgetID(Gadget)
Repeat
hWnd = GetWindow_(hWnd, #GW_CHILD)
lpClassName$ = Space(#MAX_PATH)
GetClassName_(hWnd, lpClassName$, #MAX_PATH)
If lpClassName$ = "Internet Explorer_Server"
ProcedureReturn SetFocus_(hWnd)
EndIf
Until hWnd = #Null
EndProcedure