Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
243 views
in Technique[技术] by (71.8m points)

c++ - How to check if window is "Always on top"?

In my useful hotkeys program, i have a global hotkey which sets your current foreground window to be Topmost/Not topmost by calling

SetWindowPos(hwnd, HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
SetWindowPos(hwnd, HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);

at the moment i have to have two separate hotkeys, Win+Z to set window to TOPMOST anjd Win+X to set window to NOTOPMOST.

I can't find a function in MSDN which lets you check the windows z order.. i was hoping for something like GetWindowOrder, but there isn't. I also tried checking the windows ex flags like so:

dwExStyles & WS_EX_TOPMOST

but it seems that flag isn't never changed, it just tells the window to set itself topmost when its first created.

Is there a function to check this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I think you can do this:

DWORD dwExStyle = ::GetWindowLong(m_hWnd, GWL_EXSTYLE);

if ((dwExStyle & WS_EX_TOPMOST) != 0)
{
    // do stuff
}

Here's the MSDN link - http://msdn.microsoft.com/en-us/library/ms633584(VS.85).aspx

And here's the MSDN link to the extended styles - http://msdn.microsoft.com/en-us/library/ff700543(v=VS.85).aspx - topmost is currently listed as "TBD" :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...