Write a sending image file program in C ++ Builder (3)

zhaozj2021-02-17  45

//

Source code of "Unit1.cpp"

/ / -------------------------------------------------------------------------------------------- ---------------------------

#include $ # @ 60; vcl.h $ # @ 62;

#pragma HDRSTOP

#include "unit1.h"

/ / -------------------------------------------------------------------------------------------- ---------------------------

#pragma package (smart_init)

#pragma resource "* .dfm"

TFORM1 * FORM1;

/ / -------------------------------------------------------------------------------------------- ---------------------------

__fastcall tform1 :: tform1 (tComponent * Owner)

: TFORM (OWNER)

{

}

/ / -------------------------------------------------------------------------------------------- ---------------------------

//

open a file

Void __fastcall tform1 :: button3click (TOBJECT * Sender)

{

IF (OpenPictureDialog1 - $ # @ 62; execute ())

Edit2 - $ # @ 62; Text = OpenPictureDialog1 - $ # @ 62; filename;

}

/ / -------------------------------------------------------------------------------------------- ---------------------------

//

Send image file

Void __fastcall tform1 :: button1click (Tobject * Sender)

{

TFileStream * myfstream;

Myfstream = New TFileStream (OpenPictureDialog1 - $ # @ 62; filename, fmopenread);

Try

{NMSTRM1 - $ # @ 62; host = edit1 - $ # @ 62; text; // Specify host name

NMSTRM1 - $ # @ 62; postit (myfstream); // Send file

}

Catch (...) {}

}

/ / -------------------------------------------------------------------------------------------- ---------------------------

//

Display image file

Void __fastcall tform1 :: button2click (Tobject * Sender)

{

Image1 - $ # @ 62; Picture - $ # @ 62; loadingfromfile (".// Tmp.BMP");

}

/ / -------------------------------------------------------------------------------------------- ---------------------------

//

Connect to remote host void __fastcall tform1 :: nmstrm1connect (TOBJECT * SENDER)

{

STATUSBAR1 - $ # @ 62; simpletext = "connection";

}

/ / -------------------------------------------------------------------------------------------- ---------------------------

//

This event is generated when there is no connection to the host

Void __fastcall tform1 :: nmstrm1connectionfailed (TOBJECT * SENDER)

{

ShowMessage ("Unable to connect to each other");

/ / -------------------------------------------------------------------------------------------- ---------------------------

//

This event is generated when the client file is sent to

Void __fastcall tform1 :: nmstrm1disconnect (TOBJECT * SENDER)

{

IF (statusbar1! = 0)

STATUSBAR1 - $ # @ 62; simpletext = "files are sent";

}

/ / -------------------------------------------------------------------------------------------- ---------------------------

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

New Post(0)