[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 404
  • Last Modified:

Showing a CRecordView Dialog

Hello,
I am trying to show a Dialog constructed in the AppWizard with the base-class CRecordView. Now when I try to show the dialog, I get an assertion failure. This is done in the Dialog based application.
The way I have done this is =

CMyRecordView cView;

cView.ShowWindow(SW_SHOW);
cView.Update();

Shouldn't this be enough for showing my dialog?
Is it possible to display a CRecordView in a dialog based application?
Please help me!!!
0
Imran020598
Asked:
Imran020598
  • 3
  • 2
1 Solution
 
matzonCommented:
Hi....
Your problem is, that you try to show a window which hasn't yet been created!

You have to instanciate it and then call its create command...
i.e.
//In you Header file
CMyRecordView cView;

//In your cpp file
cView.Create(YOUR_RESOURCE_ID, &TheParent);
//I don't recall whether you need the parent or not... *ponder*

hope this helps...
0
 
matzonCommented:
... Ofcourse you have to call the ShowWindow() too. :)
0
 
Imran020598Author Commented:
Hello Matzon,
This did not solve my problem. It seems to me that when the create function is called the assertion error is displayed. From what I know, I don't need to call the create function (although I have tried) because this is called by MFC itself!
From what I have found out, It does not seem to be possible to create a dialogbox in a dialogbased application with the base class as CRecordview.
0
 
matzonCommented:
achh...
My fault.... You can't create a dialog that uses a CRecordView, since a View is only used in a SDI or MDI application!

So what you want to do, is to start a new application workspace and choose either SDI or MDI instead of dialog. Include header files (or choose to have with/without file support).
At the last page of the wizard, change your view to CRecordView.
That Should do it...
If you do want to show database data in a dialog you have to manually insert the data from the database in some of the editfields(or whatever) that you have create. If this doesn't work Could you then supply a more specific question, or mail me the sample app and database then i'll have a looksee
btw: are you using ODBC?
0
 
Imran020598Author Commented:
Hello Matzon,
Thnx for your help, but actually I knew that a View class can only be used in a SDI or MDI application. But I was hoping for some dirty work arround so that it could be used in a dialog-based application. Anyway thnx for the effort and your time!
Regards
Imran
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now