vico
vico

Reputation: 18221

CWnd.wndTopMost usage

What CWnd.wndTopMost is used for?

in definition I found that it is:

static AFX_DATA const CWnd wndTopMost;

How macro AFX_DATA affects this line?

This code:

this->wndTopMost.SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);

Returns error

'CWnd::SetWindowPos' : cannot convert 'this' pointer from 'const CWnd' to 'CWnd &'

Why does it needs reference? This method returns to nothing.

Upvotes: 0

Views: 1377

Answers (1)

xMRi
xMRi

Reputation: 15375

wndTopMost is only used for the first Parameter of SetWindowPos. This variable is used to insert a Window in the Z-Order after this window.

So it is alowed to be defined as const, because the window it self is not modified.

Internally it is just a Special handle with the value -1 (look here)

And with this trick (const CWnd) nobody can do something you tried.

If you really want to do something with the topmost window, you have to retrieve the handle with GetTopWindow, GetActiveWindow or other functions.

Upvotes: 2

Related Questions