By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,773 Members | 1,778 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,773 IT Pros & Developers. It's quick & easy.

Form caption height

P: n/a
slg
Is there a simpler way to increase the mdi form caption height?

I am following this article but not sure where should i change?
I belive its most probably in the WmNCCalcSize
TIA

http://geekswithblogs.net/kobush/art...rderForms.aspx
Sep 3 '08 #1
Share this Question
Share on Google+
6 Replies


P: n/a

"slg" wrote:
Is there a simpler way to increase the mdi form caption height?
I'm afraid not
I am following this article but not sure where should i change?
I belive its most probably in the WmNCCalcSize
TIA

http://geekswithblogs.net/kobush/art...rderForms.aspx
There is an updated article on CodePlex

http://www.codeplex.com/Wiki/View.as...omerBorderForm

What you basically need to do is override the default handling of the Non
Client messages (NC_xxx) by overriding WndProc in your child form and route
some messages to your own code.

const int WM_SETTEXT = 0x000c;
const int WM_NCCALCSIZE = 0x0083;
const int WM_NCPAINT = 0x0085;

protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_SETTEXT:
WmSetText(ref m);
break;
case WM_NCCALCSIZE:
WmNCCalcSize(ref m);
break;
case WM_NCPAINT:
WmNCPaint(ref m);
break;
default:
base.WndProc(ref m);
break;
}
}
You change the size in WmNCCalcSize, draw the border and caption in
WmNCPaint and the caption text in WmSetText. If you just want to change the
size, you still need to do the drawing since the border is a set of images
that may not fit the new size. The rest of the messages can probably safely
be ignored and left to Windows to handle.

If you haven't already I suggest you download or view the source code
(Source Code tab above the article).

--
Happy Coding!
Morten Wennevik [C# MVP]
Sep 3 '08 #2

P: n/a
slg
Thx a lot
"Morten Wennevik [C# MVP]" <Mo************@hotmail.comwrote in message
news:AE**********************************@microsof t.com...
>
"slg" wrote:
>Is there a simpler way to increase the mdi form caption height?

I'm afraid not
>I am following this article but not sure where should i change?
I belive its most probably in the WmNCCalcSize
TIA

http://geekswithblogs.net/kobush/art...rderForms.aspx

There is an updated article on CodePlex

http://www.codeplex.com/Wiki/View.as...omerBorderForm

What you basically need to do is override the default handling of the Non
Client messages (NC_xxx) by overriding WndProc in your child form and
route
some messages to your own code.

const int WM_SETTEXT = 0x000c;
const int WM_NCCALCSIZE = 0x0083;
const int WM_NCPAINT = 0x0085;

protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_SETTEXT:
WmSetText(ref m);
break;
case WM_NCCALCSIZE:
WmNCCalcSize(ref m);
break;
case WM_NCPAINT:
WmNCPaint(ref m);
break;
default:
base.WndProc(ref m);
break;
}
}
You change the size in WmNCCalcSize, draw the border and caption in
WmNCPaint and the caption text in WmSetText. If you just want to change
the
size, you still need to do the drawing since the border is a set of images
that may not fit the new size. The rest of the messages can probably
safely
be ignored and left to Windows to handle.

If you haven't already I suggest you download or view the source code
(Source Code tab above the article).

--
Happy Coding!
Morten Wennevik [C# MVP]
Sep 3 '08 #3

P: n/a
slg
Morten , I tried it and it works great except one bug.
when the form looses focus and i activate it by clicking on the taskbar
the size decreases by the amount of pixels
i added to the caption.

any thoughts.

"Morten Wennevik [C# MVP]" <Mo************@hotmail.comwrote in message
news:AE**********************************@microsof t.com...
>
"slg" wrote:
>Is there a simpler way to increase the mdi form caption height?

I'm afraid not
>I am following this article but not sure where should i change?
I belive its most probably in the WmNCCalcSize
TIA

http://geekswithblogs.net/kobush/art...rderForms.aspx

There is an updated article on CodePlex

http://www.codeplex.com/Wiki/View.as...omerBorderForm

What you basically need to do is override the default handling of the Non
Client messages (NC_xxx) by overriding WndProc in your child form and
route
some messages to your own code.

const int WM_SETTEXT = 0x000c;
const int WM_NCCALCSIZE = 0x0083;
const int WM_NCPAINT = 0x0085;

protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_SETTEXT:
WmSetText(ref m);
break;
case WM_NCCALCSIZE:
WmNCCalcSize(ref m);
break;
case WM_NCPAINT:
WmNCPaint(ref m);
break;
default:
base.WndProc(ref m);
break;
}
}
You change the size in WmNCCalcSize, draw the border and caption in
WmNCPaint and the caption text in WmSetText. If you just want to change
the
size, you still need to do the drawing since the border is a set of images
that may not fit the new size. The rest of the messages can probably
safely
be ignored and left to Windows to handle.

If you haven't already I suggest you download or view the source code
(Source Code tab above the article).

--
Happy Coding!
Morten Wennevik [C# MVP]
Sep 6 '08 #4

P: n/a
slg
I did a spy trace and clearly the height is reduced from 263 to 253 and so
is width.
I belive its do with WM_SIZE
<00089004B0552 R WM_GETTEXTLENGTH cch:0
<00090004B0552 S WM_GETTEXT cchTextMax:2 lpszText:0479CCD0
<00091004B0552 R WM_GETTEXT cchCopied:0 lpszText:0479CCD0 ("")
<00092004B0552 R WM_ERASEBKGND fErased:True
<00093004B0552 S WM_WINDOWPOSCHANGED lpwp:0479DCDC
<00094004B0552 S WM_MOVE xPos:31 yPos:50
<00095004B0552 S WM_GETTEXTLENGTH
<00096004B0552 R WM_GETTEXTLENGTH cch:0
<00097004B0552 S WM_GETTEXT cchTextMax:2 lpszText:0479C348
<00098004B0552 R WM_GETTEXT cchCopied:0 lpszText:0479C348 ("")
<00099004B0552 R WM_MOVE
<00100004B0552 S WM_SIZE fwSizeType:SIZE_RESTORED nWidth:282 nHeight:263
<00101004B0552 R WM_SIZE
<00102004B0552 S WM_GETTEXTLENGTH
<00103004B0552 R WM_GETTEXTLENGTH cch:0
<00104004B0552 S WM_GETTEXT cchTextMax:2 lpszText:0479CD18
<00105004B0552 R WM_GETTEXT cchCopied:0 lpszText:0479CD18 ("")
<00106004B0552 S WM_GETTEXTLENGTH
<00107004B0552 R WM_GETTEXTLENGTH cch:0
<00108004B0552 S WM_GETTEXT cchTextMax:2 lpszText:0479CD18
<00109004B0552 R WM_GETTEXT cchCopied:0 lpszText:0479CD18 ("")
<00110004B0552 S WM_WINDOWPOSCHANGING lpwp:0479D574
<00111004B0552 S WM_GETMINMAXINFO lpmmi:0479CCD8
<00112004B0552 R WM_GETMINMAXINFO lpmmi:0479CCD8
<00113004B0552 R WM_WINDOWPOSCHANGING
<00114004B0552 S WM_NCCALCSIZE fCalcValidRects:True lpncsp:0479D548
<00115004B0552 R WM_NCCALCSIZE fuValidRect:0000 lpncsp:0479D548
<00116004B0552 S WM_NCPAINT hrgn:00000001
<00117004B0552 S WM_GETTEXT cchTextMax:510 lpszText:0479C4D0
<00118004B0552 R WM_GETTEXT cchCopied:0 lpszText:0479C4D0 ("")
<00119004B0552 R WM_NCPAINT
<00120004B0552 S WM_ERASEBKGND hdc:B0011B76
<00121004B0552 S WM_GETTEXTLENGTH
<00122004B0552 R WM_GETTEXTLENGTH cch:0
<00123004B0552 S WM_GETTEXT cchTextMax:2 lpszText:0479C560
<00124004B0552 R WM_GETTEXT cchCopied:0 lpszText:0479C560 ("")
<00125004B0552 R WM_ERASEBKGND fErased:True
<00126004B0552 S WM_WINDOWPOSCHANGED lpwp:0479D574
<00127004B0552 S WM_SIZE fwSizeType:SIZE_RESTORED nWidth:272 nHeight:253
<00128004B0552 R WM_SIZE
<00129004B0552 S WM_GETTEXTLENGTH
<00130004B0552 R WM_GETTEXTLENGTH cch:0
<00131004B0552 S WM_GETTEXT cchTextMax:2 lpszText:0479C454
<00132004B0552 R WM_GETTEXT cchCopied:0 lpszText:0479C454 ("")
<00133004B0552 S WM_GETTEXTLENGTH
<00134004B0552 R WM_GETTEXTLENGTH cch:0
<00135004B0552 S WM_GETTEXT cchTextMax:2 lpszText:0479C5B8
<00136004B0552 R WM_GETTEXT cchCopied:0 lpszText:0479C5B8 ("")
<00137004B0552 S WM_GETTEXTLENGTH
<00138004B0552 R WM_GETTEXTLENGTH cch:0
"slg" <sl*@abc.comwrote in message
news:e$***************@TK2MSFTNGP03.phx.gbl...
Morten , I tried it and it works great except one bug.
when the form looses focus and i activate it by clicking on the taskbar
the size decreases by the amount of pixels
i added to the caption.

any thoughts.

"Morten Wennevik [C# MVP]" <Mo************@hotmail.comwrote in message
news:AE**********************************@microsof t.com...
>>
"slg" wrote:
>>Is there a simpler way to increase the mdi form caption height?

I'm afraid not
>>I am following this article but not sure where should i change?
I belive its most probably in the WmNCCalcSize
TIA

http://geekswithblogs.net/kobush/art...rderForms.aspx

There is an updated article on CodePlex

http://www.codeplex.com/Wiki/View.as...omerBorderForm

What you basically need to do is override the default handling of the Non
Client messages (NC_xxx) by overriding WndProc in your child form and
route
some messages to your own code.

const int WM_SETTEXT = 0x000c;
const int WM_NCCALCSIZE = 0x0083;
const int WM_NCPAINT = 0x0085;

protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_SETTEXT:
WmSetText(ref m);
break;
case WM_NCCALCSIZE:
WmNCCalcSize(ref m);
break;
case WM_NCPAINT:
WmNCPaint(ref m);
break;
default:
base.WndProc(ref m);
break;
}
}
You change the size in WmNCCalcSize, draw the border and caption in
WmNCPaint and the caption text in WmSetText. If you just want to change
the
size, you still need to do the drawing since the border is a set of
images
that may not fit the new size. The rest of the messages can probably
safely
be ignored and left to Windows to handle.

If you haven't already I suggest you download or view the source code
(Source Code tab above the article).

--
Happy Coding!
Morten Wennevik [C# MVP]
Sep 6 '08 #5

P: n/a
Hi,

I'm afraid I can't help you there.

I tried running the CustomBorderForm project, and since it appeared to
retain its values when minimized you may be able to spot why your form does
not, by comparing the code.

--
Happy Coding!
Morten Wennevik [C# MVP]
"slg" wrote:
I did a spy trace and clearly the height is reduced from 263 to 253 and so
is width.
I belive its do with WM_SIZE
<00089004B0552 R WM_GETTEXTLENGTH cch:0
<00090004B0552 S WM_GETTEXT cchTextMax:2 lpszText:0479CCD0
<00091004B0552 R WM_GETTEXT cchCopied:0 lpszText:0479CCD0 ("")
<00092004B0552 R WM_ERASEBKGND fErased:True
<00093004B0552 S WM_WINDOWPOSCHANGED lpwp:0479DCDC
<00094004B0552 S WM_MOVE xPos:31 yPos:50
<00095004B0552 S WM_GETTEXTLENGTH
<00096004B0552 R WM_GETTEXTLENGTH cch:0
<00097004B0552 S WM_GETTEXT cchTextMax:2 lpszText:0479C348
<00098004B0552 R WM_GETTEXT cchCopied:0 lpszText:0479C348 ("")
<00099004B0552 R WM_MOVE
<00100004B0552 S WM_SIZE fwSizeType:SIZE_RESTORED nWidth:282 nHeight:263
<00101004B0552 R WM_SIZE
<00102004B0552 S WM_GETTEXTLENGTH
<00103004B0552 R WM_GETTEXTLENGTH cch:0
<00104004B0552 S WM_GETTEXT cchTextMax:2 lpszText:0479CD18
<00105004B0552 R WM_GETTEXT cchCopied:0 lpszText:0479CD18 ("")
<00106004B0552 S WM_GETTEXTLENGTH
<00107004B0552 R WM_GETTEXTLENGTH cch:0
<00108004B0552 S WM_GETTEXT cchTextMax:2 lpszText:0479CD18
<00109004B0552 R WM_GETTEXT cchCopied:0 lpszText:0479CD18 ("")
<00110004B0552 S WM_WINDOWPOSCHANGING lpwp:0479D574
<00111004B0552 S WM_GETMINMAXINFO lpmmi:0479CCD8
<00112004B0552 R WM_GETMINMAXINFO lpmmi:0479CCD8
<00113004B0552 R WM_WINDOWPOSCHANGING
<00114004B0552 S WM_NCCALCSIZE fCalcValidRects:True lpncsp:0479D548
<00115004B0552 R WM_NCCALCSIZE fuValidRect:0000 lpncsp:0479D548
<00116004B0552 S WM_NCPAINT hrgn:00000001
<00117004B0552 S WM_GETTEXT cchTextMax:510 lpszText:0479C4D0
<00118004B0552 R WM_GETTEXT cchCopied:0 lpszText:0479C4D0 ("")
<00119004B0552 R WM_NCPAINT
<00120004B0552 S WM_ERASEBKGND hdc:B0011B76
<00121004B0552 S WM_GETTEXTLENGTH
<00122004B0552 R WM_GETTEXTLENGTH cch:0
<00123004B0552 S WM_GETTEXT cchTextMax:2 lpszText:0479C560
<00124004B0552 R WM_GETTEXT cchCopied:0 lpszText:0479C560 ("")
<00125004B0552 R WM_ERASEBKGND fErased:True
<00126004B0552 S WM_WINDOWPOSCHANGED lpwp:0479D574
<00127004B0552 S WM_SIZE fwSizeType:SIZE_RESTORED nWidth:272 nHeight:253
<00128004B0552 R WM_SIZE
<00129004B0552 S WM_GETTEXTLENGTH
<00130004B0552 R WM_GETTEXTLENGTH cch:0
<00131004B0552 S WM_GETTEXT cchTextMax:2 lpszText:0479C454
<00132004B0552 R WM_GETTEXT cchCopied:0 lpszText:0479C454 ("")
<00133004B0552 S WM_GETTEXTLENGTH
<00134004B0552 R WM_GETTEXTLENGTH cch:0
<00135004B0552 S WM_GETTEXT cchTextMax:2 lpszText:0479C5B8
<00136004B0552 R WM_GETTEXT cchCopied:0 lpszText:0479C5B8 ("")
<00137004B0552 S WM_GETTEXTLENGTH
<00138004B0552 R WM_GETTEXTLENGTH cch:0
"slg" <sl*@abc.comwrote in message
news:e$***************@TK2MSFTNGP03.phx.gbl...
Morten , I tried it and it works great except one bug.
when the form looses focus and i activate it by clicking on the taskbar
the size decreases by the amount of pixels
i added to the caption.

any thoughts.

"Morten Wennevik [C# MVP]" <Mo************@hotmail.comwrote in message
news:AE**********************************@microsof t.com...
>
"slg" wrote:

Is there a simpler way to increase the mdi form caption height?
I'm afraid not

I am following this article but not sure where should i change?
I belive its most probably in the WmNCCalcSize
TIA

http://geekswithblogs.net/kobush/art...rderForms.aspx
There is an updated article on CodePlex

http://www.codeplex.com/Wiki/View.as...omerBorderForm

What you basically need to do is override the default handling of the Non
Client messages (NC_xxx) by overriding WndProc in your child form and
route
some messages to your own code.

const int WM_SETTEXT = 0x000c;
const int WM_NCCALCSIZE = 0x0083;
const int WM_NCPAINT = 0x0085;

protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_SETTEXT:
WmSetText(ref m);
break;
case WM_NCCALCSIZE:
WmNCCalcSize(ref m);
break;
case WM_NCPAINT:
WmNCPaint(ref m);
break;
default:
base.WndProc(ref m);
break;
}
}
You change the size in WmNCCalcSize, draw the border and caption in
WmNCPaint and the caption text in WmSetText. If you just want to change
the
size, you still need to do the drawing since the border is a set of
images
that may not fit the new size. The rest of the messages can probably
safely
be ignored and left to Windows to handle.

If you haven't already I suggest you download or view the source code
(Source Code tab above the article).

--
Happy Coding!
Morten Wennevik [C# MVP]

Sep 10 '08 #6

P: n/a
slg
Morten, Thx for your reply.

I changed the caption height in WM_NCCALCSIZE in customBorderForm and had
same issue.
Finally i figured out by spy trace that in wm_windowsposchanging i adjusted
the height of the window by adding caption size.
Any how it looks to be complicated to change caption size in case you have
menu's

Thx
"Morten Wennevik [C# MVP]" <Mo************@hotmail.comwrote in message
news:A8**********************************@microsof t.com...
Hi,

I'm afraid I can't help you there.

I tried running the CustomBorderForm project, and since it appeared to
retain its values when minimized you may be able to spot why your form
does
not, by comparing the code.

--
Happy Coding!
Morten Wennevik [C# MVP]
"slg" wrote:
>I did a spy trace and clearly the height is reduced from 263 to 253 and
so
is width.
I belive its do with WM_SIZE
<00089004B0552 R WM_GETTEXTLENGTH cch:0
<00090004B0552 S WM_GETTEXT cchTextMax:2 lpszText:0479CCD0
<00091004B0552 R WM_GETTEXT cchCopied:0 lpszText:0479CCD0 ("")
<00092004B0552 R WM_ERASEBKGND fErased:True
<00093004B0552 S WM_WINDOWPOSCHANGED lpwp:0479DCDC
<00094004B0552 S WM_MOVE xPos:31 yPos:50
<00095004B0552 S WM_GETTEXTLENGTH
<00096004B0552 R WM_GETTEXTLENGTH cch:0
<00097004B0552 S WM_GETTEXT cchTextMax:2 lpszText:0479C348
<00098004B0552 R WM_GETTEXT cchCopied:0 lpszText:0479C348 ("")
<00099004B0552 R WM_MOVE
<00100004B0552 S WM_SIZE fwSizeType:SIZE_RESTORED nWidth:282
nHeight:263
<00101004B0552 R WM_SIZE
<00102004B0552 S WM_GETTEXTLENGTH
<00103004B0552 R WM_GETTEXTLENGTH cch:0
<00104004B0552 S WM_GETTEXT cchTextMax:2 lpszText:0479CD18
<00105004B0552 R WM_GETTEXT cchCopied:0 lpszText:0479CD18 ("")
<00106004B0552 S WM_GETTEXTLENGTH
<00107004B0552 R WM_GETTEXTLENGTH cch:0
<00108004B0552 S WM_GETTEXT cchTextMax:2 lpszText:0479CD18
<00109004B0552 R WM_GETTEXT cchCopied:0 lpszText:0479CD18 ("")
<00110004B0552 S WM_WINDOWPOSCHANGING lpwp:0479D574
<00111004B0552 S WM_GETMINMAXINFO lpmmi:0479CCD8
<00112004B0552 R WM_GETMINMAXINFO lpmmi:0479CCD8
<00113004B0552 R WM_WINDOWPOSCHANGING
<00114004B0552 S WM_NCCALCSIZE fCalcValidRects:True lpncsp:0479D548
<00115004B0552 R WM_NCCALCSIZE fuValidRect:0000 lpncsp:0479D548
<00116004B0552 S WM_NCPAINT hrgn:00000001
<00117004B0552 S WM_GETTEXT cchTextMax:510 lpszText:0479C4D0
<00118004B0552 R WM_GETTEXT cchCopied:0 lpszText:0479C4D0 ("")
<00119004B0552 R WM_NCPAINT
<00120004B0552 S WM_ERASEBKGND hdc:B0011B76
<00121004B0552 S WM_GETTEXTLENGTH
<00122004B0552 R WM_GETTEXTLENGTH cch:0
<00123004B0552 S WM_GETTEXT cchTextMax:2 lpszText:0479C560
<00124004B0552 R WM_GETTEXT cchCopied:0 lpszText:0479C560 ("")
<00125004B0552 R WM_ERASEBKGND fErased:True
<00126004B0552 S WM_WINDOWPOSCHANGED lpwp:0479D574
<00127004B0552 S WM_SIZE fwSizeType:SIZE_RESTORED nWidth:272
nHeight:253
<00128004B0552 R WM_SIZE
<00129004B0552 S WM_GETTEXTLENGTH
<00130004B0552 R WM_GETTEXTLENGTH cch:0
<00131004B0552 S WM_GETTEXT cchTextMax:2 lpszText:0479C454
<00132004B0552 R WM_GETTEXT cchCopied:0 lpszText:0479C454 ("")
<00133004B0552 S WM_GETTEXTLENGTH
<00134004B0552 R WM_GETTEXTLENGTH cch:0
<00135004B0552 S WM_GETTEXT cchTextMax:2 lpszText:0479C5B8
<00136004B0552 R WM_GETTEXT cchCopied:0 lpszText:0479C5B8 ("")
<00137004B0552 S WM_GETTEXTLENGTH
<00138004B0552 R WM_GETTEXTLENGTH cch:0
"slg" <sl*@abc.comwrote in message
news:e$***************@TK2MSFTNGP03.phx.gbl...
Morten , I tried it and it works great except one bug.
when the form looses focus and i activate it by clicking on the
taskbar
the size decreases by the amount of pixels
i added to the caption.

any thoughts.

"Morten Wennevik [C# MVP]" <Mo************@hotmail.comwrote in
message
news:AE**********************************@microsof t.com...

"slg" wrote:

Is there a simpler way to increase the mdi form caption height?
I'm afraid not

I am following this article but not sure where should i change?
I belive its most probably in the WmNCCalcSize
TIA

http://geekswithblogs.net/kobush/art...rderForms.aspx
There is an updated article on CodePlex

http://www.codeplex.com/Wiki/View.as...omerBorderForm

What you basically need to do is override the default handling of the
Non
Client messages (NC_xxx) by overriding WndProc in your child form and
route
some messages to your own code.

const int WM_SETTEXT = 0x000c;
const int WM_NCCALCSIZE = 0x0083;
const int WM_NCPAINT = 0x0085;

protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_SETTEXT:
WmSetText(ref m);
break;
case WM_NCCALCSIZE:
WmNCCalcSize(ref m);
break;
case WM_NCPAINT:
WmNCPaint(ref m);
break;
default:
base.WndProc(ref m);
break;
}
}
You change the size in WmNCCalcSize, draw the border and caption in
WmNCPaint and the caption text in WmSetText. If you just want to
change
the
size, you still need to do the drawing since the border is a set of
images
that may not fit the new size. The rest of the messages can probably
safely
be ignored and left to Windows to handle.

If you haven't already I suggest you download or view the source code
(Source Code tab above the article).

--
Happy Coding!
Morten Wennevik [C# MVP]

Sep 12 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.