Link to home
Start Free TrialLog in
Avatar of jhunt
jhunt

asked on

Ordering by z-order.

I have a Save-All-Modified dialog that displays a list view with a list of documents that have been modified. Currently it is sorted alphabetically by filename. I would like it to be sorted by the order of when the documents were last used. Basically it comes down to this:

I have two documents. I have to decide which one has a view that is higher in the z-order than the other ones views. Isn't there a windows routine to take to HWND and tell you which one is higher in the z-order?
ASKER CERTIFIED SOLUTION
Avatar of Zoppo
Zoppo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of _mb_
_mb_

You can use the methods GetTopWindow() and GetNextWindow() to determine the z-order of your windows.
I think you can use the CWnd::SetWindowPos function.

According to the help doc, you can use the pWndInsertAfter parameter to indicate the previous window in the z-order.
To make this function ignore the (int x, int y, int cx, int cy) values, use SWP_NOMOVE|SWP_NOSIZE.
Example:
SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);

or

SetWindowPos(&MyPreviousWindow,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
Avatar of jhunt

ASKER

I tried the GetTopWindow() and GetNextWindow()/GetPreviousWindow(). I also tried GetWindow(GW_CHILD) and GetWindow(GW_HWNDNEXT)/GW_HWNDPREVIOUS. Both of these didn't return any windows that were CFrameWnds. They only return CControlBar's, CToolbar's, CStatusBar's and CTempWnd's when using GW_HWNDNEXT and when using previous they returned NULL right away. Is there a window inside the mainframe that contains the child windows or something?
It should work if you start with:
(CWnd *) wnd = MDIGetActive();
and then call (in a loop):
wnd =  wnd->GetNextWindow();

My last comment correspond to zoppo's comment.
Avatar of jhunt

ASKER

Thanks ZOPPO,

I did figure it out in the end using GetActiveFrame().