How to make program Frameless image window ?

Just starting out? Need help? Post your questions and find answers here.
vmars316
Enthusiast
Enthusiast
Posts: 474
Joined: Fri Jun 29, 2012 12:24 am
Contact:

How to make program Frameless image window ?

Post by vmars316 »

Hello;
My new laptop screen is too bright even at lowest brightness setting (causes migraines) :
So I am hoping I can make a program that shows a semi-transparent one-color image in a Frameless window .
So:
1) Frameless window .
(A sliver of a Frames would be acceptable if it was at
screen edge . )
2) Variable transparency setting .
3 Always on top .
4) Can click-thru on anything behind transparent window .

Notepad++ has a %transparency setting for Find window but it's not click-thru .

Is it possible to create such a program or
is there a sample of such ?

Thanks
vmars.us Win11 x64 , Martin Guitar 000-16 (1995)
"All things in moderation , except for love and forgiveness."
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: How to make program Frameless image window ?

Post by JHPJHP »

Hi vmars316,

Try the following:
- use the Esc key to close the window
Windows Services & Other Stuff\Other_Stuff\OtherStuff\TransparentWindow.pb
Last edited by JHPJHP on Wed Dec 16, 2020 11:47 pm, edited 1 time in total.
infratec
Always Here
Always Here
Posts: 6883
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: How to make program Frameless image window ?

Post by infratec »

Since the ESC key is also used by other programs, I modified JHPJHPs code to use a systray icon for program termination.

Code: Select all

EnableExplicit

Define lpRect.RECT

GetWindowRect_(GetDesktopWindow_(), @lpRect)
If OpenWindow(0, 0, 0, lpRect\right, lpRect\bottom, #Null$, #PB_Window_Invisible | #PB_Window_BorderLess | #PB_Window_NoGadgets | #PB_Window_NoActivate)
  StickyWindow(0, #True)
  SetWindowColor(0, $000000)
  
  SetWindowLongPtr_(WindowID(0), #GWL_EXSTYLE, #WS_EX_LAYERED | #WS_EX_TOOLWINDOW | #WS_EX_TRANSPARENT)
  SetLayeredWindowAttributes_(WindowID(0), $F0F0F0, 144, #LWA_COLORKEY | #LWA_ALPHA)
  SetWindowPos_(WindowID(0), #HWND_TOPMOST, 0, 0, 0, 0, #SWP_NOACTIVATE | #SWP_SHOWWINDOW | #SWP_ASYNCWINDOWPOS | #SWP_DEFERERASE | #SWP_NOCOPYBITS | #SWP_NOMOVE | #SWP_NOREDRAW | #SWP_NOSENDCHANGING | #SWP_NOSIZE)
  
  HideWindow(0, #False)
  
  AddSysTrayIcon(1, WindowID(0), CatchImage(0, ?Icon, ?IconEnd - ?Icon))
  SysTrayIconToolTip(1, "Click to exit")
  
  Repeat    
    If WaitWindowEvent() = #PB_Event_SysTray
      If EventType() = #PB_EventType_LeftClick
        Break
      EndIf
    EndIf
  ForEver
  
EndIf

DataSection
  Icon:
  IncludeBinary #PB_Compiler_Home + "examples/sources/Data/CdPlayer.ico"
  IconEnd:
EndDataSection
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4664
Joined: Sun Apr 12, 2009 6:27 am

Re: How to make program Frameless image window ?

Post by RASHAD »

Hi
@JHPJHP
Good one mate except using hook did some trouble to me

@infratec
Using SysTray did the job
I did not think about such solution :)

Thanks guys
Egypt my love
vmars316
Enthusiast
Enthusiast
Posts: 474
Joined: Fri Jun 29, 2012 12:24 am
Contact:

Re: How to make program Frameless image window ?

Post by vmars316 »

JHPJHP wrote:Hi vmars316,

Try the following:
- use the Esc key to close the window
Windows Services & Other Stuff\Other_Stuff\OtherStuff\TransparentWindow.pb
Pls , how do I get an access key to download ?
Thanks
vmars.us Win11 x64 , Martin Guitar 000-16 (1995)
"All things in moderation , except for love and forgiveness."
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: How to make program Frameless image window ?

Post by JHPJHP »

Hi vmars316,

Please use the script posted by infratec.
vmars316
Enthusiast
Enthusiast
Posts: 474
Joined: Fri Jun 29, 2012 12:24 am
Contact:

Re: How to make program Frameless image window ?

Post by vmars316 »

JHPJHP wrote:Hi vmars316,
Please use the script posted by infratec.
Thanks,
I tested both , but both gives me this error:
Define lpRect.RECT ; Structure not found: RECT.
How can I fix this ?
Thanks
vmars.us Win11 x64 , Martin Guitar 000-16 (1995)
"All things in moderation , except for love and forgiveness."
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: How to make program Frameless image window ?

Post by JHPJHP »

Hi vmars316,

I assume you're using the demo version of PureBasic. I don't believe the free version of PureBasic supports API calls or Windows Structures.

Structures would be easy enough to solve, just create your own, but this example also requires access to Windows API's.
vmars316
Enthusiast
Enthusiast
Posts: 474
Joined: Fri Jun 29, 2012 12:24 am
Contact:

Re: How to make program Frameless image window ?

Post by vmars316 »

JHPJHP wrote:Hi vmars316,

I assume you're using the demo version of PureBasic. I don't believe the free version of PureBasic supports API calls or Windows Structures.

Structures would be easy enough to solve, just create your own, but this example also requires access to Windows API's.
Oops , Yes I was , I didn't see the Login button .
Works great with PureBasic_Windows_X64_LTS_5.73_(refx1s).exe .
Thanks
vmars.us Win11 x64 , Martin Guitar 000-16 (1995)
"All things in moderation , except for love and forgiveness."
vmars316
Enthusiast
Enthusiast
Posts: 474
Joined: Fri Jun 29, 2012 12:24 am
Contact:

Re: How to make program Frameless image window ?

Post by vmars316 »

infratec wrote:Since the ESC key is also used by other programs, I modified JHPJHPs code to use a systray icon for program termination.
Wow , That's a wonderful program ,
Thank you All !
vmars.us Win11 x64 , Martin Guitar 000-16 (1995)
"All things in moderation , except for love and forgiveness."
Post Reply