"Seethrough" window

Share your advanced PureBasic knowledge/code with the community.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

"Seethrough" window

Post by Trond »

Code updated For 5.20+

Ok, this is probably far from advanced, but it's still quite cool.

Code: Select all

Declare FormWndProc (Hwnd, uMsg, wParam, lParam)
Declare PaintForm()

#Window_0 = 0
OpenWindow(#Window_0, 246, 197, 382, 279, "Our desktop window...",  #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget)
SetWindowCallback(@FormWndProc())
PaintForm()

Repeat
  EVENT = WaitWindowEvent()
Until EVENT = #PB_Event_CloseWindow

Procedure FormWndProc (Hwnd, uMsg, wParam, lParam)
  Result = #PB_ProcessPureBasicEvents
  If uMsg = #WM_MOVING Or uMsg = #WM_SIZING Or uMsg = #WM_PAINT
    PaintForm()
  EndIf
  ProcedureReturn Result
EndProcedure

Procedure PaintForm()
  PaintDesktop_(GetDC_(WindowID(#Window_0)))
EndProcedure
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

Re: "Seethrough" window

Post by NoahPhense »

Gives me a black window..

- np
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Do you have black as the desktop background colour? :lol:
sec
Enthusiast
Enthusiast
Posts: 792
Joined: Sat Aug 09, 2003 3:13 am
Location: 90-61-92 // EU or ASIA
Contact:

Post by sec »

This makes me remembler 'walkthroughs' in a stage of Windows XP installion :)
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

Post by NoahPhense »

Trond wrote:Do you have black as the desktop background colour? :lol:
Yeah.. <g>

- np
va!n
Addict
Addict
Posts: 1104
Joined: Wed Apr 20, 2005 12:48 pm

Post by va!n »

very awesome! really cool! nice work! :wink:
Blade
Enthusiast
Enthusiast
Posts: 362
Joined: Wed Aug 06, 2003 2:49 pm
Location: Venice - Italy, Japan when possible.
Contact:

Post by Blade »

NoahPhense wrote: Yeah.. <g>
Real programmers don't use background images.
My wife do. She isn't a programmer :wink:
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> Real programmers don't use background images

Hehehe, I agree -- my Desktop is plain black. :)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

Post by NoahPhense »

PB wrote:> Real programmers don't use background images

Hehehe, I agree -- my Desktop is plain black. :)
Black Rules..

btw - i tried the trick.. nice.. now make it not jumpy...

That will be a trick.. ;)

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

Post by Sparkie »

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 *
Last edited by Sparkie on Tue May 31, 2005 1:20 pm, edited 1 time in total.
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
benny
Enthusiast
Enthusiast
Posts: 465
Joined: Fri Apr 25, 2003 7:44 pm
Location: end of www
Contact:

Post by benny »

@Tron:

n1


@Sparkie:

Nice improvements ... runs really smooth now :!:
regards,
benny!
-
pe0ple ar3 str4nge!!!
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

Sparkie, how about adapting it to show whatever's under the window, instead
of just the Desktop? ;)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

@benny: Thanks :)

@PB: You know I can't turn down a challenge. :P :wink:
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
akee
Enthusiast
Enthusiast
Posts: 498
Joined: Wed Aug 18, 2004 9:52 am
Location: Penang, Malaysia

Post by akee »

yup! you could even have a 50% transparent window...
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

@Sparkie: Wow, if THAT wasn't perfectly smoooooth I don't know what is.

@akie: 50% transparent window can easily be achieved by an entirely different technique:

Code: Select all

;99% of code from PORFIRIO
Procedure SetWinTransparency(win,level) 
 If level>=0 And level<256 
   hLib = LoadLibrary_("user32.dll") 
   If hLib 
     adr = GetProcAddress_(hLib,"SetLayeredWindowAttributes") 
     If adr 
       SetWindowLong_(WindowID(win),#GWL_EXSTYLE,GetWindowLong_(WindowID(win),#GWL_EXSTYLE)|$00080000); #WS_EX_LAYERED = $00080000 
       CallFunctionFast(adr,WindowID(win),0,level,2) 
     EndIf 
     FreeLibrary_(hLib) 
   EndIf 
 EndIf 
EndProcedure 

OpenWindow(0,0,0,300,300,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"Layered Window") 
 SetWinTransparency(0,128)
 If CreateGadgetList(WindowID()) 
   ButtonGadget(0,10,10,200,30,"Test")
 EndIf
Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
Post Reply