|
-
Nov 19th, 2000, 07:35 PM
#1
Thread Starter
Frenzied Member
when i move the play list, instead of moving it, it makes a copy of it to the place where i move it, like sometimes when you get an illigal operation, and you move it, it just kinda leaves a copy of the form on your screen, well this is like that, and after that, my computer works very slow.... i have 1328mb of ram, and my resources are high, well here's the code:
Code:
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Private Declare Sub ReleaseCapture Lib "user32" ()
Const WM_NCLBUTTONDOWN = &HA1
Const HTCAPTION = 2
Private Sub Form_Load()
frmMP3.Visible = True
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim lngReturnValue As Long
If Button = 1 Then
Call ReleaseCapture
lngReturnValue = SendMessage(frmPlaylist.hwnd, WM_NCLBUTTONDOWN, _
HTCAPTION, 0&)
For inta = 1 To 500
For intb = 1 To 3030
If frmPlaylist.Left = frmMP3.Left + frmMP3.Width + inta Then
If frmPlaylist.Top = frmMP3.Top + frmMP3.Height - intb Then
MsgBox "you're close to the right"
End If
End If
If frmPlaylist.Left = frmMP3.Left + frmMP3.Width - inta Then
If frmPlaylist.Top = frmMP3.Top + frmMP3.Height - intb Then
MsgBox "you're close to the left"
End If
End If
Next intb
Next inta
End If
End Sub
if anyone could let me know how to fix it, i'd appreicate it
NXSupport - Your one-stop source for computer help
-
Nov 19th, 2000, 07:42 PM
#2
I see you found your problem with Next inta line .
Next inta goes after Next intb rather than before it .
You should try adding some DoEvents to that code dimava, I'm sure it may speed up the process a little bit.
-
Nov 19th, 2000, 07:55 PM
#3
Thread Starter
Frenzied Member
but if i put the NEXT INTA first, an error comes up
NXSupport - Your one-stop source for computer help
-
Nov 19th, 2000, 08:10 PM
#4
Uh..dimava?
I said you found the error by yourself.
You posted before asking why the code errors, but you found it already. So it's fine.
'For a = 0 to 10 'a-begin
'For b = 0 to 10 'b-begin
'whatever-a
'whatever-b
'or
'whatever-b
'whatever-a
'Next b 'b-end first
'Next a 'a-end second
-
Nov 19th, 2000, 08:39 PM
#5
Thread Starter
Frenzied Member
but my problem is that it makes my computer run very slow, and after i move it, it moves, and it leaves the image of the form, from where i moved it
NXSupport - Your one-stop source for computer help
-
Nov 19th, 2000, 09:50 PM
#6
Why the heck do you have so much ram???
1.3 Gig of RAM?!?!!?!?!?
Makes my 256MB look puny. Well my computer is puny actually. Gotta overclock it or something. Gotta overclock my 3dfx card too.
-
Nov 19th, 2000, 10:01 PM
#7
Thread Starter
Frenzied Member
sorry, i ment 128meg, does anyone have the answer to my question?
NXSupport - Your one-stop source for computer help
-
Nov 19th, 2000, 10:05 PM
#8
Put some DoEvents in some (or all) of your loops.
Code:
For X = 1 To 128
lblX.Caption = X
Next X
'differs from
For X = 1 To 128
lblX.Caption = X
DoEvents
Next X
-
Nov 20th, 2000, 12:32 AM
#9
Originally posted by dimava
sorry, i ment 128meg, does anyone have the answer to my question?
I said:
You should try adding some DoEvents to that code dimava, I'm sure it may speed up the process a little bit.
And then Dreamlax said:
Put some DoEvents in some (or all) of your loops.
Come arn' dimava, pay attention .
You may want to listen to the things I say, I have helped many people out with great code.
So just read everything I say, it may help you to become President someday..or at least someone of importance!..or not.
-
Nov 20th, 2000, 12:48 AM
#10
Ok, let's begin dimava.
We will begin with why you got the error.
'For a = 0 to 10 'a-begin <-start first For
'For b = 0 to 10 'b-begin <-start second For
'whatever-a 'process first For
'whatever-b 'process second For
'Next b 'b-end first <-finish what's inside first
'Next a 'a-end second <-then finish what's outside
Hope that's a little better understanding.
Q: What is the DoEvents function good for and why do we use it?
VB's definition: Yields execution so that the operating system can process other events.
A better understanding would be that you process all the code first before the DoEvents and then continue on to the next.
'blah blah blah
'blah blah blah
'blah blah blah
'DoEvents 'process all code above before continuing on the the next
'blah blah blah
'blah blah blah
'blah blah blah
Why is it used?
DoEvents can prevent freezing of code.
It is not harmful.
It is mostly used in the For...Next Statement because it can freeze most of the time, whatever code is in there, or at least be really slow.
But with DoEvents, you can do other stuff while the code is being processed.
[Edited by Matthew Gates on 11-20-2000 at 01:36 AM]
-
Nov 20th, 2000, 01:32 AM
#11
Addicted Member
Don't discourage people from asking questions by mocking them.
Firstly I think you're all being very rude to dimava. Secondly I think you are all missing the point.
DoEvents does not speed up the operation. How about looking at what happens in the For...Next loops, and how many times it happens?
500 * 3030 = 1515000
Why are those If statements performed more that 1.5 million times?
Shrog
-
Nov 20th, 2000, 02:19 AM
#12
Hey, DoEvents gives the 'effect' of making it go faster. If you can see what it is doing and where it is up to, it seems faster than having to wait for it to finish.
-
Nov 20th, 2000, 03:03 AM
#13
Addicted Member
Pay attention
You're still missing the point. Painting flames on a car to make it look faster, does not change it into a bicycle.
Dimava wants to determine if one form is being dragged close to the edge of another form. This should be a quick test, and should not require DoEvents. Can you not see that?
Dimava,
The problem is that your coding is in a loop. You are trying to check every possible point near the edge of the form to see if it is equal to the edge of the other form. This is performed 1.5 million times. That is why it's slow.
What you need to do is get rid of the loop, and just check whether the distance between the forms is smaller that a certain amount.
Code:
Dim DistFromLeft As Single
Dim DistFromTop As Single
Dim DistFromRight As Single
Dim DistFromBottom As Single
DistFromLeft = Abs(frmMP3.Left - frmPlayList.Left - frmPlaylist.Width)
DistFromTop = Abs(frmMP3.Top - frmPlayList.Top - frmPlaylist.Height)
DistFromRight = Abs(frmMP3.Left + frmMP3.Width - frmPlayList.Left)
DistFromBottom = Abs(frmMP3.Top + frmMP3.Height - frmPlayList.top)
If DistFromLeft < 500 and DistFromTop < 3030 Then
MsgBox "You are close to the Left"
End If
If DistFromRight < 500 and DistFromTop < 3030 Then
MsgBox "You are close to the Right"
End If
Shrog
-
Nov 20th, 2000, 06:55 AM
#14
Thread Starter
Frenzied Member
NXSupport - Your one-stop source for computer help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|