Page 1 of 2

"Seethrough" window

Posted: Mon May 30, 2005 3:29 pm
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

Re: "Seethrough" window

Posted: Mon May 30, 2005 3:53 pm
by NoahPhense
Gives me a black window..

- np

Posted: Mon May 30, 2005 3:58 pm
by Trond
Do you have black as the desktop background colour? :lol:

Posted: Mon May 30, 2005 4:48 pm
by sec
This makes me remembler 'walkthroughs' in a stage of Windows XP installion :)

Posted: Mon May 30, 2005 5:24 pm
by NoahPhense
Trond wrote:Do you have black as the desktop background colour? :lol:
Yeah.. <g>

- np

Posted: Mon May 30, 2005 6:30 pm
by va!n
very awesome! really cool! nice work! :wink:

Posted: Mon May 30, 2005 9:23 pm
by Blade
NoahPhense wrote: Yeah.. <g>
Real programmers don't use background images.
My wife do. She isn't a programmer :wink:

Posted: Mon May 30, 2005 9:55 pm
by PB
> Real programmers don't use background images

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

Posted: Tue May 31, 2005 12:51 am
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

Posted: Tue May 31, 2005 2:07 am
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 *

Posted: Tue May 31, 2005 11:22 am
by benny
@Tron:

n1


@Sparkie:

Nice improvements ... runs really smooth now :!:

Posted: Tue May 31, 2005 1:12 pm
by PB
Sparkie, how about adapting it to show whatever's under the window, instead
of just the Desktop? ;)

Posted: Tue May 31, 2005 6:10 pm
by Sparkie
@benny: Thanks :)

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

Posted: Tue May 31, 2005 6:18 pm
by akee
yup! you could even have a 50% transparent window...

Posted: Tue May 31, 2005 6:45 pm
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