473,769 Members | 5,885 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Resizing a form

Hi there

I have a little problem.

How do i make sure that a graph is not redrawn while the form with the graph
is being resized ?
I have tried to add a mouse up/down event handler on the form1, but it
dosn't get called when resizing :(

I would like to be able to resize my form, but also make sure the graph is
only redrawn when the user is not resizing any more.

Hope my question make sense :)

--
Søren Reinke
www.Xray-Mag.com/ - Your free diving magazin on the net.
Current issue Diving in North America, 99 pages.
Download it in PDF
Nov 17 '05 #1
12 6734
Søren Reinke wrote:
Hi there

I have a little problem.

How do i make sure that a graph is not redrawn while the form with the graph
is being resized ?
I have tried to add a mouse up/down event handler on the form1, but it
dosn't get called when resizing :(

I would like to be able to resize my form, but also make sure the graph is
only redrawn when the user is not resizing any more.

Hope my question make sense :)


First, override OnResize() and the first time you enter that method,
you set a flag. You also call this.SuspendLay out();, if the flag was
wasn't set already.

then, you override OnSizeChanged. In there, you reset the flag and call
this.ResumeLayo ut(false);. Then draw your graph.

Frans

--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Nov 17 '05 #2
"Søren Reinke" <so***@reinke.f jernmig.dk> wrote in message
news:d5******** ***@newsbin.cyb ercity.dk...
How do i make sure that a graph is not redrawn while the form with the
graph is being resized ?

I would like to be able to resize my form, but also make sure the graph is
only redrawn when the user is not resizing any more.


It depends on the control. Sometimes there is a BeginUpdate/EndUpdate
mechanism, other times you have to call the Win32 ValidateRect() function,
passing in the control's window handle and client area.

-- Alan
Nov 17 '05 #3
>>
I would like to be able to resize my form, but also make sure the graph
is only redrawn when the user is not resizing any more.

Hope my question make sense :)


First, override OnResize() and the first time you enter that method, you
set a flag. You also call this.SuspendLay out();, if the flag was wasn't
set already.

then, you override OnSizeChanged. In there, you reset the flag and call
this.ResumeLayo ut(false);. Then draw your graph.

Frans

Hi Frans

Thanks for the tip, i'll try it :)

--
Søren Reinke
www.Xray-Mag.com/ - Your free diving magazin on the net.
Current issue Diving in North America, 99 pages.
Download it in PDF
Nov 17 '05 #4
I have a similar problem, but I don't see how this will work. Both Resize
and SizeChanged events get called multiple times during a single resizing
drag.

-Rachel

"Frans Bouma [C# MVP]" <pe************ ******@xs4all.n l> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Søren Reinke wrote:
Hi there

I have a little problem.

How do i make sure that a graph is not redrawn while the form with the graph is being resized ?
I have tried to add a mouse up/down event handler on the form1, but it
dosn't get called when resizing :(

I would like to be able to resize my form, but also make sure the graph is only redrawn when the user is not resizing any more.

Hope my question make sense :)


First, override OnResize() and the first time you enter that method,
you set a flag. You also call this.SuspendLay out();, if the flag was
wasn't set already.

then, you override OnSizeChanged. In there, you reset the flag and call
this.ResumeLayo ut(false);. Then draw your graph.

Frans

--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------

Nov 17 '05 #5
Rachel Suddeth wrote:
I have a similar problem, but I don't see how this will work. Both Resize
and SizeChanged events get called multiple times during a single resizing
drag.
Hmm. If SizeChanged is called multiple times, it indeed has a problem.
It then gets hacky, you then have to set a timer or something :X...

FB

-Rachel

"Frans Bouma [C# MVP]" <pe************ ******@xs4all.n l> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Søren Reinke wrote:
Hi there

I have a little problem.

How do i make sure that a graph is not redrawn while the form with the
graph
is being resized ?
I have tried to add a mouse up/down event handler on the form1, but it
dosn't get called when resizing :(

I would like to be able to resize my form, but also make sure the graph
is
only redrawn when the user is not resizing any more.

Hope my question make sense :)


First, override OnResize() and the first time you enter that method,
you set a flag. You also call this.SuspendLay out();, if the flag was
wasn't set already.

then, you override OnSizeChanged. In there, you reset the flag and call
this.ResumeLa yout(false);. Then draw your graph.

--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Nov 17 '05 #6
The following link gives a VB solution, but it should be simple enough to
convert to C#

http://groups.google.co.uk/group/mic...a09c0cf8b9d9ca

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Frans Bouma [C# MVP]" <pe************ ******@xs4all.n l> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Rachel Suddeth wrote:
I have a similar problem, but I don't see how this will work. Both Resize
and SizeChanged events get called multiple times during a single resizing
drag.


Hmm. If SizeChanged is called multiple times, it indeed has a problem. It
then gets hacky, you then have to set a timer or something :X...

FB

-Rachel

"Frans Bouma [C# MVP]" <pe************ ******@xs4all.n l> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Søren Reinke wrote:

Hi there

I have a little problem.

How do i make sure that a graph is not redrawn while the form with the


graph
is being resized ?
I have tried to add a mouse up/down event handler on the form1, but it
dosn't get called when resizing :(

I would like to be able to resize my form, but also make sure the graph


is
only redrawn when the user is not resizing any more.

Hope my question make sense :)

First, override OnResize() and the first time you enter that method,
you set a flag. You also call this.SuspendLay out();, if the flag was
wasn't set already.

then, you override OnSizeChanged. In there, you reset the flag and call
this.ResumeL ayout(false);. Then draw your graph.

--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------

Nov 17 '05 #7
Thanks, Mick, looks like that should work.
BTW, where do you get the constants from (for Windows messages)? You pull
them from a C++ header file?

-Rachel

"Mick Doherty"
<EX***********@ AND.REMOVE.SQUA REBRACKETS.[mdaudi100#ntlwo rld.com]> wrote in
message news:eg******** ******@TK2MSFTN GP14.phx.gbl...
The following link gives a VB solution, but it should be simple enough to
convert to C#

http://groups.google.co.uk/group/mic...a09c0cf8b9d9ca
--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Frans Bouma [C# MVP]" <pe************ ******@xs4all.n l> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Rachel Suddeth wrote:
I have a similar problem, but I don't see how this will work. Both Resize and SizeChanged events get called multiple times during a single resizing drag.


Hmm. If SizeChanged is called multiple times, it indeed has a problem. It then gets hacky, you then have to set a timer or something :X...

FB

-Rachel

"Frans Bouma [C# MVP]" <pe************ ******@xs4all.n l> wrote in message news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..

Søren Reinke wrote:

>Hi there
>
>I have a little problem.
>
>How do i make sure that a graph is not redrawn while the form with the

graph

>is being resized ?
>I have tried to add a mouse up/down event handler on the form1, but it
>dosn't get called when resizing :(
>
>I would like to be able to resize my form, but also make sure the graph
is

>only redrawn when the user is not resizing any more.
>
>Hope my question make sense :)

First, override OnResize() and the first time you enter that method,
you set a flag. You also call this.SuspendLay out();, if the flag was
wasn't set already.

then, you override OnSizeChanged. In there, you reset the flag and call
this.ResumeL ayout(false);. Then draw your graph.

--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------


Nov 17 '05 #8
Depends on my mood. Sometimes I look them up (winuser.h in this case),
sometimes I google and sometimes I just put Console.WriteLi ne(m.ToString() );
in the WndProc() method. Usually the latter since I'm often checking to see
what messages are being sent. Then it's off to the MSDN documentation to
find out what info I can read/change for the message.

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Rachel Suddeth" <ra****@bldhoun d.com> wrote in message
news:OS******** ******@TK2MSFTN GP15.phx.gbl...
Thanks, Mick, looks like that should work.
BTW, where do you get the constants from (for Windows messages)? You pull
them from a C++ header file?

-Rachel

"Mick Doherty"
<EX***********@ AND.REMOVE.SQUA REBRACKETS.[mdaudi100#ntlwo rld.com]> wrote
in
message news:eg******** ******@TK2MSFTN GP14.phx.gbl...
The following link gives a VB solution, but it should be simple enough to
convert to C#

http://groups.google.co.uk/group/mic...a09c0cf8b9d9ca

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Frans Bouma [C# MVP]" <pe************ ******@xs4all.n l> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
> Rachel Suddeth wrote:
>> I have a similar problem, but I don't see how this will work. Both Resize >> and SizeChanged events get called multiple times during a single resizing >> drag.
>
> Hmm. If SizeChanged is called multiple times, it indeed has a problem. It > then gets hacky, you then have to set a timer or something :X...
>
> FB
>
>>
>> -Rachel
>>
>> "Frans Bouma [C# MVP]" <pe************ ******@xs4all.n l> wrote in message >> news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
>>
>>>Søren Reinke wrote:
>>>
>>>>Hi there
>>>>
>>>>I have a little problem.
>>>>
>>>>How do i make sure that a graph is not redrawn while the form with
>>>>the
>>
>> graph
>>
>>>>is being resized ?
>>>>I have tried to add a mouse up/down event handler on the form1, but
>>>>it
>>>>dosn't get called when resizing :(
>>>>
>>>>I would like to be able to resize my form, but also make sure the graph >>
>> is
>>
>>>>only redrawn when the user is not resizing any more.
>>>>
>>>>Hope my question make sense :)
>>>
>>>First, override OnResize() and the first time you enter that method,
>>>you set a flag. You also call this.SuspendLay out();, if the flag was
>>>wasn't set already.
>>>
>>>then, you override OnSizeChanged. In there, you reset the flag and
>>>call
>>>this.ResumeL ayout(false);. Then draw your graph.
>
>
> --
> ------------------------------------------------------------------------
> Get LLBLGen Pro, productive O/R mapping for .NET:
> http://www.llblgen.com
> My .NET blog: http://weblogs.asp.net/fbouma
> Microsoft MVP (C#)
> ------------------------------------------------------------------------



Nov 17 '05 #9
All right, I don't know VB, and I've never needed to do masking with C#, so
I have a couple questions about how to translate the WndProc in your
example. I think the "Static Sizemode" inside the method would have to be
replaces by a class level variable in C#? Also not quite sure about the
statement to set SizeMode?

----
private bool bSizeMode = false;
protected override void WndProc(ref Message m)
{
switch ( m.Msg )
{
case WM_SIZING:
// Resize event already provided
break;
case WM_SYSCOMMAND:
bSizeMode = ((m.WParam.ToIn t32() & 0xFFF0) == SC_SIZE);
break;
case WM_ENTERSIZEMOV E:
if ( bSizeMode )
{
OnBeginResize(E ventArgs.Empty) ;
}
break;
case WM_EXITSIZEMOVE :
{
if ( bSizeMode )
{
OnEndResize(Eve ntArgs.Empty);
}
break;
}

} // end switch
base.WndProc (ref m);
}
----

Here is the VB code "copied" above
------
Protected Overrides Sub WndProc(ByRef m As System.Windows. Forms.Message)
Static SizeMode As Boolean = False
Select Case m.Msg
Case WM_SIZING
'Already have a Resize Method
Case WM_SYSCOMMAND
SizeMode = ((m.WParam.ToIn t32 And &HFFF0) = SC_SIZE)
Case WM_ENTERSIZEMOV E
If SizeMode Then
OnBeginResize(E ventArgs.Empty)
End If
Case WM_EXITSIZEMOVE
If SizeMode Then
OnEndResize(Eve ntArgs.Empty)
End If
Case Else
End Select
MyBase.WndProc( m)
End Sub

---
Thanks,

Rachel

"Mick Doherty"
<EX***********@ AND.REMOVE.SQUA REBRACKETS.[mdaudi100#ntlwo rld.com]> wrote in
message news:eg******** ******@TK2MSFTN GP14.phx.gbl...
The following link gives a VB solution, but it should be simple enough to
convert to C#

http://groups.google.co.uk/group/mic...a09c0cf8b9d9ca
--
Mick Doherty
http://dotnetrix.co.uk/nothing.html

Nov 17 '05 #10

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

Similar topics

0
2626
by: TJ Talluto | last post by:
<facts> I have a "month calendar" that always displays exactly 42 days... and alongside is a vertical box that displays the detail (form fields) of any particular select event that appears on the calendar, so that the event may be changed, or a new event may be created. monthname X X X X X X X form X X X X X X X form X X X X X X X form
11
18836
by: Jozef | last post by:
I have some old code that I use from the Access 95 Developers handbook. The code works very well, with the exception that it doesn't seem to recognize wide screens, and sizes tab controls so that they are too big and wind up covering up some of the fields on the main form. Is there any good code out there that works in a similar fashion that will also either a) stretch the form width wise on widescreens or b), rely on height rather than...
1
5216
by: Terry | last post by:
I've seen several posts from people who have seen this flashing in TreeView's when resizing a form. I've noticed it in my app, but only in the child windows. For example, my main form has a splitter with a TreeView and I do not get the flickering with it. I created a new Form based Windows app. Added a TreeView (dock left), then a splitter and a property grid on the right (dock fill). For this test, I added a panel and button at the...
4
6145
by: Thomas Richter | last post by:
Hi, I can't get of the black flicker when I resize my form. this = Mainform : System.Windows.Forms.Form If I set the size from 300 to 500 I see for ca 500ms some black areas. I try to solve it with: this.SetStyle(ControlStyles.DoubleBuffer, true); this.SetStyle(ControlStyles.UserPaint, true); this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); this.SetStyle(ControlStyles.ResizeRedraw, true); But it doesn't work.
6
51925
by: John Bowman | last post by:
Hi All, I must be missing something really obvious, so I'd appreciate someone helping me out. I have a simple Windows form that currently only has a title bar (aka the Text Property is set) and the MinmizeBox, ControlBox and MaximizeBox(es) are all set to false. It's FormBorderStyle is set to "Fixed Single". Eventually this form will have a nice background image. I need to use this form as sort of back drop while other forms/operations...
11
17872
by: Sharon | last post by:
I'm writing a new control derived from UserControl. I need to get an event when the control is done resizing. I tried the Resize, SizeChanged, Move and the Layout events and I also tried to override them. But they all invoked when the control is in the middle of the resizing process. I'm not using breakpoints, I'm using trace to see which one is invoked and when.
13
2511
by: Martin Ho | last post by:
I know this must be trivial for many of you. But I am playing with this and can't figure it out. I have a form, on that form is one panel which has 3 textboxes, when I run my program and maximize the form I want to resize my 3 text boxes according to the size of the form. Each text box should take 33% of the panel's width and full hight of the panel's height. Resizing of the panel is easy with docking... but these 3 textboxes are driving...
6
4548
by: JDeats | last post by:
I have a WinForms based application written for the .NET Framework 2.0 and in this application I need to be able to be able to take some action in code when the user finishes resizing the form. I can easily create an event handler for the SizeChanged form level event, the problem is if the user is using a mouse drag to resize the form this event is firing every few milliseconds or what have you until the user stops the drag process. ...
10
7076
by: mishrarajesh44 | last post by:
hii all, I am facing a problem currently.. i have a script for image uploading and resizing.. the image uploading takes place properly for every size images.. but, the resizing works for only small sized iamages.. for eg. resizing takes place for 70 kb sized images but fails for 600kb or more.. my code is below..
0
9589
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
10045
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
9994
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8872
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7409
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
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3562
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.