|
TTrackBar에는 마우스에 대한 이벤트가 없습니다.
그래서, 상속 받아서 만들어 봤습니다.
//--- Unit1.h ---
//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ComCtrls.hpp>
//---------------------------------------------------------------------------
class TMyTrackBar : public TTrackBar
{
__published:
__property OnMouseDown;
__property OnMouseUp;
public:
__fastcall TMyTrackBar(HWND ParentWindow) : TTrackBar(ParentWindow){}
};
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TButton *Button1;
void __fastcall FormCreate(TObject *Sender);
private: // User declarations
TMyTrackBar *myTB1;
void __fastcall MyTrackBarMouseUp(TObject *Sender,TMouseButton Button,
TShiftState Shift, int x, int y);
public: // User declarations
protected:
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
// --- Unit1.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::MyTrackBarMouseUp(TObject *Sender,TMouseButton Button,
TShiftState Shift, int x, int y)
{
ShowMessage("Good");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
myTB1 = new TMyTrackBar(Form1);
myTB1->Parent = Form1;
myTB1->Left = 100;
myTB1->Top = 100;
myTB1->OnMouseUp = MyTrackBarMouseUp;
}
//---------------------------------------------------------------------------
건승을 빕니다.
김정현 님이 쓰신 글 :
: Trackbar의 slider를 움직이면 OnChange 이벤트가 항상 발생하는데요...
: VC++의 Slider에 있는 ReleasedCapture 이벤트 같은 slider를 움직이다가 멈췄을 경우에만
: 발생하는 이벤트는 없나요?
:
: 도와주삼~~~~ ㅠㅠ
|