cancel
Showing results for 
Search instead for 
Did you mean: 

"GoToPage" does not work

Former Member
0 Kudos

"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();

}

  1. Open the solution with vs2005 (if you a higher compiler, you can upgrade the solution).

  1. First build project “CRViewer” and then “MFC04”.

  1. Run the project, a crystal report will be popup.

  1. Change page to “2” and then press enter key, report does not go to page 2 (GoToPage problem.png).

"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?

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

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

0 Kudos

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

Former Member
0 Kudos

"GoToPage" always doesn't work after click the Next Page button or Last Page button. But the Next/Last Page button works well.

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Don,

Based on my comment, after build the two projects, can you reproduce the "GoToPage" problem now? How to fix this problem?

Thanks,

Ada

0 Kudos

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

Former Member
0 Kudos

Hi Don,

Thanks for your reply. What does "Managed C++ only also" mean in your reply?

So if CR for .NET does not support MFC, what kind of CR will support MFC project?

How can I find the requirement for CR for .NET(Such as CR for .NET only support managed project)?

Ada

0 Kudos

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

Former Member
0 Kudos

Hi Don,

You had mentioned something like this "I downloaded one of the test apps from the link on the Overview tab and the Go To Page does work.".

Can you give the link url ? I want to take a look at it.

Thanks,

Ada

0 Kudos

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

Former Member
0 Kudos

Ok, thanks.

Ada

Answers (0)