🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
4 messages
4 total messages Started by Thorsten Kettner Tue, 07 Mar 2006 15:29
Custom button in title bar (MDI)
#4216
Author: Thorsten Kettner
Date: Tue, 07 Mar 2006 15:29
19 lines
1733 bytes
Hi, I am trying to place a custom button in the window's title 
bar. I am catching WM_NCPAINT to do this. This works fine. On 
WM_NCACTIVATE and WM_SETTEXT Windows would paint my button over 
and not send WM_NCPAINT. I avoid this by catching these too and
suppress their drawing and do mine instead. This works fine too.

My problem: My form is an MDI sheet. When I maximize it, my 
button gets painted over. There must be another event just like
WM_NCACTIVATE and WM_SETTEXT that does this. I just don't know
which one. Who knows? Which message must I catch and treat like
I do with WM_NCACTIVATE and WM_SETTEXT?

TIA.

PS: If anybody should look for a code sample on how to draw a
custom button in the title bar, I got my information here:

  http://www.catch22.net/tuts/titlebar.asp
Re: Custom button in title bar (MDI)
#4233
Author: Kent
Date: Thu, 09 Mar 2006 04:50
22 lines
1812 bytes
> My problem: My form is an MDI sheet. When I maximize it, my
> button gets painted over. There must be another event just like


From Windows help:

"An application sends the WM_MDIMAXIMIZE message to a multiple
document interface (MDI) client window to maximize an MDI child
window. Windows resizes the child window to make its client area fill
the client window. Windows places the child window's window menu icon
in the rightmost position of the frame window's menu bar, and places
the child window's restore icon in the leftmost position. Windows also
appends the title bar text of the child window to that of the frame
window."

Unless I'm missing something, when you maximize your window the title
bar is not shown hence the child's title bar text is appended to that
of the frame window.  So wouldn't your custom button need to be drawn
on the title bar of the main window when the child is maximized?

Kent
Re: Custom button in title bar (MDI)
#4151
Author: Thorsten Kettner
Date: Fri, 10 Mar 2006 08:55
9 lines
1285 bytes
"Kent" <kentav@accessus.net> wrote:
>Unless I'm missing something, when you maximize your window 
>the title bar is not shown hence the child's title bar text is 
>appended to that of the frame window.  So wouldn't your custom 
>button need to be drawn on the title bar of the main window 
>when the child is maximized?

That makes sense. I am going to check it out. Thanx Kent.
Re: Custom button in title bar (MDI)
#4153
Author: JD
Date: Fri, 10 Mar 2006 11:09
34 lines
2342 bytes
"Thorsten Kettner" <QUESTIONBYthorsten.kettner@otto.de> wrote:
>
>"Kent" <kentav@accessus.net> wrote:
>>Unless I'm missing something, when you maximize your window 
>>the title bar is not shown hence the child's title bar text is 
>>appended to that of the frame window.  So wouldn't your custom 
>>button need to be drawn on the title bar of the main window 
>>when the child is maximized?
>
>That makes sense. I am going to check it out. Thanx Kent.

My tests confirm it. I'm thinking that you'll have to duplicate
and implement the same code in the main form with some minor
changes to correctly calculate the placement of the button(s).

If you override the mdiChild's WndProc method and intercept
WM_SYSCOMMAND (testing WParam for SC_MINIMIZE, SC_MAXIMIZE
and SC_RESTORE), you can send a custom message to the main
form to activate or deactivate the code accordingly.

To correctly calculate the first button placement:

    TRect R;
    int NumberOfDefaultButtons = 3;
    R.top = ::GetSystemMetrics( SM_CYCAPTION ) + ::GetSystemMetrics( SM_CYFRAME );
    R.bottom = R.top + ::GetSystemMetrics( SM_CYMENU );
    R.right = Application->MainForm->Width - (::GetSystemMetrics(SM_CXFRAME) + (::GetSystemMetrics(SM_CXMENUSIZE) * NumberOfDefaultButtons));
    R.left = R.right - ::GetSystemMetrics( SM_CXMENUSIZE );

Note that the calculated TRect assumes a normal window with
left to right alignment.

~ JD
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads