Share via

TOPMOST does not work.

Don Dilworth 211 Reputation points
2020-11-15T18:54:55.277+00:00

My code creates many copies of itself via CreateProcessA(). These do not display anything on the monitor except for a small status dialog with a progress bar, stop button, and some icons. That dialog is supposed to stay on top of everything else until that process terminates.

When I run the code, those dialogs all show up and function normally at first. But as the processes cycle through its data, at the next cycle those windows go behind the main window showing process 0. That's no good; the user wants to monitor the progress on the other processes, so they have to be visible.

But if I run the same data over again, without restarting the program, they show up and stay on top as they should. Here's what I have tried. This is done by the other processes when they update the status dialog.

    HWND h = (HWND)myMPROGRESSBAR;
    SetWindowPos( h, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE );

    SetForegroundWindow(h);
    SetFocus(h);

    myMPROGRESSBAR->SetActiveWindow();
    myMPROGRESSBAR->SetFocus();

    HWND h = (HWND)myMPROGRESSBAR;
    ShowWindow(h, SW_MINIMIZE);
    ShowWindow(h, SW_RESTORE);

Nothing seems to work better. Why would the second time work and not the first? All the calls and data are the same.

Developer technologies | Visual Studio | Other
Developer technologies | Visual Studio | Other

A family of Microsoft suites of integrated development tools for building applications for Windows, the web, mobile devices and many other platforms. Miscellaneous topics that do not fit into specific categories.


Answer accepted by question author

Don Dilworth 211 Reputation points
2020-11-15T22:54:29.57+00:00

Found it. When I transferred all files to vs2017, somehow the progressbar dialog lost its topmost setting! I put it back and now it works.

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.