Click here to Skip to main content
15,867,488 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to get the arguments from PaintEvent (OnPaint) in the Leave Event (OnLeave). Any idea how to access/get them.
Posted

1 solution

if you want to do something in paint when leave event fire then
use Invalidate() method and a flag which will tell your paint event now, leave event regarding if-else block should be run or not.

boolean flag = false;

Leave event ...
{
   flag = true;
   Mycontrol1.Invalidate(); // it will fire paint event of Mycontrol1
}

MyControl1 paint event ...
{
     if (flag==true)
     {
        //draw something
        flag = false;
     }
}


Happy coding!
:)
 
Share this answer
 
Comments
Itz.Irshad 11-Sep-12 6:31am    
In case of fast movement of mouse, OnPaint Event didn't perform so well.
Aarti Meswania 11-Sep-12 6:37am    
yes but same thing will be happen if you will declare page level paint argument variable and use it in leave event
if it is possible to use default properties like backcolor/font/border of control then it will be easy
Itz.Irshad 11-Sep-12 6:52am    
@Aarti: Here, by declaring page level paint argument variable didn't work for me. In fact, it close the whole application.
Aarti Meswania 11-Sep-12 7:00am    
you should go with 'invalidate() & flag' solution
and avoid painting if it's possible then use default properties for look change
or optimize paint event code
bobpowell is good site for paint regarding issues.
i have suggest a way how you can call paint event from leave event now try to optimize paint event that is a solution only if you don't want to use default properties instead of painting
:)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900