Sizechanged事件问题...... [英] Sizechanged event question...

查看:47
本文介绍了Sizechanged事件问题......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个内部显示图像的Picturebox。通过代码,

我能够拥有整个图像。在没有失真的情况下显示它。

(在大多数图像查看器程序中类似于适合所有人)


现在,当Picturebox被调整大小时用户,我希望图像重新计算并显示为全部适合再次。


所以我在Picturebox的SizeChanged事件中有代码。当

尺寸发生变化时,它会进行计算并正确显示。


它有效,但有一个问题:如果用户拖动Picturebox

窗口变大或变小,SizeChanged事件每次触发多次激活
秒。当试图显示图像时,这会导致应用程序中出现很多迟缓。


无论如何,当我们可以让SizeChanged事件激活ONCE时$>
我已经完成了调整图片框的大小了吗?


(顺便说一句,图片框间接调整大小。它的底座已设置

to Fill。当它的界面Next被调整大小时,Picturebox

自然会相应调整大小。


感谢您的帮助!


John

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

推荐答案

John,


你可以在活动中使用两个静态变量(或一个静态点),如果它发生变化,每次看到




我希望这有帮助,


Cor
John,

You can use in the event two static variables (or one static point) to see
everytime if it changed,

I hope this helps,

Cor


嗨John,


你在处理sizechanged事件吗?因为我写了一些

代码做了同样的事情,并在这3个事件中尝试了它们所有

只触发一次,当我完成拖动表格边界


Private Sub ptbImg_Resize(ByVal sender As Object,ByVal e As

System.EventArgs)处理ptbImg.Resize

结束Sub


Private Sub ptbImg_SizeChanged(ByVal sender As Object,ByVal e As

System.EventArgs)处理_ ptbImg.SizeChanged

结束Sub


Private Sub frmResize_SizeChanged(ByVal sender As Object,ByVal e As

System.EventArgs)处理_ MyBase.SizeChanged

End Sub


greetz Peter


-

今天的编程是软件之间的竞赛工程师努力建立更大,更好的防止白痴程序,并且宇宙试图生产更大更好的白痴。到目前为止,宇宙正在赢得胜利。


Cor Ligthert <无************ @ planet.nl> schreef in bericht

news:uq ************** @ tk2msftngp13.phx.gbl ...
Hi John,

which sizechanged event are you handling? Because I have written a bit of
code which does the same thing, and tried it in these 3 events and they all
only fire once, when I finish dragging the form border

Private Sub ptbImg_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) Handles ptbImg.Resize
End Sub

Private Sub ptbImg_SizeChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles _ ptbImg.SizeChanged
End Sub

Private Sub frmResize_SizeChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles _ MyBase.SizeChanged

End Sub

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.

"Cor Ligthert" <no************@planet.nl> schreef in bericht
news:uq**************@tk2msftngp13.phx.gbl...
John,
你可以在事件中使用两个静态变量(或一个静态点),每次看到
如果它发生变化,

我希望这会有所帮助,

Cor
John,

You can use in the event two static variables (or one static point) to see
everytime if it changed,

I hope this helps,

Cor



彼得,


这实际上是我所拥有的一个小组附加的SizeChanged事件。

当图像大于

面板时,我得到滚动条。


如果没有任何问题,您是否可以发布一些示例代码,使

事件只触发一次?我只是在调整一个简单的

表单上进行了一个示例测试:


Private Sub Form1_SizeChanged(...)处理MyBase.SizeChanged

MessageBox.Show(" Size Changed!")

End Sub


表单甚至不会调整大小,因为消息框会立即弹出。

如果我可以在完成调整大小后显示消息框,

那将是非常棒的。然后我可以将它改编为我的真实应用程序。


谢谢!

John

Peter,

It''s actually a Panel that I have the SizeChanged event attached to.
This is so the I get scrollbars when the image is larger than the
Panel.

If it''s not any trouble, could you post some sample code that makes the
event fire only once? I just did a sample test on resizing a plain
form:

Private Sub Form1_SizeChanged(...) Handles MyBase.SizeChanged
MessageBox.Show("Size Changed!")
End Sub

The form won''t even resize because the messagebox pops up immediately.
If I could get the messagebox to show up after finishing the resize,
that would be awesome. I could then adapt it to my real app.

Thanks!
John


这篇关于Sizechanged事件问题......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆