Custom Report Preview Control Toolbar

xiaoxiao2021-03-06  93

Custom Report Preview Control Toolbar

Note: The original VFP print preview is much more convenient. Under some specific requirements, she is very awkward, especially the printer on the print toolbar, and print it at a point. At that time, we need to make selective printing instead of the whole discharge, nor is it very troublesome to close the print preview to return to the printed print, so this update is in the original custom report preview window. And based on the total number of reports of the report, add a custom toolbar to make the program more personalized.

Tip: Because the article is in the article version of the version, it uses the Chinese characters double-byte space, and these spaces will be executed in the program, so please select the following code to copy the following words. Festival velocity, you can use some text processing software to replace all the double-byte spaces "" all the single-byte space!

* - Program Name: RPTPREVIEW.PRG * - Program function: Show a custom window to display a customized toolbar Control report preview print ... * - How to use: RPTPREVIEW

[, ctitlename])

* Or: do rptpreview with

[, ctitlename]

* - Program Description: CREPORTNAME is a report file name (no extension), if omitted, can display the toolbar

* CtitleName is the title of the report (can be omitted, then the title of the report file name)

* The extension of the report is subject to FRX

* - Original Author: Red Tiger

* - Contact: e-mail: hu_feng@163.net

* HomePage: http://www.honghoo.net

* OICQ: 1569040

* - Writing date: January 2001

Func RPTPreviewpara cReportName, cTitleName # define ready_loc "preview the report ..." # define noRptFile_loc # define noData_loc "the current work area with no co preview data, termination!" "Report file & cReportName.! There is no" # define RptExist_loc "whether to replace Original Report Preview? "# Define error_loc" error "#define norpt_loc" No report can preview "#define rptshut_loc" preview report has been closed! "# Define rptclose_loc" Close the print preview window? "# Define preview_name" Report Name "&& Window used to show the contents of the report #define Time_Refresh 500 && Clock Refreshing Frequency (microseconds) SET Message to Ready_loc # Define ISPICBTN .T. && Is the photo button, if you will use text, you will use a text button #define btn_width IIF ( ISPICBTN, 23, 56) && Press New Years #define BTN_HEIGHT IIF (ISPICBTN, 22, 25) && Press New Night * - Picture of the button and title #define home_name Iif (ISPICBTN, ", Home "#define home_pic Iif (ispicbtn," btnhome.bmp "," ") # define prev_name Iif (ISPICBTN," "" "Previous") #define prev_pic Iif (ISPICBTN, "BtnPrev.bmp", "") # Define Next_name Iif (ISPICBTN, "", "Next") #define next_pic Iif (ISPICBTN, "BTNNEXT.BMP", "") # Define end_name Iif (ISPICBTN, "", "Last") #define end_pic Iif ( ISPICBTN, "btnend.bmp", "") # define setup_name Iif (ISPICBTN, "", " ... ") # Define setup_pic Iif (ISPICBTN," BTNSetup.bmp "," ") # define print_name Iif (ISPICBTN," "," Print ... ") # define print_pic Iif (ISPICBTN," btnprint.bmp "," ") # define info_name Iif (ISPICBTN," "," Information ") #define info_pic Iif (ispicbtn," btnprop.bmp "," ") # define close_name Iif (ISPICBTN," "," Close ") # Define Close_PIC IIF (ispicbtn, "btnclose.bmp", ""

) * - Show preview toolbar

If Type ("OPRVToolsbar") = "o" and! isnull (OPRVToolsbar) * - If there is a print toolbar, the prompt information and the check clock on the toolbar OPRVToolsBar.msg.rpt_info.caption = ready_loc OPRVToolsbar.chktimer. Enabled = .t. Else * - If there is no print toolbar, create the toolbar public oprvtoolsbar && definition toolbar object global variable oprvToolsbar = createObject ("preview") && creation toolbar oprvToolsbar.msg.addObject (" RPT_INFO "," RPT_INFO "&& Add a message Tips text box oprvtoolsbar.dock (0) && to make the toolbar on the top OPRVToolsbar.Show && Show Tools Bari

* - Judgment whether the report title parameters are passed correctly

If Type ("ctitleName") # "c" * - If the data type of the report title is not a character type, use the report title with the name of the report instead of ctitleName = CreportNameEndif

* - Judgment whether the report file name parameters are passed correctly

If Type ("CREPORTNAME") # "C" or isnull (CreportName) * - If the name of the report is not a character or empty, it should be terminated, and there is no report to display * - if there is a report preview window, then to re-acquire the information of the report with oPrvToolsBar if wexist (Preview_name) .isInited = .T. .pageno = 0 .rptName = pcRptName .rptTitle = pcRptName else .msg.rpt_info.caption = NoRpt_loc endif endwith Retu .f.else * - Report file name The extension of the file name is quasi! file ("& createname..frx") * - If the passed report file does not exist, then it should be terminated, and the prompt file does not exist MessageBox (Norptfile_loc, 16, Error_Loc) Retu .f. Endifendif

* - Decision whether the current data is opened * For the report, there is a current data table to be opened, otherwise the open data dialog is opened, so if there is no data table, or the number of records of the table is 0 When you should be terminated.

!. If used () or recc () = 0 if messagebox (noData_loc, 1 48, error_loc) = 2 retu .f endifendif * - get the correct report file name and the report title oPrvToolsBar.rptName = cReportNameoPrvToolsBar.rptTitle = cTitleName * - Define Preview Window * This window is equivalent to a container, used to accommodate the report preview window, and the feature of the preview window can inherit the define window WinRptpre; from 0 ,0 to SROWS () - 10, Scols () - 10 ; FLOAT system CLOSE GROW ZOOM noMINIMIZE; TITLE Preview_name ":" cTitleName * - total number of pages calculated reports report form & cReportName nocons environment_pepage = _pageno && record the total number of pages in the report _pepage system variables in the variable does not pay attention && Can be less than or equal to 0, otherwise the system error && When the report is calculated, the && system variable _PAGENO is also returned to 1, not less than 0 pntotalpages = _PAGENO && This total page number variable is customized by the user, can In the form of a "Average page", the "Average page" is displayed & and when using this variable, you should implement the definition with public * - to maximize the window you want to display Zoom Window WinRptpre Max * - Show the report, before First release! If wexist (preview_name) && existence has report preview window if messagebox (rptexist_loc, 4 32, "inquiry) = 7 && inquiry Do you replace the original window Activate window preview_name && If you don't replace, activate the original report preview Window Zoom Window Preview_name Max && Maximizing the RETU .f. && Termination Program Continue Endifendif * - No matter whether there is an original report, first release the original report preview window * If the window does not exist If you don't do any action release window preview_name * - Show the preview report within the window range just defined, do not wait, continue to execute, * If there is no NOWAIT parameter, the report is like a mode window will stop, * So The program is running because there is no error in the presence of the report *, so this nowait is necessary, not removed! ! ! Report Form & CreportName Preview Window WinRptpre NOWAIT * - Move the system print preview tool strip to the lower right corner of the screen and release her move window "Print Preview" to 100, 100Release WINDOW "Print Preview" * - Release the original to place preview Window "container"

Window Release WINDOW WINRPTPRE * - Initialization Toolbar Completes * and Marks whether the toolbar has an initial property is true .oprvtoolsbar.isind = .t. * - Define report file named global variable public PCRPTNAMEPCRPTNAME = Creportnameset Message To " Preview Report Finish * - Define Control: Used to display report page number status define class rpt_info as label autosize = .t. Caption = "Initialization Report ..." Height = 16 Left = 5 TOP = 6 width = 86 forecolor = RGB (0, 0, 255) name = "rpt_info" Visible = .t.Enddefine * - Define Control: Print Control Tools Define Class Preview AS Toolbar Caption = "Report Preview Print Control" Name = "preview" * - Tool The following attributes of the following attributes Pageno = 0 isInited = .f. && is the initial RPTName = "" && current report file name rpttitle = Norpt_loc && current report name isrpttop = .t. && report is the most isrptbot = .T. && report far end aDD OBJECT separator1 AS separator && plus toolbar separator bar aDD OBJECT separator2 AS separator aDD OBJECT msg AS container WITH; Width = 110,; Height = btn_height,; SpecialEffect = 1,; Name = "msg" aDD OBJECT separator5 AS Separator add object cmdhome as commandbutton with; height = btn_height,; width = btn_width,; capen = ho me_name,; Name = "cmdHome",; ToolTipText = "first page",; Picture = home_pic ADD OBJECT cmdprev AS commandbutton WITH; Height = btn_height,; Width = btn_width,; Caption = prev_name,; Name = "cmdPrev", ; ToolTipText = "Previous",; Picture = prev_pic ADD OBJECT separator7 AS separator ADD OBJECT cmdnext AS commandbutton WITH; Height = btn_height,; Width = btn_width,; Caption = next_name,; Name = "

cmdNext ",; ToolTipText =" next ",; Picture = next_pic ADD OBJECT cmdend AS commandbutton WITH; Height = btn_height,; Width = btn_width,; Caption = end_name,; Name =" cmdEnd ",; ToolTipText =" Last page ",; Picture = end_pic ADD OBJECT separator9 AS separator ADD OBJECT cmdSetup AS commandbutton WITH; Height = btn_height,; Width = btn_width,; Caption = setup_name,; Name =" cmdSetup ",; ToolTipText =" system printer Setup "; Picture = setup_pic ADD OBJECT cmdprint AS commandbutton WITH; Height = btn_height,; Width = btn_width,; Caption = print_name,; Name = "cmdPrint",; ToolTipText = "enter reports Print settings",; Picture = print_pic ADD OBJECT separator10 AS separator ADD OBJECT cmdInfo AS commandbutton WITH; Height = btn_height,; Width = btn_width,; Caption = info_name,; Name = "cmdInfo",; ToolTipText = "display printing information report file",; Picture = info_pic ADD OBJECT cmdclose AS commandbutton WITH Height = btn_height,; Width = btn_width,; caption = close_name,; Name = "cmdclose",; tooltiptext = "Close the current report",; Picture = close_pic * - The special point of the toolbar is more than one clock, used to check the current page Number, and other information add object chktimer as timer with; interval = time_refresh,; name = "chktimer" * - control added, start control process * - Toolbar Initialization Procedure Init this.chktimer.Height = 0 This.chktimer.width = 0 this.refresh endproc * - to the home page procedure cmdhome.click acti window preview_name keyboard '{home}'

ENDPROC * - a turning PROCEDURE cmdPrev.Click ACTI window Preview_name KEYBOARD the '{PGUP}' ENDPROC * - down one page PROCEDURE cmdNext.Click ACTI window Preview_name KEYBOARD '{PGDN}' ENDPROC * - footer to PROCEDURE CMDEND.CLICK ACTI WINDOW preview_name keyboard '{end}' endproc * - System print setting Procedure cmdsetup.click sys (1037) endproc * - Print Option Procedure cmdprint.click * - Call the print settings dialog box, you need another program Support: rptprint rptprint (this.parent.rptname) endproc * - Get report information procedure cmdinfo.click * - Show print information for report files, requires another program: dsprptinfo dsprptinfo (this.parent.rptname) Endproc * - Close Report Preview and Print Tools Procedure Cmdclose.Click if MessageBox (rptclose_loc, 4 32, this.parent.rpterttitle) = 6 * - Release Preview Window Release Window Preview_name * - Release Print Control Tools THIS. Parent.release Endif Endproc * - Tools Refresh Procedure Refresh With * - Refresh is the available unavailable control for flip function on the toolbar, do case * - When the number of pages is in the first, and the total number of pages is also Only one page, four are not available in case _PAGENO = 1 and _pepage = 1 .srpttop = .t ..srptbot = .t. * - When the number of pages is in the first, and the total number of pages is greater than one page, the front two are not available in case _PAGENO = 1 and _pepage> 1..rpttop = .t. ..Rptbot = .f. * - When there is between the first and most, the four can be used in Case _PAGENO> 1 and _PAGENO <_pepage .srpttop = .f. .Srptbot = .f. * - When the number of pages is in the last page, the last two are not available Case _PAGENO> 1 and _PAGENO = _pepage .srpttop = .f. .srptbot = .t. endcase * - But when there is no initialization, all four are not! this.isind .isrpttop = .t ., .ismbot =. T. Endif * - or even four buttons, the first two and the next two two differently coordinated .cmdhome.enabled =! .Srpttop .cmdprev.enabled =! .Rpttop .cmdnext.enabled =

转载请注明原文地址:https://www.9cbs.com/read-122804.html

New Post(0)