473,402 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

avoid flickering during sizing form

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
Nov 21 '07 #1
4 4724
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/lib...es(VS.80).aspx

[Control.DoubleBuffered Property]
http://msdn2.microsoft.com/en-us/lib...ed(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.WindowsMess ages.WM_ERASEBKGND)

{

base.OnNotifyMessage(m);

}

}

Just see as example,...
Regards

Kerem

--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
ke*****@arcor.de

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."

Nov 21 '07 #2
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/lib...es(VS.80).aspx

[Control.DoubleBuffered Property]
http://msdn2.microsoft.com/en-us/lib...ed(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.WindowsMess ages.WM_ERASEBKGND)

{

base.OnNotifyMessage(m);

}

}

Just see as example,...
Regards

Kerem
Nov 21 '07 #3
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/lib...es(VS.80).aspx

[Control.DoubleBuffered Property]
http://msdn2.microsoft.com/en-us/lib...ed(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.WindowsMess ages.WM_ERASEBKGND)

{

base.OnNotifyMessage(m);

}

}

Just see as example,...
Regards

Kerem
Nov 21 '07 #4
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/lib...es(VS.80).aspx
[Control.DoubleBuffered Property]
http://msdn2.microsoft.com/en-us/lib...ed(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.OptimizedDoubleBuff er |
ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.EnableNotifyMessage , true);

protected override void OnNotifyMessage(Message m)

{

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

{

base.OnNotifyMessage(m);

}

}

Just see as example,...
Regards

Kerem
Nov 21 '07 #5

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

Similar topics

6
by: Joaquin Grech | last post by:
Hi I did alot of research on this on the web and msdn and I couldn't find anything. I have a listview showing as a grid (table looking, with rows and columns and no images at all, only text)....
2
by: John Lee | last post by:
Hi, I have a windows application that uses the listview to display about 50 items in detailed view - 4 columns. The first column is static and other columns will be updated in 100-1000ms - it...
2
by: John Lee | last post by:
Thanks Jay for your response. I tried your code and it still flickering a lot. To demonstrate it, you can grab a listview, create 3 columns - name, value, timestamp, in form_load event to add 50...
8
by: benben | last post by:
I created a form and overrided OnPaint, OnClick and OnResize methods. My OnPaint calls base.OnPaint then repaints the whole screen. The screen flickers a lot! It didn't happen when the app was...
5
by: n00b | last post by:
I have some forms with maybe around 30 controls on each and anytime I load these forms different parts of it start flickering though not all of them at once and not the same ones everytime. the...
2
by: sasifiqbal | last post by:
Hi, One of my developers are facing an interesting problem regarding UserControl invalidation. The problem is: We have two forms in our application. Form A does nothing except loading of...
6
by: Mark Thompson | last post by:
I have a problem with my Visual Basic .NET 2003 application which I have so far been unable to resolve. I am trying to get an OpenGL control that I have created working properly as a control on...
5
by: jtalbot_vizible | last post by:
I was looking at the code on codeproject to solve my listview flickering issue. All the references to functions in the rest of my post refer to that code. It's available at...
0
by: Prasadsm | last post by:
Hi all , how to avoid flickering of tooltip? This application was done using vs-2003 and is working fine.But after converting it to vs-2008,flickering problem has arised.Please guide me in sorting...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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
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,...

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.