I am creating a custom textbox that requires me to handle the OnPaint
mechanism. Currently, I am using WM_PRINT to draw the text in the textbox
and am running into a problem. The text will never follow the font that is
specified by the textbox, it is always the same no matter what I change it
to. Is there some way to get WM_PRINT to use the font that the textbox is
set with?

I stripped down the code for my class to the following to show the issue:
using System;
using System.Windows.Forms;
namespace TransTextBox
{
public class MyTextBox : TextBox
{
public MyTextBox()
{
this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint |
ControlStyles.DoubleBuffer | ControlStyles.SupportsTransparentBackColor,
true);
}
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
System.IntPtr hdc = e.Graphics.GetHdc();
this.SetStyle(ControlStyles.UserPaint, false);
try
{
const Int32 WM_PRINT = 0x0317;
const long PRF_CLIENT = 0x00000004;
Message m = Message.Create(this.Handle, WM_PRINT, hdc, new
System.IntPtr(PRF_CLIENT));
this.WndProc(ref m);
}
catch { }
finally
{
e.Graphics.ReleaseHdc(hdc);
this.SetStyle(ControlStyles.UserPaint, true);
}
}
}
}

I appreciate any help - thanks.

Bob Dankert

Re: UserPaint a TextBox - issue with WM_PRINT by Bob

Bob
Sun Jul 17 12:06:05 CDT 2005

I'm not really sure how the code seems similar?? After looking at that code
sample, it seems like it is creating bitmaps to display everything - I
didn't see any mention of WM_PRINT.

The code is certainly creative as far as accomplishing a transparent
textbox, though.

Anyways, I'm still having the same issue.

Bob
"Lloyd Dupont" <ld@NewsAccount.galador.net> wrote in message
news:ezMcIQtiFHA.3256@TK2MSFTNGP12.phx.gbl...
> Hi Bob!
> interesting code!
>
> while I don't have a solution for your problem, I'm using a sample
> transparent text box I found on code project, it work in a similar way (in
> fact the code seems a bit chaotic, but I didn't bother clean it), and it
> has no problem at all!!
>
> I attached the TransparentTextBox files for your convenience....
>
> "Bob Dankert" <bobatnvsn-itdotcom@nospam.nospam> wrote in message
> news:uBMqTWmiFHA.3288@TK2MSFTNGP09.phx.gbl...
>>I am creating a custom textbox that requires me to handle the OnPaint
>> mechanism. Currently, I am using WM_PRINT to draw the text in the
>> textbox
>> and am running into a problem. The text will never follow the font that
>> is
>> specified by the textbox, it is always the same no matter what I change
>> it
>> to. Is there some way to get WM_PRINT to use the font that the textbox
>> is
>> set with?
>>
>> I stripped down the code for my class to the following to show the issue:
>> using System;
>> using System.Windows.Forms;
>> namespace TransTextBox
>> {
>> public class MyTextBox : TextBox
>> {
>> public MyTextBox()
>> {
>> this.SetStyle(ControlStyles.UserPaint |
>> ControlStyles.AllPaintingInWmPaint |
>> ControlStyles.DoubleBuffer | ControlStyles.SupportsTransparentBackColor,
>> true);
>> }
>> protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
>> {
>> System.IntPtr hdc = e.Graphics.GetHdc();
>> this.SetStyle(ControlStyles.UserPaint, false);
>> try
>> {
>> const Int32 WM_PRINT = 0x0317;
>> const long PRF_CLIENT = 0x00000004;
>> Message m = Message.Create(this.Handle, WM_PRINT, hdc, new
>> System.IntPtr(PRF_CLIENT));
>> this.WndProc(ref m);
>> }
>> catch { }
>> finally
>> {
>> e.Graphics.ReleaseHdc(hdc);
>> this.SetStyle(ControlStyles.UserPaint, true);
>> }
>> }
>> }
>> }
>>
>> I appreciate any help - thanks.
>>
>> Bob Dankert
>>
>>
>
>
>



Re: UserPaint a TextBox - issue with WM_PRINT by v-jetan

v-jetan
Mon Jul 18 01:55:46 CDT 2005

Hi Bob,

Thanks for your post.

Yes, I can reproduce out your problem on my side with your code snippet.

If we use Reflector to view Control.Font property, we can see the root
cause:

public virtual void set_Font([MarshalAs(UnmanagedType.CustomMarshaler,
MarshalType="", MarshalTypeRef=typeof(Control.ActiveXFontMarshaler),
MarshalCookie="")] Font value)
{
Font font1 = (Font) this.Properties.GetObject(Control.PropFont);
Font font2 = this.Font;
bool flag1 = false;
if (value == null)
{
if (font1 != null)
{
flag1 = true;
}
}
else if (font1 == null)
{
flag1 = true;
}
else
{
flag1 = !value.Equals(font1);
}
if (flag1)
{
this.Properties.SetObject(Control.PropFont, value);
if
(this.Properties.ContainsObject(Control.PropFontHandleWrapper))
{
this.Properties.SetObject(Control.PropFontHandleWrapper,
null);
}
if (!font2.Equals(value))
{
if
(this.Properties.ContainsInteger(Control.PropFontHeight))
{
this.Properties.SetInteger(Control.PropFontHeight,
(value == null) ? -1 : value.Height);
}
this.OnFontChanged(EventArgs.Empty);
}
else if (this.IsHandleCreated &&
!this.GetStyle(ControlStyles.UserPaint))
{
this.SendMessage(0x30, this.FontHandle, 0);
}
}
}
Yes, in the last line, Winform code determines if UserPaint is enabled. If
it is true, it will not send 0x30(WM_SETFONT) message to refresh the
painting.

For this issue, we can explicitly send a 0x30(WM_SETFONT) message to enable
the font. Like this:

[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr
wParam, IntPtr lParam);

protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
SendMessage(this.Handle, 0x30, this.Font.ToHfont(), IntPtr.Zero);
System.IntPtr hdc = e.Graphics.GetHdc();
this.SetStyle(ControlStyles.UserPaint, false);
try
{
const Int32 WM_PRINT = 0x0317;
const long PRF_CLIENT = 0x00000004;
Message m = Message.Create(this.Handle, WM_PRINT, hdc, new
System.IntPtr(PRF_CLIENT));
this.WndProc(ref m);
}
catch { }
finally
{
e.Graphics.ReleaseHdc(hdc);
this.SetStyle(ControlStyles.UserPaint, true);
}
}
This works well on my side.

Additionally, if you want to do the painting ourselves, please refer to the
link below:
"27.15 When I set a TextBox to Readonly or set Enabled to false, the text
color is gray. How can I force it to be the color specified in the
ForeColor property of the TextBox."
http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c94c.aspx

Hope this helps
================================================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


Re: UserPaint a TextBox - issue with WM_PRINT by Bob

Bob
Mon Jul 18 08:21:20 CDT 2005

Thanks a lot for the help, Jeffrey. I never realized you could view the
code of the framework - this is definately nice to know! Out of curiousity,
which tools did you use to view the code of the Font property?

Thanks,

Bob

""Jeffrey Tan[MSFT]"" <v-jetan@online.microsoft.com> wrote in message
news:xgQGNX2iFHA.3472@TK2MSFTNGXA01.phx.gbl...
> Hi Bob,
>
> Thanks for your post.
>
> Yes, I can reproduce out your problem on my side with your code snippet.
>
> If we use Reflector to view Control.Font property, we can see the root
> cause:
>
> public virtual void set_Font([MarshalAs(UnmanagedType.CustomMarshaler,
> MarshalType="", MarshalTypeRef=typeof(Control.ActiveXFontMarshaler),
> MarshalCookie="")] Font value)
> {
> Font font1 = (Font) this.Properties.GetObject(Control.PropFont);
> Font font2 = this.Font;
> bool flag1 = false;
> if (value == null)
> {
> if (font1 != null)
> {
> flag1 = true;
> }
> }
> else if (font1 == null)
> {
> flag1 = true;
> }
> else
> {
> flag1 = !value.Equals(font1);
> }
> if (flag1)
> {
> this.Properties.SetObject(Control.PropFont, value);
> if
> (this.Properties.ContainsObject(Control.PropFontHandleWrapper))
> {
> this.Properties.SetObject(Control.PropFontHandleWrapper,
> null);
> }
> if (!font2.Equals(value))
> {
> if
> (this.Properties.ContainsInteger(Control.PropFontHeight))
> {
> this.Properties.SetInteger(Control.PropFontHeight,
> (value == null) ? -1 : value.Height);
> }
> this.OnFontChanged(EventArgs.Empty);
> }
> else if (this.IsHandleCreated &&
> !this.GetStyle(ControlStyles.UserPaint))
> {
> this.SendMessage(0x30, this.FontHandle, 0);
> }
> }
> }
> Yes, in the last line, Winform code determines if UserPaint is enabled. If
> it is true, it will not send 0x30(WM_SETFONT) message to refresh the
> painting.
>
> For this issue, we can explicitly send a 0x30(WM_SETFONT) message to
> enable
> the font. Like this:
>
> [DllImport("user32.dll", CharSet=CharSet.Auto)]
> public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr
> wParam, IntPtr lParam);
>
> protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
> {
> SendMessage(this.Handle, 0x30, this.Font.ToHfont(), IntPtr.Zero);
> System.IntPtr hdc = e.Graphics.GetHdc();
> this.SetStyle(ControlStyles.UserPaint, false);
> try
> {
> const Int32 WM_PRINT = 0x0317;
> const long PRF_CLIENT = 0x00000004;
> Message m = Message.Create(this.Handle, WM_PRINT, hdc, new
> System.IntPtr(PRF_CLIENT));
> this.WndProc(ref m);
> }
> catch { }
> finally
> {
> e.Graphics.ReleaseHdc(hdc);
> this.SetStyle(ControlStyles.UserPaint, true);
> }
> }
> This works well on my side.
>
> Additionally, if you want to do the painting ourselves, please refer to
> the
> link below:
> "27.15 When I set a TextBox to Readonly or set Enabled to false, the text
> color is gray. How can I force it to be the color specified in the
> ForeColor property of the TextBox."
> http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c94c.aspx
>
> Hope this helps
> ================================================================
> Thank you for your patience and cooperation. If you have any questions or
> concerns, please feel free to post it in the group. I am standing by to be
> of assistance.
>
> Best regards,
> Jeffrey Tan
> Microsoft Online Partner Support
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
>



Re: UserPaint a TextBox - issue with WM_PRINT by Lloyd

Lloyd
Mon Jul 18 08:57:42 CDT 2005

This is a multi-part message in MIME format.

------=_NextPart_000_00A9_01C58BF4.7C79B800
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I see you've got your answer!

Anyway here is where is the WM_PRINT message in=20
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
switch (m.Msg)
{
case Win32.WM_PAINT: =20
myPaintedFirstTime =3D true;
if (!myUpToDate || !myCaretUpToDate)
GetBitmaps(); =3D=3D=3D=3D=3D=3D=3D=3D=3D>>>> =
Win32.CaptureWindow(this, myBitmap);
.......






"Bob Dankert" <bob@nospamnvsn-it.com> wrote in message =
news:eM3zIHviFHA.3064@TK2MSFTNGP15.phx.gbl...
> I'm not really sure how the code seems similar?? After looking at =
that code=20
> sample, it seems like it is creating bitmaps to display everything - I =

> didn't see any mention of WM_PRINT.
>=20
> The code is certainly creative as far as accomplishing a transparent=20
> textbox, though.
>=20
> Anyways, I'm still having the same issue.
>=20
> Bob
> "Lloyd Dupont" <ld@NewsAccount.galador.net> wrote in message=20
> news:ezMcIQtiFHA.3256@TK2MSFTNGP12.phx.gbl...
>> Hi Bob!
>> interesting code!
>>
>> while I don't have a solution for your problem, I'm using a sample=20
>> transparent text box I found on code project, it work in a similar =
way (in=20
>> fact the code seems a bit chaotic, but I didn't bother clean it), and =
it=20
>> has no problem at all!!
>>
>> I attached the TransparentTextBox files for your convenience....
>>
>> "Bob Dankert" <bobatnvsn-itdotcom@nospam.nospam> wrote in message=20
>> news:uBMqTWmiFHA.3288@TK2MSFTNGP09.phx.gbl...
>>>I am creating a custom textbox that requires me to handle the OnPaint
>>> mechanism. Currently, I am using WM_PRINT to draw the text in the=20
>>> textbox
>>> and am running into a problem. The text will never follow the font =
that=20
>>> is
>>> specified by the textbox, it is always the same no matter what I =
change=20
>>> it
>>> to. Is there some way to get WM_PRINT to use the font that the =
textbox=20
>>> is
>>> set with?
>>>
>>> I stripped down the code for my class to the following to show the =
issue:
>>> using System;
>>> using System.Windows.Forms;
>>> namespace TransTextBox
>>> {
>>> public class MyTextBox : TextBox
>>> {
>>> public MyTextBox()
>>> {
>>> this.SetStyle(ControlStyles.UserPaint |=20
>>> ControlStyles.AllPaintingInWmPaint |
>>> ControlStyles.DoubleBuffer | =
ControlStyles.SupportsTransparentBackColor,
>>> true);
>>> }
>>> protected override void OnPaint(System.Windows.Forms.PaintEventArgs =
e)
>>> {
>>> System.IntPtr hdc =3D e.Graphics.GetHdc();
>>> this.SetStyle(ControlStyles.UserPaint, false);
>>> try
>>> {
>>> const Int32 WM_PRINT =3D 0x0317;
>>> const long PRF_CLIENT =3D 0x00000004;
>>> Message m =3D Message.Create(this.Handle, WM_PRINT, hdc, new
>>> System.IntPtr(PRF_CLIENT));
>>> this.WndProc(ref m);
>>> }
>>> catch { }
>>> finally
>>> {
>>> e.Graphics.ReleaseHdc(hdc);
>>> this.SetStyle(ControlStyles.UserPaint, true);
>>> }
>>> }
>>> }
>>> }
>>>
>>> I appreciate any help - thanks.
>>>
>>> Bob Dankert
>>>
>>>
>>
>>
>>=20
>=20
>
------=_NextPart_000_00A9_01C58BF4.7C79B800
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2668" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>I see you've got your =
answer!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Anyway here is where is the WM_PRINT =
message in=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT><FONT size=3D2>
<P></FONT><FONT color=3D#0000ff size=3D2>protected</FONT><FONT size=3D2> =
</FONT><FONT=20
color=3D#0000ff size=3D2>override</FONT><FONT size=3D2> </FONT><FONT =
color=3D#0000ff=20
size=3D2>void</FONT><FONT size=3D2> WndProc(</FONT><FONT color=3D#0000ff =

size=3D2>ref</FONT><FONT size=3D2> </FONT><FONT color=3D#008080=20
size=3D2>Message</FONT><FONT size=3D2> m)<BR>{<BR></FONT><FONT =
color=3D#0000ff=20
size=3D2>&nbsp;&nbsp;&nbsp; base</FONT><FONT =
size=3D2>.WndProc(</FONT><FONT=20
color=3D#0000ff size=3D2>ref</FONT><FONT size=3D2> m);<BR></FONT><FONT =
color=3D#0000ff=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;switch</FONT><FONT size=3D2>=20
(m.Msg)<BR></FONT><FONT size=3D2>&nbsp;&nbsp;&nbsp; {<BR></FONT><FONT=20
color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
case</FONT><FONT=20
size=3D2> </FONT><FONT color=3D#008080 size=3D2>Win32</FONT><FONT=20
size=3D2>.WM_PAINT:&nbsp;&nbsp;<BR></FONT><FONT =
size=3D2>&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; myPaintedFirstTime =3D =
</FONT><FONT=20
color=3D#0000ff size=3D2>true</FONT><FONT size=3D2>;<BR></FONT><FONT =
color=3D#0000ff=20
size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
if</FONT><FONT=20
size=3D2> (!myUpToDate || !myCaretUpToDate)<BR>&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; GetBitmaps();=20
=3D=3D=3D=3D=3D=3D=3D=3D=3D&gt;&gt;&gt;&gt; <FONT color=3D#008080 =
size=3D2>Win32</FONT><FONT=20
size=3D2>.CaptureWindow(</FONT><FONT color=3D#0000ff =
size=3D2>this</FONT><FONT=20
size=3D2>,=20
myBitmap);</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;=20
.......</FONT></P>
<P><FONT size=3D2></FONT><FONT size=3D2>&nbsp;</P></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>"Bob Dankert" &lt;</FONT><A=20
href=3D"mailto:bob@nospamnvsn-it.com"><FONT face=3DArial=20
size=3D2>bob@nospamnvsn-it.com</FONT></A><FONT face=3DArial =
size=3D2>&gt; wrote in=20
message </FONT><A =
href=3D"news:eM3zIHviFHA.3064@TK2MSFTNGP15.phx.gbl"><FONT=20
face=3DArial =
size=3D2>news:eM3zIHviFHA.3064@TK2MSFTNGP15.phx.gbl</FONT></A><FONT=20
face=3DArial size=3D2>...</FONT></DIV><FONT face=3DArial size=3D2>&gt; =
I'm not really=20
sure how the code seems similar??&nbsp; After looking at that code =
<BR>&gt;=20
sample, it seems like it is creating bitmaps to display everything - I =
<BR>&gt;=20
didn't see any mention of WM_PRINT.<BR>&gt; <BR>&gt; The code is =
certainly=20
creative as far as accomplishing a transparent <BR>&gt; textbox, =
though.<BR>&gt;=20
<BR>&gt; Anyways, I'm still having the same issue.<BR>&gt; <BR>&gt; =
Bob<BR>&gt;=20
"Lloyd Dupont" &lt;</FONT><A =
href=3D"mailto:ld@NewsAccount.galador.net"><FONT=20
face=3DArial size=3D2>ld@NewsAccount.galador.net</FONT></A><FONT =
face=3DArial=20
size=3D2>&gt; wrote in message <BR>&gt; </FONT><A=20
href=3D"news:ezMcIQtiFHA.3256@TK2MSFTNGP12.phx.gbl"><FONT face=3DArial=20
size=3D2>news:ezMcIQtiFHA.3256@TK2MSFTNGP12.phx.gbl</FONT></A><FONT =
face=3DArial=20
size=3D2>...<BR>&gt;&gt; Hi Bob!<BR>&gt;&gt; interesting=20
code!<BR>&gt;&gt;<BR>&gt;&gt; while I don't have a solution for your =
problem,=20
I'm using a sample <BR>&gt;&gt; transparent text box I found on code =
project, it=20
work in a similar way (in <BR>&gt;&gt; fact the code seems a bit =
chaotic, but I=20
didn't bother clean it), and it <BR>&gt;&gt; has no problem at=20
all!!<BR>&gt;&gt;<BR>&gt;&gt; I attached the TransparentTextBox files =
for your=20
convenience....<BR>&gt;&gt;<BR>&gt;&gt; "Bob Dankert" &lt;</FONT><A=20
href=3D"mailto:bobatnvsn-itdotcom@nospam.nospam"><FONT face=3DArial=20
size=3D2>bobatnvsn-itdotcom@nospam.nospam</FONT></A><FONT face=3DArial =
size=3D2>&gt;=20
wrote in message <BR>&gt;&gt; </FONT><A=20
href=3D"news:uBMqTWmiFHA.3288@TK2MSFTNGP09.phx.gbl"><FONT face=3DArial=20
size=3D2>news:uBMqTWmiFHA.3288@TK2MSFTNGP09.phx.gbl</FONT></A><FONT =
face=3DArial=20
size=3D2>...<BR>&gt;&gt;&gt;I am creating a custom textbox that requires =
me to=20
handle the OnPaint<BR>&gt;&gt;&gt; mechanism.&nbsp; Currently, I am =
using=20
WM_PRINT to draw the text in the <BR>&gt;&gt;&gt; =
textbox<BR>&gt;&gt;&gt; and am=20
running into a problem.&nbsp; The text will never follow the font that=20
<BR>&gt;&gt;&gt; is<BR>&gt;&gt;&gt; specified by the textbox, it is =
always the=20
same no matter what I change <BR>&gt;&gt;&gt; it<BR>&gt;&gt;&gt; =
to.&nbsp; Is=20
there some way to get WM_PRINT to use the font that the textbox =
<BR>&gt;&gt;&gt;=20
is<BR>&gt;&gt;&gt; set with?<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; I stripped =
down the=20
code for my class to the following to show the issue:<BR>&gt;&gt;&gt; =
using=20
System;<BR>&gt;&gt;&gt; using System.Windows.Forms;<BR>&gt;&gt;&gt; =
namespace=20
TransTextBox<BR>&gt;&gt;&gt; {<BR>&gt;&gt;&gt; public class MyTextBox :=20
TextBox<BR>&gt;&gt;&gt; {<BR>&gt;&gt;&gt; public =
MyTextBox()<BR>&gt;&gt;&gt;=20
{<BR>&gt;&gt;&gt; this.SetStyle(ControlStyles.UserPaint | =
<BR>&gt;&gt;&gt;=20
ControlStyles.AllPaintingInWmPaint |<BR>&gt;&gt;&gt; =
ControlStyles.DoubleBuffer=20
| ControlStyles.SupportsTransparentBackColor,<BR>&gt;&gt;&gt;=20
true);<BR>&gt;&gt;&gt; }<BR>&gt;&gt;&gt; protected override void=20
OnPaint(System.Windows.Forms.PaintEventArgs e)<BR>&gt;&gt;&gt; =
{<BR>&gt;&gt;&gt;=20
System.IntPtr hdc =3D e.Graphics.GetHdc();<BR>&gt;&gt;&gt;=20
this.SetStyle(ControlStyles.UserPaint, false);<BR>&gt;&gt;&gt;=20
try<BR>&gt;&gt;&gt; {<BR>&gt;&gt;&gt; const Int32 WM_PRINT =3D=20
0x0317;<BR>&gt;&gt;&gt; const long PRF_CLIENT =3D =
0x00000004;<BR>&gt;&gt;&gt;=20
Message m =3D Message.Create(this.Handle, WM_PRINT, hdc, =
new<BR>&gt;&gt;&gt;=20
System.IntPtr(PRF_CLIENT));<BR>&gt;&gt;&gt; this.WndProc(ref =
m);<BR>&gt;&gt;&gt;=20
}<BR>&gt;&gt;&gt; catch { }<BR>&gt;&gt;&gt; finally<BR>&gt;&gt;&gt;=20
{<BR>&gt;&gt;&gt; e.Graphics.ReleaseHdc(hdc);<BR>&gt;&gt;&gt;=20
this.SetStyle(ControlStyles.UserPaint, true);<BR>&gt;&gt;&gt; =
}<BR>&gt;&gt;&gt;=20
}<BR>&gt;&gt;&gt; }<BR>&gt;&gt;&gt; }<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; I=20
appreciate any help - thanks.<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; Bob=20
Dankert<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt;<BR>&gt;&gt;<BR>&gt;&gt;<BR>&gt;&g=
t;=20
<BR>&gt; <BR>&gt;</FONT></BODY></HTML>

------=_NextPart_000_00A9_01C58BF4.7C79B800--


Re: UserPaint a TextBox - issue with WM_PRINT by v-jetan

v-jetan
Tue Jul 19 01:49:43 CDT 2005

Hi Bob,

I am glad I can help you. Actually, I got the "source code" from Reflector.
Reflector is a decompiler which decompiles the IL code in assembly into
C#, VB.net or any other high level .net language.

So we can use it to view the .Net Framework source code with it. It is
definitely a must have tool for .Net developer. You can get this tool from
http://www.aisto.com/roeder/dotnet/

Hope this helps

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


Re: UserPaint a TextBox - issue with WM_PRINT by Bob

Bob
Tue Jul 19 08:28:16 CDT 2005

This is a multi-part message in MIME format.

------=_NextPart_000_0012_01C58C3B.CFDEEE60
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Lloyd - I only see the code handling the WM_PAINT (paint, not print) =
message in that code???
"Lloyd Dupont" <ld@NewsAccount.galador.net> wrote in message =
news:e65bqC6iFHA.1948@TK2MSFTNGP12.phx.gbl...
I see you've got your answer!

Anyway here is where is the WM_PRINT message in=20
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
switch (m.Msg)
{
case Win32.WM_PAINT: =20
myPaintedFirstTime =3D true;
if (!myUpToDate || !myCaretUpToDate)
GetBitmaps(); =3D=3D=3D=3D=3D=3D=3D=3D=3D>>>> =
Win32.CaptureWindow(this, myBitmap);
.......






"Bob Dankert" <bob@nospamnvsn-it.com> wrote in message =
news:eM3zIHviFHA.3064@TK2MSFTNGP15.phx.gbl...
> I'm not really sure how the code seems similar?? After looking at =
that code=20
> sample, it seems like it is creating bitmaps to display everything - =
I=20
> didn't see any mention of WM_PRINT.
>=20
> The code is certainly creative as far as accomplishing a transparent =

> textbox, though.
>=20
> Anyways, I'm still having the same issue.
>=20
> Bob
> "Lloyd Dupont" <ld@NewsAccount.galador.net> wrote in message=20
> news:ezMcIQtiFHA.3256@TK2MSFTNGP12.phx.gbl...
>> Hi Bob!
>> interesting code!
>>
>> while I don't have a solution for your problem, I'm using a sample=20
>> transparent text box I found on code project, it work in a similar =
way (in=20
>> fact the code seems a bit chaotic, but I didn't bother clean it), =
and it=20
>> has no problem at all!!
>>
>> I attached the TransparentTextBox files for your convenience....
>>
>> "Bob Dankert" <bobatnvsn-itdotcom@nospam.nospam> wrote in message=20
>> news:uBMqTWmiFHA.3288@TK2MSFTNGP09.phx.gbl...
>>>I am creating a custom textbox that requires me to handle the =
OnPaint
>>> mechanism. Currently, I am using WM_PRINT to draw the text in the =

>>> textbox
>>> and am running into a problem. The text will never follow the =
font that=20
>>> is
>>> specified by the textbox, it is always the same no matter what I =
change=20
>>> it
>>> to. Is there some way to get WM_PRINT to use the font that the =
textbox=20
>>> is
>>> set with?
>>>
>>> I stripped down the code for my class to the following to show the =
issue:
>>> using System;
>>> using System.Windows.Forms;
>>> namespace TransTextBox
>>> {
>>> public class MyTextBox : TextBox
>>> {
>>> public MyTextBox()
>>> {
>>> this.SetStyle(ControlStyles.UserPaint |=20
>>> ControlStyles.AllPaintingInWmPaint |
>>> ControlStyles.DoubleBuffer | =
ControlStyles.SupportsTransparentBackColor,
>>> true);
>>> }
>>> protected override void =
OnPaint(System.Windows.Forms.PaintEventArgs e)
>>> {
>>> System.IntPtr hdc =3D e.Graphics.GetHdc();
>>> this.SetStyle(ControlStyles.UserPaint, false);
>>> try
>>> {
>>> const Int32 WM_PRINT =3D 0x0317;
>>> const long PRF_CLIENT =3D 0x00000004;
>>> Message m =3D Message.Create(this.Handle, WM_PRINT, hdc, new
>>> System.IntPtr(PRF_CLIENT));
>>> this.WndProc(ref m);
>>> }
>>> catch { }
>>> finally
>>> {
>>> e.Graphics.ReleaseHdc(hdc);
>>> this.SetStyle(ControlStyles.UserPaint, true);
>>> }
>>> }
>>> }
>>> }
>>>
>>> I appreciate any help - thanks.
>>>
>>> Bob Dankert
>>>
>>>
>>
>>
>>=20
>=20
>
------=_NextPart_000_0012_01C58C3B.CFDEEE60
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2668" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Lloyd - I only see the code handling =
the WM_PAINT=20
(paint, not print) message in that code???</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Lloyd Dupont" &lt;<A=20
=
href=3D"mailto:ld@NewsAccount.galador.net">ld@NewsAccount.galador.net</A>=
&gt;=20
wrote in message <A=20
=
href=3D"news:e65bqC6iFHA.1948@TK2MSFTNGP12.phx.gbl">news:e65bqC6iFHA.1948=
@TK2MSFTNGP12.phx.gbl</A>...</DIV>
<DIV><FONT face=3DArial size=3D2>I see you've got your =
answer!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Anyway here is where is the WM_PRINT =
message in=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT><FONT size=3D2>
<P></FONT><FONT color=3D#0000ff size=3D2>protected</FONT><FONT =
size=3D2>=20
</FONT><FONT color=3D#0000ff size=3D2>override</FONT><FONT size=3D2> =
</FONT><FONT=20
color=3D#0000ff size=3D2>void</FONT><FONT size=3D2> =
WndProc(</FONT><FONT=20
color=3D#0000ff size=3D2>ref</FONT><FONT size=3D2> </FONT><FONT =
color=3D#008080=20
size=3D2>Message</FONT><FONT size=3D2> m)<BR>{<BR></FONT><FONT =
color=3D#0000ff=20
size=3D2>&nbsp;&nbsp;&nbsp; base</FONT><FONT =
size=3D2>.WndProc(</FONT><FONT=20
color=3D#0000ff size=3D2>ref</FONT><FONT size=3D2> m);<BR></FONT><FONT =
color=3D#0000ff=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;switch</FONT><FONT size=3D2>=20
(m.Msg)<BR></FONT><FONT size=3D2>&nbsp;&nbsp;&nbsp; {<BR></FONT><FONT=20
color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
case</FONT><FONT=20
size=3D2> </FONT><FONT color=3D#008080 size=3D2>Win32</FONT><FONT=20
size=3D2>.WM_PAINT:&nbsp;&nbsp;<BR></FONT><FONT =
size=3D2>&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; myPaintedFirstTime =3D =
</FONT><FONT=20
color=3D#0000ff size=3D2>true</FONT><FONT size=3D2>;<BR></FONT><FONT =
color=3D#0000ff=20
size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
if</FONT><FONT=20
size=3D2> (!myUpToDate || !myCaretUpToDate)<BR>&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; GetBitmaps(); =

=3D=3D=3D=3D=3D=3D=3D=3D=3D&gt;&gt;&gt;&gt; <FONT color=3D#008080 =
size=3D2>Win32</FONT><FONT=20
size=3D2>.CaptureWindow(</FONT><FONT color=3D#0000ff =
size=3D2>this</FONT><FONT=20
size=3D2>,=20
=
myBitmap);</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;=20
.......</FONT></P>
<P><FONT size=3D2></FONT><FONT size=3D2>&nbsp;</P></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>"Bob Dankert" &lt;</FONT><A=20
href=3D"mailto:bob@nospamnvsn-it.com"><FONT face=3DArial=20
size=3D2>bob@nospamnvsn-it.com</FONT></A><FONT face=3DArial =
size=3D2>&gt; wrote in=20
message </FONT><A =
href=3D"news:eM3zIHviFHA.3064@TK2MSFTNGP15.phx.gbl"><FONT=20
face=3DArial =
size=3D2>news:eM3zIHviFHA.3064@TK2MSFTNGP15.phx.gbl</FONT></A><FONT=20
face=3DArial size=3D2>...</FONT></DIV><FONT face=3DArial size=3D2>&gt; =
I'm not really=20
sure how the code seems similar??&nbsp; After looking at that code =
<BR>&gt;=20
sample, it seems like it is creating bitmaps to display everything - I =

<BR>&gt; didn't see any mention of WM_PRINT.<BR>&gt; <BR>&gt; The code =
is=20
certainly creative as far as accomplishing a transparent <BR>&gt; =
textbox,=20
though.<BR>&gt; <BR>&gt; Anyways, I'm still having the same =
issue.<BR>&gt;=20
<BR>&gt; Bob<BR>&gt; "Lloyd Dupont" &lt;</FONT><A=20
href=3D"mailto:ld@NewsAccount.galador.net"><FONT face=3DArial=20
size=3D2>ld@NewsAccount.galador.net</FONT></A><FONT face=3DArial =
size=3D2>&gt; wrote=20
in message <BR>&gt; </FONT><A=20
href=3D"news:ezMcIQtiFHA.3256@TK2MSFTNGP12.phx.gbl"><FONT face=3DArial =

size=3D2>news:ezMcIQtiFHA.3256@TK2MSFTNGP12.phx.gbl</FONT></A><FONT =
face=3DArial=20
size=3D2>...<BR>&gt;&gt; Hi Bob!<BR>&gt;&gt; interesting=20
code!<BR>&gt;&gt;<BR>&gt;&gt; while I don't have a solution for your =
problem,=20
I'm using a sample <BR>&gt;&gt; transparent text box I found on code =
project,=20
it work in a similar way (in <BR>&gt;&gt; fact the code seems a bit =
chaotic,=20
but I didn't bother clean it), and it <BR>&gt;&gt; has no problem at=20
all!!<BR>&gt;&gt;<BR>&gt;&gt; I attached the TransparentTextBox files =
for your=20
convenience....<BR>&gt;&gt;<BR>&gt;&gt; "Bob Dankert" &lt;</FONT><A=20
href=3D"mailto:bobatnvsn-itdotcom@nospam.nospam"><FONT face=3DArial=20
size=3D2>bobatnvsn-itdotcom@nospam.nospam</FONT></A><FONT face=3DArial =
size=3D2>&gt;=20
wrote in message <BR>&gt;&gt; </FONT><A=20
href=3D"news:uBMqTWmiFHA.3288@TK2MSFTNGP09.phx.gbl"><FONT face=3DArial =

size=3D2>news:uBMqTWmiFHA.3288@TK2MSFTNGP09.phx.gbl</FONT></A><FONT =
face=3DArial=20
size=3D2>...<BR>&gt;&gt;&gt;I am creating a custom textbox that =
requires me to=20
handle the OnPaint<BR>&gt;&gt;&gt; mechanism.&nbsp; Currently, I am =
using=20
WM_PRINT to draw the text in the <BR>&gt;&gt;&gt; =
textbox<BR>&gt;&gt;&gt; and=20
am running into a problem.&nbsp; The text will never follow the font =
that=20
<BR>&gt;&gt;&gt; is<BR>&gt;&gt;&gt; specified by the textbox, it is =
always the=20
same no matter what I change <BR>&gt;&gt;&gt; it<BR>&gt;&gt;&gt; =
to.&nbsp; Is=20
there some way to get WM_PRINT to use the font that the textbox=20
<BR>&gt;&gt;&gt; is<BR>&gt;&gt;&gt; set =
with?<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt;=20
I stripped down the code for my class to the following to show the=20
issue:<BR>&gt;&gt;&gt; using System;<BR>&gt;&gt;&gt; using=20
System.Windows.Forms;<BR>&gt;&gt;&gt; namespace =
TransTextBox<BR>&gt;&gt;&gt;=20
{<BR>&gt;&gt;&gt; public class MyTextBox : TextBox<BR>&gt;&gt;&gt;=20
{<BR>&gt;&gt;&gt; public MyTextBox()<BR>&gt;&gt;&gt; {<BR>&gt;&gt;&gt; =

this.SetStyle(ControlStyles.UserPaint | <BR>&gt;&gt;&gt;=20
ControlStyles.AllPaintingInWmPaint |<BR>&gt;&gt;&gt;=20
ControlStyles.DoubleBuffer |=20
ControlStyles.SupportsTransparentBackColor,<BR>&gt;&gt;&gt;=20
true);<BR>&gt;&gt;&gt; }<BR>&gt;&gt;&gt; protected override void=20
OnPaint(System.Windows.Forms.PaintEventArgs e)<BR>&gt;&gt;&gt;=20
{<BR>&gt;&gt;&gt; System.IntPtr hdc =3D =
e.Graphics.GetHdc();<BR>&gt;&gt;&gt;=20
this.SetStyle(ControlStyles.UserPaint, false);<BR>&gt;&gt;&gt;=20
try<BR>&gt;&gt;&gt; {<BR>&gt;&gt;&gt; const Int32 WM_PRINT =3D=20
0x0317;<BR>&gt;&gt;&gt; const long PRF_CLIENT =3D =
0x00000004;<BR>&gt;&gt;&gt;=20
Message m =3D Message.Create(this.Handle, WM_PRINT, hdc, =
new<BR>&gt;&gt;&gt;=20
System.IntPtr(PRF_CLIENT));<BR>&gt;&gt;&gt; this.WndProc(ref=20
m);<BR>&gt;&gt;&gt; }<BR>&gt;&gt;&gt; catch { }<BR>&gt;&gt;&gt;=20
finally<BR>&gt;&gt;&gt; {<BR>&gt;&gt;&gt;=20
e.Graphics.ReleaseHdc(hdc);<BR>&gt;&gt;&gt;=20
this.SetStyle(ControlStyles.UserPaint, true);<BR>&gt;&gt;&gt;=20
}<BR>&gt;&gt;&gt; }<BR>&gt;&gt;&gt; }<BR>&gt;&gt;&gt;=20
}<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; I appreciate any help -=20
thanks.<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; Bob=20
=
Dankert<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt;<BR>&gt;&gt;<BR>&gt;&gt;<BR>&gt;&g=
t;=20
<BR>&gt; <BR>&gt;</FONT> </BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0012_01C58C3B.CFDEEE60--


Re: UserPaint a TextBox - issue with WM_PRINT by Lloyd

Lloyd
Wed Jul 20 05:44:11 CDT 2005

This is a multi-part message in MIME format.

------=_NextPart_000_0035_01C58D6B.C8ABDA50
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

as you see in WM_PAINT there is a call to GetBitmaps().
I write (as an hint) GetBimtap next to it.
That means, if you look in the code of GetBitmap() you will see it =
callls Win32.CaptureWindow() that send the WM_PRINT message to the =
control.

On top of that code "handle" WM_PAINT, yes, but how do you think it =
*actually* does the painting?
By "sending" WM_PRINT to the win32 control, hey!



"Bob Dankert" <bobatnvsn-itdotcom@nospam.nospam> wrote in message =
news:%23$rl5WGjFHA.1968@TK2MSFTNGP14.phx.gbl...
Lloyd - I only see the code handling the WM_PAINT (paint, not print) =
message in that code???
"Lloyd Dupont" <ld@NewsAccount.galador.net> wrote in message =
news:e65bqC6iFHA.1948@TK2MSFTNGP12.phx.gbl...
I see you've got your answer!

Anyway here is where is the WM_PRINT message in=20
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
switch (m.Msg)
{
case Win32.WM_PAINT: =20
myPaintedFirstTime =3D true;
if (!myUpToDate || !myCaretUpToDate)
GetBitmaps(); =3D=3D=3D=3D=3D=3D=3D=3D=3D>>>> =
Win32.CaptureWindow(this, myBitmap);
.......






"Bob Dankert" <bob@nospamnvsn-it.com> wrote in message =
news:eM3zIHviFHA.3064@TK2MSFTNGP15.phx.gbl...
> I'm not really sure how the code seems similar?? After looking at =
that code=20
> sample, it seems like it is creating bitmaps to display everything =
- I=20
> didn't see any mention of WM_PRINT.
>=20
> The code is certainly creative as far as accomplishing a =
transparent=20
> textbox, though.
>=20
> Anyways, I'm still having the same issue.
>=20
> Bob
> "Lloyd Dupont" <ld@NewsAccount.galador.net> wrote in message=20
> news:ezMcIQtiFHA.3256@TK2MSFTNGP12.phx.gbl...
>> Hi Bob!
>> interesting code!
>>
>> while I don't have a solution for your problem, I'm using a =
sample=20
>> transparent text box I found on code project, it work in a =
similar way (in=20
>> fact the code seems a bit chaotic, but I didn't bother clean it), =
and it=20
>> has no problem at all!!
>>
>> I attached the TransparentTextBox files for your convenience....
>>
>> "Bob Dankert" <bobatnvsn-itdotcom@nospam.nospam> wrote in message =

>> news:uBMqTWmiFHA.3288@TK2MSFTNGP09.phx.gbl...
>>>I am creating a custom textbox that requires me to handle the =
OnPaint
>>> mechanism. Currently, I am using WM_PRINT to draw the text in =
the=20
>>> textbox
>>> and am running into a problem. The text will never follow the =
font that=20
>>> is
>>> specified by the textbox, it is always the same no matter what I =
change=20
>>> it
>>> to. Is there some way to get WM_PRINT to use the font that the =
textbox=20
>>> is
>>> set with?
>>>
>>> I stripped down the code for my class to the following to show =
the issue:
>>> using System;
>>> using System.Windows.Forms;
>>> namespace TransTextBox
>>> {
>>> public class MyTextBox : TextBox
>>> {
>>> public MyTextBox()
>>> {
>>> this.SetStyle(ControlStyles.UserPaint |=20
>>> ControlStyles.AllPaintingInWmPaint |
>>> ControlStyles.DoubleBuffer | =
ControlStyles.SupportsTransparentBackColor,
>>> true);
>>> }
>>> protected override void =
OnPaint(System.Windows.Forms.PaintEventArgs e)
>>> {
>>> System.IntPtr hdc =3D e.Graphics.GetHdc();
>>> this.SetStyle(ControlStyles.UserPaint, false);
>>> try
>>> {
>>> const Int32 WM_PRINT =3D 0x0317;
>>> const long PRF_CLIENT =3D 0x00000004;
>>> Message m =3D Message.Create(this.Handle, WM_PRINT, hdc, new
>>> System.IntPtr(PRF_CLIENT));
>>> this.WndProc(ref m);
>>> }
>>> catch { }
>>> finally
>>> {
>>> e.Graphics.ReleaseHdc(hdc);
>>> this.SetStyle(ControlStyles.UserPaint, true);
>>> }
>>> }
>>> }
>>> }
>>>
>>> I appreciate any help - thanks.
>>>
>>> Bob Dankert
>>>
>>>
>>
>>
>>=20
>=20
>
------=_NextPart_000_0035_01C58D6B.C8ABDA50
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2668" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>as you see in WM_PAINT there is a call =
to=20
GetBitmaps().</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I write (as an hint) GetBimtap next to=20
it.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>That means, if you look in the code of =
GetBitmap()=20
you will see it callls Win32.CaptureWindow() that send the WM_PRINT =
message to=20
the control.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>On top of that code "handle" WM_PAINT,=20
yes,&nbsp;but how do you think it *actually* does the =
painting?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>By "sending" WM_PRINT to the win32 =
control,=20
hey!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>"Bob Dankert" &lt;<A=20
href=3D"mailto:bobatnvsn-itdotcom@nospam.nospam">bobatnvsn-itdotcom@nospa=
m.nospam</A>&gt;=20
wrote in message <A=20
href=3D"news:%23$rl5WGjFHA.1968@TK2MSFTNGP14.phx.gbl">news:%23$rl5WGjFHA.=
1968@TK2MSFTNGP14.phx.gbl</A>...</DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV><FONT face=3DArial size=3D2>Lloyd - I only see the code handling =
the WM_PAINT=20
(paint, not print) message in that code???</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Lloyd Dupont" &lt;<A=20
=
href=3D"mailto:ld@NewsAccount.galador.net">ld@NewsAccount.galador.net</A>=
&gt;=20
wrote in message <A=20
=
href=3D"news:e65bqC6iFHA.1948@TK2MSFTNGP12.phx.gbl">news:e65bqC6iFHA.1948=
@TK2MSFTNGP12.phx.gbl</A>...</DIV>
<DIV><FONT face=3DArial size=3D2>I see you've got your =
answer!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Anyway here is where is the =
WM_PRINT message in=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT><FONT size=3D2>
<P></FONT><FONT color=3D#0000ff size=3D2>protected</FONT><FONT =
size=3D2>=20
</FONT><FONT color=3D#0000ff size=3D2>override</FONT><FONT size=3D2> =
</FONT><FONT=20
color=3D#0000ff size=3D2>void</FONT><FONT size=3D2> =
WndProc(</FONT><FONT=20
color=3D#0000ff size=3D2>ref</FONT><FONT size=3D2> </FONT><FONT =
color=3D#008080=20
size=3D2>Message</FONT><FONT size=3D2> m)<BR>{<BR></FONT><FONT =
color=3D#0000ff=20
size=3D2>&nbsp;&nbsp;&nbsp; base</FONT><FONT =
size=3D2>.WndProc(</FONT><FONT=20
color=3D#0000ff size=3D2>ref</FONT><FONT size=3D2> =
m);<BR></FONT><FONT=20
color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;switch</FONT><FONT =
size=3D2>=20
(m.Msg)<BR></FONT><FONT size=3D2>&nbsp;&nbsp;&nbsp; =
{<BR></FONT><FONT=20
color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
case</FONT><FONT=20
size=3D2> </FONT><FONT color=3D#008080 size=3D2>Win32</FONT><FONT=20
size=3D2>.WM_PAINT:&nbsp;&nbsp;<BR></FONT><FONT =
size=3D2>&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; myPaintedFirstTime =3D =
</FONT><FONT=20
color=3D#0000ff size=3D2>true</FONT><FONT size=3D2>;<BR></FONT><FONT =
color=3D#0000ff=20
size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
if</FONT><FONT size=3D2> (!myUpToDate ||=20
!myCaretUpToDate)<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; GetBitmaps();=20
=3D=3D=3D=3D=3D=3D=3D=3D=3D&gt;&gt;&gt;&gt; <FONT color=3D#008080 =
size=3D2>Win32</FONT><FONT=20
size=3D2>.CaptureWindow(</FONT><FONT color=3D#0000ff =
size=3D2>this</FONT><FONT=20
size=3D2>,=20
=
myBitmap);</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;=20
.......</FONT></P>
<P><FONT size=3D2></FONT><FONT size=3D2>&nbsp;</P></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>"Bob Dankert" &lt;</FONT><A=20
href=3D"mailto:bob@nospamnvsn-it.com"><FONT face=3DArial=20
size=3D2>bob@nospamnvsn-it.com</FONT></A><FONT face=3DArial =
size=3D2>&gt; wrote in=20
message </FONT><A =
href=3D"news:eM3zIHviFHA.3064@TK2MSFTNGP15.phx.gbl"><FONT=20
face=3DArial =
size=3D2>news:eM3zIHviFHA.3064@TK2MSFTNGP15.phx.gbl</FONT></A><FONT=20
face=3DArial size=3D2>...</FONT></DIV><FONT face=3DArial =
size=3D2>&gt; I'm not=20
really sure how the code seems similar??&nbsp; After looking at that =
code=20
<BR>&gt; sample, it seems like it is creating bitmaps to display =
everything=20
- I <BR>&gt; didn't see any mention of WM_PRINT.<BR>&gt; <BR>&gt; =
The code=20
is certainly creative as far as accomplishing a transparent <BR>&gt; =

textbox, though.<BR>&gt; <BR>&gt; Anyways, I'm still having the same =

issue.<BR>&gt; <BR>&gt; Bob<BR>&gt; "Lloyd Dupont" &lt;</FONT><A=20
href=3D"mailto:ld@NewsAccount.galador.net"><FONT face=3DArial=20
size=3D2>ld@NewsAccount.galador.net</FONT></A><FONT face=3DArial =
size=3D2>&gt;=20
wrote in message <BR>&gt; </FONT><A=20
href=3D"news:ezMcIQtiFHA.3256@TK2MSFTNGP12.phx.gbl"><FONT =
face=3DArial=20
size=3D2>news:ezMcIQtiFHA.3256@TK2MSFTNGP12.phx.gbl</FONT></A><FONT =
face=3DArial=20
size=3D2>...<BR>&gt;&gt; Hi Bob!<BR>&gt;&gt; interesting=20
code!<BR>&gt;&gt;<BR>&gt;&gt; while I don't have a solution for your =

problem, I'm using a sample <BR>&gt;&gt; transparent text box I =
found on=20
code project, it work in a similar way (in <BR>&gt;&gt; fact the =
code seems=20
a bit chaotic, but I didn't bother clean it), and it <BR>&gt;&gt; =
has no=20
problem at all!!<BR>&gt;&gt;<BR>&gt;&gt; I attached the =
TransparentTextBox=20
files for your convenience....<BR>&gt;&gt;<BR>&gt;&gt; "Bob Dankert" =

&lt;</FONT><A href=3D"mailto:bobatnvsn-itdotcom@nospam.nospam"><FONT =

face=3DArial =
size=3D2>bobatnvsn-itdotcom@nospam.nospam</FONT></A><FONT=20
face=3DArial size=3D2>&gt; wrote in message <BR>&gt;&gt; </FONT><A=20
href=3D"news:uBMqTWmiFHA.3288@TK2MSFTNGP09.phx.gbl"><FONT =
face=3DArial=20
size=3D2>news:uBMqTWmiFHA.3288@TK2MSFTNGP09.phx.gbl</FONT></A><FONT =
face=3DArial=20
size=3D2>...<BR>&gt;&gt;&gt;I am creating a custom textbox that =
requires me to=20
handle the OnPaint<BR>&gt;&gt;&gt; mechanism.&nbsp; Currently, I am =
using=20
WM_PRINT to draw the text in the <BR>&gt;&gt;&gt; =
textbox<BR>&gt;&gt;&gt;=20
and am running into a problem.&nbsp; The text will never follow the =
font=20
that <BR>&gt;&gt;&gt; is<BR>&gt;&gt;&gt; specified by the textbox, =
it is=20
always the same no matter what I change <BR>&gt;&gt;&gt; =
it<BR>&gt;&gt;&gt;=20
to.&nbsp; Is there some way to get WM_PRINT to use the font that the =
textbox=20
<BR>&gt;&gt;&gt; is<BR>&gt;&gt;&gt; set=20
with?<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; I stripped down the code for =
my class=20
to the following to show the issue:<BR>&gt;&gt;&gt; using=20
System;<BR>&gt;&gt;&gt; using System.Windows.Forms;<BR>&gt;&gt;&gt;=20
namespace TransTextBox<BR>&gt;&gt;&gt; {<BR>&gt;&gt;&gt; public =
class=20
MyTextBox : TextBox<BR>&gt;&gt;&gt; {<BR>&gt;&gt;&gt; public=20
MyTextBox()<BR>&gt;&gt;&gt; {<BR>&gt;&gt;&gt;=20
this.SetStyle(ControlStyles.UserPaint | <BR>&gt;&gt;&gt;=20
ControlStyles.AllPaintingInWmPaint |<BR>&gt;&gt;&gt;=20
ControlStyles.DoubleBuffer |=20
ControlStyles.SupportsTransparentBackColor,<BR>&gt;&gt;&gt;=20
true);<BR>&gt;&gt;&gt; }<BR>&gt;&gt;&gt; protected override void=20
OnPaint(System.Windows.Forms.PaintEventArgs e)<BR>&gt;&gt;&gt;=20
{<BR>&gt;&gt;&gt; System.IntPtr hdc =3D =
e.Graphics.GetHdc();<BR>&gt;&gt;&gt;=20
this.SetStyle(ControlStyles.UserPaint, false);<BR>&gt;&gt;&gt;=20
try<BR>&gt;&gt;&gt; {<BR>&gt;&gt;&gt; const Int32 WM_PRINT =3D=20
0x0317;<BR>&gt;&gt;&gt; const long PRF_CLIENT =3D =
0x00000004;<BR>&gt;&gt;&gt;=20
Message m =3D Message.Create(this.Handle, WM_PRINT, hdc, =
new<BR>&gt;&gt;&gt;=20
System.IntPtr(PRF_CLIENT));<BR>&gt;&gt;&gt; this.WndProc(ref=20
m);<BR>&gt;&gt;&gt; }<BR>&gt;&gt;&gt; catch { }<BR>&gt;&gt;&gt;=20
finally<BR>&gt;&gt;&gt; {<BR>&gt;&gt;&gt;=20
e.Graphics.ReleaseHdc(hdc);<BR>&gt;&gt;&gt;=20
this.SetStyle(ControlStyles.UserPaint, true);<BR>&gt;&gt;&gt;=20
}<BR>&gt;&gt;&gt; }<BR>&gt;&gt;&gt; }<BR>&gt;&gt;&gt;=20
}<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; I appreciate any help -=20
thanks.<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; Bob=20
=
Dankert<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt;<BR>&gt;&gt;<BR>&gt;&gt;<BR>&gt;&g=
t;=20
<BR>&gt; <BR>&gt;</FONT> </BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0035_01C58D6B.C8ABDA50--