Sample Application: CPPURLTest.cpp

Project source
Form header (C++)
Form source (C++)
Form source (DFM)

Design-time form image
Project source: CPPURLTest.cpp

//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
USERES("CPPURLTest.res");
USEFORM("fmCPPURLtest.cpp", Form1);
//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
    try
    {
        Application->Initialize();
        Application->CreateForm(__classid(TForm1), &Form1);
        Application->Run();
    }
    catch (Exception &exception)
    {
        Application->ShowException(&exception);
    }
    return 0;
}
//------------------
Back to top
Form header: fmCPPURLTest.h

//---------------------------------------------------------------------------
#ifndef fmCPPURLtestH
#define fmCPPURLtestH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "uoole.hpp"
#include <ComCtrls.hpp>
#include <ExtCtrls.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:	// IDE-managed Components
    TUOTextTarget *UOTextTarget1;
    TPanel *Panel1;
    TListView *ListView1;
    void __fastcall UOTextTarget1Drop(TObject *Sender,
          TWinControl *Acceptor, const AnsiString dropText, int X, int Y);
private:	// User declarations
public:		// User declarations
    __fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
Back to top
Form source: fmCPPURLTest.cpp

//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop

#include "fmCPPURLtest.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "uoole"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::UOTextTarget1Drop(TObject *Sender,
      TWinControl *Acceptor, const AnsiString dropText, int X, int Y)
{
  TUOTextTarget* uott;
  TListItem* aLi;

  // Cast Sender to a TUOTextTarget for simplicity
  uott = (TUOTextTarget*) Sender;

  // Add a new item to the list view
  aLi = ListView1->Items->Add();

  // Set its caption as the URL title dropped
  aLi->Caption = uott->URLTitle;
  // And its URL as the first sub-item
  aLi->SubItems->Add(dropText);

}
//---------------------------------------------------------------------------
Back to top
Form source: fmCPPTest.dfm

object Form1: TForm1
  Left = 245
  Top = 170
  Width = 443
  Height = 267
  Caption = 'Drag a URL from IE or Netscape onto this list view'
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  PixelsPerInch = 96
  TextHeight = 13
  object Panel1: TPanel
    Left = 0
    Top = 0
    Width = 435
    Height = 240
    Align = alClient
    BevelOuter = bvNone
    BorderWidth = 3
    Caption = 'Panel1'
    TabOrder = 0
    object ListView1: TListView
      Left = 3
      Top = 3
      Width = 429
      Height = 234
      Align = alClient
      ColumnClick = False
      Columns = <
        item
          Caption = 'Title'
          Width = 175
        end
        item
          Caption = 'URL'
          Width = 250
        end>
      TabOrder = 0
      ViewStyle = vsReport
    end
  end
  object UOTextTarget1: TUOTextTarget
    AcceptorControl = ListView1
    AcceptTextFormats = [dtfURL]
    OnDrop = UOTextTarget1Drop
    Left = 64
    Top = 136
  end
end

Back to top

Back to the examples page