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

C / C++ / MFC

 
Answer[OT] use PRE tags Pin
toxcct4-Dec-06 21:48
toxcct4-Dec-06 21:48 
GeneralRe: [OT] use PRE tags Pin
ThatsAlok4-Dec-06 22:57
ThatsAlok4-Dec-06 22:57 
GeneralRe: [OT] use PRE tags Pin
toxcct4-Dec-06 23:04
toxcct4-Dec-06 23:04 
GeneralRe: [OT] use PRE tags Pin
includeh105-Dec-06 7:48
includeh105-Dec-06 7:48 
AnswerRe: how to get RUNTIME_CLASS? Pin
jhwurmbach4-Dec-06 22:31
jhwurmbach4-Dec-06 22:31 
QuestionUsing Intel IPP libraries?? Pin
pavanbabut4-Dec-06 12:43
pavanbabut4-Dec-06 12:43 
AnswerRe: Using Intel IPP libraries?? Pin
uusheikh4-Dec-06 14:51
uusheikh4-Dec-06 14:51 
QuestionModal and Modeless Dialogs / Non-Working child dialog controls ... Pin
digitalmythology4-Dec-06 11:31
digitalmythology4-Dec-06 11:31 
Thanks in advance, fellow coders.

I am creating a dialog based app in MSVC++ 6.0.
[No I AM NOT switching to .NET, or should I say .NOT working, LoL).
Anyway, my dilema is this :
I have 1 main dialog, an AboutBox, and 7 child dialogs.
My functions / code for my child dialog buttons wil not work. The exact same code will work when tested in the main dialog or the AboutBox. The AboutBox is a default modal dialog generated by MFC using DoModal. I have now idea how DoModal works [code please?], but I am going for modeless, preferably anyway.

This is a snippet of code [from my main dialog's .cpp file], used to dispaly one of the modeless dialog boxes :

 void CInvenStoryDlg::OnButtonNewitem()
{
  // TODO: Add your control notification handler code here
CInvenStoryDlg *dlg = new CInvenStoryDlg (/*... construction args ... */);
dlg->Create(IDD_DIALOG_NEWITEM, this);
dlg->ShowWindow(SW_SHOW);
}


As you all can tell, I have one heck of a memory leak going here. I know I should use DetroyWindow() for modeless dialogs, as oppossed to EndDialog() for Modal ones, but where in the world do I actually PUT that code?
I assume in the code for the parent dialog, but I want to be sure.

This is a snippet of code [from one of my child dialog's .cpp file]. The code is supposed to be activated when a certain button is clicked. It should read some text from an EditBox into a CSTring, and then fwrite it to a .TXT file in binary mode.
[There is a reason that it is in binary mode instead of ASCII, but that is not relevant here.]
Anyway, here is the function :

void CDialogNewItem::OnButtonWriteNew() 
{
#include <stdio.h>
	
FILE *stream;
int b; // will hold the length of the CString m_newitemname
GetDlgItemText(IDC_EDIT_ITEMNAME, m_newitemname);
b = m_newitemname.GetLength();
      MessageBox(m_newitemname);
   // Attempt to open file for write in binary mode:
   // File will be NULLified (erased) if it exists,
   // or created if it does not yet exist ...
   
   if( (stream = fopen("filename.txt","wb")) != NULL )
   {
	  // If open was successful, then execute this code
      fwrite(m_newitemname,1,b,stream);
      fclose(stream);
   }
   
   else
	  // if error occurred, then execute this code instead ...
      MessageBox("File could not be opened\n");
}  


Yes, yes, I know header includes go up top; this was just for experimental purposes. All will be relocated properly upon final completion ... Wink | ;)
As I stated before, the [guts] of this function work fine when used in either the main dialog or on the AboutBox, but not in a child dialog. Is it my dialog box settings?
my dialog Create methods? What??!? I've tried everything.

Anyway, I'd like to see code for functional child dialogs, both Modal and Modeless versions, created and destroyed properly. Please speak in English, people, like a normal human, instead of all of that
micro$oft double-talk ala MSDN flavor :

Hwnd, *pArent, (LPCSTR): Be all you can be in the ARMY, COleInsertDialog::DoModal virtual int DoModal( ); int DoModal( DWORD dwFlags );


Whatever the ##@$% all that garble means. Give me actual code please, and no code for

CAboutDlg dlgAbout;
     dlgAbout.DoModal();


I have plenty, but I won't be able to understand it until someone shows me how it works for a custom Dilaog, say, like for mine named IDD_DIALOG_NEWITEM.

Anywho, thankees for all the help, and please, dumb it down a bit, use #includes where needed, and please, please, use comments. A download for a full VC6 project covering this material wouldn't hurt either. Appreciate it peoples ... Happy Codin' ...



-digitalmythology -dm

AnswerRe: Modal and Modeless Dialogs / Non-Working child dialog controls ... Pin
Christian Graus4-Dec-06 11:51
protectorChristian Graus4-Dec-06 11:51 
GeneralRe: Modal and Modeless Dialogs / Non-Working child dialog controls ... Pin
digitalmythology4-Dec-06 12:50
digitalmythology4-Dec-06 12:50 
GeneralRe: Modal and Modeless Dialogs / Non-Working child dialog controls ... Pin
Leah_Garrett4-Dec-06 13:34
Leah_Garrett4-Dec-06 13:34 
GeneralRe: Modal and Modeless Dialogs / Non-Working child dialog controls ... Pin
Christian Graus4-Dec-06 17:10
protectorChristian Graus4-Dec-06 17:10 
QuestionRe: Modal and Modeless Dialogs / Non-Working child dialog controls ... Pin
David Crow4-Dec-06 15:53
David Crow4-Dec-06 15:53 
AnswerRe: Modal and Modeless Dialogs / Non-Working child dialog controls ... Pin
digitalmythology4-Dec-06 16:14
digitalmythology4-Dec-06 16:14 
QuestionRe: Modal and Modeless Dialogs / Non-Working child dialog controls ... Pin
David Crow5-Dec-06 2:42
David Crow5-Dec-06 2:42 
QuestionChange bg color of editbox. Pin
acerunner3164-Dec-06 11:13
acerunner3164-Dec-06 11:13 
AnswerRe: Change bg color of editbox. Pin
Christian Graus4-Dec-06 11:55
protectorChristian Graus4-Dec-06 11:55 
GeneralRe: Change bg color of editbox. Pin
acerunner3164-Dec-06 12:09
acerunner3164-Dec-06 12:09 
AnswerRe: Change bg color of editbox. Pin
Mark Salsbery4-Dec-06 13:27
Mark Salsbery4-Dec-06 13:27 
GeneralRe: Change bg color of editbox. Pin
#realJSOP5-Dec-06 0:20
professional#realJSOP5-Dec-06 0:20 
GeneralRe: Change bg color of editbox. Pin
Mark Salsbery5-Dec-06 5:23
Mark Salsbery5-Dec-06 5:23 
AnswerHow to make all your edit controls "Christmasy" Pin
Mark Salsbery4-Dec-06 13:44
Mark Salsbery4-Dec-06 13:44 
GeneralRe: Change bg color of editbox. Pin
ThatsAlok4-Dec-06 22:39
ThatsAlok4-Dec-06 22:39 
GeneralRe: Change bg color of editbox. Pin
Mark Salsbery5-Dec-06 5:21
Mark Salsbery5-Dec-06 5:21 
AnswerRe: Change bg color of editbox. Pin
vikas amin4-Dec-06 23:41
vikas amin4-Dec-06 23:41 

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.