Dialog and asserts

Hi,
	I have a dialog based application and I want to open another
dialog. I have a function 

int CMyDialog::Execute
{ // CMyDialog::Execute
	int ret_code;
	CNewDialog m_NewDialog(this);

	ret_code = m_NewDialog.DoModal();

	return ret_code;
} // CMyDialog::Execute

that opens this dialog but this fail :(
I got at assert on this line

BOOL CWnd::Attach(HWND hWndNew)
{
--->	ASSERT(m_hWnd == NULL);     // only attach once, detach on 

I have realized my application with the Wizard so I am not
very expert about this stuff.
Can someone tell me what's happening ?


       Stefano Malavasi
__________________________________________________________________________________________
Email:		s_malavasi_REMOVE_@_REMOVE_lycos.it
Note: 		Remove _REMOVE_ string to reply


0
Stefano
12/2/2003 7:40:12 PM
vc.mfc 33608 articles. 0 followers. Follow

8 Replies
508 Views

Similar Articles

[PageSpeed] 2

hi,
   I havenot tried this, but try creating your new dialog with
      CNewDialog m_NewDialog(NULL);
hth
gangadhar npk
Stefano Malavasi wrote:
> Hi,
> 	I have a dialog based application and I want to open another
> dialog. I have a function 
> 
> int CMyDialog::Execute
> { // CMyDialog::Execute
> 	int ret_code;
> 	CNewDialog m_NewDialog(this);
> 
> 	ret_code = m_NewDialog.DoModal();
> 
> 	return ret_code;
> } // CMyDialog::Execute
> 
> that opens this dialog but this fail :(
> I got at assert on this line
> 
> BOOL CWnd::Attach(HWND hWndNew)
> {
> --->	ASSERT(m_hWnd == NULL);     // only attach once, detach on 
> 
> I have realized my application with the Wizard so I am not
> very expert about this stuff.
> Can someone tell me what's happening ?
> 
> 
>        Stefano Malavasi
> __________________________________________________________________________________________
> Email:		s_malavasi_REMOVE_@_REMOVE_lycos.it
> Note: 		Remove _REMOVE_ string to reply
> 
> 


0
12/3/2003 5:04:30 AM
On Wed, 03 Dec 2003 10:34:30 +0530, gangadhar npk
<npkatgoogle@rediffmail.com> wrote:

>hi,
>   I havenot tried this, but try creating your new dialog with
>      CNewDialog m_NewDialog(NULL);

No it doesn't work :(

0
Stefano
12/3/2003 9:34:12 AM
I don't see any errors in the code posted. The error must be in the
CNewDialog class, i suspect the constructor or the OnInitDialog() function.
Do you call Create() or something like that inside your CNewDialog class?
If the CNewDialog class is not too big, which I expect it isn't, maybe you
could post that code.

-- 
Bjarne Nielsen

"Stefano Malavasi" <s_malavasi_REMOVE_@_REMOVE_lycos.it> skrev i en
meddelelse news:c9brsv0dv59nt4tcm6erbqp18l1fpsllca@4ax.com...
> On Wed, 03 Dec 2003 10:34:30 +0530, gangadhar npk
> <npkatgoogle@rediffmail.com> wrote:
>
> >hi,
> >   I havenot tried this, but try creating your new dialog with
> >      CNewDialog m_NewDialog(NULL);
>
> No it doesn't work :(
>


0
12/3/2003 10:25:40 AM
On Wed, 3 Dec 2003 11:25:40 +0100, "Bjarne Nielsen"
<bnielsenIH8spam@post11.tele.dk> wrote:

>I don't see any errors in the code posted. The error must be in the
>CNewDialog class, i suspect the constructor or the OnInitDialog() function.
>Do you call Create() or something like that inside your CNewDialog class?
>If the CNewDialog class is not too big, which I expect it isn't, maybe you
>could post that code.

Thanks for you answer. I found the errore. I have subclassed 2 times
the same control and that was my fault. Now I have another problem.
When the variable of the class is deleted I got this error

DAMAGE after client block (NNNN) at YYYYY

After a research I foud out that this is error maybe a problem with
the memory allocated by the class.
So I commented all the source code in OnInitDialog, in the class
costructor and in the DDX. But I still get this error.
Where should I look to find out the error ?

       Stefano Malavasi
__________________________________________________________________________________________
Email:		s_malavasi_REMOVE_@_REMOVE_lycos.it
Note: 		Remove _REMOVE_ string to reply


0
Stefano
12/3/2003 2:42:51 PM
I don't think it's the amount of memory your class is using, if that's what
you're worried about.
You are probably overwriting some data. Make sure, that when you compile,
you don't get any type conversion warnings, and if you have type casts, that
you are absolutely sure they are valid.
Also check, that if you are writing to an array, that you don't write past
the end. Pointers are also very dangerous, especially if you are not used to
handle them. Normally when you get a "damaged block" error, you can see
which variable(s) is damaged, and that is likely to give you a hint.

-- 
Bjarne Nielsen

"Stefano Malavasi" <s_malavasi_REMOVE_@_REMOVE_lycos.it> skrev i en
meddelelse news:n8trsv0t6gnmsdk1h0i63ssc3tfai0n3do@4ax.com...
> On Wed, 3 Dec 2003 11:25:40 +0100, "Bjarne Nielsen"
> <bnielsenIH8spam@post11.tele.dk> wrote:
>
> >I don't see any errors in the code posted. The error must be in the
> >CNewDialog class, i suspect the constructor or the OnInitDialog()
function.
> >Do you call Create() or something like that inside your CNewDialog class?
> >If the CNewDialog class is not too big, which I expect it isn't, maybe
you
> >could post that code.
>
> Thanks for you answer. I found the errore. I have subclassed 2 times
> the same control and that was my fault. Now I have another problem.
> When the variable of the class is deleted I got this error
>
> DAMAGE after client block (NNNN) at YYYYY
>
> After a research I foud out that this is error maybe a problem with
> the memory allocated by the class.
> So I commented all the source code in OnInitDialog, in the class
> costructor and in the DDX. But I still get this error.
> Where should I look to find out the error ?
>
>        Stefano Malavasi
>
____________________________________________________________________________
______________
> Email: s_malavasi_REMOVE_@_REMOVE_lycos.it
> Note: Remove _REMOVE_ string to reply
>
>


0
12/3/2003 3:32:34 PM
On Wed, 3 Dec 2003 16:32:34 +0100, "Bjarne Nielsen"
<bnielsenIH8spam@post11.tele.dk> wrote:

>You are probably overwriting some data. Make sure, that when you compile,
>you don't get any type conversion warnings, and if you have type casts, that
>you are absolutely sure they are valid.
>Also check, that if you are writing to an array, that you don't write past
>the end. Pointers are also very dangerous, especially if you are not used to
>handle them. 

But I don't have any code ... well only the class declaration because
I commented every piece of code that is executed when I open the
dialog.

>Normally when you get a "damaged block" error, you can see
>which variable(s) is damaged, and that is likely to give you a hint.

I get only an error like this

DAMAGE after client block (NNNN) at YYYYY

how can I see the variable ?

       Stefano Malavasi
__________________________________________________________________________________________
Email:		s_malavasi_REMOVE_@_REMOVE_lycos.it
Note: 		Remove _REMOVE_ string to reply



0
Stefano
12/3/2003 3:56:48 PM
Stefano Malavasi wrote:
> 
> 
> I get only an error like this
> 
> DAMAGE after client block (NNNN) at YYYYY
> 
> how can I see the variable ?
> 

Use the debugger to find out what variable is allocated at address NNNN. 
  The error will happen if NNNN is an array and you write beyond the 
bounds of the array.

-- 
Scott McPhillips [VC++ MVP]

0
scottmcp1 (239)
12/4/2003 1:12:09 AM
On Wed, 03 Dec 2003 20:12:09 -0500, "Scott McPhillips [MVP]"
<scottmcp@mvps.org.nowhere> wrote:


>Use the debugger to find out what variable is allocated at address NNNN. 
>The error will happen if NNNN is an array and you write beyond the 
>bounds of the array.

Thanks for your answer. The code is something like

	Dialog2 = new CDialog2;
	Dialog2->DoModal();
	delete Dialog2;	<--- Error

So Dialog2 is gone out of scope when I got the error. So I have to put
a watch for every variable of the class and note their address ... or
is there a more efficient way to find out wchich variable is allocated
at address NNNN ?

0
Stefano
12/4/2003 11:55:03 AM
Reply:

Similar Artilces:

Dialogs
Hi Is there any arguments to I can add to the statement below for the dialogue's "Look in:" to default to a specific folder? Application.Dialogs(xlDialogOpen).Show Thanks. >-----Original Message----- >Hi > >Is there any arguments to I can add to the statement >below for the dialogue's "Look in:" to default to a >specific folder? > >Application.Dialogs(xlDialogOpen).Show > > >Thanks. >. > You can try FileFilter = FileFilter + "Look in: name of directory,," ...

Links in Outlook 2003 open Save As... dialog box
I'm not sure exactly when this started happening. Whenever I click a link in Outlook 2003 now, it opens the Save As... dialog box as well as the Website connected to the link. It doesn't matter what type of link it is; the dialog always shows up with the .exe file type selected. Any ideas? Does it oen the Save As dialog or does it open the Locate Link Browser dialog? In case of the last direct it to iexplore.exe -- Robert Sparnaaij [MVP-Outlook] www.howto-outlook.com Tips of the month: -Backup and Restore -Create an Office XP CD slipstreamed with Service Pack 3 ----- "S...

How to Move Two Dialogs at Once
Hello, One of my work's project specifications is to allow users to move two Dialog boxes together so when a user moves one box, the other one moves together with the first. This is what I am trying to do: 1) Create OnMove() event //Import a function to create a Second Dialog extern "C" __declspec(dllimport) long CallDlg(); //Import a function to move a Second Dialog extern "C" __declspec(dllimport) long CallDlg2(int x, int y); void CSvg::OnMove(int x, int y) { //Detect if a user selected two-dialogs move option if (m_attach) { ...

Dialog form Linked To Report
I have created a dialog form, on this form I select the company name from the dropdown list. when a company name is selected, then the report should be generated. presently I have a button on the form when i click on it the macro is set to propt the dialog where i have to type the name of the company, if the company name is wrong the report opens with no values, if the company name is right then I get the report. whereas what i want is insted of button I should have the List Box with company names. Which I have created. But am stuck linking this form with the report Name &q...

Dialog on Dialog?
Hello, Following up from a request several days ago regarding frames, I would like to ask for a little assistance on actually implimenting it! I have creating my 2 dialog templates, both have a class associated with them already. I have added an object of the kind i wish to make child of the main dialog, but I can not figure out how to go from here with rgeards to actually creating it. Could someone give me some indication pleasE? - MR MR, You will now want to investigate creating modeless dialogs. CDialog::Create is the call you use for this. Add a member variable of one of the s...

Modal dialog box question
Hi, I've created a dialog called InfoWindow. Previously I had called it like so: c_InfoWindow = new InfoWindow(); c_InfoWindow->Create(InfoWindow::IDD, this); c_InfoWindow->SetWindowPos(NULL, r, t, w, h, SWP_NOZORDER); c_InfoWindow->ShowWindow(SW_SHOW); Now I want to create it as a Modal dialog, but I can't work out how to set it's size / position at runtime. InfoWindow IW(); // somehow set properties here (SetWindowPos gives runtime error) IW.DoModal(); Hi, Could you try to pass some variables to InfoWindow before calling its DoModal()? For example: MyDlg dlg; ...

How to show icon for a dialog.
Hi, I am adding a simple dialog to my aplication. This dialog is not having any customized code..I want to add my custom icon for that dialog. i mean whenever the dialog is shown it should display 16 X 16 icon in the titlebar.. so, how to do that ? Jigar In OnInitDialog method of your dialog box class load the icon using ::LoadIcon(..) and the call the dialog box's SetIcon(..) method. AliR. "Jigar Mehta" <jigar.programmer@gmail.com> wrote in message news:1141156992.695173.29930@v46g2000cwv.googlegroups.com... > Hi, > > I am adding a simple dialog to my aplic...

Outlook '02 Network Password Dialog box
Help! I have recently added 1 additional email account to my outlook. Now everytime the email checks for messages I get a dialog box with "Enter Network Password". It comes up in the middle of the screen no matter what I am doing. I have clicked on "Save this password in your password list" box but it continues to come up everytime. Is there a way to get rid of this box? Thank you. Kris ...

Dynamic creation of owner-drawn button inside a dialog
Hi some months ago I created a owner-drawn button class that works really fine when assigning this class to a resource id via a DDX member variable. But now we want to reuse this class for dynamic creation of a button control inside the OnInitDialog member funtion of a dialog. Creating the control like that MyButton.CreateNULL,NULL,WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_OWNERDRAW,CRec t(0,0,100,100),this,2); seems to be OK. But the button never appeared inside the dialog. DrawItem of the button class is never called. So what may be missing? Thanks in advance Bernd How have you declared My...

Common dialog not registered
When trying to load the common dialog tool I get the message 'not registered' why is this and how do I register? Hi, As the message says that control isn't licensed for use in Excel except 'as I understand' in the Developer edition. I believe this performs a similar function fname = Application.GetOpenfileName(.... Mike "Cash" wrote: > When trying to load the common dialog tool I get the message 'not registered' > why is this and how do I register? ...

how to pass a value to a modeless dialog?
hi all.. i have created a modeless dialog i had no compiler errors. i want it to take a global value (buffer) from the parent dialog and do some processing to it. i tried putting the processing code i need immediately after i create & show the modeless dialog.but it didn`t work.i also tried to override the constructor for modeless dialog & make it take a pointer to the parent dialog as a parameter& reach the buffer i want but it didn`t work also.what`s the problem?? There are a couple of things you can do. First let me ask you. if the data is global why do you have to pass anyth...

MFC Dialog app "Including" another MFC Dialog app problems.
WIN XP, VC6 I'm trying to use a CDialog based app from another CDialog based app and can't get around the following error: bla,bla\..\WagCom\DlgThreadmill.h(27) : error C2065: 'IDD_THREADMILL' : undeclared identifier IDD_THREADMILL is obviosly resource in the "Included" app. I don't know how to make that resource visible to the calling app. I have the Include statement in the calling object : #include "..\WagCom\DlgThreadmill.h" and I know that the path is correct.. Any help appreciated. Thanks Is the ID in the using applications resource.h...

modeless dialog boxes #2
I have a VS 6.0 MFC dialog-based application. The main dialog has an edit box for displaying messages as things happen. A button on the main dialog starts a modeless dialog. The modeless dialog has a 'DoIt' button which executes a long process, updating the main dialog edit box. I'm finding that the main dialog and modeless dialog are unresponsive as long as I'm in the 'OnDoIt' routine. I had thought that a modeless dialog box would essentially run 'independent' of the main dialog but that doesn't seem to be the case. What have I misunderstood? ...

How to hide the dialog in a dialog based application..
Hi, I have a dialog based application which has MFC support.. (developed from class wizard...) Now, according to the my database situation, i want to show / hide the dialog.. so, what should i do ? What i do currently is, inside, oninit i start a thread and pass a dialog pointer.. now, after 500 ms of initialization, i will call ShowWindow(SW_HIDE) to hide the dialog.. and to work in invisible mode.. but this is not a good way.. so, any other way to hide the dialog before it gets shown.. ?? My exe should run in processes but it should not show the dialog only.. Hope you understand my...

Dialog::OnOK....
I want my dialog box to show a messagebox when I click "ok". With certain conditions I want my dialog box to return to it's original state and not close which nomally happens after clicking "ok" Is there an easy way to do this or do I need to create a command button? Thanks, RABMissouri Override the virtual function OnOK. If you don't call CDialog::OnOK then the dialog box does not close. void CMyDlg::OnOK() { if (MessageBox("Are you sure?","Exit",ID_YESNO) == IDYES) { CDialog::OnOK(); } } You can do the same thi...

Howto: Place icon in a Wizard dialog?
Being new to MFC, I was happy to read how the SetWizardMode() call of a CPropertySheet could reprecent a Wizard dialog automatically. I have one major problem with this build-in shortcut for creating wizards and that has to do with the icon - or lack there of - in the application. Apparently CPropertySheet is a specialization of CDialog WITHOUT the possebility of setting style for including an icon in the caption area. I tried: <CPropertySheet>.SetIcon(LoadIcon(IDR_MAINFRAME),FALSE); And many other things but neither yields an icon. I am quessing it is simply impossible to have...

How to display a dialog as part of a dialog
Hello, i have two dialog-resources in my project IDD_DIALOG1 and IDD_DIALOG2 and i want to be the second a "real" part of my first one. I don't want to show it modal or modeless, the user should not recognize that this are two dialogs. How can i do this or where can i get a simple example? Thx. This must be the third time we have had this question in the past week. The short answer to your question is : Declare the second dialog in your dialog editor as a Child not a popup. And then in the OnInitDialog of the first dialog create the second dialog like you would a modless (...

Debug assertion
I'm getting a debug assertion on a standard, unmodified MFC AppWizard app, in CMyApp::InitInstance(), at pFrame->ShowWindow(). The m_hWnd is NULL. Why is this? "Brian Toothill" <.> wrote in message news:%23zGbHsIcDHA.1540@tk2msftngp13.phx.gbl... > I'm getting a debug assertion on a standard, unmodified MFC AppWizard app, > in CMyApp::InitInstance(), at pFrame->ShowWindow(). The m_hWnd is NULL. > > Why is this? One possibility is that your Frame window is failing to create. -- Jeff Partch [VC++ MVP] ...

Handling mouse messages for a ListBox in a dialog created in the editor
I created a dialog in MSVC resource editor and placed a listbox in there for which I need to handle certain mouse messages (WM_LBUTTONDOWN) to get the cursor position when the button was clicked. I can't solve this by inheriting my own class from CListBox because the dialog is created in the resource editor? TIA. Sure you can; I do it all the time. Twice, this morning. Just create your subclass, and the use the classWizard to create a control member variable. Done. Take a look at my essay on Avoiding GetDlgItem for more details. joe On Thu, 06 Nov 2003 17:20:21 GMT, Daar <user@is...

File name list in the open dialog box.
In the open dialog box, how to delete the list of files appearing in the file name drag down menu in excel 2007? Not sure where you are finding this list. Do you mean the Recent Documents you see when you click on the Button? You can clear that by setting your MRU list to 0 under Button>Excel Options>Advanced>Display. If you mean the list you see when you go to Button>Open then you will have to set a new default file path to a folder that is empty. Gord Dibben MS Excel MVP On Thu, 4 Mar 2010 09:10:01 -0800, Acs <Acs@discussions.microsoft.com> wrote: ...

Pinning dialog on top of other dialogs
I have an MFC app[1] that is essentially a dialog app controlled by a process control layer. The control layer is responsible for hiding and showing the various dialogs. All of these dialogs are modeless dialogs created when the app starts (for speed reasons), then hidden, like so: pFrame->Log(_T("Symbol Bar loading")); m_pDlgSymbolBar->Create(IDD_SYMBOL_BAR, NULL); OnInitDialog: ShowWindow(SW_HIDE); When it's time for a dialog to appear, it is sent a message along with any new data. The dialog updates itself and calls its parent class to make it visible. It...

Transparent bitmap in dialog box
Hi! I want to display a bitmap in a dialog box. I use the resource editor to specify the bitmap. How can I make the bitmap transparent? For example; all white areas should have the same color as the dialog window. Regards /Anders I remember seeing examples on how to do this but for the life of me I now cannot find them! Try looking at: www.codeproject.com www.codeguru.com Larry "Anders W�hlin" <anders.wahlin@erv.ericsson.se> wrote in message news:bi2div$25b$1@newstree.wise.edt.ericsson.se... > Hi! > > I want to display a bitmap in a dialog box. I use the resou...

Dialog based application and generated OnPaint for the dialog class
Hello, I'm using MSVC++ 8.0 SP1 and I created a dialog based MFC application using the application wizard. In my CDialog-derived class, MyDialog, the appwizard generated the following OnPaint() for me: // If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework. void MyDialog::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc....

Open Dialog has changed
Hello When I click open the file listing has changed... For instance If I sort by filename the files are sorted but there is a line that says "A" then all the A files, a "B" then all the B Files etc. This is happening in all office applications but not in windows explorer. Has anyone seen this before and how to I retore it? Operating System has a lot to do with what Views are available, but if you select View in the dialog box you should have your choice there. Thanks wrote: > Hello > When I click open the file listing has changed... > For ins...

Log on dialog box
I don't need the log on box, but can't find out how to deactivate it. Can you help - please? Hi, ninner. "ninner" <ninner@discussions.microsoft.com> wrote in message news:6697A114-6951-4F86-A8D5-9B3B8467AA6D@microsoft.com... > I don't need the log on box, but can't find out how to deactivate it. Can > you > help - please? At an Administrator Command Prompt, enter: control userpasswords2 In the next window, clear the box that says, "Users must enter a user name and password to use this computer." RC -- R. C. White, C...