PC Review


Reply
Thread Tools Rate Thread

avoid flickering during sizing form

 
 
R.A.F.
Guest
Posts: n/a
 
      21st Nov 2007
Hi,

Basically i've read that under C++ we can avoid flickering forms during
sizing (maximize, minimize, restore,...) in SDi/MDI application.

I understood that for that i need to override the WndProc with WM_PAINT
and WM_SIZE messages.

however, under MFC there is a useful method called SetRedraw(bool);
it allows or not, to redraw the relative control.

i would like to know if a similar method exists under C# ?

thanks a lot,

RAF
 
Reply With Quote
 
 
 
 
Kerem Gümrükcü
Guest
Posts: n/a
 
      21st Nov 2007
Hi,

you can set the forms double buffered property to true
and you can set special style flags which can make the
painting of your the way you want it. Also you can override
the WndProc of the forms and catch window messages
and manipulate the windows message queue.

See here for the Flasg and Double Buffer:

[ControlStyles]
http://msdn2.microsoft.com/en-us/library/system.windows.forms.controlstyles(VS.80).aspx

[Control.DoubleBuffered Property]
http://msdn2.microsoft.com/en-us/library/system.windows.forms.control.doublebuffered(VS.80).aspx

What i recommend is to set everything you want in
a class where you inerit from the control/form of
interesst and set its flags and properties in tis constructor.


Something like that here i made for a ListView Control
to reduce its filcker on redrawing new elements dramatically:


public REListView(){

//Activate double buffering

this.SetStyle(ControlStyles.OptimizedDoubleBuffer |
ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.EnableNotifyMessage, true);

protected override void OnNotifyMessage(Message m)

{

if(m.Msg !=
(int)REWin32ApiClass.Win32ApiConstants.WindowsMessages.WM_ERASEBKGND)

{

base.OnNotifyMessage(m);

}

}

Just see as example,...


Regards

Kerem

--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
(E-Mail Removed)

Best Quote: "Ain't nobody a badass with a double dose
of rock salt...", Kill Bill Vol.2

Microsoft Live Space: http://kerem-g.spaces.live.com/
Latest Open-Source Projects: http://entwicklung.junetz.de
Sign my guestbook: http://entwicklung.junetz.de/guestbook/
-----------------------
"This reply is provided as is, without warranty express or implied."



 
Reply With Quote
 
R.A.F.
Guest
Posts: n/a
 
      21st Nov 2007
thanks for the info but unfortunatelly it does not help me.
so i do not know what to do :-(


Kerem Gümrükcü wrote:
> Hi,
>
> you can set the forms double buffered property to true
> and you can set special style flags which can make the
> painting of your the way you want it. Also you can override
> the WndProc of the forms and catch window messages
> and manipulate the windows message queue.
>
> See here for the Flasg and Double Buffer:
>
> [ControlStyles]
> http://msdn2.microsoft.com/en-us/library/system.windows.forms.controlstyles(VS.80).aspx
>
> [Control.DoubleBuffered Property]
> http://msdn2.microsoft.com/en-us/library/system.windows.forms.control.doublebuffered(VS.80).aspx
>
> What i recommend is to set everything you want in
> a class where you inerit from the control/form of
> interesst and set its flags and properties in tis constructor.
>
>
> Something like that here i made for a ListView Control
> to reduce its filcker on redrawing new elements dramatically:
>
>
> public REListView(){
>
> //Activate double buffering
>
> this.SetStyle(ControlStyles.OptimizedDoubleBuffer |
> ControlStyles.AllPaintingInWmPaint, true);
> this.SetStyle(ControlStyles.EnableNotifyMessage, true);
>
> protected override void OnNotifyMessage(Message m)
>
> {
>
> if(m.Msg !=
> (int)REWin32ApiClass.Win32ApiConstants.WindowsMessages.WM_ERASEBKGND)
>
> {
>
> base.OnNotifyMessage(m);
>
> }
>
> }
>
> Just see as example,...
>
>
> Regards
>
> Kerem
>

 
Reply With Quote
 
R.A.F.
Guest
Posts: n/a
 
      21st Nov 2007
Basically it seems to flick due to SDI child form frame, client area and
its caption.
so, somehow i need to block drawing of this SDI child form till it is
not maximized, and once it is done...to show this form...

but how to do it ?

Kerem Gümrükcü wrote:
> Hi,
>
> you can set the forms double buffered property to true
> and you can set special style flags which can make the
> painting of your the way you want it. Also you can override
> the WndProc of the forms and catch window messages
> and manipulate the windows message queue.
>
> See here for the Flasg and Double Buffer:
>
> [ControlStyles]
> http://msdn2.microsoft.com/en-us/library/system.windows.forms.controlstyles(VS.80).aspx
>
> [Control.DoubleBuffered Property]
> http://msdn2.microsoft.com/en-us/library/system.windows.forms.control.doublebuffered(VS.80).aspx
>
> What i recommend is to set everything you want in
> a class where you inerit from the control/form of
> interesst and set its flags and properties in tis constructor.
>
>
> Something like that here i made for a ListView Control
> to reduce its filcker on redrawing new elements dramatically:
>
>
> public REListView(){
>
> //Activate double buffering
>
> this.SetStyle(ControlStyles.OptimizedDoubleBuffer |
> ControlStyles.AllPaintingInWmPaint, true);
> this.SetStyle(ControlStyles.EnableNotifyMessage, true);
>
> protected override void OnNotifyMessage(Message m)
>
> {
>
> if(m.Msg !=
> (int)REWin32ApiClass.Win32ApiConstants.WindowsMessages.WM_ERASEBKGND)
>
> {
>
> base.OnNotifyMessage(m);
>
> }
>
> }
>
> Just see as example,...
>
>
> Regards
>
> Kerem
>

 
Reply With Quote
 
R.A.F.
Guest
Posts: n/a
 
      21st Nov 2007
so i finally solve my problem as following :

in my main form (SDI parent form), i have a private data member named
fOption defined as :
FOptions fOption; // refering to my form called "Options"

// later on my menuitem

private void MenuOptions_Click(object sender, EventArgs e)
{
TSContainer.ContentPanel.Controls.Clear();
if (this.fOption != null)
{
fOption.SuspendLayout();
fOption.Parent = TSContainer.ContentPanel;
NativeMethods.SendMessage(fOption.Handle, (int)(Msg_WM.WM_SETREDRAW),
0, 0);
fOption.WindowState = FormWindowState.Maximized;
NativeMethods.SendMessage(fOption.Handle, (int)(Msg_WM.WM_SETREDRAW),
1, 0);
fOption.ResumeLayout();
}
else
{
fOption = new FOptions();
fOption.TopLevel = false;
fOption.Parent = TSContainer.ContentPanel;
fOption.WindowState = FormWindowState.Maximized;
fOption.Show();
}
}

this avoid user to see fOption form flicks (caption, bar, frame +
process to maximize it) when SDI child is going to be shift from another
child form to this fOption form.

Does a better method exist ?
thanks a lot,

RAF.

R.A.F. wrote:
> Basically it seems to flick due to SDI child form frame, client area and
> its caption.
> so, somehow i need to block drawing of this SDI child form till it is
> not maximized, and once it is done...to show this form...
>
> but how to do it ?
>
> Kerem Gümrükcü wrote:
>> Hi,
>>
>> you can set the forms double buffered property to true
>> and you can set special style flags which can make the
>> painting of your the way you want it. Also you can override
>> the WndProc of the forms and catch window messages
>> and manipulate the windows message queue.
>>
>> See here for the Flasg and Double Buffer:
>>
>> [ControlStyles]
>> http://msdn2.microsoft.com/en-us/library/system.windows.forms.controlstyles(VS.80).aspx
>>
>>
>> [Control.DoubleBuffered Property]
>> http://msdn2.microsoft.com/en-us/library/system.windows.forms.control.doublebuffered(VS.80).aspx
>>
>>
>> What i recommend is to set everything you want in
>> a class where you inerit from the control/form of
>> interesst and set its flags and properties in tis constructor.
>>
>>
>> Something like that here i made for a ListView Control
>> to reduce its filcker on redrawing new elements dramatically:
>>
>>
>> public REListView(){
>>
>> //Activate double buffering
>>
>> this.SetStyle(ControlStyles.OptimizedDoubleBuffer |
>> ControlStyles.AllPaintingInWmPaint, true);
>> this.SetStyle(ControlStyles.EnableNotifyMessage, true);
>>
>> protected override void OnNotifyMessage(Message m)
>>
>> {
>>
>> if(m.Msg !=
>> (int)REWin32ApiClass.Win32ApiConstants.WindowsMessages.WM_ERASEBKGND)
>>
>> {
>>
>> base.OnNotifyMessage(m);
>>
>> }
>>
>> }
>>
>> Just see as example,...
>>
>>
>> Regards
>>
>> Kerem
>>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
BalloonTrayIcon and Form Hiding: Avoid Flickering Hector Santos Microsoft C# .NET 1 30th May 2010 07:31 AM
Best way to avoid flickering when redrawing VGA image?? juvi Microsoft Dot NET Compact Framework 10 30th Aug 2008 08:41 PM
Avoid Flickering Jon Abaunza Microsoft Dot NET Compact Framework 1 31st Oct 2005 10:02 AM
How to Avoid Flickering? Manohar Microsoft ASP .NET 1 6th Nov 2003 11:04 PM
how to avoid flickering in listview? Joaquin Grech Microsoft C# .NET 6 4th Nov 2003 06:51 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:37 PM.