Reading software is your own

zhaozj2021-02-11  219

Reading software is your own

I don't know if you are interested in E_BOOK's reading effect. It is done with VB, in fact, in C Builder, you can easily achieve similar effects. Let us now Step By Step! 1) New project. The unit store is added to "read.cpp" to join a popupMenu; form property settings Name: mainform; autoscroll: false; borderstyle: bsnone; font: Song, Fontsize: 9; Position: POSCREENCENTER; POPMENU: POPMENU1; 2) Add a panel Set to: bevelouter: bvnone; borderstyle: bssingle; ctl3d: false; name: panel_1; caution; color: 0x00ce9600; (light blue) can be self-defined 3) A: Prace Panel_1 (arbitrary), Add two panels to LE_PAN, RI_PAN; Le_pan: Color: CLBLACK ALIGN: AlLeft; Width: 20; The rest of the same panel_1; ri_pan: align: alright; the rest of the same LE_PAN; B: Add 1 label in Panel_1, Set the attribute to transparent: true; Visible: false; select Label1, knock Ctrl C once, knock Ctrl V 69 times, (70 label) C: Add two image controls to Panel_1, name back_image, frame_image; back_image Stretch property To true; back_image can load your background image you want; 4) Add a MEMO control, the property is name: buf_memo; width: 310; Visible: false; enabled: false; ctl3d: false; 5) Add OpenDialog, OpenPictureDialog One; PopMenu1 is created 3 press. 1) CAPTION: Open Name: OpenN 2) CAPTION: Background Name: Backn 3) CAPTION: Exit Name: Closen; OpenDialog1 Filter property is: Text file | * .txt | All files | *. * Principles: first file file The content is loaded into MEMO, and then it is displayed by traversing the Label control. The following is the unit file: // #include

#Pragma HDRSTOP

#Include "read.h"

//

#Pragma package (smart_init)

#Pragma resource "* .dfm"

TMAINFORM * MainForm;

const Int Page_nums = 34; / / The number of rows per page

INT now_LINE; / / Current line

BOOL end; // Is there end?

//

__fastcall Tmainform :: TMAINFORM (Tcomponent * Owner)

: TFORM (OWNER)

{

ININ_FACE ();

}

//

Void __fastcall tMainform :: face_imagemousedown (TOBJECT * SENDER,

TMOUSEBUTTON button, TshiftState Shift, Int X, Int Y)

{

/ / Drag the window, this skill is more useful if (Button == Mbleft)

{INT SC_DRAGMOVE = 61458;

Releasecapture ();

Mainform-> Perform (WM-SysCommand, SC-DRAGMOVE, 0);

}

}

//

Void __fastcall tMainform :: Opennclick (TOBJECT * SENDER)

{

IF (OpenDialog1-> Execute ())

{Buf_memo-> lines-> loadFromfile (OpenDialog1-> filename);

ININ ();

}

}

//

Void__fastcall tMainform :: Backnclick (Tobject * Sender)

{

IF (OpenPictureDialog1-> Execute ())

Back_Image-> Picture-> LoadFromFile (OpenPictureDialog1-> filename);

}

//

Void __fastcalltmainform :: ClosenClick (Tobject * Sender)

{

Application-> Terminate ();

}

//

Void TMAIN FORM :: Print Page (int line_cou)

// Execute the Print book content

{

Const Int L-top = label1-> height;

/ / This parameter is used to set the line spacing

Const Int TitleLineCount = BUF-MEMO-> LINES-> count; // MEMO total number

INT labelleft = 40;

INT labeltop = 38;

IF (line_cou <0)

// line_cou is the labeling now

LINE_COU = 0;

INT lineinx = 0;

// Current row number pointer

INT i = 0;

BOOL VIS = 1;

INT C = Panel_1-> ControlCount;

/ / Get the number of controls on the panel_1

TLABEL * PLA;

/ / Define the pointer to the TLABEL class

While (i

{

// Traverse all controls on Panel_1, this method is useful,

IF (Panel-1-> Controls [I] -> ClassNameis ("TLabel"))

/ / Judgment the control class name

{PLA = Dynamic_Cast (Panel_1-> Controls [I]); // Forced Conversion Pointer Type

PLA-> Visible = VIS;

IF (! VIS) {i ; Continue;}

// Set excess Label to not visualize

Pla-> TOP = labeltop;

PLA-> Left = labelleft;

Pla-> CAPTION = BUF_MEMO-> LINES-> strings [lineinx line_cou];

// Use the Label to display the line content

Labeltop = l_top;}

Else

// If you don't want the (Label) class, continue to judge the next control

{i ; continue;}

i ;

LineinX ;

IF (Labelleft <300)

IF (LineinX 1 == Page_NUMS)

{Labeltop = 38;

Labelleft = 410;

}

IF (LineinX 1 == 2 * Page_nums) // If a page has been displayed

VIS = 0;

IF (LineinX Line_Cou == TitleLineCount-1) // If the full text is over

VIS = 0;

}

IF (LineinX Line_Cou

{

Now_line = line_cou lineinx; // Record the current number of lines

End = 0;

}

Else

End = 1;

}

//

Void TMAINFORM :: Inin ()

{

End = 0;

PRINTPAGE (0);

}

//

Void TMAINFORM :: ININ_FACE ()

// Initialization interface

{

Width = 740;

// Setting the form size here

HEIGHT = 495;

Back_image-> sendtoback ();

Face_image-> bringtofront ();

Panel_1-> align = alclient;

ACK_IMAGE-> align = alclient;

Face_Image-> align = alclient;

// These initialization settings, although there is an intention of "what you see", it makes it easier to edit

}

//

Void __fastcall tMainform :: ri_panclick (TOBJECT * SENDER)

{

/ / Turn forward forward

IF (! End)

PRINTPAGE (now_LINE);

}

//

Void __fastcall tMainform :: Le_PANCLICK (TOBJECT * Sender)

{

// turn the page back

IF (end)

PRINTPAGE (now_line - 2 * page_nums 1);

Else

PRINTPAGE (now_line - 4 * page_nums 2);

}

//

In the top plus

head File

#Include

The generated file can be imported into the JPG image file as a background color

In addition, in the publication of the header file, plus:

Public: // user declarations

Void PrintPage (Int line_cou);

// Main execution function

Void inin;

// Initialize the open file

Void inin_face (void);

// Initialization interface

For beginners, it is important to point out that in addition to the three functions above, the other Events page double-click to generate, and then write the function main body.

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

New Post(0)