如何讓TComboBox之內容完整顯示? |
尚未結案
|
wangjp
一般會員 發表:2 回覆:3 積分:1 註冊:2003-07-25 發送簡訊給我 |
|
dllee
站務副站長 發表:321 回覆:2519 積分:1711 註冊:2002-04-15 發送簡訊給我 |
void __fastcall TForm1::ComboBox1Change(TObject *Sender) { ComboBox1->Hint=ComboBox1->Text; }記得將 ComboBox1 的 ShowHint 屬性設 true 如果內容不會修改,是固定的 ItemList 則可以設定其 Style 為 csDropDownList 沒空更新的網頁... http://dllee.ktop.com.tw C及指標教學,計算機概論,資訊管理導論... http://dllee.adsldns.org 介紹Shells,LiteStep,GeoShell....
------
http://www.ViewMove.com |
wangjp
一般會員 發表:2 回覆:3 積分:1 註冊:2003-07-25 發送簡訊給我 |
|
wangjp
一般會員 發表:2 回覆:3 積分:1 註冊:2003-07-25 發送簡訊給我 |
|
dllee
站務副站長 發表:321 回覆:2519 積分:1711 註冊:2002-04-15 發送簡訊給我 |
引言: hi dllee, 這個方法我已試過,不過我想要的功能是當滑鼠移到下拉選單的項目時,該項目能以hint的方式顯示,或是下拉選單的寛度能改成最長項目的長度。對不起,我會錯意了 可能找找 >< face="Verdana, Arial, Helvetica">引言: Provides access to the window handle for the list portion of the combo box. __property HWND ListHandle = {read=FListHandle, nodefault}; Description Read ListHandle for Windows API calls that need a handle for the window used by the list portion of the combo box. 本來以為可以用它經由 SetWindowPos() 這個 API 來改變視窗的大小,但實驗的結果並不樂觀... // .h // 一個與 TCustomComboBox 相同的物件,只是可以取出 ListHandle class TMyComboBox : public TCustomComboBox { public: HWND __fastcall GetListHandle(void) { return this->ListHandle; } public: inline __fastcall virtual TMyComboBox(Classes::TComponent* AOwner) : TCustomComboBox(AOwner) { } inline __fastcall virtual ~TMyComboBox(void) { } public: inline __fastcall TMyComboBox(HWND ParentWindow) : TCustomComboBox(ParentWindow) { } }; // .cpp void __fastcall TFormTest::ComboBox1DropDown(TObject *Sender) { TMyComboBox *MyComboBox=(TMyComboBox *)ComboBox1; HWND hwnd=MyComboBox->GetListHandle(); if(hwnd!=NULL) { SetWindowPos(hwnd, NULL, 0,0, 300, // 新的寬 400, // 新的高 SWP_NOMOVE | SWP_NOZORDER); } }所得到的 hwnd 都是 NULL!! 連想改的機會都沒有... 後來,去追 TCustomComboBox 的 VCL 原始碼,發現這個 ListHandle 也不是它自己去產生視窗的 Handle,而是向 Windows 系統要的,因為 ComboBox 其實是 Windows 系統提供的物件,只是 BCB/Delphi 幫我們把它包成 VCL,其內部有大部分的功能都是系統提供的功能。 So... 找 3rd party 的元件比較快... 如果要自己作,那可能下拉視窗要自己作才有可能。 沒空更新的網頁... http://dllee.ktop.com.tw C及指標教學,計算機概論,資訊管理導論... http://dllee.adsldns.org 介紹Shells,LiteStep,GeoShell....
------
http://www.ViewMove.com |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |