String Gadget Background Transparent?

Just starting out? Need help? Post your questions and find answers here.
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post by Dare »

Again ...? :shock:
Dare2 cut down to size
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Post by Fangbeast »

Dare wrote:Again ...? :shock:
Did you see the first lot of pictures already? What's that hairy thing down between his legs? probably the result of eating genetically modified crops.
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post by Dare »

[ REMOVED ]

Before srod sees it and revokes my egrid licence!
Last edited by Dare on Mon Dec 03, 2007 12:36 pm, edited 1 time in total.
Dare2 cut down to size
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Post by Fangbeast »

Dare wrote:
Fangbeast wrote:What's that hairy thing down between his legs?
His girlfriend?



* This post won't last very long *
Thanks a lot, I nearly snorted hot tea up both nostrils!
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

You Aussies are nuts!

Complete screwballs!

Now leave me in peace whilst I negotiate purchasing the moon from this kind hearted broom handle. And to think that the washing machine said I'd never get a decent price!

Blooming crazy Aussies...

:)

(btw dare, your egrid licence will self-destruct in 24 hours. Say your prayers laddie!)
I may look like a mule, but I'm not a complete ass.
abc123
Enthusiast
Enthusiast
Posts: 195
Joined: Wed Apr 18, 2007 9:27 pm

Post by abc123 »

i wanted to make the background the same as the window background (a panel gadget behind it is what is behind) but i wanted it to show wat is behind it.
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post by Dare »

srod wrote:(btw dare, your egrid licence will self-destruct in 24 hours. Say your prayers laddie!)
* grovels *

Sorry mate, but the below waist bits are starting to work again and it makes me feisty.

Traceur (parkour) by end 2008!


/hijack
Dare2 cut down to size
Foz
Addict
Addict
Posts: 1359
Joined: Tue Nov 13, 2007 12:42 pm
Location: Manchester, UK

Re: String Gadget Background Transparent?

Post by Foz »

A little threadnomancy here, but it feels the best place to ask - if I want to use the EditorGadget, what needs to change?

Whenever I try it, I just get a solid black background...
Nituvious
Addict
Addict
Posts: 1027
Joined: Sat Jul 11, 2009 4:57 am
Location: United States

Re: String Gadget Background Transparent?

Post by Nituvious »

I thought this was a new post! Ugh, oh well. Maybe this will be useful to someone...

Code: Select all

;IncludeFile "C:\code\pb\include\WinAPI.pbi"
Declare OpenTransparentWindow(transColor.l, x.l, y.l, width.l, height.l, title.s, flag.l)

window = OpenTransparentWindow(RGB(255,254,253), 0, 0, 400, 400, "Invisible string gadget background", #PB_Window_SystemMenu)
StringGadget(0, 5, 5, 105, 23, "Test contents")
font = LoadFont(#PB_Any, "Arial", 12)
SetGadgetFont(0, FontID(font))
SetGadgetColor(0, #PB_Gadget_BackColor, RGB( 255,254, 253))
SetGadgetColor(0, #PB_Gadget_FrontColor, RGB( 255, 255, 255))

SetWindowColor(window, RGB(200,200,200))
HideWindow(window, 0)

While Not eventID = #PB_Event_CloseWindow
	eventID = WaitWindowEvent(1)
	Delay(10)
Wend




Procedure OpenTransparentWindow(transColor.l, x.l, y.l, width.l, height.l, title.s, flag.l) ;-- Create an invisible, borderless, and transparent window
	; HideWindow(winResult, 0) after gadgets have been placed. Otherwise you may see flicker.
	; I do not know if this works on all versions of windows or just Vista / 7
	; I have only tested on both x86 and x64 Windows 7

	winResult = OpenWindow(#PB_Any, 1, 1, 1, 1, title.s, #PB_Window_Invisible | flag.l)
	SetWindowColor(winResult,transColor)

	SetWindowLongPtr_(WindowID(winResult),#GWL_EXSTYLE,  #WS_EX_LAYERED)  ; -- According to the MSDN, this function will work with both x86 and x64 ( http://msdn.microsoft.com/en-us/library/ms644898(v=VS.85).aspx )
	SetWindowPos_(WindowID(winResult),#Null, x, y, width, height, #Null) ; -- Must redraw window, according to the MSDN

	SetLayeredWindowAttributes_(WindowID(winResult),transColor,#Null,#LWA_COLORKEY)

	ProcedureReturn winResult

EndProcedure
▓▓▓▓▓▒▒▒▒▒░░░░░
Foz
Addict
Addict
Posts: 1359
Joined: Tue Nov 13, 2007 12:42 pm
Location: Manchester, UK

Re: String Gadget Background Transparent?

Post by Foz »

Thanks, I found the answer now.

The complete question I should have asked was "how do I make a transparent, borderless, wordwrapped, scrollbarless editorgadget?"

Answer?

Code: Select all

UseJPEGImageDecoder()

Procedure.l hWndTransparent( hWnd.l )
   Define.l lwTemp
   #WS_EX_TRANSPARENT = $20
   lwTemp = GetWindowLong_(hWnd, #GWL_STYLE)
   SetWindowLong_(hWnd, #GWL_EXSTYLE, lwTemp | #WS_EX_TRANSPARENT)
   ProcedureReturn lwTemp
   
 EndProcedure
  
; --> Get our background image
imageBG$ = (OpenFileRequester("Select background", "c:\", "Image files (JPG, JPEG, BMP)|*.jpg;*.bmp", 0))

If imageBG$ <> ""
  myImage = LoadImage(0, imageBG$)
  ; --> create brush for our window background
  containerBrush = CreatePatternBrush_(ImageID(0))
Else
  ; cancelled
  End
EndIf

StartDrawing(ImageOutput(0))
For x = 10 To 210
  For y = 10 To 210
    colour = Point(x, y) | $AAAAAA
    Plot(x, y, colour)
  Next
Next
StopDrawing()

Global stringpattern.l, bkswitch.l = 0

OpenWindow(0,0,0,320,240,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)

ImageGadget(0,0,0,0,0,ImageID(0))
DisableGadget(0, #True)
EditorGadget(1,10,10,200,200)

SetWindowTheme_(GadgetID(1), @null.w, @null.w)
SetWindowLongPtr_(GadgetID(1),#GWL_EXSTYLE,0)
SendMessage_(GadgetID(1), #EM_SETTARGETDEVICE,0, 0)
SendMessage_(GadgetID(1),#EM_SHOWSCROLLBAR, 1, 0) ; disable scrollbar

hWndTransparent(GadgetID(1))

Repeat:Until WaitWindowEvent()=#WM_CLOSE

DeleteObject_(stringpattern) 
Post Reply