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.
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:
Is there a way to avoid that?
The display of P1 is done using OpenGL 3.3.