|
I've accomplished this in the past by creating a CStringArray variable in the page2, and filling that array while still on page1.
Maybe kinda bloated, but it worked.
Good Luck,
Frank
|
|
|
|
|
Your right, the data held in the dialogs that make up the wizard are no longer accessible. You should have a class that represents the wizard itself. This is the object whose DoModal method is executed. It is still accessible:
Here is a sample from a project I worked on last year. The first listing is the Wizard class itself. It is derived from CPropertySheet. The dialogs it presents are CPropertyPage derived objects. These are stored as member variables in the CWizard object.
Each of the property pages can access the CWizard class (as a parent window). While this one has no actual data stored in it, it could have. In this project, I have the individual property pages store data in project wide globals, so I didn't need to retrieve data from the Wizard itself.
#if !defined(AFX_WIZARD_H__14E36E7B_5840_11D4_BD9F_00B0D0209426__INCLUDED_)
#define AFX_WIZARD_H__14E36E7B_5840_11D4_BD9F_00B0D0209426__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "Welcomeppg.h"
#include "Detectionppg.h"
#include "ComponentSelectionPpg.h"
#include "ComponentInstallationPpg.h"
#include "installCompletePpg.h"
#include "verifyppg.h"
class CWizard : public CPropertySheet
{
DECLARE_DYNAMIC(CWizard)
public:
CWizard(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
CWizard(LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
public:
public:
CWelcomePpg m_ppgWelcome;
CDetectionPpg m_ppgDetection;
CComponentSelectionPpg m_ppgComponentSelection;
CComponentInstallationPpg m_ppgComponentInstallation;
CInstallCompletePpg m_ppgInstallComplete;
CVerifyPpg m_ppgVerify;
public:
virtual BOOL OnInitDialog();
virtual BOOL PreTranslateMessage(MSG* pMsg);
public:
virtual ~CWizard();
protected:
virtual void OnCancel();
DECLARE_MESSAGE_MAP()
};
#endif // !defined(AFX_WIZARD_H__14E36E7B_5840_11D4_BD9F_00B0D0209426__INCLUDED_)
|
|
|
|
|
Good idea!! I havent tried that yet, and it looks like it should work.
Thanks!
Rob
|
|
|
|
|
All of my wizard pages are derived from the CNewWizPage class so if I try to add a member variable ( Public: CItemDlg m_dItemDlg) inside of my CNewWizPage or CNewWizDialog class it errors... Maybe I should scrap the custom class and derive my own class from CPropertySheet instead.. This is the class I'm using "http://www.codeproject.com/dialog/wizard2000.asp" I dont know if you have tried it..
Just incase im doing something dumb here is what I did.. maybe I'm over looking something..
#if !defined(AFX_NEWWIZDIALOG_H__915D4C89_2E27_11D4_9FA9_0030DB0011C6__INCLUDED_)
#define AFX_NEWWIZDIALOG_H__915D4C89_2E27_11D4_9FA9_0030DB0011C6__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "ItemDlg.h"
class CNewWizPage;
class CNewWizDialog : public CDialog
{
public:
CNewWizDialog (LPCTSTR lpszTemplate, CWnd* pParent = NULL);
CNewWizDialog (UINT nIDTemplate, CWnd* pParent = NULL);
virtual ~CNewWizDialog ();
public:
protected:
CObList m_PageList;
UINT m_nPlaceholderID;
public:
CItemDlg m_dItemDlg;
void AddPage(CNewWizPage* pPage, UINT nID);
void SetActivePageByResource(UINT nResourceID);
BOOL SetFirstPage();
void SetNextPage();
void EnableFinish(BOOL bEnable);
void EnableBack(BOOL bEnable);
void EnableNext(BOOL bEnable);
int GetActiveIndex() const;
int GetPageIndex(CNewWizPage* pPage) const;
int GetPageCount();
CNewWizPage* GetPage(int nPage) const;
BOOL SetActivePage(int nPage);
BOOL SetActivePage(CNewWizPage* pPage);
void SetTitle(LPCTSTR lpszText);
void SetTitle(UINT nIDText);
void SetFinishText(LPCTSTR lpszText);
void SetFinishText(UINT nIDText);
protected:
BOOL ActivatePage(CNewWizPage* pPage);
BOOL DeactivatePage();
void SetPlaceholderID(int nPlaceholderID);
CNewWizPage* GetPageByResourceID(UINT nResourceID);
private:
void Init();
BOOL DestroyPage(CNewWizPage* pPage);
CNewWizPage* GetFirstPage();
CNewWizPage* GetLastPage();
CNewWizPage* GetActivePage() const;
CNewWizPage* GetNextPage();
protected:
virtual void DoDataExchange(CDataExchange* pDX);
virtual BOOL OnInitDialog();
protected:
afx_msg void OnDestroy();
afx_msg void OnWizardFinish();
afx_msg void OnWizardBack();
afx_msg void OnWizardNext();
afx_msg void OnCancel();
DECLARE_MESSAGE_MAP()
};
#endif // !defined(AFX_NEWWIZDIALOG_H__915D4C89_2E27_11D4_9FA9_0030DB0011C6__INCLUDED_)
Heres where it errors with an error of "e:\Wizard\itemdlg.h(22) : error C2065: 'IDD_ITEM' : undeclared identifier
e:\Wizard\itemdlg.h(22) : error C2057: expected constant expression"
class CItemDlg : public CNewWizPage
{
public:
CItemDlg(CWnd* pParent = NULL);
enum { IDD = IDD_ITEM }; <-- HERE
CString m_strPassword;
CString m_strVpassword;
CString m_strItem;
CString m_strName;
Any ideas?
Rob
|
|
|
|
|
I've not used this class (or 2wK wizards). so, I don't have any specific information for you. Just these general questions.
Where is IDD_ITEM defined? is it the resource id for your dialog? Make sure its defined in the context of ItemDlg.h.
|
|
|
|
|
It's the resource ID of my 1st page dialog of the wizard.. and its only defined in resource.h.. I just defined it in my ItemDlg.h and it seems to compile fine now..
Thanks for all your help man!!
Rob
|
|
|
|
|
Hi
is there any RAS event that is fired when a user just connected to or disconnected from the internet using the dial-up network?
thanks
|
|
|
|
|
Hello, the codegurus around the world.;)
Check the RAS notification message called WM_RASDIALEVENT,
and check WPARAM wParam to figure out which RAS event occures.
Good luck!
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
As some of you may be aware I have an owner drawn button class (CButtonSSL), which is capable of displaying a drop-down arrow and a menu.
I have recently discovered that if the parent window of the button loses focus then when focus is regained the check state of the menu items is lost, i.e. none of the menu items are checked any more
For those of you without the source code the class stores a CMenu member variable, m_menu . In the call to SetSSLButtonMenu the menu is initialised with a call to m_menu.LoadMenu passing in the resource ID of the menu. The menu item check states are altered in the call to CheckSSLMenuItem which calls m_menu.CheckMenuItem () passing in the menu ID and the check state.
In the OnLButtonDown event handler the popup menu is shown as follows:
CMenu* pMenu = m_menu.GetSubMenu (0);
pMenu->TrackPopupMenu (TPM_RIGHTALIGN | TPM_LEFTBUTTON, x, y, GetParent ());
I have scoured the MSDN and other such resources and get work out why the menu would be losing it's check states. Any suggestions?
Derek Lakin.
Salamander Software Ltd.
|
|
|
|
|
Hi all, I have got a little lost with regards to pointers. I think its quite simple (if you know the answer), basically I have some code like :
void NewPointer()
{
if (m_pPointer == NULL)
{
m_pPointer = new(MyCPointClass)
if (m_pPointer->NewPoint)
return;
else
delete(m_pPointer);
}
}
However, the pointer is deleted in this function, and then its deleted elsewhere in my program through a destructor (which is called when i exit the app). If the BOOL function NewPoint returns TRUE every time then everything is OK (my app doesn`t try to delete the same pointer twice). HOWEVER, it does if it returns FALSE. Basically I need to know if a memory leak would occur if I inserted :
m_pPointer = NULL;
instead of actually deleting it in the function? What actually happens to the memory allocated by new in this case? The reason I ask is because, although my program WOULD expel any memory leaks upon exiting the program, I don`t want them building up whilst I am running the damn thing, because in the end I could run out of memory. So, basically, what I need to know is, if I make the m_pPointer = NULL, will a memory leak occur, and why/why not? Thanks again guys for your intuition,
Cheers,
Alan.
"When I left you I was but the learner, now I am the Master" - Darth Vader
|
|
|
|
|
What you have new'd you must delete
What you have new'd you must delete
What you have new'd you must delete
If you then make it null that's a good programming practice.
but if you make it null without deleting it then you simply create a memory leak.
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
Nish is a BIG fan of Goran Ivanisevic
|
|
|
|
|
Nish answered your question, but here's a little debugging tip:
When doing comparisons, put the constant value on the LHS of the comparison operator:
if (NULL == m_pPointer)
If you happen to accidentally leave off one of the equal signs (i.e., NULL = m_pPointer), your code won't compile because you can't assign a value to a literal.
This has saved me lots of debugging headaches.
Jon Sagara
"We assume you already know not to consider something like Windows as a firewall platform. Does the name "Windows" evoke images of security? Silly rabbit, Windows is for desktops." -- Unix System Administration Handbook
|
|
|
|
|
Jon Sagara wrote:
When doing comparisons, put the constant value on the LHS of the comparison operator:
Quote/Unquote 'Debugging Windows Application' Microsoft Press
Regards
Ray
"Je Suis Mort De Rire"
|
|
|
|
|
Yep, it's in there, too.
Jon Sagara
"We assume you already know not to consider something like Windows as a firewall platform. Does the name "Windows" evoke images of security? Silly rabbit, Windows is for desktops." -- Unix System Administration Handbook
|
|
|
|
|
Jon Sagara wrote:
When doing comparisons, put the constant value on the LHS of the comparison operator:
if (NULL == m_pPointer)
If you happen to accidentally leave off one of the equal signs (i.e., NULL = m_pPointer), your code won't compile because you can't assign a value to a literal.
Here's a better tip:
Write it in the readable fashion, as you did, eg:
if (m_pointer == NULL)
and then use the following pragma to prevent assignments in the body of an if statement:
#pragma warning(error : 4706) // Assignment in conditional
This keeps your code readable and safe at the same time. And while the pragma is not portable, the resulting safe, readable code is.
|
|
|
|
|
Jim A. Johnson wrote:
if (NULL == m_pPointer)
I didn't realize that this was non-portable. It has worked for me using VC6 and the GNU compilers.
Also, what is so difficult to read? I actually prefer this method because I know right away what the value of the variable is supposed to be.
Jon Sagara
"We assume you already know not to consider something like Windows as a firewall platform. Does the name "Windows" evoke images of security? Silly rabbit, Windows is for desktops." -- Unix System Administration Handbook
|
|
|
|
|
He meant the #pragma that disallows assignments in if conditions is non-portable.
--Mike--
http://home.inreach.com/mdunn/
#include "witty_sig.h"
your with and
|
|
|
|
|
Context - The Mother of all Flame Wars.
Thanks for the note Michael,
Jon Sagara
"We assume you already know not to consider something like Windows as a firewall platform. Does the name "Windows" evoke images of security? Silly rabbit, Windows is for desktops." -- Unix System Administration Handbook
|
|
|
|
|
Jon Sagara wrote:
I didn't realize that this was non-portable. It has worked for me using VC6 and the GNU compilers
That's not what I said. Read it again, please.
|
|
|
|
|
This keeps your code readable and safe at the same time. And while the pragma is not portable, the resulting safe, readable code is.
Misunderstanding. My bad. Please forgive me this one transgression.
Just out of curiosity, why don't you consider if (NULL == m_pPointer) readable? I admit it looked strange to me at first, but it's such a simple coding trick that you can use to save debugging time without having to remember some obscure pragma directive.
Jon Sagara
"We assume you already know not to consider something like Windows as a firewall platform. Does the name "Windows" evoke images of security? Silly rabbit, Windows is for desktops." -- Unix System Administration Handbook
|
|
|
|
|
Yeah, I agree. It is all about just getting use to it.
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
Why not use:
if (!m_pPointer)
instead of
if (NULL == m_pPointer)
|
|
|
|
|
Because the second is instantly readable, whereas with the first one you have to remember that "!pointer" means "pointer is not zero".
--Mike--
http://home.inreach.com/mdunn/
#include "witty_sig.h"
your with and
|
|
|
|
|
I agree with Mike, but I would make it
if (m_pPointer == NULL)
instead.
It just looks better to me because it flows more like the way you speak the same phrase. I've never heard anyone say "If NULL is the pointer...", but instead, people say "If the pointer is NULL...".
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
void NewPointer()
{
if (m_pPointer == NULL)
{
m_pPointer = new(MyCPointClass);
if (NULL != pPointer && m_pPointer->NewPoint()) // NewPoint is a function, right?
{
return;
}
else
{
delete(m_pPointer);
m_pPointer = NULL; // avoid deleting the memory twice! deleting a NULL pointer is safe, but has a performance penalty since a call to the C-runtime library is done.
}
}
}
void DeletePointer()
{
if (NULL != m_pPointer)
{
delete m_pPointer;
m_pPointer = NULL;
}
}
if you insert
m_pPointer = NULL
somewhere in your code between NewPointer() and DeletePointer(), then yes you have a memory leak.
--------------------------------------------------
If my messages appear curt, I apologize.
I try to be brief to save your time as well as mine.
--------------------------------------------------
|
|
|
|