修復lazarus linux(ubuntu/銀河麒麟)Object Inspector、使用combobox、colorbox等控件style為csOwnerDraw*時下拉列表文字不顯示的問題(在樹莓派正常),這類問題大概率是ubuntu/銀河麒麟引起的,如果使用中也遇到同樣的問題可參照以下方法處理。
打開lazarus/lcl/include/customcombobox.inc,(第109行)定位TCustomComboBox.DrawItem(Index: Integer; ARect: TRect; State: TOwnerDrawState);
添加紅字1行,重繪背景,重新編譯應用程序就可以解決Object Inspector、combobox和colorbox列表的不顯示item的問題,這方法不一定是最佳的,但能解決我遇到的問題。
修復前:


修復后:

procedure TCustomComboBox.DrawItem(Index: Integer; ARect: TRect; State: TOwnerDrawState); begin //TControlCanvas(FCanvas).UpdateTextFlags; //2022.05.28 LBZ {$ifdef linux} FCanvas.FillRect(ARect); {$endif} //2022.05.28 LBZ if Assigned(FOnDrawItem) then FOnDrawItem(Self, Index, ARect, State) else begin if not (odBackgroundPainted in State) then FCanvas.FillRect(ARect) else InternalDrawItem(Self, FCanvas, ARect, Items[Index]); end; end;

浙公網安備 33010602011771號