.


:




:

































 

 

 

 


. 1. Memo ( Standart) RichEdit ( Win32)




1. Memo ( Standart) RichEdit ( Win32)

Memo RichEdit . Memo (, , ) Font, RichEdit RTF. .

:

¨ Font

¨ Lines - TStrings.

¨ ScrollBars - .

ú SsNone ( ). .

ú ssHorizontal - .

ú ssVertical -

ú ssBoth

, Lines . . < CodeEditor> . , , , , Close Page .

Lines.

(Memo1->Lines->)

¨ Add ( ) - . .

¨ Append ( ) - . .

¨ Delete ( N ) N.

¨ Insert ( N, ) N

¨ Exchange ( N1, N2 ) N1 N2.

¨ Move ( N1, N2 ) N1 N2.

¨ LoadFromFile ( FileName ) FileName
LoadFromStream ( Stream ) - Stream

¨ SaveToFile ( FileName ) - FileName
SaveToStream ( Stream ) - Stream

¨ Clear () - . Lines, Memo.

Memo1->Lines->Clear() Memo1->Clear()

 

2.

. :

Þ New File

Þ New Items Projects

Þ Application Wizard.

OK .

, .

1 , .

2 , File, , . Add (Description) () (Extension(s)), , .com; .exe

3 Remove, Insert Space .

4 ( ) ( ) , , :

Þ Create MDI Application ;

Þ Create a status line ;

Þ Enable Hints .

, .

3. MainMenu pupMenu ( Standart)

C++Builder , :MainMenu pupMenu . .

- , .. , , , .

, . . MainMenu Menu, . MainMenu.

, PopupMenu. . PopupMenu , , AutoPop true. . .

4.

Items. , .. Items, . Items . , .1, .

ü . , (. .1) Caption, . Caption -, .

 

 
 

, .. Items, TMenuItem, , , .
Name , . .

ü . , Ins Insert ( , . .1).

ü . .

ü . , , Ctrl+ Create Submenu .

ü . Del Delete .

ü . Insert From Template . . : Delete Templates, Save As Template .

ü . , .. . . , Select Menu . ( , Shift Ctrl), , Ctrl-C. Select Menu , Ctrl-V.

ü .
ShortCut , , , , . , ShortCut . .

Caption. ( S) &, Alt-S.

ü . Default , , .. , .

ü . C++Builder-4 . Bitmap. Glyph BitBtn (. ..1): , Load . OK.

 

5.

OnClick, . , Events ( , ).

 

6.

. . include.

v , Main.cpp, MyDialog.cpp, Main.cpp :

#include MyDialog.h

 

. Visible false, - , , . Show () ShowModal (), ,

Form2->Show()

ShowModal() . . , . , . , . , ShowModal. Show(), .

ModalResul t. . ShowModal ModalResult=mrNone=0. - ModalResult 1=mrOK 8=mrAll, .

, ModalResult ModalResult . ModalResult , . ModalResult .

v :

{

Form2->ShowModal();

if (Form2->ModalResult = = mrCancel)

Edit1->Text = Form2

}

, , , , , , , .

 

7.

, .. , New Form File, , , .., . , , , OK, Cancel, Help; .

:

Þ New File

Þ New Items Dialogs

Þ , , StandardDialog DialogWizard, , , .

, . , - .

, . Shift+F12.

 

8.

OnClick . , ShowModal (), .

v :

, OKRightDlg. CallDlg OnClick :

void __fastcall TForm1::CallDlgClick(TObject *Sender)

{ OKRightDlg->ShowModal(); // OKRightDlg

//

}

9.

. , .h ( <Ctrl>+F6), , .cpp.

v :

6 AnsiString :

1. MyDialog.h :

extern AnsiString stroka;

2. MyDialog.cpp -

AnsiString stroka;

Memo1, Edit1 . stroka. . OnClick :

void __fastcall TOKRightDlg::OKBtnClick(TObject *Sender)

{ stroka = Edit1->Text; }

ModalResult ModalResult , ( mrNone), mrOK=1, , ModalResult .

OnClick , . , Memo1 stroka. OnClick CallDlg :

void __fastcall TForm1::CallDlgClick(TObject *Sender)

{ OKRightDlg->ShowModal();

if (OKRightDlg->ModalResult==mrOk) Memo1->Lines->Add(stroka);

}

v :

.

MyForm

Þ Memo1

Þ MainMenu1

< >.

o 2 MainMenu1

o Caption : &

. File New Form. :

Þ Label1 Caption =

Þ Edit1

Þ Label2 Caption =

Þ Edit2

Þ Label3 Caption =

Þ Edit3

Þ Label4 Caption =

Þ DateTimePicker1

Þ Button1 Caption = , ModalResult = MrOk

Þ Button1 Caption = , ModalResult = MrCancel

.

Unit2.h ( Ctrl+F6)

struct TNewMen

{ AnsiString Fam, Name, Otch;

TDateTime Date;

};

extern TNewMen NewMen;

extern AnsiString Str;

Unit2.cpp:

TNewMen NewMen;

extern AnsiString Str;

Unit1.cpp:

#include Unit2.h;

OnClick Button1

NewMen.Fam=Edit1->Text;

NewMen.Name=Edit2->Text;

NewMen.Otch=Edit3->Text;

NewMen.Date=DateTimePicker1->Date;

Str = NewMen.Fam+' '+NewMen.Name+' '+NewMen.Otch+' '+

NewMen.Date.FormatString("ddddd");

( ) :

Form2->ShowModal();

if (Form2->ModalResult==mrOk) Memo1->Lines->Add(Str);

Anketa.txt ( ) .

void __fastcall TForm1::FormCreate(TObject *Sender)

{ Memo1->Lines->LoadFromFile("Anketa.txt");}

 

void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)

{ Memo1->Lines->SaveToFile("Anketa.txt"); }

 





:


: 2015-10-01; !; : 461 |


:

:

.
==> ...

1516 - | 1351 -


© 2015-2024 lektsii.org - -

: 0.086 .