Duilib using Fastreport

Source: Internet
Author: User

Fastreport is a simple and excellent report, Fastreport More is used in conjunction with Delphi to preview and print data. I started using Duilib to do the project, printing and data preview are self-drawn, so not only to draw trouble, but also the customer needs are changeable, their own drawing is not so flexible. Later I think, can use the report and other tools with Duilib to display or print, here I use the way OCX call Fastreport.

First of all, we download fastreport from the Internet to install, here provide the download of the network disk, if the link fails please contact me. Link: http://pan.baidu.com/s/1bp4ZrCr Password: 3y5j. After installing the Fastreport there are some examples that interested students can look at.

After the completion of the above work, you can write our code, DUILIB has encapsulated the support for OCX, XML key code is as follows:

      <name= "Fastreport"  clsid= "{9207e7eb-4ce3-40e1-8a5a-77c43da9f503 } "  mouse=" false ">      </ActiveX>

Next we write a window to show this OCX

1 classCframewindowwnd2: PublicWindowimplbase3 {4  Public:5 Cframewindowwnd ();6~Cframewindowwnd ();7 8 protected:9Cduistring Getskinfolder ()Override;TenCduistring Getskinfile ()Override; OneLPCTSTR Getwindowclassname (void)Const Override; A     voidOnFinalMessage (HWND hwnd)Override; -     voidNotify (tnotifyui&msg); -     voidOnClick (tnotifyui&msg); the  - protected: -  - Private: +ifrxactivepreviewform*M_pfastreportview; -cactivexui*M_pactivex; + ifrxreportptr M_preport; A  at     //Control -Cbuttonui *m_ploadreportbtn; -};
1#include"stdafx.h"2#include"FrameWindowWnd.h"3 4 Cframewindowwnd::cframewindowwnd ()5 : M_pfastreportview (nullptr),6 M_pactivex (nullptr),7 m_ploadreportbtn (nullptr),8 M_preport (nullptr)9 {Ten     { One ifrxreportptr Preport (__uuidof (Tfrxreport)); AM_preport =Preport; -     } - } the  -  -cframewindowwnd::~Cframewindowwnd () - { +M_preport->Release (); - } +  A duilib::cduistring Cframewindowwnd::getskinfolder () at { -     return_t (""); - } -  - duilib::cduistring cframewindowwnd::getskinfile () - { in     return_t ("Framewindowwnd.xml"); - } to  +LPCTSTR Cframewindowwnd::getwindowclassname (void)Const - { the     return_t ("Framewindowwnd"); * } $ Panax Notoginseng //"87caf5e4-3add-4abd-baf5-76f3ee604c3d" - Static ConstGUID Iid_iz = the{0x87caf5e4,0x3add,0x4abd, {0xba,0xf5,0x76,0xf3,0xEE,0x60,0x4c,0x3d } }; +  A voidCframewindowwnd::notify (tnotifyui&msg) the { +     if(Msg.stype = = _t ("Showactivex")) -     { $         if(Msg.psender->getname ()! = _t ("Fastreport"))return; $M_pactivex = static_cast<cactivexui*>(Msg.psender); -         if(M_pactivex! =nullptr) -         { theM_pactivex->getcontrol (Iid_iz, (void* *) &M_pfastreportview); - Wuyi             if(M_pfastreportview! =nullptr) the             { -                   Wu //duitrace ("%d", m_pfastreportview->report); -Duitrace ("Test"); About //m_pfastreportview->init (); $Frxpreviewbuttons btns = M_preport->getpreviewoptions ()getbuttons (); -  -Btns = Frxpreviewbuttons (btns^frxpreviewbuttons::p b_noclose); -  AM_preport->getpreviewoptions ()putbuttons (btns); +  theM_pfastreportview->Putreport (m_preport); -M_pfastreportview->Init (); $              } the         } the     } the     Else if(Msg.stype = =dui_msgtype_windowinit) the     { -M_PLOADREPORTBTN = static_cast<cbuttonui*> (M_paintmanager.findcontrol (_t ("Loadreport"))); inDuitrace (M_paintmanager.findcontrol (_t ("Loadreport")),GetName ()); theDuitrace (M_paintmanager.findcontrol (_t ("Loadreport")),getclass ()); theASSERT (m_ploadreportbtn! =nullptr); About     } the  the __super::notify (msg); the } +  - voidCframewindowwnd::onfinalmessage (HWND hwnd) the {Bayi windowimplbase::onfinalmessage (hWnd); thePostQuitMessage (0); the     Delete  This; - } -  the voidCframewindowwnd::onclick (tnotifyui&msg) the { the     if(Msg.psender = =m_ploadreportbtn) the     { -         //M_pfastreportview->lock (); the #if0 theCduistring szreportfilename = Cpaintmanagerui::getinstancepath () + _t ("01.Simple LIST.FR3"); theM_preport->Loadreportfromfile (Szreportfilename.getdata ());94M_preport->preparereport (true); theM_preport->Showreport (); the #else the 98M_pfastreportview->lock ();//Workspace.lock (); About         Try -         {101Cduistring szreportfilename = Cpaintmanagerui::getinstancepath () + _t ("01.Simple LIST.FR3");102M_preport->Loadreportfromfile (Szreportfilename.getdata ());103M_preport->preparereport (true);104         } the         Catch (...)106         {107         }108M_pfastreportview->unlock ();//Workspace.unlock ();109         //m_pfastreportview->update (); the #endif111         //M_pfastreportview->unlock ();//Workspace.unlock (); the     }113 __super::onclick (msg); the}
View Code

Well, this is a simple page. The report here is I casually copied from under the Fastreport's installation directory. Compile to see our results.

The effect is still good, right?! As for Duilib to fastreport parameters, binding variables can be studied Fastreport example.

deployment, we do not have to install Fastreport, you can directly copy the Fastreport3.dll to the client and then regsvr32 a bit, is it simple?

Reprint please specify the source http://www.cnblogs.com/fyluyg/p/5748626.html

Duilib using Fastreport

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.