Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Object Depth, Page Buffer, and Sound question
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
zwnage




PostPosted: Sun Jan 21, 2007 12:16 am   Post subject: Object Depth, Page Buffer, and Sound question

Is there a way to change the depth of an object so that other objects don't cover it (ie: bring to front)? I am using Load to create balls in my form, but the balls end up behind some of my other objects. Is there a way to fix this?

Also, I am having trouble with flashy images. Is there some sort of buffer or page flip system in VB? (sorta like in turing with the "offscreenonly" option and View.Update)

Lastly, I'm having issues with sound. I want the music file to loop and play again after its finished. I'm using something like this:
code:

Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

Private Sub soundTimer_Timer()
    Call sndPlaySound(App.Path & "\" & "test.wav", 1)
End Sub


I know VB should have a way to detect when a sound file is done since the Play Until Done command detects when the sound file is finished playing before going back to my program (I think its 0 or 2 in the last argument of Call sndPlaySound, another one is 12, but I have no idea what it does), but I don't want to use this since I want both the music and the program to run simultaneously. Is there any way to do this?

Thanks for your time.
Sponsor
Sponsor
Sponsor
sponsor
Monstrosity_




PostPosted: Sun Jan 21, 2007 10:04 pm   Post subject: Re: Object Depth, Page Buffer, and Sound question

zwnage @ Sun Jan 21, 2007 1:16 am wrote:
Is there a way to change the depth of an object so that other objects don't cover it (ie: bring to front)? I am using Load to create balls in my form, but the balls end up behind some of my other objects. Is there a way to fix this?

You could play with the zOrder, but thats probably going to be more of a pain. Looking into drawing to a buffer first.. this way you will select what to draw in what order and not mess around with moving controls.

zwnage @ Sun Jan 21, 2007 1:16 am wrote:
Also, I am having trouble with flashy images. Is there some sort of buffer or page flip system in VB? (sorta like in turing with the "offscreenonly" option and View.Update)

You don't buffer a single image in this sense, and your not drawing them all to the same place. The idea with the buffer is that you draw all your balls to it, then draw that single new image to the screen/form. Or you can instead make the controls not visible and draw them to the form yourself (I think this might be what your describing above). Turning the forms AutoRedraw property On sometimes helps with the control flickering, as does moving the control a reasonable amount.. for example don't move a control 2 twips each iteration of the timer instead use something like 2 pixels.

zwnage @ Sun Jan 21, 2007 1:16 am wrote:
I know VB should have a way to detect when a sound file is done since the Play Until Done command detects when the sound file is finished playing before going back to my program (I think its 0 or 2 in the last argument of Call sndPlaySound, another one is 12, but I have no idea what it does), but I don't want to use this since I want both the music and the program to run simultaneously. Is there any way to do this?

That's the problem, your using the function with arguments that you have no idea what they do. Look up the function and find out what values this function accepts and what they do. You should make such numbers constants with meaningful names so when you look at it later on you know what the argument does. VB also comes with a multimedia control if you fail at the WinAPI.
zwnage




PostPosted: Thu Jan 25, 2007 9:37 pm   Post subject: RE:Object Depth, Page Buffer, and Sound question

Thanks for the help. I did play around with the order of my pictures, and it solved that problem for now.

For the sound tho, I'm still a little lost. I looked up the internet VB library, and they have the properties of sndPlaySound, but I still don't know which one to use. I'm currently just timing the time that the music is playing and repeating the playSound when the timer equals the length of the song (a pretty bad way to do it, I assume)
Monstrosity_




PostPosted: Thu Jan 25, 2007 11:51 pm   Post subject: Re: Object Depth, Page Buffer, and Sound question

zwnage wrote:

For the sound tho, I'm still a little lost. I looked up the internet VB library, and they have the properties of sndPlaySound, but I still don't know which one to use.


Look up the function, which has NOTHING to do with VB. Then find the constants you need. Getting used to research early on will help you later.

Note: There are also VB API Guides out there that contain EVERYTHING from explainations to examples. Happy hunting.

zwnage wrote:
I'm currently just timing the time that the music is playing and repeating the playSound when the timer equals the length of the song (a pretty bad way to do it, I assume)

Then don't do it Wink
Silent Avenger




PostPosted: Fri Jan 26, 2007 11:25 am   Post subject: Re: Object Depth, Page Buffer, and Sound question

One thing you may want to consider using is the MMControl which will play most sounds and you can use code to make songs repeat. You can also use media player if you want to.
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: