|
I think this is not unique error message from my compiler but can some one tell me what is wrong when a message like this appears!?? HEEEELP!!
Compiling...
ReminderSEDlg.cpp
C:\Program\Microsoft Visual Studio\MyProjects\Reminder Special Edition\ReminderSEDlg.cpp(22) : error C2370: 'THIS_FILE' : redefinition; different storage class
c:\program\microsoft visual studio\myprojects\reminder special edition\configdlg.cpp(12) : see declaration of 'THIS_FILE'
Error executing cl.exe.
Reminder Special Edition.exe - 1 error(s), 0 warning(s)
------------------------------
CodeCracker - That's me!
------------------------------
|
|
|
|
|
It means the compiler has already found a definition fo THIS_FILE. Either it is defined in more than one place or you need to ifdef it out...
x.h
#ifndef x.h
// This will only be compiled once no matter how many times it is referenced.
#define x.h
#define THIS_FILE something
#endif
Thanks for the help,
Bill
|
|
|
|
|
It means the compiler has already found a definition fo THIS_FILE. Either it is defined in more than one place or you need to ifdef it out...
x.h
#ifndef x.h
// This will only be compiled once no matter how many times it is referenced.
#define x.h
#define THIS_FILE something
#endif
Hope this helps,
Bill
|
|
|
|
|
In addition to what Bill said, most of the code I deal has this little section near the top :
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif // _DEBUG
|
|
|
|
|
Hello,
I have created a dialog type app(called "A")and a dialog type wizard (Property Page type of wizard) (called "B") to be used with in dialog "A"..
I am having problems pulling string information from previous pages of the wizzard before the wizard dialog is destroyed. Im a newb to property pages, any ideas on how I can pull the string info that the user inputs into the wizard before its closed/finished?
Thanks,
Rob
|
|
|
|
|
Create member variables in your dialog class. Store the data you wish to access in the member variables. After the DoModal call returns, the dialog object still exists. You should be able to access its public members and methods just like any other object.
Hope this helps,
Bill
|
|
|
|
|
I have tried that with out success. I create the DoModal() wizard and when the OnFinish is returned I tried to pull the strings from the items on each dialog.. Maybe I need to add a OnKillActive and do UpdateData(FALSE) on each dialog?
I Have even tried to do a simple MessageBox on the destruction of the wizard and it's unable to pull the string info from the previous pages.. the MessageBox pops up blank.. I'll try to put the UpdateData(FALSE)function on each page OnKillActive..
If you have any other ideas please let me know.
Thanks,
Rob Jones
|
|
|
|
|
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
|
|
|
|