shinnuei
一般會員
![](./myimg/board/mystar_empty.gif)
![](images/icon_photo_none.gif) 發表:32 回覆:48 積分:21 註冊:2002-03-13
發送簡訊給我
|
各位先進大家好:
小弟最近想要找一個 hint 的元件,就像是 statplus 的泡泡式說明,但是我去
http://www.vclxx.org/
試了將近十個左右的元件,能正常出現hint的沒幾個,但是能使用的元件,也不太滿意他的效果。
於是只好自己寫了,小弟找到相關的討論,但是是用 delphi 寫的:
【Delphi】【問題】怎樣是組件的hint字串的字變大?
http://delphi.ktop.com.tw/topic.php?topic_id=42958
其中有一行程式(下方紅色那一行),不知道要怎麼翻成 bcb 的語法,
麻煩各位 delphi/bcb 雙修的先進指點。
Type
TMyHintWindow = Class (THintWindow)
Constructor Create (AOwner: TComponent); override;
end; Constructor TMyHintWindow.Create (AOwner: TComponent);
Begin
Inherited Create (Aowner);
Canvas.Font.Name := 'Times New Roman';
Canvas.Font.Size := 14;
end; procedure TForm1.FormCreate(Sender: TObject);
begin
Application.ShowHint := False;
HintWindowClass := TMyHintWindow;
Application.ShowHint := True;
end; end.
|
allenchan
資深會員
![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif)
![](images/icon_photo_none.gif) 發表:10 回覆:306 積分:283 註冊:2004-01-06
發送簡訊給我
|
試試看這樣行嗎? HintWindowClass = __classid(TMyHintWindow);
|
shinnuei
一般會員
![](./myimg/board/mystar_empty.gif)
![](images/icon_photo_none.gif) 發表:32 回覆:48 積分:21 註冊:2002-03-13
發送簡訊給我
|
to allenchan:
不行哦,他會出現
[Linker Error] Unresolved external '__fastcall Controls::THintWindow::NCPaint(void *)' referenced from C:\HINT\FORM1\UNIT1.OBJ
另外Edit1,Memo1 只是打了一些hint 上去,並把 showhint = true.
程式碼如下:
unit1.h
//--------------------------------------------------------------------------- #ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include
#include
#include
#include <Forms.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TButton *Button1;
TMemo *Memo1;
TEdit *Edit1;
void __fastcall Button1MouseMove(TObject *Sender, TShiftState Shift,
int X, int Y);
void __fastcall FormCreate(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
class TMyHintWindow : public THintWindow
{
private:
public:
__fastcall TMyHintWindow(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
unit1.cpp
//--------------------------------------------------------------------------- #include
#pragma hdrstop #include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1MouseMove(TObject *Sender,
TShiftState Shift, int X, int Y)
{//會一直產生重覆的物件,先不要管他
TRect rcTemp;
THintWindow * phwTest = new THintWindow(this); rcTemp.Top = 100;
rcTemp.Left = 100;
rcTemp.Bottom = 200;
rcTemp.Right = 200;
// phwTest->Font = "新細明體";
phwTest->Font->Size = 30;
phwTest->ActivateHint(rcTemp,"Hint Test");
}
//---------------------------------------------------------------------------
__fastcall TMyHintWindow::TMyHintWindow(TComponent* Owner) : THintWindow(Owner)
{
Canvas->Font->Name = "新細明體";
Canvas->Font->Size = 30;
}
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Application->ShowHint = false;
HintWindowClass = __classid(TMyHintWindow);
Application->ShowHint = true;
}
//---------------------------------------------------------------------------
|
allenchan
資深會員
![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif)
![](images/icon_photo_none.gif) 發表:10 回覆:306 積分:283 註冊:2004-01-06
發送簡訊給我
|
class TMyHintWindow : public THintWindow
{
private: protected:
virtual void __fastcall NCPaint(HDC DC)
{
TRect R(0, 0, Width, Height);
DrawEdge(DC, &R, BDR_RAISEDOUTER, BF_RECT);
}
public:
__fastcall TMyHintWindow(TComponent* Owner);
};
|
shinnuei
一般會員
![](./myimg/board/mystar_empty.gif)
![](images/icon_photo_none.gif) 發表:32 回覆:48 積分:21 註冊:2002-03-13
發送簡訊給我
|
謝謝 allenchan.
但小弟有一個疑問,為什麼下了這行程式
HintWindowClass = __classid(TMyHintWindow);
他會預設去找裡面的 NCPaint function呢?
|