OK, having answered my questions in a previous feed about pulling my derived
class into the IDE....
Here's a new problem that I'm hoping can be fixed and isn't a .NET bug....
I have created an inherited class based on the textbox... which, all I am
doing is allowing a forecolor to be set when .enabled is set to true.
it works nicely, EXCEPT that when I click into the box, the font (set as
default MS Sans 8.25pt) does not appear to be used and instead what looks
like an Arial 10pt or larger is used - and there is some messy painting
going on.....doesn't clear the original text and the 2 fonts run into each
other...
Here's the entire class;
Public Class LinkMAN_TextBox
Inherits System.Windows. Forms.TextBox
Protected Overrides Sub OnPaint(ByVal e As
System.Windows. Forms.PaintEven tArgs)
Dim drawBrush As New SolidBrush(Me.F oreColor)
e.Graphics.Draw String(Me.Text, Me.Font, drawBrush, 0.0F, 0.0F)
End Sub
Public Sub New()
MyBase.New()
Me.SetStyle(Con trolStyles.User Paint, True)
End Sub
End Class
I suspect this may be a bug, but if anyone can help I'd appreciate it.
Thanks,
Graham 7 1465
Hi,
Try this. I solved some of the problems by only drawing the textbox
when it is readonly. I also invalidate when it recieves the wm_setcursor
message. Hope this helps.
Public Class ExtendedTextbox
Inherits TextBox
Public Sub New()
setstyle(Contro lStyles.UserPai nt, True)
End Sub
Protected Overrides Sub OnPaintBackgrou nd(ByVal pevent As
System.Windows. Forms.PaintEven tArgs)
If Me.ReadOnly Then
pevent.Graphics .Clear(Me.BackC olor)
Else
MyBase.OnPaintB ackground(peven t)
End If
End Sub
Protected Overrides Sub OnPaint(ByVal e As
System.Windows. Forms.PaintEven tArgs)
Dim br As New SolidBrush(Me.F oreColor)
Dim sf As New StringFormat
Dim rDraw As RectangleF = RectangleF.op_I mplicit(Me.Clie ntRectangle)
rDraw.Inflate(-5, 0)
Select Case Me.TextAlign
Case HorizontalAlign ment.Center
sf.Alignment = StringAlignment .Center
Case HorizontalAlign ment.Left
sf.Alignment = StringAlignment .Near
Case HorizontalAlign ment.Right
sf.Alignment = StringAlignment .Far
End Select
If Me.ReadOnly Then
e.Graphics.Draw String(Me.Text, Me.Font, br, rDraw, sf)
Else
MyBase.OnPaint( e)
End If
End Sub
Protected Overrides Sub WndProc(ByRef m As System.Windows. Forms.Message)
Const WM_SETCURSOR As Integer = &H20
If m.Msg = WM_SETCURSOR And Me.ReadOnly Then
Me.Invalidate()
Else
MyBase.WndProc( m)
End If
End Sub
End Class
Ken
--------------------------------
"Graham Blandford" <gr************ **@sympatico.ca > wrote in message
news:b7******** *************@n ews20.bellgloba l.com... OK, having answered my questions in a previous feed about pulling my derived class into the IDE....
Here's a new problem that I'm hoping can be fixed and isn't a .NET bug....
I have created an inherited class based on the textbox... which, all I am doing is allowing a forecolor to be set when .enabled is set to true.
it works nicely, EXCEPT that when I click into the box, the font (set as default MS Sans 8.25pt) does not appear to be used and instead what looks like an Arial 10pt or larger is used - and there is some messy painting going on.....doesn't clear the original text and the 2 fonts run into each other...
Here's the entire class;
Public Class LinkMAN_TextBox Inherits System.Windows. Forms.TextBox Protected Overrides Sub OnPaint(ByVal e As System.Windows. Forms.PaintEven tArgs)
Dim drawBrush As New SolidBrush(Me.F oreColor) e.Graphics.Draw String(Me.Text, Me.Font, drawBrush, 0.0F, 0.0F)
End Sub
Public Sub New() MyBase.New() Me.SetStyle(Con trolStyles.User Paint, True) End Sub
End Class
I suspect this may be a bug, but if anyone can help I'd appreciate it.
Thanks, Graham
Hi Ken,
Appears to raise more issues than resolving...
My disabled boxes show empty, and nothing changes on the enabled box - I'm
gonna try and play with performing the Mybase.?? methods and replace them
one at a time to see what happens - or indeed see if executing the mybase
methods still causes the problem - in which case it is safe to say these are
bugs???
Thanks,
Graham
"Ken Tucker [MVP]" <vb***@bellsout h.net> wrote in message
news:uy******** ******@TK2MSFTN GP12.phx.gbl... Hi,
Try this. I solved some of the problems by only drawing the
textbox when it is readonly. I also invalidate when it recieves the wm_setcursor message. Hope this helps.
Public Class ExtendedTextbox
Inherits TextBox Public Sub New()
setstyle(Contro lStyles.UserPai nt, True)
End Sub
Protected Overrides Sub OnPaintBackgrou nd(ByVal pevent As System.Windows. Forms.PaintEven tArgs)
If Me.ReadOnly Then
pevent.Graphics .Clear(Me.BackC olor)
Else
MyBase.OnPaintB ackground(peven t)
End If
End Sub
Protected Overrides Sub OnPaint(ByVal e As System.Windows. Forms.PaintEven tArgs)
Dim br As New SolidBrush(Me.F oreColor)
Dim sf As New StringFormat
Dim rDraw As RectangleF = RectangleF.op_I mplicit(Me.Clie ntRectangle)
rDraw.Inflate(-5, 0)
Select Case Me.TextAlign
Case HorizontalAlign ment.Center
sf.Alignment = StringAlignment .Center
Case HorizontalAlign ment.Left
sf.Alignment = StringAlignment .Near
Case HorizontalAlign ment.Right
sf.Alignment = StringAlignment .Far
End Select If Me.ReadOnly Then
e.Graphics.Draw String(Me.Text, Me.Font, br, rDraw, sf)
Else
MyBase.OnPaint( e)
End If
End Sub Protected Overrides Sub WndProc(ByRef m As System.Windows. Forms.Message)
Const WM_SETCURSOR As Integer = &H20
If m.Msg = WM_SETCURSOR And Me.ReadOnly Then
Me.Invalidate()
Else
MyBase.WndProc( m)
End If
End Sub
End Class Ken
--------------------------------
"Graham Blandford" <gr************ **@sympatico.ca > wrote in message news:b7******** *************@n ews20.bellgloba l.com... OK, having answered my questions in a previous feed about pulling my derived class into the IDE....
Here's a new problem that I'm hoping can be fixed and isn't a .NET
bug.... I have created an inherited class based on the textbox... which, all I
am doing is allowing a forecolor to be set when .enabled is set to true.
it works nicely, EXCEPT that when I click into the box, the font (set as default MS Sans 8.25pt) does not appear to be used and instead what
looks like an Arial 10pt or larger is used - and there is some messy painting going on.....doesn't clear the original text and the 2 fonts run into
each other...
Here's the entire class;
Public Class LinkMAN_TextBox Inherits System.Windows. Forms.TextBox Protected Overrides Sub OnPaint(ByVal e As System.Windows. Forms.PaintEven tArgs)
Dim drawBrush As New SolidBrush(Me.F oreColor) e.Graphics.Draw String(Me.Text, Me.Font, drawBrush, 0.0F, 0.0F)
End Sub
Public Sub New() MyBase.New() Me.SetStyle(Con trolStyles.User Paint, True) End Sub
End Class
I suspect this may be a bug, but if anyone can help I'd appreciate it.
Thanks, Graham
Hi Graham
This looks like the same problem that I am having with custom controls with
style set to userpaint.
I have been trying to solve the problem of TabItems not resizing to
accomodate the set Font in a userpaint TabControl, and it looks like this is
the problem. If I find the answer I'll post it. A quick look at MSDN shows
that when WM_GETFONT returns 0 the system default font is used to draw
text(which would probably be Arial 10) I cannot catch a WM_GETFONT or
WM_SETFONT message though, unless I remove the userpaint style.
--
Mick Doherty http://dotnetrix.co.uk/nothing.html
"Graham Blandford" <gr************ **@sympatico.ca > wrote in message
news:b7******** *************@n ews20.bellgloba l.com... OK, having answered my questions in a previous feed about pulling my
derived class into the IDE....
Here's a new problem that I'm hoping can be fixed and isn't a .NET bug....
I have created an inherited class based on the textbox... which, all I am doing is allowing a forecolor to be set when .enabled is set to true.
it works nicely, EXCEPT that when I click into the box, the font (set as default MS Sans 8.25pt) does not appear to be used and instead what looks like an Arial 10pt or larger is used - and there is some messy painting going on.....doesn't clear the original text and the 2 fonts run into each other...
Here's the entire class;
Public Class LinkMAN_TextBox Inherits System.Windows. Forms.TextBox Protected Overrides Sub OnPaint(ByVal e As System.Windows. Forms.PaintEven tArgs)
Dim drawBrush As New SolidBrush(Me.F oreColor) e.Graphics.Draw String(Me.Text, Me.Font, drawBrush, 0.0F, 0.0F)
End Sub
Public Sub New() MyBase.New() Me.SetStyle(Con trolStyles.User Paint, True) End Sub
End Class
I suspect this may be a bug, but if anyone can help I'd appreciate it.
Thanks, Graham
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ( http://www.grisoft.com).
Version: 6.0.719 / Virus Database: 475 - Release Date: 12/07/2004
Thanks Mick - if you do manage to find a solution, feel free to let me know.
In the meantime, any ideas on my recourse - should this be reported as a bug
to MS - if it hasn't already - and is there a 'correct' way to reporting
these?
Thanks,
Graham
"Mick Doherty"
<EX***********@ AND.REMOVE.SQUA REBRACKETS.[mdaudi100#ntlwo rld.com]> wrote in
message news:eQ******** *****@TK2MSFTNG P10.phx.gbl... Hi Graham
This looks like the same problem that I am having with custom controls
with style set to userpaint. I have been trying to solve the problem of TabItems not resizing to accomodate the set Font in a userpaint TabControl, and it looks like this
is the problem. If I find the answer I'll post it. A quick look at MSDN shows that when WM_GETFONT returns 0 the system default font is used to draw text(which would probably be Arial 10) I cannot catch a WM_GETFONT or WM_SETFONT message though, unless I remove the userpaint style.
-- Mick Doherty http://dotnetrix.co.uk/nothing.html
"Graham Blandford" <gr************ **@sympatico.ca > wrote in message news:b7******** *************@n ews20.bellgloba l.com... OK, having answered my questions in a previous feed about pulling my derived class into the IDE....
Here's a new problem that I'm hoping can be fixed and isn't a .NET
bug.... I have created an inherited class based on the textbox... which, all I
am doing is allowing a forecolor to be set when .enabled is set to true.
it works nicely, EXCEPT that when I click into the box, the font (set as default MS Sans 8.25pt) does not appear to be used and instead what
looks like an Arial 10pt or larger is used - and there is some messy painting going on.....doesn't clear the original text and the 2 fonts run into
each other...
Here's the entire class;
Public Class LinkMAN_TextBox Inherits System.Windows. Forms.TextBox Protected Overrides Sub OnPaint(ByVal e As System.Windows. Forms.PaintEven tArgs)
Dim drawBrush As New SolidBrush(Me.F oreColor) e.Graphics.Draw String(Me.Text, Me.Font, drawBrush, 0.0F, 0.0F)
End Sub
Public Sub New() MyBase.New() Me.SetStyle(Con trolStyles.User Paint, True) End Sub
End Class
I suspect this may be a bug, but if anyone can help I'd appreciate it.
Thanks, Graham
--- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.719 / Virus Database: 475 - Release Date: 12/07/2004
I can't get it to play nicely. I can change the font, but it's not quite the
right size.
In sub New() add the line:
\\\
Font = New Font(Font, Font.Size)
///
Then add:
\\\
Protected Overrides Sub OnFontChanged(B yVal e As System.EventArg s)
MyBase.OnFontCh anged(e)
Const WM_SETFONT As Integer = &H30
WndProc(Message .Create(Handle, WM_SETFONT, Font.ToHfont, IntPtr.Zero))
End Sub
///
--
Mick Doherty http://dotnetrix.co.uk/nothing.html
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ( http://www.grisoft.com).
Version: 6.0.719 / Virus Database: 475 - Release Date: 12/07/2004
Hi Mick,
It certainly put me on the right track - and think I've cracked it. Well ...
at least for this particular scenario. I can change the forecolour of my
disabled boxes...
Notice I used Font.Style instead of Font.Size in the Font assign.
Anyway, this is what I have ended up with...
Public Class ExtendedTextBox
Inherits System.Windows. Forms.TextBox
Public Sub New()
MyBase.New()
Font = New Font(Font, Font.Style)
End Sub
Protected Overrides Sub OnPaint(ByVal e As
System.Windows. Forms.PaintEven tArgs)
Dim drawBrush As New SolidBrush(Me.F oreColor)
e.Graphics.Draw String(Me.Text, Me.Font, drawBrush, 0.0F, 0.0F)
End Sub
Protected Overrides Sub OnFontChanged(B yVal e As System.EventArg s)
MyBase.OnFontCh anged(e)
Const WM_SETFONT As Integer = &H30
WndProc(Message .Create(Handle, WM_SETFONT, Font.ToHfont,
IntPtr.Zero))
End Sub
Protected Overrides Sub OnEnabledChange d(ByVal e As System.EventArg s)
MyBase.OnEnable dChanged(e)
If Not Me.Enabled Then
Me.SetStyle(Con trolStyles.User Paint, True)
End If
End Sub
End Class
Thanks for all your help guys!
Graham
"Mick Doherty"
<EX***********@ AND.REMOVE.SQUA REBRACKETS.[mdaudi100#ntlwo rld.com]> wrote in
message news:ee******** ******@TK2MSFTN GP09.phx.gbl... I can't get it to play nicely. I can change the font, but it's not quite
the right size.
In sub New() add the line: \\\ Font = New Font(Font, Font.Size) ///
Then add: \\\ Protected Overrides Sub OnFontChanged(B yVal e As System.EventArg s) MyBase.OnFontCh anged(e) Const WM_SETFONT As Integer = &H30 WndProc(Message .Create(Handle, WM_SETFONT, Font.ToHfont, IntPtr.Zero)) End Sub ///
-- Mick Doherty http://dotnetrix.co.uk/nothing.html
--- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.719 / Virus Database: 475 - Release Date: 12/07/2004
Yes, I started with Font.Style and made several changes whilst trying to get
the correct size. There's not much of a difference, but there is one.
What I have found, is that EnableVisualSty les messes up the TabSize in my
TabControl, but it didn't appear to make any difference to the TextBox. I
have disabled Visual Styles in my TabControl and Tabs now seem to size
correctly if they have a relatively short Text (Items with a long Text give
me some curious results).
I would probably never have thought to look at WM_SETTEXT if I hadn't seen
your post, so Thankyou for finding this problem.
--
Mick Doherty http://dotnetrix.co.uk/nothing.html
"Graham Blandford" <gr************ **@sympatico.ca > wrote in message
news:Sw******** ************@ne ws20.bellglobal .com... Hi Mick,
It certainly put me on the right track - and think I've cracked it. Well
.... at least for this particular scenario. I can change the forecolour of my disabled boxes...
Notice I used Font.Style instead of Font.Size in the Font assign.
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ( http://www.grisoft.com).
Version: 6.0.719 / Virus Database: 475 - Release Date: 12/07/2004 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Verane |
last post by:
Hi all,
I want to define a user control (called BaseUserControl) in one
assembly, and define another user control (called derivedUserControl)
in another assembly which derived from BaseUserControl.
I achieve to do this by doing add/new element/derived user control in
my second assembly.
But my problem is the following :
I first write a lot of code for BaseUserControl, then I create
|
by: DotNetJunkies User |
last post by:
I have created a User Control (a Pareto Chart) using C#. It works great in .Net Windows Apps, but I also need to use it in a Web Application (to view in IE). Everything I read on this seems to be talking about Web Controls (although the terms "Web Control" and "User Control" seem to be used interchangeably). Can I use this Control in IE even though its not a Web Control? Whats the alternative? The Control project is fairly extensive, using...
|
by: Charlie |
last post by:
Hi:
When I derive a new user control from an existing user control that contains
UI elements (buttons, textboxes, etc.) and put derived control on a form, UI
elements don't appear when I run the form. Why doesn't derived control
inherit them?
Thanks,
Charlie
|
by: ABC |
last post by:
I write a Base Web User Control which contains several public properties and
a Inherited Web User Control which only have some codes in new method. When
I use the Inherited Web User Control on Web Form, I don't know why the
Inherited Web User Control have not any properties inherited from Base Web
User Control.
How should I do?
The based web user control as:
using System;
....
|
by: BradC |
last post by:
(VB.NET 2002, Windows app).
I'm going to be provided a two-letter string like "BV" or "TP" that
represents a location.
I then need to perform some actions on several form controls that have names
derived from that location.
For example: lblBVimp, txtBVsignoff, txtBVsignoffdate, chkBV
Now I know i can do a "For Each XXX in myForm.Controls", If XXX.name =
blahblahblah,
| |
by: mschep |
last post by:
Hi,
I built an assembly with a set of user controls.
This can be done with the Visual Studio 2005 Deployment Project:
building and merging for example all your aspx and ascx in one dll
(lets say BunchOfUserControls.dll)
Doing so it's possible to resuse user controls in other web projects
without transferring the ascx files. Just the dll.
The reason I need this is because I need to load dynamicly controls in
a website.
|
by: Jobs |
last post by:
Download the JAVA , .NET and SQL Server interview with answers
Download the JAVA , .NET and SQL Server interview sheet and rate
yourself. This will help you judge yourself are you really worth of
attending interviews. If you own a company best way to judge if the
candidate is worth of it.
http://www.questpond.com/InterviewRatingSheet.zip
|
by: Jonathan Wood |
last post by:
I could really use some help on this.
First of all, I want to create a Web control where I render the control
completely from scratch based on information from a database.
In the book "Beginning ASP.NET 2.0 in C# 2005", it provides an example of
doing this, which is declared as:
public class ConfigurableRepeater : WebControl.
|
by: ajk |
last post by:
Hi
I was wondering how to show different properties in design and
run-mode for a user control? Is it possible to do this when
implementing the System.ComponentModel.ICustomTypeDescriptor
interface?
e.g. when selecting the control from a toolbox with controls other
properties show up when the program is in design mode than in run
mode.
|
by: =?Utf-8?B?Q2hyaXN0aWFuIFdlaW5lcnQ=?= |
last post by:
Hello,
I currently fight with a problem during the derivative of WinForm controls.
In Visual Studio I created a new User Control. This control is derived from
the DataGridView of the System.Windows.Forms namespace. I want to use this
control as a template for futher controls. Within this control i want to set
some property values to be pre-defined for further derived controls.
My base class looks like this:
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |