473,618 Members | 3,170 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4758
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.DoubleB uffered 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(C ontrolStyles.Op timizedDoubleBu ffer |
ControlStyles.A llPaintingInWmP aint, true);
this.SetStyle(C ontrolStyles.En ableNotifyMessa ge, true);

protected override void OnNotifyMessage (Message m)

{

if(m.Msg !=
(int)REWin32Api Class.Win32ApiC onstants.Window sMessages.WM_ER ASEBKGND)

{

base.OnNotifyMe ssage(m);

}

}

Just see as example,...
Regards

Kerem

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

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.DoubleB uffered 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(C ontrolStyles.Op timizedDoubleBu ffer |
ControlStyles.A llPaintingInWmP aint, true);
this.SetStyle(C ontrolStyles.En ableNotifyMessa ge, true);

protected override void OnNotifyMessage (Message m)

{

if(m.Msg !=
(int)REWin32Api Class.Win32ApiC onstants.Window sMessages.WM_ER ASEBKGND)

{

base.OnNotifyMe ssage(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.DoubleB uffered 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(C ontrolStyles.Op timizedDoubleBu ffer |
ControlStyles.A llPaintingInWmP aint, true);
this.SetStyle(C ontrolStyles.En ableNotifyMessa ge, true);

protected override void OnNotifyMessage (Message m)

{

if(m.Msg !=
(int)REWin32Api Class.Win32ApiC onstants.Window sMessages.WM_ER ASEBKGND)

{

base.OnNotifyMe ssage(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_Cli ck(object sender, EventArgs e)
{
TSContainer.Con tentPanel.Contr ols.Clear();
if (this.fOption != null)
{
fOption.Suspend Layout();
fOption.Parent = TSContainer.Con tentPanel;
NativeMethods.S endMessage(fOpt ion.Handle, (int)(Msg_WM.WM _SETREDRAW),
0, 0);
fOption.WindowS tate = FormWindowState .Maximized;
NativeMethods.S endMessage(fOpt ion.Handle, (int)(Msg_WM.WM _SETREDRAW),
1, 0);
fOption.ResumeL ayout();
}
else
{
fOption = new FOptions();
fOption.TopLeve l = false;
fOption.Parent = TSContainer.Con tentPanel;
fOption.WindowS tate = 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.DoubleB uffered 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.O ptimizedDoubleB uffer |
ControlStyles. AllPaintingInWm Paint, true);
this.SetStyle( ControlStyles.E nableNotifyMess age, true);

protected override void OnNotifyMessage (Message m)

{

if(m.Msg !=
(int)REWin32Ap iClass.Win32Api Constants.Windo wsMessages.WM_E RASEBKGND)

{

base.OnNotifyM essage(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
8852
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). I get the information to display on the listview from the network and I add items often and stuff. But more than adding items, what worries me is the step of modifying items.
2
8608
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 looks awful when it's running - flickering too much!!! Anyone know how to solve this flickering problem? or how should I deal with this issue? I see some other C++ app can display more than 100 items without any flickering in such as speed. Can...
2
2514
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 items into that listview as Item1 - Item49, add a timer to your windows form, set the timer interval to 100 ms, in the event handler, add the code to update the value and timestamp Random r = new Random(); listView1.BeginUpdate();
8
16916
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 written in C++. What is the general strategy to reduce screen flickering with C# Forms? Perhaps saving the screen as a bitmap and just bitblip when painted, and only change the bitmap when necessary? is it possible? ben
5
2344
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 forms are each generally separated into 2-3 different panels and they start flickering with no apparent pattern. I've tried turning on double buffering, same thing, no improvements. I've tested it on different computers with different specifications...
2
2097
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 Form B and Form B contains an array of UserButton kind of contol (we have created our own buttons deriving from UserButton). All the drawings activities in Form B are okay and nothing gets wrong if we
6
3626
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 my main form in my VB.NET application. It does work and render correctly but the problem is that there is an awful flickering that happens on most PCs I try it on. The flickering is reminiscent of the sort that you get on a TV when it is not tuned...
5
9511
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 http://www.codeproject.com/cs/miscctrl/listviewff.asp?df=100&forumid=14314&select=1488858&msg=1488858 That code didn't solve my problem. I have a ListView (in Details mode) with about 70 rows and 12 columns. It's a stock ticker kind of app. When it first starts, each...
0
1514
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 out this issue. Thanks, Prasad
0
8207
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8150
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8650
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8593
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6098
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5552
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4064
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4147
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2582
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 we have to send another system

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.