473,809 Members | 2,719 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
Addendum:

\\\
Private m_Image As Image
Private m_Redraw As Boolean = True

Private Sub Form1_Load( _
ByVal sender As Object, _
ByVal e As EventArgs _
) Handles MyBase.Load
m_Image = Image.FromFile( "C:\WINDOWS\Ang ler.bmp")
End Sub

Protected Overrides Sub WndProc( _
ByRef m As Message _
)
Const WM_ENTERSIZEMOV E As Int32 = &H231
Const WM_EXITSIZEMOVE As Int32 = &H232
Select Case m.Msg
Case WM_ENTERSIZEMOV E
m_Redraw = False
Case WM_EXITSIZEMOVE
m_Redraw = True
Me.Panel1.Inval idate()
End Select
MyBase.WndProc( m)
End Sub

Private Sub Panel1_Paint( _
ByVal sender As Object, _
ByVal e As PaintEventArgs _
) Handles Panel1.Paint
If m_Redraw Then
e.Graphics.Draw Image( _
m_Image, _
0, 0, _
Me.Panel1.Clien tSize.Width, Me.Panel1.Clien tSize.Height _
)
End If
End Sub
///

However, this solution would prevent the panel from redrawing if the window
is dragged by the mouse.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #31
Herfried,

The main problem is a
dockable window (thanks to dotnetbar (www.devcomponents.com)).

The rest of the solutions where already given (I think mine is nicer), do
you know something about this control and to stop actions using this while
resizing.

Cor
Nov 21 '05 #32
"Cor Ligthert" <no************ @planet.nl> schrieb:
\\\
Public SwMoving As Boolean
Private Sub Panel1_SizeChan ged(ByVal sender As Object, _
ByVal e As System.EventArg s) Handles Panel1.SizeChan ged
SwMoving = True
End Sub
Protected Overrides Sub WndProc(ByRef m As Message)
If m.Msg = &HA0 Then 'is up


'&HA0' is 'WM_NCMOUSEMOVE '! In addition to that, note that the user can
change the size of a window using the keyboard (Alt+Space -> "Resize" ->
arrow keys), which won't fire non-client mouse events. All together I don't
see the benefits of your solution.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #33
Herfried,
In addition to that, note that the user can change the size of a window
using the keyboard (Alt+Space -> "Resize" ->


A good addition. However for that can be tested in this procedure probably
just keyup &H291 with orelse (I did not test it).

I could not find all those shortcuts from C++ on Google, however I have now
copied a page from Bob Powell where it is was in, therefore I have them now
saved in my HKW system.

I thought yesterday it would be a nice extension if somebody like Herfried
makes a nice dll so that we can get those in the same way as all other
enumerations.

When you need that information from Bob Powell to make this than I can sent
them you by mail. (Before you say it, yes I can make it myself as well
however it looks so nice as a link to your page)

The Herfried.K.Wagn er namespace extension to the framework.

:-)

Cor
Nov 21 '05 #34
Cor,

"Cor Ligthert" <no************ @planet.nl> schrieb:
I thought yesterday it would be a nice extension if somebody like Herfried
makes a nice dll so that we can get those in the same way as all other
enumerations.


Untested:

A Win32 Library for .NET
<URL:http://www.codeproject .com/csharp/win32.asp>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #35
Herfried,

I will have a look at it, (as you know, do I hate sites which wants my
emailadres, although I know from you that this one is harmless)

Thanks,

Cor
Nov 21 '05 #36
Cor,

"Cor Ligthert" <no************ @planet.nl> schrieb:
I will have a look at it, (as you know, do I hate sites which wants my
emailadres, although I know from you that this one is harmless)


Yeah, I hate them too because I have to lookup my password every time I log
in.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #37
Sorry I couldn't try your suggestions out until now. ... and thanks
for the continued help with this! Unfortunately the dotnetbar
"dockable window" does not have a splitter that has events. No
splitter at all that I can see. It's probably using one in the
background, but I have no idea how to access it.

I think i'm just going to lay this issue to rest. I will not bother
having an instantly re-drawable picturebox/panel. Thanks again for all
your help!!!

John

Nov 21 '05 #38
Herfried,

I tried your code, but in my app it produced some side effect errors
that I could not figure out. As I wrote to Cor above, I decided to
just give up on this effect. But at least this thread was not for
nothing... it does have some valuable code for having the SizeChanged
event fire once if the "form" itself is resized.

Thanks!
John

Nov 21 '05 #39

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
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...
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
10120
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
9200
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...
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();...
0
5550
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
5688
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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

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.