Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Parsing error while creating dialog resource.

Posted on 1999-06-29
5
Medium Priority
?
330 Views
Last Modified: 2013-11-20
I have an MDI, doc/view app.  I recently added code to check the screen resolution and, based on that, choose which of two different-sized form views to load on the screen (640x480 gets the smaller form view/800x600 and up, the larger).  I created the two form views with the same control ID’s etc. so they are interchangable and added a static struct in the constructor to check the resolution and choose the proper form view.  The weird part may be the way I handled it in the header file – it was a guess that worked.

In the header…

public:
      //{{AFX_DATA(CMyView)
      enum { IDD = IDD_MYFIRSTFORMVIEW };
      enum { IDD1 = IDD_MYSECONDFORMVIEW };
//lots of CStrings, etc.
      //}}AFX_DATA

In the .cpp constructor…

// CMyView construction/destruction

static int m_nIDD;
static struct _stDummy
{
_stDummy()
{
      int x = GetSystemMetrics(SM_CXSCREEN);
      if(x == 640)
            m_nIDD = CMyView::IDD;
      else
            m_nIDD = CMyView::IDD1;
}
}g_Dummy;

CMyView::CMyView()
      : CFormView(m_nIDD)
{
      //{{AFX_DATA_INIT(CMyView)
//stuff initializing the variables
      //}}AFX_DATA_INIT
}

Everything works great and on every machine I’ve tried.  It’s very stable and works excellent.  However, when I tried to add a new dialog resource I got this: “Parsing Error: Resource ID already defined for this class.  Input Line: “enum {IDD1 = IDD_MYSECONDFORMVIEW }”  I tried adding the second form view to the CMyView class and got the same message (I tried a lot of different things, but always got that same parsing error message).  What’s wrong here?  How can I change this code so I can add more dialog resources?  I'm sure it's a problem with the header.  Thanks for any help.
0
Comment
Question by:jjjkkklll
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 1

Expert Comment

by:malmq
ID: 1308397
Just a thought

public:
//{{AFX_DATA(CMyView)
enum { IDD = IDD_MYFIRSTFORMVIEW,
IDD1 = IDD_MYSECONDFORMVIEW  };
enum { IDD1 = IDD_MYSECONDFORMVIEW };
//lots of CStrings, etc.
//}}AFX_DATA
0
 
LVL 1

Expert Comment

by:malmq
ID: 1308398
This was the REAL thought that I had.  Not sure if it corrects the problem.

public:
//{{AFX_DATA(CMyView)
enum { IDD = IDD_MYFIRSTFORMVIEW,
IDD1 = IDD_MYSECONDFORMVIEW  };
//lots of CStrings, etc.
//}}AFX_DATA
0
 

Author Comment

by:jjjkkklll
ID: 1308399
I tried that and got the exact same parsing error.  Thanks for the thought, though.
0
 
LVL 2

Accepted Solution

by:
The Master earned 280 total points
ID: 1308400
It's the ClassWizard that's parsing that and giving you that error.  Just move the enum{IDD1=...} outside of the AFX_DATA brackets.

Good luck!
0
 

Author Comment

by:jjjkkklll
ID: 1308401
Well, this falls into the category "I can't believe I didn't try that."  I made the change and everything works great.  Thanks for your excellent help.
0

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question