Placing an image inside a combo box (right edge) in Delphi / Win32

I want to draw an image inside a combo box (right edge) in Delphi / Win32.

The mapping has a csDropDown style. This does not work with csOwnerDrawFixed or csOwnerDrawVariable.

The combobox should be editable similarly to the address bar of the browser.

Is there a Win32 solution without creating an additional Delphi component?

I tried the following, but that will not work. Can I do this with Delphi 7?

TForm1 = class(TForm) ... private FChDirComboWndProc: TWndMethod; procedure ChDirComboWndProc(var Message: TMessage); ... procedure TForm1.FormCreate(Sender: TObject); begin FChDirComboWndProc := ChDirComboBox.WindowProc; // save old window proc ChDirComboBox.WindowProc := ChDirComboWndProc; // subclass end; procedure TForm1.ChDirComboWndProc(var Message: TMessage); begin WM_ERASEBKGND: begin // WM_PAINT ? SetBkMode(Message.WParam, TRANSPARENT); SetTextColor(Message.wParam, GetSysColor(COLOR_GRAYTEXT)); FillRect(Message.wParam, Rect(3,3,300,30), GetStockObject(BLACK_BRUSH )); Rectangle(Message.wParam, 15,15, 100, 100); //Test OutputDebugString(PCHar(Format('aa %d %d %d',[Message.WParam, Message.LParam, ChDirComboBox.Handle]))); end; end; FChDirComboWndProc(Message); // process message end; 
+6
source share
1 answer

The way to do this is to implement Owner-Drawn Combo Boxes . See Custom Color Cabinets on MSDN or find a Delphi sample, for example. Draw owner - ComboBox .

+2
source

Source: https://habr.com/ru/post/899202/


All Articles