 |
|
 |
First, I addressed the Overlfow problem in fluideffect.vb by simply replacing the following line: alpha = CByte(200 - xOffset) with this: If xOffset < -55 Then xOffset = 55 alpha = CByte(200 - xOffset) Second, for a really nifty enhancement to it, add the following event code to the control: 'add a dragging ripple effect when the select mouse button is down Private Sub fluidEffectControl_MouseMove(ByVal sender As Object, _ ByVal e As System.Windows.Forms.MouseEventArgs) _ Handles Me.MouseMove 'ignore if left mouse button not down If e.Button <> Windows.Forms.MouseButtons.Left Then Exit Sub 'do ripple effect from current position Dim realX As Integer = CInt((e.X / CDbl(Me.ClientRectangle.Width)) * _waveWidth) Dim realY As Integer = CInt((e.Y / CDbl(Me.ClientRectangle.Height)) * _waveHeight) _stopRipples = False PutDrop(realX, realY, _dropHeight) End Sub David Goben The surest way to spot a faith of the blind is to hear them call themselves the one true faith.
|
|
|
|
 |
|
 |
Really Very Nice
If you can think then I Can.
|
|
|
|
 |
|
 |
I could find two places where it breaks :
1 - In fluidEffect.vb, just after 'generate alpha
replace the if then by:
Dim newAlpha As Integer = 200 - xOffset
alpha = If(newAlpha < 0, 0, If(newAlpha > 255, 255, CByte(newAlpha)))
Then I had another error which I shamelessly hide by adding a try catch block
Try
_waves(x, y, newBuffer) = CShort((BSRight(_waves(x - 1, y - 1, _activeBuffer) + _
_waves(x, y - 1, _activeBuffer) + _
_waves(x + 1, y - 1, _activeBuffer) + _
_waves(x - 1, y, _activeBuffer) + _
_waves(x + 1, y, _activeBuffer) + _
_waves(x - 1, y + 1, _activeBuffer) + _
_waves(x, y + 1, _activeBuffer) + _
_waves(x + 1, y + 1, _activeBuffer), 2)) - _waves(x, y, newBuffer))
Catch ex As Exception
_waves(x, y, newBuffer) = 0
End Try
|
|
|
|
 |
|
 |
nice it work perfect
manoj joshi
|
|
|
|
 |
|
 |
"An error occurred creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object."
I know it's because the fluideffects control cannot find the bmp file... Pardon my ignorance... Anyone have the quick answer, help a rookie out, also can this control be attached to a custom control which inherits from a panel???
|
|
|
|
 |
|
 |
Could someone please post the correct code to substitute my bitmap image into this control... OUTSIDE THE DEMO APP... Using just the code within fluidEffect.vb file...
PLEASE... Ken
|
|
|
|
 |
|
 |
I have a nifty control that I built from code snippets online, it is basically a custom user control inheriting from a panel control... I have a lot of control over that panel and was wondering how to incorporate it into this fluid effect control, basically I want to provide the "panel" that this control uses which is normally placed on the form seperately from within the control itself, brining along all the flexibility of my panel with the addition of the "fluid effects" Please tell me that this can be done... I have had some dificulty using this code outside the demo app (I can't seem to incorporate it into my project)
Any help would be appreciated... Ken
|
|
|
|
 |
|
 |
How to make hyperlink to change color opn mouse move?
|
|
|
|
 |
|
 |
this program is really nice,
i made the first modification as say in the thread.
and i change the short by a int64 is it a good idea ?
thanks a lot
|
|
|
|
 |
|
 |
I tried both suggestions in the threads below with little luck. I am trying to alter the demo project to simulate rain (many drops at a time) with the following code. After 4 seconds or so theres the overflow exception. I've added the delta change and converted all shorts to longs. Anyone else have any luck with this?
Dim lUntil As Long = Environment.TickCount + 10000
Dim r As New Random
While Environment.TickCount < lUntil
Panel1.PutDrop(r.Next(0, Panel1.Width), r.Next(0, Panel1.Height), bar_dropHeight.Value)
Application.DoEvents()
System.Threading.Thread.Sleep(10)
End While
|
|
|
|
 |
|
|
 |
|
 |
5 mouse clicks at the same point and :
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.OverflowException: Arithmetic operation resulted in an overflow.
at fluidEffectDemo.fluidEffect.fluidEffectControl.fluidEffectControl_Paint(Object sender, PaintEventArgs e)
at System.Windows.Forms.Control.OnPaint(PaintEventArgs e)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
|
|
|
|
 |
|
 |
Yep, that is listed as "Gotcha #3" in the article. We are extremely busy here at work, so I haven't had time to take a look at it.
Don Pattee
http://www.x-caiver.com
|
|
|
|
 |
|
 |
Hello
GREAT CODE !!!!!
It is very interesting (for those of us who only work with VB an are sad to see those great samples/demos of C#).
I have debug the code and I found that in sub : "fluidEffectControl_Paint"
there is a variable :
Dim alpha As Byte
(so it can only handle betwenn 0 and 255)
but in debug mode i found:
'generate alpha
alpha = CByte(200 - xOffset)
And the value of xOffSet was -56.... So it "overflows".
I hope it helps!
Thanks again for post your code !
Hegemon
Spain.
|
|
|
|
 |
|
 |
Hello.
To test I introduce these lines before se apha assigement:
If (xOffset < -55) Then
xOffset = -55
End If
and WORKS perfectly! No more exceptions !
Regards
Hegemon
|
|
|
|
 |
|
 |
Hello again.
There is still one more exception but it happens after a long long number of clicks
It is in the next code:
'_waves(x, y, newBuffer) = CShort((BSRight(_waves(x - 1, y - 1, _activeBuffer) + _
' _waves(x, y - 1, _activeBuffer) + _
' _waves(x + 1, y - 1, _activeBuffer) + _
' _waves(x - 1, y, _activeBuffer) + _
' _waves(x + 1, y, _activeBuffer) + _
' _waves(x - 1, y + 1, _activeBuffer) + _
' _waves(x, y + 1, _activeBuffer) + _
' _waves(x + 1, y + 1, _activeBuffer), 2)) - _waves(x, y, newBuffer))
Sometimes the addition is greater than 32767 or lower than -32767 and gives a overflow because it is a "short".
Regards.
Hegemon
|
|
|
|
 |
|
 |
Im using the project on visual studio 2008, i simply placed the generate alpha line of code in a try/catch like this:
'generate alpha
Try
alpha = CByte(200 - xOffset)
Catch ex As Exception
alpha = 0
End Try
That seems to fix the overflow problem for me. I also changed all of the integer types to long, which might also have helped.
|
|
|
|
 |
|
 |
Very nice indeed. I haven't looked at any of the code yet, but I'm anxious to. One thing happened though when I was executing it. If I clicked a bunch of times to create lots of ripples, I got the following exception:
System.OverflowException: Arithmetic operation resulted in an overflow.
at fluidEffectDemo.fluidEffect.fluidEffectControl.fluidEffectControl_Paint(Object sender, PaintEventArgs e) (eek added by me)
It's probably something simple-ish to fix, but I though I'd bring it up so you at least know about it (if you didn't already).
Great work!
RabidK
|
|
|
|
 |
|
 |
Looks good! atlast something that looks good for the VB developers.
There is a small bug though. If you click as hell on the image an "Arimetric overflow" exception occures, but hey it still looks good!
Greets,
Poolbeer
Speak Out! Use the Source, Luke!
(Dr. GUI .NET #5)
|
|
|
|
 |
|
 |
Yep, haven't had time to figure that out. It is listed as "Gotcha #3" for now.
Don Pattee
http://www.x-caiver.com
|
|
|
|
 |