By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,292 Members | 1,381 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,292 IT Pros & Developers. It's quick & easy.

Help with managed C++/.NET/windows form viewer

P: n/a
Hello, all...

I am attempting to write a managed c++ dll that will open a crystal
report in the windows form viewer. For various reasons, I need to be
able to write this in C++ w/MFC as opposed to C#. The code below is
called when the user doubleclicks an entry in a tree control. The
first time the user doubleclicks this entry, the code below works
wonderfully. However, the second time the user doubleclicks, the
windows form viewer flashes the report on the screen for a split
second, then disappears. It appears that the code below works fine on
the odd-numbered invocations, but the even numbered invocations act as
described (i.e. the code below works every other attempt, but on the
attempts when it doesn't work the viewer flashes on the screen for a
split second). Also, it seems like the destructor never gets called
(perhaps this is a symptom of the problem???) I have never worked
much with managed code or .NET, so any advice or help would be
appreciated.

Thanks,
Dean
__gc class ViewForm : public System::Windows::Forms::Form
{
private:
CrystalDecisions::Windows::Forms::CrystalReportVie wer
*crystalReportViewer1;
ReportDocument *crReportDocument;
public:
ViewForm()
{
MessageBox(NULL, "CONSTRUCTOR", "TEST", MB_OK);
InitForm() ;
}
~ViewForm()
{
MessageBox(NULL, "DESTRUCTOR", "TEST", MB_OK);
Dispose() ;
}
void InitForm()
{
#pragma push_macro("new")
#undef new
crystalReportViewer1 = new
CrystalDecisions::Windows::Forms::CrystalReportVie wer();
#pragma pop_macro("new")
crystalReportViewer1->ActiveViewIndex = -1;
crystalReportViewer1->Dock =
System::Windows::Forms::DockStyle::Fill;
crystalReportViewer1->Name = "crystalReportViewer1";
crystalReportViewer1->TabIndex = 0;
Controls->Add (crystalReportViewer1);
WindowState =
System::Windows::Forms::FormWindowState::Maximized ;
Load += new System::EventHandler (this, ViewForm_Load);
}
void ViewForm_Load(System::Object* sender, System::EventArgs* e)
{
#pragma push_macro("new")
#undef new
crReportDocument = new ReportDocument();
#pragma pop_macro("new")
crReportDocument->Load("C:\\Reports\\test.rpt");
crystalReportViewer1->ReportSource = crReportDocument;
}
};

extern void EXPORT testReportViewer()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
Application::Run(new ViewForm());
}
Nov 16 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi Dean,

Thanks for your post. Please refer to the following sample which
demonstrates opening a crystal report in the windows form viewer.
C++ .NET Windows Application - Accessing Subreport
http://support.crystaldecisions.com/...s/cppnet_win_s
ubreport_basic.exe.asp

The following article lists more .NET Crystal Report sample in C++ .NET.
Crystal Reports: Listing of .NET Sample Applications in C# and C++ .NET
http://support.crystaldecisions.com/...s/apps_net.pdf

In addition, please be noted that "Microsoft supports setup and
installation for the Crystal Reports products that are included with Visual
Studio .NET. All other support is provided by Crystal Decisions."
(described in the KB article 317789 below). So I recommend you contact
Crystal Decisions to check whether there is any known issue on their side.

INFO: Licensing and Support for Crystal Reports for Visual Studio .NET
http://support.microsoft.com/?id=317789

Please feel free to let me know if you have any problems or concerns.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! C www.microsoft.com/security
This posting is provided as is with no warranties and confers no rights.
Nov 16 '05 #2

P: n/a
Hello Dean,

Did the information I posted last time help you resolve the problem?

I look forward to your response.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! C www.microsoft.com/security
This posting is provided as is with no warranties and confers no rights.
Nov 16 '05 #3

P: n/a
Tian,

Thanks for responding to the original message. The site you posted
did not help me much, but I did find a solution through other means.
I was attempting to open my class with Application::Run, but instead I
should have used the ShowDialog() method. Now my application works
great!

Thanks again,
Dean
Nov 16 '05 #4

P: n/a
Hello Dean,

I am very glad to hear that you have resolved the problem! :-)

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! C www.microsoft.com/security
This posting is provided as is with no warranties and confers no rights.
Nov 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.