Project source
Form header (C++)
Form source (C++)
Form source (DFM)
Project source: CPPTest.cpp |
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop USERES("CPPTest.res"); USEFORM("fmCPPTest.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: fmCPPTest.h |
//--------------------------------------------------------------------------- #ifndef fmCPPTestH #define fmCPPTestH //--------------------------------------------------------------------------- #include <Classes.hpp> #include <Controls.hpp> #include <StdCtrls.hpp> #include <Forms.hpp> #include <ExtCtrls.hpp> #include "uoole.hpp" //--------------------------------------------------------------------------- class TForm1 : public TForm { __published: // IDE-managed Components TUOTextTarget *UOTextTarget1; TPanel *Panel1; TMemo *Memo1; TPanel *Panel2; TImage *Image1; TUOGraphicTarget *UOGraphicTarget1; void __fastcall UOTextTarget1Drop(TObject *Sender, TWinControl *Acceptor, const AnsiString dropText, int X, int Y); void __fastcall UOGraphicTarget1Drop(TObject *Sender, TWinControl *Acceptor, TPicture *thePicture, int X, int Y); private: // User declarations public: // User declarations __fastcall TForm1(TComponent* Owner); }; //--------------------------------------------------------------------------- extern PACKAGE TForm1 *Form1; //--------------------------------------------------------------------------- #endifBack to top |
Form source: fmCPPTest.cpp |
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "fmCPPTest.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "uoole" #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) { // Someone dropped text or a URL on us. TUOTextTarget *uott; AnsiString s; uott = (TUOTextTarget*) Sender; // If it's a URL, put "title = URL" on the memo if (uott->DroppedTextFormat == dtfURL) { s = ((TUOTextTarget*) Sender)->URLTitle + " = " + dropText; } else { // if it's ordinary text, put that on the memo s = dropText; } // Add the string to the memo Memo1->Lines->Add(s); } //--------------------------------------------------------------------------- void __fastcall TForm1::UOGraphicTarget1Drop(TObject *Sender, TWinControl *Acceptor, TPicture *thePicture, int X, int Y) { // Someone dropped a picture on us. Give it to the image control. Image1->Picture = thePicture; } //---------------------------------------------------------------------------Back to top |
Form source: fmCPPTest.dfm |
object Form1: TForm1 Left = 245 Top = 220 Width = 508 Height = 298 Caption = 'C++Builder test of OLE Drag and Drop Components' 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 = 500 Height = 129 Align = alTop BevelOuter = bvNone Caption = 'Panel1' TabOrder = 0 object Memo1: TMemo Left = 0 Top = 0 Width = 500 Height = 129 Align = alClient Lines.Strings = ( 'Drag text or a URL onto this memo.') TabOrder = 0 end end object Panel2: TPanel Left = 0 Top = 129 Width = 500 Height = 142 Align = alClient BevelOuter = bvNone Caption = 'Drag an image onto this blank space' TabOrder = 1 object Image1: TImage Left = 0 Top = 0 Width = 500 Height = 142 Align = alClient end end object UOTextTarget1: TUOTextTarget AcceptorControl = Memo1 AcceptTextFormats = [dtfURL, dtfText] OnDrop = UOTextTarget1Drop Left = 48 Top = 56 end object UOGraphicTarget1: TUOGraphicTarget AcceptorControl = Panel2 AcceptGraphicFormats = [dgfMetafile, dgfBitmap] PreferredFormat = dgfMetafile OnDrop = UOGraphicTarget1Drop Left = 48 Top = 201 end endBack to top |