0

I'm trying to make a function similar to the wallpaper engine, by adding a child window to the Progman window. The function did allow me to add the video, however, the window size is fixed, which made me unable to fit the video to the entire desktop.

I tried to change the window size, but neither MoveWindow nor SetWindowPos worked. The Progman's hwnd Rect is just screen size (1920x1080), so it's not a boundary issue. The video window size is 640x480. I'm able to change the location of the window, meaning no permission issue, just can't change the size of it.

Here is the code.

LPCWSTR lpParam = L" videoTest2.mp4 -noborder -fs -loop 0";
STARTUPINFO si{ 0 };
PROCESS_INFORMATION pi{ 0 };

if (CreateProcess(L"ffplay.exe", (LPWSTR)lpParam, 0, 0, 0, 0, 0, 0, &si, &pi)) {
    Sleep(200);

    HWND hProgram = FindWindow(_T("Progman"), _T("Program Manager"));
    HWND hFfplay = FindWindow(L"SDL_app", 0);
    SetParent(hFfplay, hProgram);

    // MoveWindow(hFfplay, 0, 0, 3840, 1080, true);
    SetWindowPos(hFfplay, NULL, 0, 0, 3840, 1080, SWP_NOZORDER);
    ShowWindow(hFfplay, SW_MAXIMIZE);


    EnumWindows(EnumWindowProc, (LPARAM)SW_HIDE);

    Sleep(1000);

    EnumWindows(EnumWindowProc, (LPARAM)SW_SHOW);
}
else {
    std::cout << GetLastError() << std::endl;
}

EnumWindowProc is just for showing and hiding system background images.

  • Can you resize it before 'SetParent`? – Anders Dec 13 '21 at 19:09
  • Hmmm, I tried a bunch of different more things. You are right about resizing before SetParent, and there also has to be a bit of wait in between the resize and setparent. I wrote a Sleep(500) in between, and it seems to work. – Zeke Fan Dec 13 '21 at 20:56
  • Can you add the solution to the question? – Sahin Nov 09 '22 at 05:39

0 Answers0