[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Shawn Jackson

10/14/2004 10:26:00 PM


Hi,

In windows forms (vb.net), i use my own controls subclassed from base
controls and i override the Onxxx methods.

for example:
Public Class MyBouton
Inherits System.Windows.Forms.Button
.
Protected Overrides Sub OnPaint(ByVal pe As
System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(pe)
.
Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
Mybase.OnClick(e)
.

I saw that :
- for some controls (ex: combobox), i can't access to OnPaint but i can
access to OnClick ..
- for these controls, if i had in the constructor :
Me.SetStyle(ControlStyles.UserPaint, true)
i can now access to OnPaint (then i must draw the control even if i put
MyBase.OnPaint(pe))
but if i put : Me.SetStyle(ControlStyles.UserPaint, false)
i can't access to none Onxxx
- in some controls (ex: Button) without Me.SetStyle, it is ok, i can
access to OnPaint

I saw also if i intercept a windows message, it is ok :

Protected Overrides Sub WndProc(ByRef m As Message)
MyBase.WndProc(m)
Select Case m.Msg
Case &HF ' =15 =Paint

Can anybody explain this strangeness ?
Is it a known bug ?

Is it better to use always windows message instead of OnPaint ?

Thanks for advice.

Dominique Gratpain





*** Sent via Developersdex http://www.develop... ***
Don't just participate in USENET...get rewarded for it!
4 Answers

Bob Powell

10/15/2004 12:31:00 PM

0

Many of the Windows Forms controls are a loose wrapper around the underlying
Win32 control. ComboBox is an example of this. Many of these controls paint
themselves without intervention from the managed side of the equation and so
expose no paint methods because they aren''t needed.

Many of these controls have hidden capabilities such as notification
messages for custom painting and so-on. The only way to take advantage of
these facilities is to override the WndProc, trap the messages and then
interpret them as you would in the win32 world.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdipl...

The GDI+ FAQ RSS feed: http://www.bobpowell.net/f...
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tips...
Bob''s Blog: http://bobpowelldotnet.blogspot.co...






"dominique" <anonymous@Devdex.com> wrote in message
news:OblbKzjsEHA.2320@TK2MSFTNGP12.phx.gbl...
>
> Hi,
>
> In windows forms (vb.net), i use my own controls subclassed from base
> controls and i override the Onxxx methods.
>
> for example:
> Public Class MyBouton
> Inherits System.Windows.Forms.Button
> .
> Protected Overrides Sub OnPaint(ByVal pe As
> System.Windows.Forms.PaintEventArgs)
> MyBase.OnPaint(pe)
> .
> Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
> Mybase.OnClick(e)
> .
>
> I saw that :
> - for some controls (ex: combobox), i can''t access to OnPaint but i can
> access to OnClick ..
> - for these controls, if i had in the constructor :
> Me.SetStyle(ControlStyles.UserPaint, true)
> i can now access to OnPaint (then i must draw the control even if i put
> MyBase.OnPaint(pe))
> but if i put : Me.SetStyle(ControlStyles.UserPaint, false)
> i can''t access to none Onxxx
> - in some controls (ex: Button) without Me.SetStyle, it is ok, i can
> access to OnPaint
>
> I saw also if i intercept a windows message, it is ok :
>
> Protected Overrides Sub WndProc(ByRef m As Message)
> MyBase.WndProc(m)
> Select Case m.Msg
> Case &HF '' =15 =Paint
>
> Can anybody explain this strangeness ?
> Is it a known bug ?
>
> Is it better to use always windows message instead of OnPaint ?
>
> Thanks for advice.
>
> Dominique Gratpain
>
>
>
>
>
> *** Sent via Developersdex http://www.develop... ***
> Don''t just participate in USENET...get rewarded for it!


Shawn Jackson

10/16/2004 9:33:00 AM

0


Thanks Bob for your answer.

Can you provide the list of the control in this situation "Many of the
Windows Forms controls are a loose wrapper .." ?
Perharps a new useful thread in your blog ;))

Dominique


*** Sent via Developersdex http://www.develop... ***
Don''t just participate in USENET...get rewarded for it!

Bob Powell

10/16/2004 10:56:00 AM

0

They include ListView, ComboBox, TextBox, RichTextBox, ListBox, TreeView...

All the basic common controls really. Some of these have a Paint event but
that''s not quite the same.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdipl...

The GDI+ FAQ RSS feed: http://www.bobpowell.net/f...
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tips...
Bob''s Blog: http://bobpowelldotnet.blogspot.co...






"dominique" <anonymous@Devdex.com> wrote in message
news:uV0HTM2sEHA.2128@TK2MSFTNGP11.phx.gbl...
>
> Thanks Bob for your answer.
>
> Can you provide the list of the control in this situation "Many of the
> Windows Forms controls are a loose wrapper .." ?
> Perharps a new useful thread in your blog ;))
>
> Dominique
>
>
> *** Sent via Developersdex http://www.develop... ***
> Don''t just participate in USENET...get rewarded for it!


konijn_

2/20/2008 5:10:00 PM

0

On 2008-02-20 14:26:41, Gerry Quinn <gerryq@indigo.ie> wrote:

> In article , konijn@gmail.com says...
> > On 2008-02-19 21:00:26, miller.paul.w@gmail.com wrote:
> >
> > > Automated unit tests are a great way to catch a large class of silly,
> > > low-level bugs in your code. Some folks even go so far as to write
> > > tests for functionality before the actual code implementing that
> > > functionality ("test-driven development").
> > >
> > > So, how many roguelike developers are familiar with unit testing? Do
> > > you use it in your personal projects? If so, do you write the tests
> > > first? I'm interested in taking a look at some well-tested roguelike
> > > code (preferably in a language that's not C, C++, or Java). Can
> > > anyone point me in the right direction?
> >
> > Check out Tyrant, it has a slew of JUnit tests.
> > http://sourceforge.net/projec...
>
> Still has bugs though!

I hope no one is so deluded to think unit tests prevent all bugs. If you find
bugs, please do write me an email or put them in the tracker.

> > Part of the reason why many roguelikes fail is because their developers think
> > they're above unit testing.
> >
> > /me grins and ducks
>
> I think a lot of us think it's a good idea in principle, but question
> its practical value.
>
> Of course, its value might be a function of a particular coder's style
> (as well as skill).

Eh. I think the value is in function of how many people work on the same source
code. and how many operating systems are supported. That is why most of people
here dont need it.

>
> - Gerry Quinn
> --
> Lair of the Demon Ape (a coffee-break roguelike)
>

--
* Go to Hell (http://hellband.googlepages.com/...), now version 0.8.6! *