![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Programmer
Join Date: Jun 2005
Location: Kent (old) England
Posts: 34
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#12 |
|
Programmer
|
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. |
|
|
|
|
|
#13 |
|
Programmer
Join Date: Jun 2005
Location: Kent (old) England
Posts: 34
Rep Power: 0
![]() |
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. |
|
|
|
|
|
#14 |
|
Programmer
|
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 |
|
|
|
|
|
#15 | |
|
Professional Programmer
|
Quote:
![]()
__________________
% 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;} |
|
|
|
|
|
|
#16 |
|
Programmer
Join Date: Jun 2005
Location: Kent (old) England
Posts: 34
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#17 |
|
Programmer
|
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|