Any ideas how? This little tool will be windows only, so if it takes API, then please be Windows API
Window With Border Without Caption
Window With Border Without Caption
I'm trying to create a little popup window that takes the system theme (in terms of the window border) but it is to be captionless.
Any ideas how? This little tool will be windows only, so if it takes API, then please be Windows API
Any ideas how? This little tool will be windows only, so if it takes API, then please be Windows API
Re: Window With Border Without Caption
Hi Foz
Tested with Win 7 x64
Tested with Win 7 x64
Code: Select all
hWnd = OpenWindow(0,0,0,640,480,"",#PB_Window_BorderLess|#WS_THICKFRAME| #PB_Window_ScreenCentered)
WindowBounds(0, 640, 480, 640, 480)
SetWindowColor(0,$000000)
TextGadget(1,200,20,240,40,"Hi Foz",#SS_CENTERIMAGE | #SS_CENTER| #WS_BORDER)
LoadFont(1, "BroadWay", 16)
SetGadgetFont(1, FontID(1))
SetGadgetColor(1, #PB_Gadget_FrontColor, $0102FE)
SetGadgetColor(1, #PB_Gadget_BackColor, $B5FFFE)
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
Select EventGadget()
EndSelect
Case #PB_Event_CloseWindow
End
Case #WM_LBUTTONDOWN ;Move Borderless Windows / Resize Capture
SendMessage_(hWnd, #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
EndSelect
Until quit
Egypt my love
- Kwai chang caine
- Always Here

- Posts: 5499
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: Window With Border Without Caption
Cool the tips little border 3D with #WS_THICKFRAME
Thanks
Thanks
The happiness is a road...Not a destination
Re: Window With Border Without Caption
Ahhh the hidden styles of Windows! Perfect!
Thanks!
Thanks!
Re: Window With Border Without Caption
You are welcome Foz
Thanks KCC
Code modified to fit XP & 2003
Thanks KCC
Code modified to fit XP & 2003
Code: Select all
hWnd = OpenWindow(0,0,0,640,480,"",#PB_Window_BorderLess|#PB_Window_ScreenCentered)
SetWindowColor(0,$000000)
If OSVersion() >= #PB_OS_Windows_Vista
SetWindowLongPtr_(WindowID(0), #GWL_STYLE, GetWindowLongPtr_(WindowID(0), #GWL_STYLE)|#WS_THICKFRAME)
WindowBounds(0, 640, 480, 640, 480)
Else
dc=GetDC_(WindowID(0))
SelectObject_(dc,CreatePen_(#PS_SOLID,10,GetSysColor_(#COLOR_ACTIVECAPTION)))
BeginPath_(dc)
Rectangle_(dc,0,0,640,480)
;RoundRect_(dc,0,0,640,480,10,10) ;Round Rect
EndPath_(dc)
EndIf
TextGadget(1,200,20,240,40,"Hi Foz",#SS_CENTERIMAGE | #SS_CENTER| #WS_BORDER)
LoadFont(1, "BroadWay", 16)
SetGadgetFont(1, FontID(1))
SetGadgetColor(1, #PB_Gadget_FrontColor, $0102FE)
SetGadgetColor(1, #PB_Gadget_BackColor, $B5FFFE)
Repeat
StrokePath_(dc)
Select WaitWindowEvent()
Case #PB_Event_Gadget
Select EventGadget()
EndSelect
Case #PB_Event_CloseWindow
End
Case #WM_LBUTTONDOWN
SendMessage_(hWnd, #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
EndSelect
Until quit
Egypt my love
Re: Window With Border Without Caption
On Windows XP it's not so clever... is there some redraw update that needs to be performed?
Re: Window With Border Without Caption
See next
Code: Select all
hWnd = OpenWindow(0,0,0,640,480,"",#PB_Window_BorderLess|#PB_Window_ScreenCentered)
If OSVersion() >= #PB_OS_Windows_Vista
;SetWindowColor(0,$000000)
SetWindowLongPtr_(WindowID(0), #GWL_STYLE, GetWindowLongPtr_(WindowID(0), #GWL_STYLE)|#WS_THICKFRAME)
WindowBounds(0, 640, 480, 640, 480)
Else
SetWindowColor(0,GetSysColor_(#COLOR_ACTIVECAPTION))
OpenWindow(1, 4, 4, 632,472, "", #PB_Window_BorderLess)
;SetWindowColor(1,$000000)
SetParent_(WindowID(1), WindowID(0))
EndIf
TextGadget(1,200,20,240,40,"Hi Foz",#SS_CENTERIMAGE | #SS_CENTER| #WS_BORDER)
LoadFont(1, "BroadWay", 16)
SetGadgetFont(1, FontID(1))
SetGadgetColor(1, #PB_Gadget_FrontColor, $0102FE)
SetGadgetColor(1, #PB_Gadget_BackColor, $B5FFFE)
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
Select EventGadget()
EndSelect
Case #PB_Event_CloseWindow
End
Case #WM_LBUTTONDOWN
SendMessage_(hWnd, #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
EndSelect
Until quit
Egypt my love
Re: Window With Border Without Caption
@RASHAD: IMHO there is a missing ReleaseCapture in your code:
Greetings ... Kiffi
Code: Select all
[...]
ReleaseCapture_()
SendMessage_(hWnd, #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
[...]Hygge
Re: Window With Border Without Caption
Thanks Kiffi
Usually I do not care about too many things because I belief that the forum members
are much better than me
Beside what I post is always ver 0.0 then after I finish it (in that case it will be ver 10.0
) I save it to my archive
Thanks again Kiffi
Have a good day mate
Usually I do not care about too many things because I belief that the forum members
are much better than me
Beside what I post is always ver 0.0 then after I finish it (in that case it will be ver 10.0
Thanks again Kiffi
Have a good day mate
Egypt my love
Re: Window With Border Without Caption
For Windows 7 and Vista, something like this maybe using DWM? Can be made borderless or captionless or both if thats what you want. A piece of code that i originally posted a while back...
for borderless and no title make these changes
And... combined with the code already posted - no caption and windows 'theme' (if dwm used);
Code: Select all
#DWM_BB_ENABLE = 1
#DWM_BB_BLURREGION = 2
#DWM_BB_TRANSITIONONMAXIMIZED = 4
Structure DWM_BLURBEHIND
dwFlags.l
fEnable.b
hRgnBlur.l
fTransitionOnMaximized.b
EndStructure
Procedure EnableBlurBehindWindow(hWnd.l, enable.b = #True, region.l = 0, transitionOnMaximized.b = #False)
blurBehind.DWM_BLURBEHIND
blurBehind\dwFlags = #DWM_BB_ENABLE | #DWM_BB_TRANSITIONONMAXIMIZED
;blurBehind\dwFlags = #DWM_BB_ENABLE
blurBehind\fEnable = enable
blurBehind\fTransitionOnMaximized = transitionOnMaximized
Lib = LoadLibrary_("dwmapi.dll") ; load the library
If Lib
If (enable And 0) <> region
blurBehind\dwFlags = #DWM_BB_BLURREGION
blurBehind\hRgnBlur = region
EndIf
*pAfunc = GetProcAddress_(Lib, "DwmEnableBlurBehindWindow")
CallFunctionFast(*pAfunc, hWnd, @blurBehind) ; call the function
MessageRequester("Information", "Blur Behind is enabled", #PB_MessageRequester_Ok)
FreeLibrary_(Lib)
EndIf
ProcedureReturn ; returns 1 if function called sucessfully
EndProcedure
hWnd.l = OpenWindow(0,100,100,300,300, "", #PB_Window_Tool)
Color = RGB(000, 000, 000)
SetWindowColor(0, Color)
;will not see DWM blur glass effect in PB windows unless we
;change the client area color to something less 'white' (opaque).
;We need to paint our own color for windows here. don't use white
;(255,255,255) or similar as will not see blur effect very well
;some colors look a whole lot better. Vista DWM uses ARGB
;I just do a simple quick set window color here for demo purposes
EnableBlurBehindWindow(hWnd.l)
Repeat
Event = WindowEvent()
If Event ; event in queue then process
Else
Delay(1) ; No queue event, CPU time for something else
EndIf
Until Event = #PB_Event_CloseWindow
Code: Select all
change:
OpenWindow(0,100,100,300,300, "", #PB_Window_Tool)
to
OpenWindow(0,100,100,300,300, "", #PB_Window_BorderLess)
Code: Select all
#DWM_BB_ENABLE = 1
#DWM_BB_BLURREGION = 2
#DWM_BB_TRANSITIONONMAXIMIZED = 4
Structure DWM_BLURBEHIND
dwFlags.l
fEnable.b
hRgnBlur.l
fTransitionOnMaximized.b
EndStructure
Procedure EnableBlurBehindWindow(hWnd.l, enable.b = #True, region.l = 0, transitionOnMaximized.b = #False)
blurBehind.DWM_BLURBEHIND
blurBehind\dwFlags = #DWM_BB_ENABLE | #DWM_BB_TRANSITIONONMAXIMIZED
;blurBehind\dwFlags = #DWM_BB_ENABLE
blurBehind\fEnable = enable
blurBehind\fTransitionOnMaximized = transitionOnMaximized
Lib = LoadLibrary_("dwmapi.dll") ; load the library
If Lib
If (enable And 0) <> region
blurBehind\dwFlags = #DWM_BB_BLURREGION
blurBehind\hRgnBlur = region
EndIf
*pAfunc = GetProcAddress_(Lib, "DwmEnableBlurBehindWindow")
CallFunctionFast(*pAfunc, hWnd, @blurBehind) ; call the function
;MessageRequester("Information", "Blur Behind is enabled", #PB_MessageRequester_Ok)
FreeLibrary_(Lib)
EndIf
ProcedureReturn ; returns 1 if function called sucessfully
EndProcedure
hWnd = OpenWindow(0,0,0,640,480,"",#PB_Window_BorderLess|#PB_Window_ScreenCentered)
If OSVersion() >= #PB_OS_Windows_Vista
;SetWindowColor(0,$000000)
SetWindowLongPtr_(WindowID(0), #GWL_STYLE, GetWindowLongPtr_(WindowID(0), #GWL_STYLE)|#WS_THICKFRAME)
WindowBounds(0, 640, 480, 640, 480)
Color = RGB(000, 000, 000)
SetWindowColor(0, Color)
EnableBlurBehindWindow(hWnd)
Else
SetWindowColor(0,GetSysColor_(#COLOR_ACTIVECAPTION))
OpenWindow(1, 4, 4, 632,472, "", #PB_Window_BorderLess)
;SetWindowColor(1,$000000)
SetParent_(WindowID(1), WindowID(0))
EndIf
TextGadget(1,200,20,240,40,"Hi Foz",#SS_CENTERIMAGE | #SS_CENTER| #WS_BORDER)
LoadFont(1, "BroadWay", 16)
SetGadgetFont(1, FontID(1))
SetGadgetColor(1, #PB_Gadget_FrontColor, $0102FE)
Colorback = RGB(000, 000, 255)
SetGadgetColor(1, #PB_Gadget_BackColor, Colorback)
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
Select EventGadget()
EndSelect
Case #PB_Event_CloseWindow
End
Case #WM_LBUTTONDOWN
ReleaseCapture_()
SendMessage_(hWnd, #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
EndSelect
Until quit
Last edited by SFSxOI on Fri Sep 09, 2011 1:46 pm, edited 1 time in total.
The advantage of a 64 bit operating system over a 32 bit operating system comes down to only being twice the headache.
Re: Window With Border Without Caption
XP is now sorted and a *really* cool effect with DWM! 
Thanks Guys!
Thanks Guys!
- Michael Vogel
- Addict

- Posts: 2819
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Re: Window With Border Without Caption
Need to create a window without caption with exact size, but I need to enlarge it by 14 pixels to get the correct result. Didn't find a system metrics value which matches to the difference, the results of the WindowWidth/Height commands are do not help either.
Code: Select all
plusx=14; GetSystemMetrics_(#SM_CXBORDER)*2
plusy=14; GetSystemMetrics_(#SM_CYCAPTION), GetSystemMetrics_(#SM_CXDLGFRAME)*2; ?
x=OpenWindow(0,0,0,400+plusx,200+plusy,"",#PB_Window_BorderLess|#PB_Window_ScreenCentered)
SetWindowLongPtr_(x,#GWL_STYLE,GetWindowLongPtr_(x,#GWL_STYLE)|#WS_THICKFRAME)
;Debug WindowHeight(0,#PB_Window_FrameCoordinate)-WindowHeight(0)
TextGadget(1,0,0,390,190,"X",#SS_CENTERIMAGE|#SS_CENTER|#WS_BORDER)
TextGadget(2,390,0,10,190,">",#SS_CENTERIMAGE|#SS_CENTER|#WS_BORDER)
TextGadget(3,0,190,390,10,"V",#SS_CENTERIMAGE|#SS_CENTER|#WS_BORDER)
TextGadget(4,390,190,10,10,"\",#SS_CENTERIMAGE|#SS_CENTER|#WS_BORDER)
Repeat : Select WaitWindowEvent() : Case #PB_Event_CloseWindow,#WM_CHAR : End : EndSelect : ForEver
Re: Window With Border Without Caption
Hi
Code: Select all
AdjustWindowRectEx_(r.RECT,#PB_Window_BorderLess | #WS_THICKFRAME,0,0)
plusx = -2*r\left
plusy = -2*r\top
x=OpenWindow(0,0,0,400+plusx,200+plusy,"",#PB_Window_BorderLess|#PB_Window_ScreenCentered)
SetWindowLongPtr_(x,#GWL_STYLE,GetWindowLongPtr_(x,#GWL_STYLE)|#WS_THICKFRAME)
;Debug WindowHeight(0,#PB_Window_FrameCoordinate)-WindowHeight(0)
TextGadget(1,0,0,390,190,"X",#SS_CENTERIMAGE|#SS_CENTER|#WS_BORDER)
TextGadget(2,390,0,10,190,">",#SS_CENTERIMAGE|#SS_CENTER|#WS_BORDER)
TextGadget(3,0,190,390,10,"V",#SS_CENTERIMAGE|#SS_CENTER|#WS_BORDER)
TextGadget(4,390,190,10,10,"\",#SS_CENTERIMAGE|#SS_CENTER|#WS_BORDER)
Repeat : Select WaitWindowEvent() : Case #PB_Event_CloseWindow,#WM_CHAR : End : EndSelect : ForEver
Egypt my love
- Michael Vogel
- Addict

- Posts: 2819
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Re: Window With Border Without Caption
Cool, but...
...for my special case there's still a delta of one single pixel
I'm sure, I am doing something wrong in the following line:
ResizeWindow(1,GadgetX(.)+WindowX(0,Inside)-[WindowX(0,Inside)-WindowX(0)]-#StringGadgetBorder + 1,GadgetY(.)+WindowY(0,Inside)-EditOffsetY-StringGadgetOffset,...)
...for my special case there's still a delta of one single pixel
I'm sure, I am doing something wrong in the following line:
ResizeWindow(1,GadgetX(.)+WindowX(0,Inside)-[WindowX(0,Inside)-WindowX(0)]-#StringGadgetBorder + 1,GadgetY(.)+WindowY(0,Inside)-EditOffsetY-StringGadgetOffset,...)
Code: Select all
Global StringGadgetOffset
Procedure StringGadgetInitialize(GadgetID)
#StringGadgetBorder=6
#StringGadgetHeight=28
Protected hdc
Protected fsz.Size
Protected Rect.Rect
Protected font
font=GetGadgetFont(GadgetID)
GadgetID=GadgetID(GadgetID)
hdc=GetDC_(GadgetID)
SelectObject_(hdc,font)
GetTextExtentPoint32_(hdc,"|",1,fsz)
ReleaseDC_(GadgetID,hdc)
GetWindowRect_(GadgetID,Rect)
StringGadgetOffset=Rect\bottom-Rect\top
StringGadgetOffset=StringGadgetOffset>>1-fsz\cy<<4/20; cy*16/20 (Text eher weiter oben) bis cy*16/22 (eher weiter unten)
EndProcedure
Procedure StringGadgetAlignment(GadgetID)
Protected hwndEdit
Protected erect.Rect
hwndEdit=GadgetID(GadgetID)
GetClientRect_(hwndEdit,eRect)
erect\left=#StringGadgetBorder
eRect\top=StringGadgetOffset
eRect\bottom=#StringGadgetHeight
SendMessage_(hwndEdit,#EM_SETRECT,0,eRect)
EndProcedure
Procedure ResizeComboGadget(gadget,x,y,width,height)
ResizeGadget(gadget,x,y,width,height)
If GetActiveGadget()<>gadget
SendMessage_(GadgetID(gadget),#CB_SETEDITSEL,0,-1)
EndIf
EndProcedure
Enumeration 1000
#keyF4
#keyOk
#keyCancel
#keyEscape
EndEnumeration
WinID=OpenWindow(0,0,0,400,200,"",#WS_SYSMENU|#PB_Window_ScreenCentered|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget)
TextGadget(1,20,30,60,20,"Datei&name:",#SS_CENTERIMAGE)
ComboBoxGadget(2,95,29,207,22,#PB_ComboBox_Editable)
TextGadget(4,20,80,75,20,"&Erweiterung:",#SS_CENTERIMAGE)
ComboBoxGadget(5,95,79,125,22,#PB_ComboBox_Editable)
SetGadgetText(2,"Press F4 to edit....")
SetGadgetText(5,"Press F4 to edit....")
r.rect
AdjustWindowRectEx_(r,#PB_Window_BorderLess|#WS_THICKFRAME,0,0)
EditOffsetX=-r\left
EditOffsetY=-r\top
OpenWindow(1,0,0,800+EditOffsetX<<1,#StringGadgetHeight+EditOffsetY<<1,"",#PB_Window_Invisible|#PB_Window_BorderLess,WinID)
SetWindowLongPtr_(WindowID(1),#GWL_STYLE,GetWindowLongPtr_(WindowID(1),#GWL_STYLE)|#WS_THICKFRAME)
StringGadget(9,0,0,800,#StringGadgetHeight,"",#ES_MULTILINE)
StringGadgetInitialize(9)
StringGadgetAlignment(9)
AddKeyboardShortcut(0,#PB_Shortcut_F4,#keyF4)
AddKeyboardShortcut(0,#PB_Shortcut_Escape,#keyEscape)
AddKeyboardShortcut(1,#PB_Shortcut_F4,#keyOk)
AddKeyboardShortcut(1,#PB_Shortcut_Return,#keyOk)
AddKeyboardShortcut(1,#PB_Shortcut_Escape,#keyCancel)
SetActiveGadget(2)
Repeat
Select WaitWindowEvent()
Case #PB_Event_Menu,#PB_Event_Gadget
etype=EventType()
egadget=EventGadget()
Select egadget
Case #keyOk
If EditMode
HideWindow(1,1)
DisableWindow(0,0)
SetGadgetText(EditMode,GetGadgetText(9))
SetActiveGadget(EditMode)
EditMode=0
EndIf
Case #keyCancel
If EditMode
HideWindow(1,1)
DisableWindow(0,0)
SetActiveGadget(EditMode)
EditMode=0
EndIf
Case #keyF4
n=GetActiveGadget()
If n>0 And GadgetType(n)=#PB_GadgetType_ComboBox
SetGadgetText(9,GetGadgetText(n))
EditMode=n
n=WindowX(0,#PB_Window_InnerCoordinate)-WindowX(0)
ResizeWindow(1,GadgetX(EditMode)+WindowX(0,#PB_Window_InnerCoordinate)-n-#StringGadgetBorder+1,GadgetY(EditMode)+WindowY(0,#PB_Window_InnerCoordinate)-EditOffsetY-StringGadgetOffset,#PB_Ignore,#PB_Ignore)
DisableWindow(0,1)
HideWindow(1,0)
SetActiveGadget(9)
EndIf
Case #keyEscape
End
EndSelect
Case #PB_Event_CloseWindow
End
EndSelect
ForEver
Re: Window With Border Without Caption
Hi MV
For each window you have to run AdjustWindowRectEx_() with it's flags to get the proper dimensions
For each window you have to run AdjustWindowRectEx_() with it's flags to get the proper dimensions
Code: Select all
AdjustWindowRectEx_(r.RECT,#WS_SYSMENU|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget,0,0)
EditOffsetX=-r\left
EditOffsetY=-r\top
Debug EditOffsetX
Debug EditOffsetY
AdjustWindowRectEx_(r2.RECT,#PB_Window_BorderLess | #WS_THICKFRAME,0,0)
EditOffsetX2=-r2\left
EditOffsetY2=-r2\top
Debug EditOffsetX2
Debug EditOffsetY2
WinID=OpenWindow(0,0,0,400,200,"",#WS_SYSMENU|#PB_Window_ScreenCentered|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget)
TextGadget(1,20,30,60,20,"Datei&name:",#SS_CENTERIMAGE)
ComboBoxGadget(2,95,29,207,22,#PB_ComboBox_Editable)
TextGadget(4,20,80,75,20,"&Erweiterung:",#SS_CENTERIMAGE)
ComboBoxGadget(5,95,79,125,22,#PB_ComboBox_Editable)
SetGadgetText(2,"Press F4 to edit....")
SetGadgetText(5,"Press F4 to edit....")
OpenWindow(1,0,0,800+EditOffsetX<<1,#StringGadgetHeight+EditOffsetY<<1,"",#PB_Window_Invisible|#PB_Window_BorderLess,WinID)
SetWindowLongPtr_(WindowID(1),#GWL_STYLE,GetWindowLongPtr_(WindowID(1),#GWL_STYLE)|#WS_THICKFRAME)
Egypt my love
