473,508 Members | 2,289 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

only run code paint event fires?

I know there is a way to do this, but I don't know how. Via a custom
event? I have some code that I only want to run during a paint event.
I could build a form instance that has the code and inherit it in all
my other forms, but a simple event link? if that is the right term
would be easier?

Thx.
Nov 20 '05 #1
7 1674
You should be able to overload the render event with your own event. The
base class render event will still fire but will include your extra
functionality

Jody
MCSD.NET

"Schorschi" <Sc*******@DSLExtreme.COM> wrote in message
news:21**************************@posting.google.c om...
I know there is a way to do this, but I don't know how. Via a custom
event? I have some code that I only want to run during a paint event.
I could build a form instance that has the code and inherit it in all
my other forms, but a simple event link? if that is the right term
would be easier?

Thx.

Nov 20 '05 #2
"Schorschi" <Sc*******@DSLExtreme.COM> schrieb
I know there is a way to do this, but I don't know how. Via a
custom event? I have some code that I only want to run during a
paint event.
I could build a form instance that has the code and inherit it in
all
my other forms, but a simple event link? if that is the right term
would be easier?


Maybe I'm the only one who doesn't understand your question, but could you
please explain it once more?
--
Armin

Nov 20 '05 #3
Cor
Hi Schorschi,
I don't know what it does, but it is standard and fires when the form paint
I think

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
End Sub

I don't know if it helps you?
Cor
Nov 20 '05 #4
Hi Schorschi,

Sounds to me like you need global MessageHandler, and need to capture the
WM_PAINT message.

If you create a class that implements the IMessageHandler interface, then
use the Application object to add a message handler, look for m.Msg = &HF

(or Public Const WM_PAINT As Integer = &HF)

When m.Msg = WM_PAINT, a paint event is occurring on 'some' object, in your
application.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations
"Schorschi" <Sc*******@DSLExtreme.COM> wrote in message
news:21**************************@posting.google.c om...
I know there is a way to do this, but I don't know how. Via a custom
event? I have some code that I only want to run during a paint event.
I could build a form instance that has the code and inherit it in all
my other forms, but a simple event link? if that is the right term
would be easier?

Thx.

Nov 20 '05 #5
Tom,

I think you are right, a global message handler would work fine, but
is not a very .NET way of doing it. If I was using C or C++ I would
go the message routine route, but overloading the the paint handler is
acceptable as well to an extent.

What I was also thinking was a chained sequence of paint routines, for
example, if I add a custom handler that draws a custom panel on a
given form, then a custom icon, then a geometric pattern, etc. but
these draw routines if you will, are a list of drawing elements, or a
collection that I can add or remove from.

Overloading the existing paint handler would allow for the same thing,
I just write an overloaded paint routine on top of another, one key
issue, what if I want to drop out a specific paint element? If it was
a linked list of drawing elements I could do this.

For example, the list might be...

1) Draw square
2) Draw circle
3) Draw Triangle
4) Draw Rectangle

Then I could drop the Draw circle code

1) Draw square
3) Draw Triangle
4) Draw Rectangle

This was the idea. So do I implement handler for each routine and
only call the ones that should be active, i.e. disable others, or
build a collection list and fire all on a paint event? Lots of
options, just need to pick one I guess.
Nov 20 '05 #6
> I think you are right, a global message handler would work fine, but
is not a very .NET way of doing it.
Why not.... .NET provides a solid implementation of a global message
handler.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations
"Schorschi" <Sc*******@DSLExtreme.COM> wrote in message
news:21**************************@posting.google.c om... Tom,

I think you are right, a global message handler would work fine, but
is not a very .NET way of doing it. If I was using C or C++ I would
go the message routine route, but overloading the the paint handler is
acceptable as well to an extent.

What I was also thinking was a chained sequence of paint routines, for
example, if I add a custom handler that draws a custom panel on a
given form, then a custom icon, then a geometric pattern, etc. but
these draw routines if you will, are a list of drawing elements, or a
collection that I can add or remove from.

Overloading the existing paint handler would allow for the same thing,
I just write an overloaded paint routine on top of another, one key
issue, what if I want to drop out a specific paint element? If it was
a linked list of drawing elements I could do this.

For example, the list might be...

1) Draw square
2) Draw circle
3) Draw Triangle
4) Draw Rectangle

Then I could drop the Draw circle code

1) Draw square
3) Draw Triangle
4) Draw Rectangle

This was the idea. So do I implement handler for each routine and
only call the ones that should be active, i.e. disable others, or
build a collection list and fire all on a paint event? Lots of
options, just need to pick one I guess.

Nov 20 '05 #7
Hi Schorschi,

You can override a Control's WndProc quite legitimately in .NET. However
that's a side issue.

It sounds as if you are wanting the flexibility of a dynamic chain of
actions. That makes the word Delegate leap into my mind. Delegates are the
..NET version of C's function pointers, but being objects in their own right,
are much more sophisticated. For instance, they can work synchronously or
async.

You have two choices using Delegates. You can have one Delegate
(multicast) handle a list of drawing elements, or you can have an array
handling one drawing element each.

Another way to go, by the sound of it, would be to define the drawing
elements as independant objects which know how to draw themselves in a given
graphics context. And have a chain of these attached to your actual GUI
elements.

Like you say, including those you already have, lots of options. ;-)

Regards,
Fergus
Nov 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
7712
by: Joe | last post by:
Hello All, I have an ASP.NET page with one Textbox (SearchTextBox) and one ImageButton (SearchButton) server controls. The user can type search text in SearchTextBox and click SearchButton and...
22
2330
by: Colin McGuire | last post by:
I apologize for posting yet another scrollbar question. Here is my code. All I want is for a diagonal line to appear from coordinates (0,0) to (width,height) in a usercontrol regardless of whether...
3
1257
by: LDD | last post by:
After upgrading sucessfully to VB.Net... WooHoo!!! It was a slow process, but in the end it seemed to have worked out well. I've noticed the the form_active (VB6) is no longer available. There is...
3
2260
by: Greg | last post by:
My problem is that values in the bool column of a datagrid are only being updated to the database once the focus of the bool cell is lost. This is completely counter-intuitative. When a user clicks...
6
8754
by: Joseph Geretz | last post by:
I'm porting a C# Outlook Addin originally engineered as a COM Addin over to use VSTO. I've gotten this to the point where my VSTO Addin installs its Menu items and Toolbar buttons when Outlook...
3
3572
by: Techsatish | last post by:
how to make a mouseup event called only once during a double click event? here double click is made on a tree node in a tree control. I have the code inside mouseup event....in runtime the...
4
4872
by: Kürşat | last post by:
Hi all, I do some drawing in a form's paint event handler and I have a button on that form. Whenever the mouse enters or leaves the button Form's paint event occurs. Isn't that a strange...
0
1665
by: Andy Wynn | last post by:
I have a custom control that has a rectangle drawn at the bottom of the control. Nothing fancy, just a rectangle with a color fill. The control has the ability to be resized ( Collapsed -...
7
2338
by: Rotsey | last post by:
Hi, I have a interface that I use for a form so I can pass the form to another object. How do I add the Paint event to the interface and subsequently handle the paint event in my other...
0
7120
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...
0
7380
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7039
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...
0
7494
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5626
agi2029
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,...
0
3192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1553
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 ...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.