(LONG lStyle=GetWindowLong(Hwnd, GWL_STYLE
SetWindowLong Hwnd,GWL_STYLE, lStyle And Not WS_SYSMENU
If I removed the caption and then changed the client area on WM_NCCALCSIZE that would alow me to alocate some space for the nonclient caption that I need to draw! I really think this could work... I'm already modifying the client area a little as it is in
... WM_NCCALCSIZE
SetWindowLong(Handle, GWL_STYLE, GetWindowLong(Handle, GWL_STYLE) and (not
WS_CAPTION) or WS_THICKFRAME)
private { Private declarations } FDownButton: TRect
FUpButton: TRect
FCloseButton: TRect
FYCaption, FXTtlBit, FYTtlBit: Integer
const BTN_TOP = 10
const htCloseBtn = htSizeLast + 100 htDropBtn = htSizeLast + 101 htCloseUpBtn = htSizeLast + 102
: Procedure DrawTitleButton
FXTtlBit=GetSystemMetrics(SM_CXSIZE)'Button Width
FYTtlBit=GetSystemMetrics(SM_CYSIZE) 'Button Height
(FYCaption=GetSystemMetrics(SM_CYCAPTION
Caption Height'
FCloseButton=Width-FXTtlBit-5,BTN_TOP,FXTtlBit,FYTtlBit
FDownButton=Width-(2 * FXTtlBit)-3
(BTN_TOP,FXTtlBit,FYTtlBit,
FUpButton=Width-(3 * FXTtlBit)-1
(BTN_TOP,FXTtlBit,FYTtlBit,
GetWindowDc
FillRect
: Message WM_NCACTIVATE
DrawTitleButton
:Message WM_NCHITTEST
if PtInRect(FCloseButton,Point(XPos- Left,YPos-Top)) then
DrawTitleButton
Result=htCloseBtn
End if
if PtInRect(FDownButton,Point(XPos-Left,YPos-Top)) then
DrawTitleButton
Result=htDropBtn
End If
if PtInRect(FUpButton,Point(XPos-Left, YPos-Top)) then
DrawTitleButton
Result=htCloseUpBtn
End if
: Message WM_NCLBUTTONDOWN
if (Msg.HitTest=htCloseBtn) then
DrawTitleButton
End if
if (Msg.HitTest=htDropBtn) then
DrawTitleButton
End if
if (Msg.HitTest=htCloseUpBtn) then
DrawTitleButton
End if
: Procedure FoldDown
if ClientHeight=0 then ClientHeight= 100
: Procedure FoldUp
if ClientHeight > 0 then ClientHeight= 0
: Message WM_NCLBUTTONUP
wParam'
The hit-test value returned by the'
DefWindowProc function as a result 'of processing the'
WM_NCHITTEST message. For a list 'of hit-test values
see WM_NCHITTEST'
lParam'
A POINTS structure that contains the x-'and coordinates of the cursor. The 'coordinates are relative'to the upper-left 'corner of the screen'
if (Msg.HitTest=htCloseBtn) then
Hide
End if
if (Msg.HitTest=htDropBtn) then FoldDown
End if
if (Msg.HitTest=htCloseUpBtn) then FoldUp
End if
: Message WM_NCPAINT
DrawTitleButton
Draw your custom buttons where the caption would normally place them. Position doesn't matter. In the WM_COMMAND
section of your callback, use ShowWindow(hwnd, SW_MAXIMIZE)
and ShowWindow(hwnd, SW_RESTORE)
. That's all there is to it.