|
API말고 TEdit를 동적생성해서 사용하세요.
아래처럼 마우스 클릭하면 TEdit 동적 생성해서
입력 받을 수 있습니다.
// TForm1.h -----------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
void __fastcall FormMouseDown(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y);
void __fastcall EditExit(TObject *Sender);
private: // User declarations
TEdit *pE;
int x, y;
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
// TForm1.cpp ---------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseDown(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
x = X;
y = Y;
pE = new TEdit( this );
pE->Parent = this;
pE->Top = Y;
pE->Left = X;
pE->Width = 150;
//pE->ParentColor = true; // 배경색과 같게하느냐 아니면 default(흰색)을 쓰는가
pE->BorderStyle = bsNone;
pE->OnExit = EditExit;
pE->Visible = true;
ActiveControl = pE;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::EditExit(TObject *Sender)
{
if( pE == NULL ) return;
Canvas->TextOut( pE->Left, pE->Top, pE->Text );
delete pE;
}
//---------------------------------------------------------------------------
^^* 님이 쓰신 글 :
: Timage에다가 마우스 클릭하믄 글짜가 써지는 걸 만들라구 하는데영...
: GetCaretPos나 SetCaretPos를 이용하라는디...ㅡㅜ:
: 에이피 아이는 영 꽝 이라서영...
: 어캐 하믄 돼는지 쪼금만 도움을 주셔영...
|