winapi - Starting a windows-application with focus -
i'm writing small windows application in visual c++ without mvc. small, contains 1 textfield, ok-button , cancel-button.
the application started background-process when user starts printing. when opening application doesn't focus, isn't visible.
for user it's importend application directly in focus, have lease clicks possible use it.
i tried many many things application in focus:
setwindowpos(hwnd, hwnd_topmost, 0, 0, 0, 0, swp_nomove | swp_nosize); setforegroundwindow(hwnd); showwindow(hwnd, sw_restore); setfocus(hwnd);
i repeated calls in timer. of doesn't work. found remarks on msdn:
the system restricts processes can set foreground window. process can set foreground window if 1 of following conditions true:
the process foreground process. process started foreground process. process received last input event. there no foreground process. foreground process being debugged. foreground not locked (see locksetforegroundwindow). foreground lock time-out has expired (see spi_getforegroundlocktimeout in systemparametersinfo). no menus active.
anybody knows workaround this?
there no workaround this. whole point of new windows behavior prevent applications bringing foreground on own , being nuisance. in case, suggest using notification icon , showing balloon message when necessary instead of window. however, in case notification icon can hidden user , there no workaround, same reason above.
Comments
Post a Comment