[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Paint Event Question

Posted on 2006-05-17
9
Medium Priority
?
243 Views
Last Modified: 2010-04-23
Using VB.NET:

How can I subscribe to the "BeginPaint" and "EndPaint" events of a control or form with managed code?

Thanks,
Tony

0
Comment
Question by:mytonytiger
  • 6
  • 3
9 Comments
 
LVL 5

Author Comment

by:mytonytiger
ID: 16702004
Further information of interest is:

I'm using Visual Studio 2005, hence, .NET 2.0

0
 
LVL 5

Author Comment

by:mytonytiger
ID: 16702045
I'm interested in captureing the event for panel control so I can reset the scroll bars to the position they were in before the paint event.
0
 
LVL 3

Accepted Solution

by:
GilesBathgate earned 2000 total points
ID: 16702388
You can override the WndProc method, this provides a managed way of accessing the windows messages being sent to the panel. The Windows Message constants that reperesent "BeginPaint" and "EndPaint" will be fairly easy to find on google.

Public Class myPanel
        Inherits Panel

    Public Overrides Sub WndProc(m as Message)
        If m.Message = &H??? ' <--- Begin Paint Constant goes here
           'Begin Paint code
        Else If m.Message = &H???
           'End Paint Code
        End If
    End Sub
End Class
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 5

Author Comment

by:mytonytiger
ID: 16702896
I'm trying to find the constants now, but so far no luck.

if you can find them, please post them. Then I can check out the solution
Thanks.
0
 
LVL 3

Expert Comment

by:GilesBathgate
ID: 16703028
0
 
LVL 5

Author Comment

by:mytonytiger
ID: 16703070
Yes, I had seen this... but no reference to a "BeforePaint" or "AfterPaint" event.

So, I've done this and it seems to be working.

    Protected Overrides Sub WndProc(ByRef m As Message)
        If m.Msg = 15 Then
            'Do code before paint here.
        End If
        MyBase.WndProc(m)
        If m.Msg = 15 Then
            'Do Code after paint here.
        End If
    End Sub
0
 
LVL 3

Expert Comment

by:GilesBathgate
ID: 16703089
Yeah I assumed that there was actually some Windows Message that you were aware of trying to hook into your application.
0
 
LVL 5

Author Comment

by:mytonytiger
ID: 16703146
well, there are several pages in the net referring to a "BeginPaint" and and "EndPaint" event. But, I guess they aren't actual windows messages.
0
 
LVL 5

Author Comment

by:mytonytiger
ID: 16703352
Thanks for the help. I do appreciate it.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question