Article View: borland.public.cppbuilder.nativeapi
Article #4153Re: Custom button in title bar (MDI)
From: JD
Date: Fri, 10 Mar 2006 11:09
Date: Fri, 10 Mar 2006 11:09
34 lines
2342 bytes
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
Technical Details
Message-ID:
<44116c82$2@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news3.google.com!newshub.sdsu.edu!peer01.west.cox.net!cox.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<440db4f7$1@newsgroups.borland.com> <440fb3f6$1@newsgroups.borland.com> <44114d07$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,c1474b588c71f3fa X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "JD" <nospam@nospam.com> Sender: "JD" <nospam@nospam.com> Reply-To: "JD" <nospam@nospam.com> Subject: Re: Custom button in title bar (MDI) Newsgroups: borland.public.cppbuilder.nativeapi X-User-Info: 152.163.100.201 X-Forwarded-For: 172.149.148.106 References: <440db4f7$1@newsgroups.borland.com> <440fb3f6$1@newsgroups.borland.com> <44114d07$1@newsgroups.borland.com> NNTP-Posting-Host: 207.105.83.66 Message-ID: <44116c82$2@newsgroups.borland.com> Date: 10 Mar 2006 04:09:38 -0700 X-Trace: newsgroups.borland.com 1141992578 207.105.83.66 (10 Mar 2006 04:09:38 -0700) Lines: 35 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news3.google.com!newshub.sdsu.edu!peer01.west.cox.net!cox.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail