"Seethrough" window

Share your advanced PureBasic knowledge/code with the community.
GreenGiant
Enthusiast
Enthusiast
Posts: 252
Joined: Fri Feb 20, 2004 5:43 pm

Post by GreenGiant »

Surely if you want it show exactly what's under if you'd just region out the main part of the window. Or if you wanted to draw some stuff in the window, but with a transparent background, and possibly change the stuff in realtime you could use *this*.
akee
Enthusiast
Enthusiast
Posts: 498
Joined: Wed Aug 18, 2004 9:52 am
Location: Penang, Malaysia

Post by akee »

Trond wrote:@akie: 50% transparent window can easily be achieved by an entirely different technique:
COOL! THANKS! :D
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

Post by NoahPhense »

Sparkie wrote:Nice one Trond :)
NoahPhense wrote:btw - i tried the trick.. nice.. now make it not jumpy...
This seems to work pretty good...

Code: Select all

; --> Original "Desktop Window" inspired Trond
Procedure myCallback(hwnd, msg, wparam, lparam) 
  Result = #PB_ProcessPureBasicEvents 
  Select msg
    Case #WM_PAINT
      hdc = BeginPaint_(hwnd, @ps.PAINTSTRUCT) 
      PaintDesktop_(hdc)
      EndPaint_(hwnd,@ps) 
      Result = 0
    Case #WM_MOVING
      InvalidateRect_(WindowID(), 0, 0)
    Case #WM_SIZE
      InvalidateRect_(WindowID(), 0, 0)
  EndSelect 
  ProcedureReturn Result 
EndProcedure 
If OpenWindow(0, 0, 0, 300, 300,  #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget, "Desktop Window")
  SetClassLong_(WindowID(), #GCL_HBRBACKGROUND, 0)
  SetWindowCallback(@myCallback()) 
  Repeat 
    event = WaitWindowEvent() 
  Until event = #PB_EventCloseWindow 
EndIf
End

* Edited to remove un-needed line *
Wow Sparkie.. very nice.. that sh!t is tight.. ;)

- np
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

NoahPhense wrote:Wow Sparkie.. very nice.. that sh!t is tight..
Thanks np. :)
... but are you saying I'm a tight a$$ :P :wink:
PB wrote:Sparkie, how about adapting it to show whatever's under the window, instead
of just the Desktop?
There may be a better way, but here's your See-Through window. Only tested on WinXP. ;)

Code: Select all

borderW = GetSystemMetrics_(#SM_CXSIZEFRAME)
borderH = GetSystemMetrics_(#SM_CYSIZEFRAME)
captionH = GetSystemMetrics_(#SM_CYCAPTION)
If OpenWindow(0, 0, 0, 300, 300,  #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget, "See-Through Window")
  outterRgn  = CreateRectRgn_(0, 0, WindowWidth() + (borderW * 2), WindowHeight() + captionH + (borderH * 2))
  innerRgn = CreateRectRgn_(borderW, captionH + borderH, WindowWidth() + borderW, WindowHeight() + captionH + borderH)
  winRgn = outterRgn
  CombineRgn_(winRgn, outterRgn, innerRgn, #RGN_XOR)
  SetWindowRgn_(WindowID(), winRgn, 1)
  DeleteObject_(outterRgn)
  DeleteObject_(innerRgn)
  Repeat 
    event = WaitWindowEvent() 
    Select event
      Case #PB_Event_SizeWindow
        outterRgn  = CreateRectRgn_(0, 0, WindowWidth() + (borderW * 2), WindowHeight() + captionH + (borderH * 2))
        innerRgn = CreateRectRgn_(borderW, captionH + borderH, WindowWidth() + borderW, WindowHeight() + captionH + borderH)
        winRgn = outterRgn
        CombineRgn_(winRgn, outterRgn, innerRgn, #RGN_XOR)
        SetWindowRgn_(WindowID(), winRgn, 1)
        DeleteObject_(outterRgn)
        DeleteObject_(innerRgn)
    EndSelect
  Until event = #PB_EventCloseWindow 
EndIf 
End
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

Post by NoahPhense »

Sparkie wrote:
NoahPhense wrote:Wow Sparkie.. very nice.. that sh!t is tight..
Thanks np. :)
... but are you saying I'm a tight a$$ :P :wink:
No. It is one of the highest praises I know of using slang. :D
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

I got that np, I was being sarcastic. ;)

Back in the 60's, when I was a wee little boy, the highest praise was... boss-or-what. :roll:
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

Post by NoahPhense »

Sparkie wrote:I got that np, I was being sarcastic. ;)

Back in the 60's, when I was a wee little boy, the highest praise was... boss-or-what. :roll:
When I was younger, one of them was: choice.. :)

..another was Rad.

- np
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> here's your See-Through window

:shock: Words fail me... that's just effing awesome! CONGRATULATIONS! :D
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

On XP the TITLEBAR changes to the DOS-WINDOW-STYLE...

Other than that 8)
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

Cool as always, Sparkie!

OT: fsw, glad you decided _not_ to shut up :)
Good programmers don't comment their code. It was hard to write, should be hard to read.
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

traumatic wrote: OT: fsw, glad you decided _not_ to shut up :)
[german]
manchmal schaue ich hier rein (in den deutschen forum auch :wink: ), hab aber schon lange nichts mit pb gemacht... ausser Sparkies code testen 8)
[/german]

Sometimes I come by and test Sparkie's code 8)
...but besides that I didn't do anything with pb lately :wink:
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

@fsw & traumatic: Thank you :)

@fsw: I was hoping nobody would notice the loss of XP style. No sure how useful the code is, but I'll work on correcting that as my next challenge. ;)
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Post Reply