change height of title (foreign window)

Just starting out? Need help? Post your questions and find answers here.
ZX80
Enthusiast
Enthusiast
Posts: 330
Joined: Mon Dec 12, 2016 1:37 pm

change height of title (foreign window)

Post by ZX80 »

sorry for the simple question, but I want to know if it's possible. handle of target window is determinate. and now need reduce title bar to some pixels. for example, was 21 became 4. it may be necessary to somehow increase client area? or apply skin? important: should not be resident (hook etc.). only change style of window if it possible. and only for a target window. not for all. I was recommended the API DwmExtendFrameIntoClientArea. can anybody help me with this extraordinary task?
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8425
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: change height of title (foreign window)

Post by netmaestro »

I've never used that api before but I thought I'd give it a try. I have the function working and succeeding but the visual look of the window doesn't change. Maybe someone knows why:

Code: Select all

Prototype DwmExtendFrameIntoClientArea(hwnd, *margins)

dwmapi = OpenLibrary(#PB_Any, "dwmapi.dll")
Global DwmExtendFrameIntoClientArea_.DwmExtendFrameIntoClientArea = GetFunction(dwmapi, "DwmExtendFrameIntoClientArea")

Structure MARGINS
  cxLeftWidth.w
  cxRightWidth.w
  cyTopHeight.w
  cyBottomHeight.w
EndStructure
  
With margins.MARGINS
  \cxLeftWidth    = 0
  \cxRightWidth   = 0
  \cyTopHeight    = 0
  \cyBottomHeight = 40  
EndWith

OpenWindow(0,0,0,640,480,"", #PB_Window_Invisible|#PB_Window_SystemMenu)

result = DwmExtendFrameIntoClientArea_(WindowID(0), @margins)
If result = #S_OK
  Debug "succeeded"
Else
  Debug "failed"
EndIf
HideWindow(0,0,#PB_Window_ScreenCentered)

Repeat:Until WaitWindowEvent() = #PB_Event_CloseWindow
BERESHEIT
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Re: change height of title (foreign window)

Post by nco2k »

the margins are stored as long, and not as word.

the easiest way to achieve this, would be by painting the client area black: https://msdn.microsoft.com/en-us/librar ... 85%29.aspx

Code: Select all

Prototype DwmExtendFrameIntoClientArea(hwnd, *margins)

dwmapi = OpenLibrary(#PB_Any, "dwmapi.dll")
Global DwmExtendFrameIntoClientArea_.DwmExtendFrameIntoClientArea = GetFunction(dwmapi, "DwmExtendFrameIntoClientArea")

Structure MARGINS
  cxLeftWidth.l
  cxRightWidth.l
  cyTopHeight.l
  cyBottomHeight.l
EndStructure
  
With margins.MARGINS
  \cxLeftWidth    = 0
  \cxRightWidth   = 0
  \cyTopHeight    = 0
  \cyBottomHeight = 40  
EndWith

OpenWindow(0,0,0,640,480,"", #PB_Window_Invisible|#PB_Window_SystemMenu)
SetClassLongPtr_(WindowID(0), #GCL_HBRBACKGROUND, GetStockObject_(#BLACK_BRUSH))

result = DwmExtendFrameIntoClientArea_(WindowID(0), @margins)
If result = #S_OK
  Debug "succeeded"
Else
  Debug "failed"
EndIf
HideWindow(0,0,#PB_Window_ScreenCentered)

Repeat:Until WaitWindowEvent() = #PB_Event_CloseWindow
c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8425
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: change height of title (foreign window)

Post by netmaestro »

So next hurdle now that it works: Can it be executed successfully on an unowned window? Unfortunately I'm out of playtime for now.
BERESHEIT
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Re: change height of title (foreign window)

Post by nco2k »

technically sure, but practically, you really dont want to go down this road. that would be a total redraw nightmare.

i dont really see the point in what ZX80 is trying to achieve to be honest. if you really want to do something like this, you should consider skinning your window. but personally, i prefer apps that arent skinned. having 10 apps with 8 different skins is pretty annoying if you ask me. there are only few types of apps, where it makes sense to apply a skin. also if you really want to do this, please dont try to mimic your operating systems skin. as soon as a new windows version comes out, your skin will look like ass.

c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
Post Reply