on 03-23-2016 9:54 AM
"GoToPage" does not work in my project, which was created by vs2010 + CRforVS_13_0_13.exe (which was downloaded from http://scn.sap.com/docs/DOC-7824). change CRforVS_13_0_13.exe to CRforVS_13_0_16.exe still cannot fix this problem:
Please see below for my project information.
1. Create a C++ project, using "CMultiDocTemplate* pTemplate = LoadCRViewer_CFormView(&theApp);" to display project.
BOOL CMFC04App::InitInstance()
{
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// Set this to include all the common control classes you want to use
// in your application.
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
// Initialize OLE libraries
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(4); // Load standard INI file options (including MRU)
// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
{
delete pMainFrame;
return FALSE;
}
m_pMainWnd = pMainFrame;
// call DragAcceptFiles only if there's a suffix
// In an MDI app, this should occur immediately after setting m_pMainWnd
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line. Will return FALSE if
// app was launched with /RegServer, /Register, /Unregserver or /Unregister.
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The main window has been initialized, so show and update it
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
// Loading the MFC Extension dll
CMultiDocTemplate* pTemplate = LoadCRViewer_CFormView(&theApp);
return TRUE;
}
2. Create the other project, add report dialog information into .rc file.
IDD_CRYSTALREPORTVIEWER DIALOGEX 0, 0, 320, 200
STYLE DS_SETFONT | WS_CHILD
EXSTYLE WS_EX_OVERLAPPEDWINDOW | WS_EX_ACCEPTFILES
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
CONTROL "",IDC_CRVIEWER,"Static",SS_GRAYRECT | NOT WS_VISIBLE,7,7,306,186
END
3. Add method in related .cpp file, so that we can use this method in step 1.
extern "C" AFX_EXT_API CMultiDocTemplate* WINAPI LoadCRViewer_CFormView(CWinApp* pApp)
{
// Register the doc templates we provide to the app
//CWinApp* pApp = AfxGetApp();
if(pApp) {
ASSERT(pApp != NULL);
CMultiDocTemplate* pTemplate = new CMultiDocTemplate(IDR_CRVIEWER,
RUNTIME_CLASS(CDummyDoc),
RUNTIME_CLASS(CMDIChildWnd),
RUNTIME_CLASS(CCrystalReportViewer));
pApp->AddDocTemplate(pTemplate);
pTemplate->OpenDocumentFile(NULL);
return pTemplate;
}
return NULL;
}
4. Load crystal report in .cpp file.
void CCrystalReportViewer::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
CString reportName = L"rassdk://" + GetAppPath() + L"\\View.rpt";
CString databastLocation = GetAppPath() + L"\\schedules.mdb";
ShowCrystalReport(reportName,databastLocation);
SetCRViewerWin(this);
// start up resizing, and do initial one.
m_okToResizeIt = true;
RestoreSize();
}
void CCrystalReportViewer::ShowCrystalReport(CString &reportName, CString &databaseLocation)
{
CrystalDecisions::CrystalReports::Engine::ReportDocument^ reportDocument1 = (gcnew CrystalDecisions::CrystalReports::Engine::ReportDocument());
reportDocument1->FileName = gcnew System::String(reportName);
CrystalDecisions::CrystalReports::Engine::Database^ database = reportDocument1->Database;
CrystalDecisions::CrystalReports::Engine::Tables^ databaseTables = database->Tables;
CrystalDecisions::Shared::ConnectionInfo^ connectionInfo = (gcnew CrystalDecisions::Shared::ConnectionInfo());
connectionInfo->ServerName = gcnew System::String(databaseLocation);
CrystalDecisions::CrystalReports::Engine::Table^ databaseTable = databaseTables[0];
CrystalDecisions::Shared::TableLogOnInfo^ tableLogonInfo = databaseTable->LogOnInfo;
tableLogonInfo->ConnectionInfo = connectionInfo;
databaseTable->ApplyLogOnInfo(tableLogonInfo);
//
// m_CRViewerControl
//
m_CRViewerControl->ActiveViewIndex = 0;
m_CRViewerControl->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
m_CRViewerControl->Dock = System::Windows::Forms::DockStyle::Fill;
m_CRViewerControl->Location = System::Drawing::Point(0, 0);
m_CRViewerControl->Name = L"CrystalReportViewer";
m_CRViewerControl->ReportSource = reportDocument1;
CRect rect;
GetClientRect(&rect);
m_CRViewerControl->Size = System::Drawing::Size(rect.Width(), rect.Height());
m_CRViewerControl->TabIndex = 0;
m_CRViewerControl->PageChanged += gcnew EventHandler(crystalReportViewer1_PageChanged);
m_CRViewerControl->Navigate += gcnew CrystalDecisions::Windows::Forms::NavigateEventHandler(Navigate_To);
m_CRViewerControl->Show();
}
"GoToPage" only does not work in this project, if I create a winform project to load crystal report, no problem for "GoToPage". What’s wrong with “GoToPage” in my project?
If you click the Next Page button does it go there?
If you click the Last Page button and then Go To does that work?
Can you attach a complete project, use the Advanced editor link and zip the project up and then add a .txt extension to the zip file. 1 meg max so delete all of the build files.
Don
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ada,
I think you sent this to Ludek.....
Problem is you are using the ActiveX viewer library....
Error 1 error LNK1104: cannot open file '..\CRViewer\Debug\CRViewer.lib' D:\Atest\Ada\MFCWinForm\MFC04\LINK MFC04
Not supported, you need to update your form to use the CrystalReportsWindows.Form viewer
Don
Hi Don,
I think you had alreay got the project from Ludek. I didn't use the ActiveX viewer library, the viewer I used in my project is like below. You can check CrystalReportViewer.h and CrystalReportViewer.cpp files.
CWinFormsControl<CrystalDecisions::Windows::Forms::CrystalReportViewer> m_CRViewerControl;
"cannot open file '..\CRViewer\Debug\CRViewer.lib'" error will disappeared if you build "CRViewer" project first and then build "MFC04"(just like below screenshot). Now if you run my project, it will works well and display with crystal report.
Thanks,
Ada
Hi Yan,
I've been on holidays. Sorry, that was name of the old ActiveX viewer so a little misleading on my part.
Yes, your app does not work. It's MFC, CR for .NET does not support MFC, Managed C++ only also.
Appears that interactive window is not triggering any kind of an event and the TAB key does not get there either.
I downloaded one of the test apps from the link on the Overview tab and the Go To Page does work.
If you can duplicate the issue using a Managed C++ app I can escalate it but since we don't support MFC I can't.
Don
Hi Ada,
When you create a new project in C++ I think it mentions or shows "Managed" in the list or when you try to convert an older app to a VS Project it shows some Managed message, I don't recall exactly, it's been a while since I tried.
CR no longer supports MFC since CR 10 when we stopped supporting crpe32.dll as the report engine. .NET, Java or RESTfull are the only platforms we support now.
Don
Links to samples is on the Overview tab.
Crystal Reports for .NET SDK Samples - Business Intelligence (BusinessObjects) - SCN Wiki
Go down the page to the Viewer sections, you'll find C++ samples. You will need to update the imports.
Don
User | Count |
---|---|
75 | |
8 | |
8 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.