⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.cpp

📁 C++Builder网络应用例程. C++Builder网络应用例程.
💻 CPP
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <printers.hpp>

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
 HTML1->RequestDoc(Host->Text);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::HTML1BeginRetrieval(TObject *Sender)
{
 Host->Text=HTML1->URL;
 ProgressBar1->Max=HTML1->RetrieveBytesTotal;        
}
//---------------------------------------------------------------------------
void __fastcall TForm1::HTML1UpdateRetrieval(TObject *Sender)
{
 ProgressBar1->Position=HTML1->RetrieveBytesDone;        
}
//---------------------------------------------------------------------------
void __fastcall TForm1::HTML1EndRetrieval(TObject *Sender)
{
 ProgressBar1->Position=0;        
}
//---------------------------------------------------------------------------
void __fastcall TForm1::HTML1Timeout(TObject *Sender)
{
 StatusBar1->SimplePanel=true;
 StatusBar1->SimpleText="Time Out!";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::HostKeyDown(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
 if(Key==VK_RETURN)
   Button1Click(Sender);        
}
//---------------------------------------------------------------------------
void __fastcall TForm1::HTML1LayoutComplete(TObject *Sender)
{
 StatusBar1->SimpleText="Layout Complete";        
}
//---------------------------------------------------------------------------
void __fastcall TForm1::HTML1ParseComplete(TObject *Sender)
{
 StatusBar1->SimpleText="Parse Complete";        
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button5Click(TObject *Sender)
{
 HTML1->RequestDoc("202.112.87.220/IISSamples/Default/welcome.htm");        
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
 //OleVariant& Message;
 //HTML1->Cancel(Message);
}
//---------------------------------------------------------------------------
/*调用HTML控件的BeginPrinting方法,
用于在打印前进行设置工作。然后调用控件
的PrintPage方法,调用文档中的指定页,
此方法的定义为:
Procedure PrintPage(int hDC, int PageNumber),
参数hDC时打印机的设备描述表,
PageNumber参数指定要打印的页码。
最后调用EndPrinting,结束对打印的设置。
下一步就调用Printer()对象的EndDoc方法开始打印文档。*/
void __fastcall TForm1::Button3Click(TObject *Sender)
{
 int Page=1;
 bool DonePrinting=false;
 Printer()->BeginDoc();
 HTML1->BeginPrinting((int)(Printer()->Handle),0,0,HTML1->Width,
                      HTML1->Height,NULL,NULL);
 while(!DonePrinting)   {
    HTML1->PrintPage((int)(Printer()->Handle),Page);
	    Page+=1;
    DonePrinting=HTML1->IsPrintingDone(Page);
    Printer()->NewPage();
   }
 HTML1->EndPrinting();
 Printer()->EndDoc();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
 Printer()->BeginDoc();
 HTML1->AutoPrint((int)(Printer()->Handle));
 Printer()->EndDoc();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::HTML1MouseUp(TObject *Sender, TMouseButton Button,
      TShiftState Shift, int X, int Y)
{
 if(Button==mbRight)
   PopupMenu1->Popup(X,Y);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RadioGroup1Click(TObject *Sender)
{
 if(RadioGroup1->ItemIndex==0)
   HTML1->ViewSource=false;
 else
   HTML1->ViewSource=true;
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -