|
what about putting delete this; in the dtor?
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
If I put delete this is the destructor, it will fail since PostNCDestroy does it by default.
the problem is not deleting the window, the problem is how to know weather the window deleted itself (after the user closed it) or weather it's open...
If I try pWindow->IsWindowOpen() but pWindow is already deleted, I am dead in the water....
Shay
|
|
|
|
|
Shay Harel wrote:
If I try pWindow->IsWindowOpen() but pWindow is already deleted, I am dead in the water....
Will this work:
if (NULL != pWindow)
{
if (pWindow->IsWindowOpen())
...
}
This ensures that a NULL pointer is not dereferenced.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
The problem is that when the user close the window for me, pWindow is not turning to NULL (0x000000) it may turn to 0xddddd or anything else....
ha !
|
|
|
|
|
Well, After I thought about it again, I saw what you mean..
And it actually worked (The NULL as the first operand)
Thanks
|
|
|
|
|
Shay Harel wrote:
The problem is that the pointer is not really NULL but 0xdddd...
Which indicates freed memory. However, that value is subject to change.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Well,
I can't count on it to be always 0xddddd... this is unprofessional.
I am sure my problem is less complecated that I described it.
Basicall, if I pop up a window with a pointer and go on, how do I check if this window is either open/close/destroyed ?
Shay
|
|
|
|
|
I take it you have a derived CWnd or CSplitterWnd class you are using. How about overriding the default handlers so, that each of them sets a boolean before calling the base class ?
<span style='cpp-keyword'>class</span> CMyDerivedWnd : <span style='cpp-keyword'>public</span> CWnd
{
...
RESULT Create(PARAMS)
{
<span style='cpp-keyword'>this</span>->bIsCreated = TRUE;
<span style='cpp-keyword'>return</span> CWnd::Create(PARAMS);
}
...
<span style='cpp-keyword'>private</span>:
BOOL bIsCreated;
BOOL bIsOpen;
BOOL bIsDestroyed;
}
This, of course, assumes that you've marked the base class as virtual. I am unsure whether the original Create functions are virtual in the CWnd class (why wouldn't they be ? Ask MS)..
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Thank you but I found another way to do it:
Shay Harel wrote:
If I try pWindow->IsWindowOpen() but pWindow is already deleted, I am dead in the water....
Will this work:
if (NULL != pWindow){ if (pWindow->IsWindowOpen()) ...}
This ensures that a NULL pointer is not dereferenced.
|
|
|
|
|
My application contains skins which changed by user. Procedure of change occurs as follows:
::OnChangeSkin()
{
if (NULL != m_rgnWindow)
{
::DeleteObject(m_rgnWindow);
m_rgnWindow = NULL;
}
m_rgnWindow = GetRegionFromFile(...);
SetWindowRgn(m_rgnWindow, TRUE);
}
For any paint to call a following method
::OnDisplayWindow()
{
...
::FrameRgn(hMemDC, m_rgnWindow, hBrush, 1, 1);
...
::SelectClipRgn(hMemDC, m_rgnWindow);
::BitBlt();
::SelectClipRgn(hMemDC, NULL);
...
}
In the places specified as "//Error" BoundsChecker finds out a mistake
In what a mistake?
Best regards,
Eugene Pustovoyt
|
|
|
|
|
I had this same problem with CPen - I think it applies to any GDIObject. The object doesn't seem to be completely destroyed. In addition, you should be careful to separate the freeing of resources verses the actual deletion of the object, although Microsoft tries to make them the same with the questionable practice of self deleting functions. I can't be more helpful without seeing more code.
J.
----------------------------
|
|
|
|
|
Hi Everyone,
I'm having problems using messagebox
There is a parameter defined with messagebox, called MB_SERVICE_NOTIFICATION.
I use this parameter in my code:
MessageBox(NULL, "some text", "error", MB_SETFOREGROUND + MB_SERVICE_NOTIFICATION);
But i'm getting a compiler error, MB_SERVICE_NOTIFICATION : Undeclared identifier.
I went on the msdn that describes using messagebox, and it says that i should define _WIN32_WINNT.
So i did, and my preprocessor definition looks like: #define _WIN32_WINNT = 0x0400
I'm still getting the undeclared identifier error message, can someone please help me??? i'm looking at this problem for several hours without any luck.
Thank you in advance
Rico
|
|
|
|
|
just
#define _WIN32_WINNT 0x0400
You can find in winuser.h in the include
#ifdef _WIN32_WINNT
#if (_WIN32_WINNT >= 0x0400)
#define MB_SERVICE_NOTIFICATION 0x00200000L
#else
#define MB_SERVICE_NOTIFICATION 0x00040000L
#endif
#define MB_SERVICE_NOTIFICATION_NT3X 0x00040000L
#endif
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Thanks for your response,
I already have winuser.h and windows.h defined in the preprocessor definitions.
I also have the code: #define _WIN32_WINNT 0x0400 defined in the preprocessor definitions.
i'm not sure what you're suggesting in your response, can you please clarify?
Thank you
Rico
|
|
|
|
|
Then make sure
NOUSER and NOMB are not defined.
if MB_SERVICE_NOTIFICATION_NT3X works then you have a problem defining or undefining these constants
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Hi there,
i don't have nouser and nomb defined anywhere.
the error happens during compilation. i'm still confused as to what i'm doing wrong
Thanks for your responses.
|
|
|
|
|
did MB_SERVICE_NOTIFICATION_NT3X work?
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Hi Papa
replacing MB_SERVICE_NOTIFICATION with MB_SERVICE_NOTIFICATION_NT3X still does not work.
I have the #define _WIN32_WINNT 0x0400 declared
also, changed it to #define _WIN32_WINNT 0x0300 and it still doesn't work.
The error message that I'm recieving is the same, undeclared identifier.
Rico
|
|
|
|
|
What are you trying to do, just to pop a messagebox ?
|
|
|
|
|
You need #define _WIN32_WINNT 0x0400 in the stdafx.h file, above any #include statement.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
oh, thank you very much!
i thought i was going to be stuck forever with that error!
just wondering, if the app. i'm building should be compatible with any nt version, should i use
0x0300 instead of 0x0400?
THanks
Rico
|
|
|
|
|
Hey ,I've a dialog based application with a menu (menu bar). It works very well on windows 2000 Professional and Windows XP. But when I open it on Windows 98, there is no menu bar. Instead of the menu you can see a part of the desktop.
What can I do?
I work with Visual Studio 6.0 and I create the menu with the Ressource -Editor. To include the ressource I use this code:
CMenu menu;
menu.LoadMenu(IDR_MAINFRAME);
ASSERT(menu);
SetMenu(&menu);
Thnak's
Beppo
|
|
|
|
|
Just a guess, but it sounds like Internet Explorer (the Common Control DLL, actually) is not up-to-date on the Windows 98 machine.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Your CMenu object is local, so it will delete its HMENU object in its destructor when it goes out of scope, this could mean that your window has an invalid HMENU selected.
CMenu menu;
menu.LoadMenu(IDR_MAINFRAME);
ASSERT(menu);
SetMenu(&menu);
menu.Detach(); // stop menu being destroyed in destructor
Roger Allen
Sonork 100.10016
Death come early, death come late,
It takes us all, there is no reason.
For every purpose under heaven,
To each a turn, to each a season.
A time to weep and a time to sigh,
A time to laugh and a time to cry,
A time to be born and a time to die.
Dust to dust and ashes to ashes,
And so I end my song.
|
|
|
|
|
Thanks Roger, now it works
|
|
|
|