Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 4th, 2005, 2:45 PM   #11
Nellie
Programmer
 
Nellie's Avatar
 
Join Date: Jun 2005
Location: Kent (old) England
Posts: 34
Rep Power: 0 Nellie is on a distinguished road
I wanted to make a dialog open when the app started a loop, and close it when the loop completes. (like the example at the top of this thread).

I have checked the web, but most just confuse me even more.
__________________
I use MSVC6.0, on XP Pro

Happy Programming :D

http://www.danasoft.com/sig/NelliesSig.jpg
Nellie is offline   Reply With Quote
Old Jun 4th, 2005, 5:59 PM   #12
kirkl_uk
Programmer
 
kirkl_uk's Avatar
 
Join Date: Apr 2005
Location: England
Posts: 86
Rep Power: 4 kirkl_uk is on a distinguished road
Send a message via MSN to kirkl_uk
I've just dug out the assignment I mentioned above. It contains a modeless dialog using MFC, as this was one of the assessment areas for the assignment.

There are a few things you need to do for the modeless dialog, that I can show you here:

First, you need a class for the dialog itself, which contains:

1. A pointer to its parent. (For example, a view.)
I did this by adding a CView* to the dialog's constructor.
2. A Create() override method, to create the actual dialog, as follows:

BOOL CModelessDlg::Create()
{
	// Create the dialog.
	return CDialog::Create(CModelessDlg::IDD, m_pParent);
	// Where m_pParent is the CView* passed to the constructor.
}

3. A PostNcDestroy() override method, as follows:

void CModelessDialog::PostNcDestroy() 
{
	// Delete the dialog.
	delete this;
	
	CDialog::PostNcDestroy();
}

4. An OnClose() override.

void CModelessDlg::OnClose() 
{
	// Set the parent's dialog pointer to NULL.
	((CWhatever*)m_pParent)->m_pModelessDlg = NULL;
	// Destroy the window.
	DestroyWindow();	
}

Then, in your parent class, you will need:

1. A pointer to the dialog, such as:

CModelessDialog* m_pModelessDlg;

2. A function for creating, or "switching to" the modeless dialog:

void CWhatever::OnShowModelessDlg() 
{
	if(!m_pModelessDlg)
	{
		// Create the dialog.
		m_pModelessDlg = new CModelessDlg(this);
		m_pModelessDlg->Create();
	}
	else
		// Set the dialog active.
		m_pModelessDlg->SetActiveWindow();	
}

I hope that helps, but I know it's hard to understand if you are new to MFC. I'll try and answer any questions that you may have.

kirkl_uk

PS: Sorry this is such a long post. Give those scrolling muscles some action tho eh!?

Last edited by kirkl_uk; Jun 4th, 2005 at 6:02 PM.
kirkl_uk is offline   Reply With Quote
Old Jun 5th, 2005, 5:22 AM   #13
Nellie
Programmer
 
Nellie's Avatar
 
Join Date: Jun 2005
Location: Kent (old) England
Posts: 34
Rep Power: 0 Nellie is on a distinguished road
I make a new class when i put the dialog in, the class manager (or whatever its called?) comes up and asks if i want to make a new class for it.

How exactly do i make a pointer?
(i have herd about them, but never (knowingly :o ) used one.)
is the CView* the pointer?

The only bit that i can read through in my mind without thinking 'what the...' is the last bit of code (except the '->')
if(!m_pModelessDlg)
	{
		// Create the dialog.
		m_pModelessDlg = new CModelessDlg(this);
		m_pModelessDlg->Create();
	}
	else
		// Set the dialog active.
		m_pModelessDlg->SetActiveWindow();

thanks
__________________
I use MSVC6.0, on XP Pro

Happy Programming :D

http://www.danasoft.com/sig/NelliesSig.jpg

Last edited by Nellie; Jun 5th, 2005 at 5:26 AM.
Nellie is offline   Reply With Quote
Old Jun 5th, 2005, 5:56 AM   #14
kirkl_uk
Programmer
 
kirkl_uk's Avatar
 
Join Date: Apr 2005
Location: England
Posts: 86
Rep Power: 4 kirkl_uk is on a distinguished road
Send a message via MSN to kirkl_uk
Is this part of an assignment, or something you are doing for yourself? If it's not an assignment, I reccommend you go through standard C++ first to learn about things such as pointers.

kirkl_uk
kirkl_uk is offline   Reply With Quote
Old Jun 5th, 2005, 9:29 AM   #15
iignotus
Professional Programmer
 
iignotus's Avatar
 
Join Date: Apr 2005
Location: Nowhere Special
Posts: 466
Rep Power: 4 iignotus is on a distinguished road
Send a message via AIM to iignotus
Quote:
Originally Posted by uman
Nellie: your sig should say "members who consisted of a large portion..." you're using "whom" incorrectly.

Just wanted to let you know.
Well, if you want to be pedantic, he's improperly using that second comma as well as 'consisted'. But, pedanticism never got anyone anywhere
__________________
% rc4 hexkey < input > output
#define S ,t=s[i],s[i]=s[j],s[j]=t /* rc4 hexkey <file */
unsigned char k[256],s[256],i,j,t;main(c,v,e)char**v;{++v;while(++i)s[ 
i]=i;for(c=0;*(*v)++;k[c++]=e)sscanf((*v)++-1,"%2x",&e);while(j+=s[i]
+k[i%c]S,++i);for(j=0;c=~getchar();putchar(~c^s[t+=s[i]]))j+=s[++i]S;}
iignotus is offline   Reply With Quote
Old Jun 5th, 2005, 11:48 AM   #16
Nellie
Programmer
 
Nellie's Avatar
 
Join Date: Jun 2005
Location: Kent (old) England
Posts: 34
Rep Power: 0 Nellie is on a distinguished road
its not part of an assignment, i do all this for my own learning.

i have a basic understanding of cpp, but having never had to use pointers, never lernt about them, or how to implement. (although i probably have used them, but in an example code i found).

(is this thread about modeless CDialog's or my sig?)
__________________
I use MSVC6.0, on XP Pro

Happy Programming :D

http://www.danasoft.com/sig/NelliesSig.jpg
Nellie is offline   Reply With Quote
Old Jun 5th, 2005, 1:13 PM   #17
kirkl_uk
Programmer
 
kirkl_uk's Avatar
 
Join Date: Apr 2005
Location: England
Posts: 86
Rep Power: 4 kirkl_uk is on a distinguished road
Send a message via MSN to kirkl_uk
Here's an introduction to pointers:

http://www.cprogramming.com/tutorial/lesson6.html

kirkl_uk
kirkl_uk is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:56 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC