Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: TOpenDialog/TSaveDialog and PlaySound() issue


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 4 - Last Post: Mar 22, 2016 8:57 PM Last Post By: Philip Strong
Philip Strong

Posts: 3
Registered: 12/17/13
TOpenDialog/TSaveDialog and PlaySound() issue  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 22, 2016 4:45 PM
Hi all,

I have a Delphi WIN32 VCL application built in XE4. I am trying to use the MSDN function
Played := PlaySound(PWideChar(FileString), 0, SND_NODEFAULT or SND_ASYNC or SND_FILENAME or SND_NOSTOP);
. The function plays the sounds correctly, but once I execute either a TOpenDialog or TSaveDialog (even if I close the dialog without selecting a file) the PlaySound() function no longer plays the sound (despite the function returning true).

Any ideas/suggestions?

Edited by: Philip Strong on Mar 22, 2016 4:46 PM

Edited by: Philip Strong on Mar 22, 2016 4:47 PM
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: TOpenDialog/TSaveDialog and PlaySound() issue  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 22, 2016 5:29 PM   in response to: Philip Strong in response to: Philip Strong
Philip Strong wrote:
I have a Delphi WIN32 VCL application built in XE4. I am trying to use the MSDN function

Played := PlaySound(PWideChar(FileString), 0, SND_NODEFAULT or SND_ASYNC or SND_FILENAME or SND_NOSTOP);
.

The function plays the sounds correctly, but once I execute either a TOpenDialog or TSaveDialog (even if I close the dialog without selecting a file) the PlaySound() function no longer plays the sound (despite the function returning true).

Those components do not do anything with sounds. My guess would be maybe they are loading a Shell Namespace Extension that is internally stopping sound playback for the calling process.

--
Remy Lebeau (TeamB)
Philip Strong

Posts: 3
Registered: 12/17/13
Re: TOpenDialog/TSaveDialog and PlaySound() issue  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 22, 2016 6:44 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Philip Strong wrote:
I have a Delphi WIN32 VCL application built in XE4. I am trying to use the MSDN function

Played := PlaySound(PWideChar(FileString), 0, SND_NODEFAULT or SND_ASYNC or SND_FILENAME or SND_NOSTOP);
.

The function plays the sounds correctly, but once I execute either a TOpenDialog or TSaveDialog (even if I close the dialog without selecting a file) the PlaySound() function no longer plays the sound (despite the function returning true).

Those components do not do anything with sounds. My guess would be maybe they are loading a Shell Namespace Extension that is internally stopping sound playback for the calling process.

--
Remy Lebeau (TeamB)

Thanks Remy,

I realise those components have nothing to do with sound. I have also tried loading the sound to a TMemoryStream when the form is created, and playing that instead:
  WavStream := TMemoryStream.Create;
  WavStream.LoadFromFile('TestSound.wav');
 
  PlaySound(WavStream.Memory, 0, SND_NODEFAULT or SND_ASYNC or SND_MEMORY);   //play from memory


This has the same behavior so I know it is not directly related to loading the sound file.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: TOpenDialog/TSaveDialog and PlaySound() issue [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 22, 2016 7:24 PM   in response to: Philip Strong in response to: Philip Strong
Philip wrote:

I realise those components have nothing to do with sound. I have also
tried loading the sound to a TMemoryStream when the form is created,
and playing that instead:

WavStream := TMemoryStream.Create;
WavStream.LoadFromFile('TestSound.wav');
PlaySound(WavStream.Memory, 0, SND_NODEFAULT or SND_ASYNC or
SND_MEMORY);   //play from memory


This has the same behavior so I know it is not directly related to
loading the sound file.

My point is, maybe a SNE is calling PlaySound(NULL, 0, 0) internally to stop
all sound playback regardless of how it was started.

--
Remy Lebeau (TeamB)
Philip Strong

Posts: 3
Registered: 12/17/13
Re: TOpenDialog/TSaveDialog and PlaySound() issue  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 22, 2016 8:57 PM   in response to: Philip Strong in response to: Philip Strong
Further information:

If I launch the application in compatibility mode for "Windows XP (Service Pack 3)" there are no issues (running on Windows 7 64bit).
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02