Message Box Message Box Buttons buttons Message Box

  • Slides: 9
Download presentation

Message Box Ø Message. Box. Buttons buttons = Message. Box. Buttons: : OKCancel; Message.

Message Box Ø Message. Box. Buttons buttons = Message. Box. Buttons: : OKCancel; Message. Box: : Show (this, "You clicked on the form!", "Message Box", buttons, Message. Box. Icon: : Question); Ø Ο χρήστης δεν μπορεί να επέμβει στο παράθυρο First Form εάν δεν επιλέξει κάποιο από τα buttons του Message Box. 3

Άνοιγμα αρχείου using namespace System: : IO (1/3) Ø String^ file. Name; File. Stream^

Άνοιγμα αρχείου using namespace System: : IO (1/3) Ø String^ file. Name; File. Stream^ fs; Stream. Reader^ sr; this->open. File. Dialog 1 ->Default. Ext = "txt"; this->open. File. Dialog 1 ->File. Name = "txt. Display. txt"; this->open. File. Dialog 1 ->Filter="Text files (*. txt)|*. txt|All files (*. *|*. *)"; this->open. File. Dialog 1 -> Initial. Directory =Application: : Executable. Path; if ( open. File. Dialog 1 ->Show. Dialog() == System: : Windows: : Forms: : Dialog. Result: : OK) 6

Άνοιγμα αρχείου (2/3) try { file. Name = open. File. Dialog 1 ->File. Name;

Άνοιγμα αρχείου (2/3) try { file. Name = open. File. Dialog 1 ->File. Name; fs = gcnew File. Stream(file. Name, File. Mode: : Open, File. Access: : Read. Write); sr = gcnew Stream. Reader(fs); txt. Display->Text = sr->Read. To. End(); sr->Close(); } catch (System: : Exception ^e) { Message. Box: : Show("File Open Error: n" + e->To. String(), "File Open Error", Message. Box. Buttons: : OK, Message. Box. Icon: : Error); sr->Close(); } 7