線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1016
推到 Plurk!
推到 Facebook!

Clipboard 取出來的 event 不能動,該怎ㄇ解決?

尚未結案
wsxcv123
一般會員


發表:36
回覆:27
積分:12
註冊:2004-11-10

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-12-23 14:22:50 IP:61.222.xxx.xxx 未訂閱
我有一個 component: 在 component 的 panel 案 double click 會把 component 裡面的 string 秀出來。    //Component //CTestPanel.h #ifndef CTestPanelH #define CTestPanelH //------------------------------------------------------------------- #include  #include #include #include //------------------------------------------------------------------- class PACKAGE CTestPanel : public TPanel { private: TPanel *m_pPanel; TStringList *m_StrList; void __fastcall DlClick(TObject *Sender); protected: public: __fastcall CTestPanel(TComponent* Owner); __fastcall ~CTestPanel(); __published: __property TPanel *Panel = {read = m_pPanel, write = m_pPanel}; __property TStringList *StrList = {read = m_StrList, write = m_StrList}; }; //------------------------------------------------------------------- #endif //CTestPanel.cpp #include <basepch.h> #pragma hdrstop #include "CTestPanel.h" #pragma package(smart_init) //------------------------------------------------------------------ // ValidCtrCheck is used to assure that the components created do // not have any pure virtual functions. static inline void ValidCtrCheck(CTestPanel *) { new CTestPanel(NULL); } //------------------------------------------------------------------ __fastcall CTestPanel::CTestPanel(TComponent* Owner) : TPanel(Owner) { Width = 200; Height = 100; m_pPanel = new TPanel(this); m_pPanel->Parent = this; m_pPanel->Left = 20; m_pPanel->Top = 20; m_pPanel->Width = Width - 40; m_pPanel->Height = Height - 40; m_pPanel->Color = clInfoBk; m_pPanel->Caption = "Double Click me"; m_pPanel->OnDblClick = DlClick; m_StrList = new TStringList(); } //------------------------------------------------------------------- void __fastcall CTestPanel::DlClick(TObject *Sender) { if(m_StrList->Count > 0) { for(int i = 0; i < m_StrList->Count; i ) Application->MessageBoxA(m_StrList->Strings[i].c_str(),"Inside",0); } else Application->MessageBoxA("Empty","Inside",0); } //------------------------------------------------------------------- __fastcall CTestPanel::~CTestPanel() { delete m_pPanel; m_StrList->Clear(); delete m_StrList; } //------------------------------------------------------------------- namespace Ctestpanel { void __fastcall PACKAGE Register() { TComponentClass classes[1] = {__classid(CTestPanel)}; RegisterComponents("Samples", classes, 0); } } //------------------------------------------------------------------- ////////////////////////////////////////////////////////////// Form 的 code //Unit.h #ifndef Unit1H #define Unit1H //--------------------------------------------------------------------------- #include #include #include #include <Forms.hpp> #include //------------------------------------------------------------------- class TForm1 : public TForm { __published: // IDE-managed Components TButton *ButtonAdd; TButton *ButtonCut; TButton *ButtonPaste; void __fastcall ButtonAddClick(TObject *Sender); void __fastcall FormCreate(TObject *Sender); void __fastcall ButtonCutClick(TObject *Sender); void __fastcall ButtonPasteClick(TObject *Sender); private: // User declarations CTestPanel *pTest; public: // User declarations __fastcall TForm1(TComponent* Owner); }; //------------------------------------------------------------------- extern PACKAGE TForm1 *Form1; //------------------------------------------------------------------- #endif //Unit.cpp #include #pragma hdrstop #include "CTestPanel.h" #include "Unit1.h" //------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { TMetaClass *MetaClassTestPanel = __classid(CTestPanel); RegisterClasses(&MetaClassTestPanel, 0); } //------------------------------------------------------------------- void __fastcall TForm1::FormCreate(TObject *Sender) { pTest = new CTestPanel(this); pTest->Parent = this; pTest->Left = 100; pTest->Top = 100; } //------------------------------------------------------------------- void __fastcall TForm1::ButtonAddClick(TObject *Sender) { for(int i = 0; i < 5; i ) pTest->StrList->Add("String : " IntToStr(i 1)); } //------------------------------------------------------------------- void __fastcall TForm1::ButtonCutClick(TObject *Sender) { Clipboard()->SetComponent(pTest); delete pTest; } //------------------------------------------------------------------- void __fastcall TForm1::ButtonPasteClick(TObject *Sender) { CTestPanel *tpTmp; tpTmp = (CTestPanel *)Clipboard()->GetComponent(this, this); ShowMessage("out count = " IntToStr(tpTmp->StrList->Count) ); } //------------------------------------------------------------------- Paste 之後,案 double click 沒有反應 該怎ㄇ解決阿?
系統時間:2024-04-28 8:46:39
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!