Rounded borderless editorgadget in a custom color window

Just starting out? Need help? Post your questions and find answers here.
firace
Addict
Addict
Posts: 946
Joined: Wed Nov 09, 2011 8:58 am

Rounded borderless editorgadget in a custom color window

Post by firace »

Struggling to get this to work... (for Windows)

This is my code right now:

Code: Select all

OpenWindow(0, 0, 0, 405, 240, "Rounded corners and Borderless", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ContainerGadget(10, 10, 10, 390, 220)  ;; only needed to make custom color window look good ;)

SetWindowColor(0, $565656)
SetGadgetColor(10, #PB_Gadget_BackColor, $565656)

EditorGadget(3, 10, 10, 330, 200)
SetGadgetColor(3, #PB_Gadget_BackColor, $D4B2B2)


AddGadgetItem(3, -1, "Harry Rannit"   + #LF$ +   "12 Parliament Way, By the Bay")

SetWindowLongPtr_(GadgetID(3),#GWL_EXSTYLE,GetWindowLongPtr_(GadgetID(3),#GWL_EXSTYLE)&~#WS_EX_CLIENTEDGE)   ;  borderless gadget!
setwindowTheme_(GadgetID(3), "", "")

SetWindowPos_(GadgetID(3), 0, 0, 0, 0, 0, #SWP_NOMOVE | #SWP_NOSIZE | #SWP_NOZORDER | #SWP_FRAMECHANGED)

CloseGadgetList()


hRgn = CreateRoundRectRgn_(0, 0, DesktopScaledX(GadgetWidth(3)), DesktopScaledY(GadgetHeight(3)), 12, 12)
SetWindowRgn_(GadgetID(3), hRgn, 1)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow 
firace
Addict
Addict
Posts: 946
Joined: Wed Nov 09, 2011 8:58 am

Re: Rounded borderless editorgadget in a custom color window

Post by firace »

Another failed attempt :)

Code: Select all

OpenWindow(0, 0, 0, 405, 240, "Round-Borderless!", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ContainerGadget(10, 10, 10, 390, 220)  ;; only needed to make custom color window look good ;)

SetWindowColor(0, $565656)
SetGadgetColor(10, #PB_Gadget_BackColor, $565656)
; 
EditorGadget(3, -2, -2, 394, 224)
SetGadgetColor(3, #PB_Gadget_BackColor, $D4B2B2)
AddGadgetItem(3, -1, "Harry Rannit"   + #LF$ +   "12 Parliament Way, By the Bay")

CloseGadgetList()


hRgn = CreateRoundRectRgn_(0, 0, DesktopScaledX(GadgetWidth(10)), DesktopScaledY(GadgetHeight(10)), 32, 32)
SetWindowRgn_(GadgetID(10), hRgn, 1)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow 
breeze4me
Enthusiast
Enthusiast
Posts: 633
Joined: Thu Mar 09, 2006 9:24 am
Location: S. Kor

Re: Rounded borderless editorgadget in a custom color window

Post by breeze4me »

Add another container or use a layered style control.

Code: Select all

OpenWindow(0, 0, 0, 405, 240, "Round-Borderless!", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

ContainerGadget(11, 10, 10, 390, 220)
  SetGadgetColor(11, #PB_Gadget_BackColor, $565656)
  
  ContainerGadget(10, 0, 0, 390, 220)  ;; only needed to make custom color window look good ;)
    
    SetWindowColor(0, $565656)
    SetGadgetColor(10, #PB_Gadget_BackColor, $565656)
    ; 
    
    EditorGadget(3, -2, -2, 394, 224)
    SetGadgetColor(3, #PB_Gadget_BackColor, $D4B2B2)
    AddGadgetItem(3, -1, "Harry Rannit"   + #LF$ +   "12 Parliament Way, By the Bay")
    
  CloseGadgetList()
  
CloseGadgetList()


hRgn = CreateRoundRectRgn_(0, 0, DesktopScaledX(GadgetWidth(10)), DesktopScaledY(GadgetHeight(10)), 32, 32)
SetWindowRgn_(GadgetID(10), hRgn, 1)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow 

Code: Select all

OpenWindow(0, 0, 0, 415, 240, "Round-Borderless!", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

SetWindowColor(0, $565656)

EditorGadget(3, 10, 10, 394, 224)
SetGadgetColor(3, #PB_Gadget_BackColor, $D4B2B2)
AddGadgetItem(3, -1, "Harry Rannit"   + #LF$ +   "12 Parliament Way, By the Bay")

w = DesktopScaledX(GadgetWidth(3))
h = DesktopScaledY(GadgetHeight(3))

If CreateImage(0, w, h, 24, $565656)
  If StartDrawing(ImageOutput(0))
    RoundBox(2, 2, w-4, h-4, 10, 10, #White)
    StopDrawing()
  EndIf
  ImageGadget(11, 10, 10, 0, 0, ImageID(0))
  BringWindowToTop_(GadgetID(11))
  
  SetWindowLongPtr_(GadgetID(11), #GWL_EXSTYLE, GetWindowLongPtr_(GadgetID(11), #GWL_EXSTYLE) | #WS_EX_LAYERED)
  SetLayeredWindowAttributes_(GadgetID(11), #White, 0, #LWA_COLORKEY)
EndIf

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow 
firace
Addict
Addict
Posts: 946
Joined: Wed Nov 09, 2011 8:58 am

Re: Rounded borderless editorgadget in a custom color window

Post by firace »

breeze4me: very clever, thanks.

first solution works great for me! (the second one has no effect here for some reason, maybe I should update my PB version)
breeze4me
Enthusiast
Enthusiast
Posts: 633
Joined: Thu Mar 09, 2006 9:24 am
Location: S. Kor

Re: Rounded borderless editorgadget in a custom color window

Post by breeze4me »

firace wrote: Sat Apr 12, 2025 12:44 pm (the second one has no effect here for some reason, maybe I should update my PB version)
Yes, you need to update your PB.
The manifest content of the executable should have a supportedOS entry for Windows 8.0. So it won't work on Windows 7 and earlier.
Post Reply