void CWnd::CenterWindow(CWnd* pAlternateOwner) small (?) bug [modified]
-
Not really a question, but rather signaling a MFC pitfall... wincore.cpp, approx. line 3152 (Visual C++ 6.0, SP6) void CWnd::CenterWindow(CWnd* pAlternateOwner) { ASSERT(::IsWindow(m_hWnd)); // determine owner window to center against DWORD dwStyle = GetStyle(); HWND hWndCenter = pAlternateOwner->GetSafeHwnd(); if (pAlternateOwner == NULL) { ... Seems to me that pAlternateOwner calls first GetSafeHwnd, then is tested if is NULL... -- modified at 1:55 Monday 7th August, 2006
-
Not really a question, but rather signaling a MFC pitfall... wincore.cpp, approx. line 3152 (Visual C++ 6.0, SP6) void CWnd::CenterWindow(CWnd* pAlternateOwner) { ASSERT(::IsWindow(m_hWnd)); // determine owner window to center against DWORD dwStyle = GetStyle(); HWND hWndCenter = pAlternateOwner->GetSafeHwnd(); if (pAlternateOwner == NULL) { ... Seems to me that pAlternateOwner calls first GetSafeHwnd, then is tested if is NULL... -- modified at 1:55 Monday 7th August, 2006
GetSafeHwnd()
works fine ifpAlternateOwner
is null:HWND CWnd::GetSafeHwnd() const { return this == NULL ? NULL : m_hWnd; }
If the
this
object isNULL
, it just returnsNULL
.--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
-
Not really a question, but rather signaling a MFC pitfall... wincore.cpp, approx. line 3152 (Visual C++ 6.0, SP6) void CWnd::CenterWindow(CWnd* pAlternateOwner) { ASSERT(::IsWindow(m_hWnd)); // determine owner window to center against DWORD dwStyle = GetStyle(); HWND hWndCenter = pAlternateOwner->GetSafeHwnd(); if (pAlternateOwner == NULL) { ... Seems to me that pAlternateOwner calls first GetSafeHwnd, then is tested if is NULL... -- modified at 1:55 Monday 7th August, 2006
Is pAlternateOwner valid?
_**
**_
WhiteSky
-
GetSafeHwnd()
works fine ifpAlternateOwner
is null:HWND CWnd::GetSafeHwnd() const { return this == NULL ? NULL : m_hWnd; }
If the
this
object isNULL
, it just returnsNULL
.--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
Correct, I didn't checked. Sorry about that.
-
Is pAlternateOwner valid?
_**
**_
WhiteSky
Can be NULL or not, but Mike Dunn corrected me. GetSafeHwnd returns NULL if "this" is NULL. A little bit strange to me to have CWnd *pAlternateOwner = NULL; HWND hwndAlternate = pAlternateOwner->GetSafeHwnd(); // NULL because pAlternateOwner is NULL
-
Not really a question, but rather signaling a MFC pitfall... wincore.cpp, approx. line 3152 (Visual C++ 6.0, SP6) void CWnd::CenterWindow(CWnd* pAlternateOwner) { ASSERT(::IsWindow(m_hWnd)); // determine owner window to center against DWORD dwStyle = GetStyle(); HWND hWndCenter = pAlternateOwner->GetSafeHwnd(); if (pAlternateOwner == NULL) { ... Seems to me that pAlternateOwner calls first GetSafeHwnd, then is tested if is NULL... -- modified at 1:55 Monday 7th August, 2006
Cristian Amarie wrote:
HWND hWndCenter = pAlternateOwner->GetSafeHwnd();
GetSafeHwnd()
is an inline function, so there's nothing to dereference.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb