c# - How TopMost work when is set to true then back to it's previous state -


i working on legacy c# winforms application , today have found code:

// our current "topmost" value (ours false though) bool top = topmost; // make our form jump top of topmost = true; // set whatever topmost = top; 

it makes current form pop-up, seems silly me (even additional comments). have tried in small isolated winforms application, , seems me can safely replaced simple call focus method.

am wrong, or can replace , still sleep tonight?

i appreciate of help!

no, should not focus window. msdn:

focus low-level method intended custom control authors. instead, application programmers should use select method or activecontrol property child controls, or the activate method forms.

perhaps original author didn't know activate, or perhaps had topmost form in app causing nuisance, has since gone away , method of popping fore remnant.. can safely replace activate? don't know enough app ui certain; on face of yes, i've said if existing code works per expectation there seems little mileage gained changing it, , possibly loss of functionality if app acquires other topmost forms on future. i'm sure time better spent on other parts! :)


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -