473,809 Members | 2,701 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sizechanged event question...

I have a Picturebox that has an image displayed inside. Through code,
I was able to have the "whole image" display in it without distortion.
(Like a "Fit All" in most any image viewer program)

Now, when the Picturebox gets resized by the user, I want the image to
recalculate and display as "Fit All" again.

So I have code in my SizeChanged event of the picturebox. When the
"size changed", it does it's calculation, and displays properly.

It works, but there is a problem: If the user drags the Picturebox
window larger or smaller, the SizeChanged event fires many times per
second. This causes alot of sluggishness in the app when trying to
display the image.

Is there anyway that i can have the SizeChanged event fire ONCE when
i'm done resizing the picturebox?

(By the way, the picturebox gets resized indirectly. It's dock is set
to Fill. When the interface "Next" to it gets resized, the Picturebox
naturally will resize accordingly)

Thanks for all your help!

John

Nov 21 '05
38 3036
John,

I forgot it, however this is classic
Private Sub Pnl_Image_SizeC hanged(...) Handles
Pnl_Image.SizeC hanged
Static OldSize As Size
If Not OldSize.Equals( Pnl_Image.Size) Then
' call procedure to resize and display image
End If
OldSize = Pnl_Image.Size
End Sub


I hope this helps,

:-)

Cor
Nov 21 '05 #11
Cor,

That didn't make a difference. My procedure fires again and again
until I let go of the mouse.

It's actually not "as" bad now that i'm at work on a much faster
computer. But it's still annoying.

Any more suggestions, or should I just give up?

Thanks,
John

Nov 21 '05 #12
John,

Sorry, I was reading it not well I thought that the picture stayed the same,
of course does this not help.

The only thing that I can come up that can help you here is probably a
timer.
We people are not able to see some things that fast.

I never tried it, however you can probably do it in the same way as
mysample, and than there is not much to change.

Private Sub Pnl_Image_SizeC hanged(...) Handles
Pnl_Image.SizeC hanged
Static OldTime As Integer
If (Environment.Ti cksCount - OldTime) > 50 Then
' call procedure to resize and display image
End If
OldTime = Environments.Ti cksCount
End Sub

And than set that 50 to a proper value.

Maybe this helps,

I am curious.

Cor
Nov 21 '05 #13
Cor,

Interesting idea, thanks!

But the only benefit it has is the image redraw happens a little less
frequently. And if I let go of the mouse at the wrong time, the image
doesn't redraw. I have to let go of the mouse immediately after it
redraws if I want the image displayed properly.

I played w/ the number value. A number too high refreshes too
infrequently, and often when I let go of the mouse, my subroutine
doesn't fire, and thus my image doesn't get resized/redrawn. A number
too low, and the effect is similar to the original code.

Well, I really appreciate all the help you've given me, Cor. But it
looks like this is pretty much impossible! :(

John

Nov 21 '05 #14
John, have you looked at my example?

in my opinion it does what you want.

Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.

"johnb41" <or****@informa tik.com> schreef in bericht
news:11******** *************@g 44g2000cwa.goog legroups.com...
Cor,

Interesting idea, thanks!

But the only benefit it has is the image redraw happens a little less
frequently. And if I let go of the mouse at the wrong time, the image
doesn't redraw. I have to let go of the mouse immediately after it
redraws if I want the image displayed properly.

I played w/ the number value. A number too high refreshes too
infrequently, and often when I let go of the mouse, my subroutine
doesn't fire, and thus my image doesn't get resized/redrawn. A number
too low, and the effect is similar to the original code.

Well, I really appreciate all the help you've given me, Cor. But it
looks like this is pretty much impossible! :(

John

Nov 21 '05 #15
Peter,

Yes, I have. For me, the SizeChanged event fires again and again as
the Panel gets resized, not just when I let go of the mouse. Am I
missing something? Did you write any special code so it works as you
say?

John

Nov 21 '05 #16
Peter,

Yes, I have. For me, the SizeChanged event fires again and again as
the Panel gets resized, not just when I let go of the mouse. Am I
missing something? Did you write any special code so it works as you
say?

John

Nov 21 '05 #17
Hi John, sorry for not responding faster, but after 5 o' clock (belgian
time), I haven't got access to the ng's for the moment (pc at home is broke)
The example I posted, runs very smooth at my computer, it only fires the
sizechanged event once, and that's when I release the form border after
resizing.
Which version of VS do you have? 2002, 2003? I have got 2003.

Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.
"johnb41" <or****@informa tik.com> schreef in bericht
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
Peter,

Yes, I have. For me, the SizeChanged event fires again and again as
the Panel gets resized, not just when I let go of the mouse. Am I
missing something? Did you write any special code so it works as you
say?

John

Nov 21 '05 #18
I have VS 2003 also. So let me get this straight, if you simply put in
a messagebox inside a Sizechanged event (for a Form), the messagebox
does not appear until AFTER you let go of the mouse button? No extra
code required?

Amazing. I can't even resize a form because the messagbox pops up too
soon.

If anyone else is reading this, does this happen to you also?

If this is true, i'm surprised that the others that posted in this
thread didn't mention it. Cor really went out of his way to help w/ a
couple potential solutions. Now i'm more confused than ever! (but that
isn't new)

John

Nov 21 '05 #19
I also find it very strange, if I put a msgbox in the sizechanged event of a
form, it first pops up before the form is even visible (that's just the form
initializing) and then when the form is loaded it only pops up AFTER I let
go of the mouse button, no extra code required.

For example the example I posted at my pc only fires the sizechanged event
after I let go of the mousebutton.

Greetz Peter
a messagebox inside a Sizechanged event (for a Form), the messagebox
does not appear until AFTER you let go of the mouse button? No extra
code required?

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.

"johnb41" <or****@informa tik.com> schreef in bericht
news:11******** *************@g 14g2000cwa.goog legroups.com... I have VS 2003 also. So let me get this straight, if you simply put in
a messagebox inside a Sizechanged event (for a Form), the messagebox
does not appear until AFTER you let go of the mouse button? No extra
code required?

Amazing. I can't even resize a form because the messagbox pops up too
soon.

If anyone else is reading this, does this happen to you also?

If this is true, i'm surprised that the others that posted in this
thread didn't mention it. Cor really went out of his way to help w/ a
couple potential solutions. Now i'm more confused than ever! (but that
isn't new)

John

Nov 21 '05 #20

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

Similar topics

18
2893
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code that applies to all these events, but I need to have specific code execute when the form closes. The properties for this method are sender (the originator) and e (event arguments). I know how to get typeof (sender) to determine what form or...
2
17037
by: Dominic | last post by:
Hi guys, I'm not sure if this question belongs to FAQ, but I couldn't find a concrete answer. I created a Datagrid control using ItemTemplate, but it's NOT a in-place editing datagrid. One of the columns of the data grid contains a DropDownlist. I managed to create this datagrid control as follows.
0
1007
by: Mike hofer | last post by:
I am studying up for my MCAD, and came across an interesting conundrum. According to my textbook, there are FOUR steps to publish an event: 1. Define a delegate type that specifies the prototype of the event handler. If the event generates no data, use the predefined EventHandler delegate. 2. Define an event based on the delegate type defined in the preceding step. 3. Define a protected, virtual method that raises the event. 4. When the...
5
3372
by: Mike Salter | last post by:
I created a page that reads a DB for questions and possible answers (usuallyYes/No). I create a panel for each group of questions, and add a panel for each question to the Group panel. To the Question panel I add a label with the question text, and a radiobuttonlist with the answers. I have an eventhandler I add to each radiobuttonlist, which is the same for all. The Group panels are then added to Placeholder1.Controls. I then add...
6
1710
by: Tim | last post by:
Hi, I have a module that acts as a publisher of events. The clients subscribe for the events using the '+=' operator. Instead, I would like the clients to call a method like "RegisterForXEvent" passing the required information. Inside that method, I would like to add the client to the list of subscribers. Is it possible to implement the above. If so, how do I do it? What kinda information should the client pass to the Event publisher?
3
1670
by: jm | last post by:
>From a C. Petzold book I have Programming Windows C#. It's a little old now, but anyway, it has on page 71 (shortened): form.Paint += new PaintEventHandler(MyPaintHandler); static void MyPaintHandler(object objSender, PaintEventArgs pea) { Graphics grfx = pea.Graphics; grfx.Clear(Color.Chocolate); }
0
9721
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
9602
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
10639
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
10376
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
10383
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
6881
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();...
1
4332
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
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
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.