Solved

Showing a CRecordView Dialog

Posted on 1998-05-18
5
372 Views
Last Modified: 2008-02-01
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
Comment
Question by:Imran020598
  • 3
  • 2
5 Comments
 

Expert Comment

by:matzon
ID: 1163001
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
 

Expert Comment

by:matzon
ID: 1163002
... Ofcourse you have to call the ShowWindow() too. :)
0
 

Author Comment

by:Imran020598
ID: 1163003
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
 

Accepted Solution

by:
matzon earned 20 total points
ID: 1163004
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
 

Author Comment

by:Imran020598
ID: 1163005
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

786 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