question

DavidL-9972 avatar image
0 Votes"
DavidL-9972 asked ·

Win32: When a parent program launches a console program, the screen blinks

Hello

For my DIY jukebox, to play a CD, as there is a bug with MCI (see the issue here mci-mci-close-needed-if-the-cd-has-been-ejected.html), I coded a console program (let's call it P2) that doesn't display the command window ( #pragma comment(linker, "/SUBSYSTEM:WINDOWS") ) and that creates a dummy window just to receive and send message from and to the parent (HWND_MESSAGE) that doesn't display either.

It works this way:
- When I need to play a CD track, my main program (P1) calls P2 via CreateProcess with 4 arguments: the CD reader letter, the first track to be played, the last track to be played and the HWND of P1
- Once P2 is completely initialized, it sends a private message WM_USER+k to P1 containing its HWND in the lParam, so now they can communicate with each other
- P2 sets a timer that every 0.1s sends a message to P1 with the current track number, length and play position
- P1 can send a message to P2 to set the play position in the current track.
- P1 can send a message to P2 to command it to kill itself
- When P2 has stopped to play the requested track(s), it sends a message to P1 before killing itself

Now my problem:
When P1 launches P2 (=starts to play a track), P2 gets the focus, I suppose , so, on my desktop (i5 4th gen, GTX970, SATA CD reader) the screen blinks quickly and blinks again if I click on the screen (so P1 gets back the focus). When P1 sets the play position to P2, it is not visible.
watch
BUT... on the mini PC inside the jukebox (Ryzen 5 PRO 2500U with Vega 8, external USB CD reader), this is more than a simple blink and even when setting the play position, the display holds on a black then a blue screen before getting back to normal:
watch

Is there a way to avoid that?

Thanks
David


The display of P1 is done using OpenGL 3.3.




winapi-general
· 1
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Your problem is difficult to reproduce (I don't have your configuration),
but I did some tests (Windows 10) with the WMP method (IWMPPlayer, IWMPCdromCollection, IWMPCdrom, IWMPPlaylist, ...) to play a CD Audio and it seems to work better than MCI (the music stops correctly when I remove the CD while a track is playing for example)
I also tested the 3rd method (IOCTL_CDROM_RAW_READ) but it is too complex




0 Votes 0 ·
DavidL-9972 avatar image
0 Votes"
DavidL-9972 answered ·

Thanks to @Castorix31 and @StriveSun-MSFT for your answers, I am going to look at it. I close this thread.

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

DavidL-9972 avatar image
0 Votes"
DavidL-9972 answered ·

Is there a way to launch the child process without losing the focus, perhaps it would solvemy problem?

· 3 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

On Windows 10, I don't lose the focus when I launch with CreateProcess a Win32 app (GUI) with a hidden main window

0 Votes 0 ·

So, if we stick to the video from my desktop here watch, why is this really short black screen when P2 is launch (=when I click a track) and another short black screen when I click again on the window? I thought it was because P1 was losing the focus and then getting it back.

(For the problem with the long black and blue screen on the mini PC side, I found the problem: my CD reader has 2 USB ports to act as a hub and my mistake was to plug the USB cable of the touch screen on it. I suppose that when the motor of the CD reader starts, there is a strong drain of power from the USB and then the touchscreen plugged on it loses all the power needed, sorry)


0 Votes 0 ·

I cannot reproduce your problem. I think this is not caused by the focus, but the more possibility is the P1 program. Please check the redraw code of the P1 program.

0 Votes 0 ·