Click here to Skip to main content
15,900,725 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralC++ Object HELL. Pin
vikramlinux8-May-05 22:40
vikramlinux8-May-05 22:40 
GeneralRe: C++ Object HELL. Pin
cmk8-May-05 23:09
cmk8-May-05 23:09 
GeneralRe: C++ Object HELL. Pin
vikramlinux8-May-05 23:29
vikramlinux8-May-05 23:29 
GeneralRe: C++ Object HELL. Pin
Tim Smith9-May-05 3:55
Tim Smith9-May-05 3:55 
GeneralRe: C++ Object HELL. Pin
vikramlinux9-May-05 18:31
vikramlinux9-May-05 18:31 
QuestionHow to get rid of "Log on to Windows" Dialog ,when computer is in a Domain? Pin
pubududilena8-May-05 22:29
pubududilena8-May-05 22:29 
AnswerRe: How to get rid of "Log on to Windows" Dialog ,when computer is in a Domain? Pin
David Crow9-May-05 2:10
David Crow9-May-05 2:10 
GeneralCObject::operator new() Pin
PJ Arends8-May-05 21:31
professionalPJ Arends8-May-05 21:31 
Hey, I was wondering if there was a way to prevent operator new() from calling the class constructor.

I have a CDialog derived class that creates a modeless dialog when it's constructor is called and I want to limit it to one instance. So what I want to do is when the dialog's operator new() is called, I want it to return a pointer to the already existing dialog. To accomplish this I have overridden the operator new() function
CWnd *CMyDialog::pMyDialog = NULL; // static member
 
#ifdef _DEBUG
void CMyDialog::operator new(size_t Size, LPCSTR File, int Line)
{
   if (pMyDialog)
      return pMyDialog;
   else
      return CDialog::operator new(Size, File, Line)
}
#else
   // non-debug version ...
The problem is that once operator new() returns it immediately jumps to the class constructor, which initializes everthing to NULL, totally messing up the dialog that was created previously.

Now I know that I can keep a pointer for the dialog in it's parent window, and check that pointer to see if the dialog is active, but I want to try something different if it at all possible. This way the dialog can be created or accessed from any other class without having to have access to the stored pointer.



"You're obviously a superstar." - Christian Graus about me - 12 Feb '03

"Obviously ???  You're definitely a superstar!!!" mYkel - 21 Jun '04

Within you lies the power for good - Use it!
Honoured as one of The Most Helpful Members of 2004

GeneralRe: CObject::operator new() Pin
Zdeslav Vojkovic8-May-05 22:34
Zdeslav Vojkovic8-May-05 22:34 
GeneralRe: CObject::operator new() Pin
PJ Arends9-May-05 7:09
professionalPJ Arends9-May-05 7:09 
Generalabout shutdown dialog box Pin
feitianli_38-May-05 21:25
feitianli_38-May-05 21:25 
GeneralRe: about shutdown dialog box Pin
P-Rex8-May-05 22:09
P-Rex8-May-05 22:09 
GeneralRe: about shutdown dialog box Pin
ThatsAlok8-May-05 22:20
ThatsAlok8-May-05 22:20 
GeneralRe: about shutdown dialog box Pin
feitianli_39-May-05 15:39
feitianli_39-May-05 15:39 
GeneralMemory leak.... vector of pointers.... Pin
franz19998-May-05 20:22
franz19998-May-05 20:22 
GeneralRe: Memory leak.... vector of pointers.... Pin
jmkhael8-May-05 23:37
jmkhael8-May-05 23:37 
Generaltell me a solution...if u can Pin
VCSharp0078-May-05 19:32
VCSharp0078-May-05 19:32 
GeneralRe: tell me a solution...if u can Pin
Christian Graus8-May-05 19:35
protectorChristian Graus8-May-05 19:35 
GeneralRe: tell me a solution...if u can Pin
VCSharp0078-May-05 20:21
VCSharp0078-May-05 20:21 
GeneralRe: tell me a solution...if u can Pin
David Crow9-May-05 5:04
David Crow9-May-05 5:04 
GeneralRe: tell me a solution...if u can Pin
VCSharp0079-May-05 17:31
VCSharp0079-May-05 17:31 
GeneralRe: tell me a solution...if u can Pin
David Crow10-May-05 2:06
David Crow10-May-05 2:06 
GeneralRe: tell me a solution...if u can Pin
VCSharp00710-May-05 23:58
VCSharp00710-May-05 23:58 
GeneralRe: tell me a solution...if u can Pin
David Crow11-May-05 2:24
David Crow11-May-05 2:24 
Generalcheck a string if it is a number Pin
Anonymous8-May-05 19:27
Anonymous8-May-05 19:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.