Delphi轉成BCB程式.. |
答題得分者是:chtai
|
pika2005
初階會員 發表:27 回覆:48 積分:25 註冊:2005-02-17 發送簡訊給我 |
大家好,小弟要把以下程式轉成BCB..而紅色內容是我改寫的..但是還是有錯..
Error Message:Call to undefined function 'Inc'..
請問使用Inc函數,要引用那個.h檔.. combobox中下拉後的內容不夠寬
http://delphi.ktop.com.tw/topic.php?topic_id=24612
procedure SetComboDropDownWidth(ComboBox: TComboBox; Width: Longint = -1); var I, TextLen: Longint; begin if Width < ComboBox.Width then begin ComboBox.Canvas.Handle := GetDC(ComboBox.Handle); try for I := 0 to ComboBox.Items.Count -1 do begin TextLen := ComboBox.Canvas.TextWidth(ComboBox.Items[I]); if TextLen > Width then Width := TextLen; end; (* Standard ComboBox drawing is Rect.Left 2, adding the extra spacing offsets this *) Inc(Width, 10); finally ReleaseDC(ComboBox.Handle, ComboBox.Canvas.Handle); end; end; SendMessage(ComboBox.Handle, CB_SETDROPPEDWIDTH, Width, 0); end; void __fastcall SetComboDropDownWidth(TComboBox *ComboBox1,int Width) { int I,TextLen; ShowMessage("1"); if(Width < ComboBox1->Width) { ComboBox1->Canvas->Handle = GetDC(ComboBox1->Handle); __try { for(I = 0;I < ComboBox1->Items->Count-1;I ) { AnsiString data = ComboBox1->Items->Strings[I].SubString(0,100); TextLen = ComboBox1->Canvas->TextWidth(data); if(TextLen > Width) Width = TextLen; } /*(* Standard ComboBox drawing is Rect.Left 2, adding the extra spacing offsets this *) */ Inc(Width, 10); } __finally { ReleaseDC(ComboBox1->Handle,ComboBox1->Canvas->Handle); } } SendMessage(ComboBox1->Handle, CB_SETDROPPEDWIDTH, Width, 0); } |
chtai
高階會員 發表:68 回覆:238 積分:116 註冊:2004-05-21 發送簡訊給我 |
引言:應該是for(I = 0;I < ComboBox1->Items->Count-1;I ) { ............... } Inc(Width, 10); for(I = 0; I < ComboBox1->Items->Count; I )而不是 Count-1 另, Inc(Width, 10); 就是 Width = 10; 啦 --
------
My Web: http://nelson.csie.us My Blog: http://blog.nelson.csie.us |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |