Question : Button Combobox

Hello,

Since Windows Vista, for example, the "Address bar" is like a Combobox where you can click in the path example

C:\Windows\System32\

You can click in Windows or C:\, not necessarily click in the backward button

To see what i'm talking about, open in Windows 7 the control panel and navigate in categories... in the address bar, you can return or choose another path by clicking in the buttons inside the combobox!

Somebody know some component that simulate the same? I already saw, but don't remember the name :/

Regards,
Carlos

Answer : Button Combobox

On versions of Windows later then Win95, you can subclass an edit control to
intercept the WM_CTLCOLOREDIT message (for TEdit, it would be
CN_CTLCOLOREDIT instead) and return a brush that is created from a bitmap.
You can then draw a bitmap of whatever type of progress display you want.
Here is a simple example:

TForm1 = class(TForm)
published
Edit1: TEdit;
Timer1: TTimer;
procedure FormCreate(Sender: TObject)
procedure Timer1Timer(Sender: TObject);
private
OldWndProc: TWndMethod;
procedure EditWndProc(var Message: TMessage);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
OldWndProc := Edit1.WindowProc;
Edit1.WindowProc := EditWndProc;
end;

procedure TForm1.EditWndProc(var Message: TMessage);
var
bmp: TBitmap;
r: TRect;
oldRight: Integer;
begin
if Message.Msg = CN_CTLCOLOREDIT then
begin
Windows.SetTextColor(Message.WParam,
ColorToRGB(Edit1.Font.Color));
Window.SetBkMode(Message.WParam, TRANSPARENT);

bmp := TBitmap.Create;
try
r := Edit1.ClientRect;
bmp.Width := (r.Right - r.Left);
bmp.Height := (r.Bottom - r.Top);

if Edit1.Tag > 0 then
begin
oldRight := r.Right;
r.Right := r.Left + ((r.Right - r.Left) *
(Extended(Edit1->Tag) / 100);

bmp.Canvas.Brush.Color := clAqua;
bmp.Canvas.FillRect(r);

r.Left := r.Right;
r.Right := oldRight;
end;

bmp.Canvas.Brush.Color := Edit1.Color;
bmp.Canvas.FillRect(r);

Message.Result := Windows.CreatePatternBrush(bmp.Handle);
finally
bmp.Free;
end;

Exit;
end;

OldWndProc(Message);
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
// I set Timer1.Interval to 50ms...

if Edit1.Tag >= 100 then
Edit1.Tag := 0
else
Edit1.Tag := Edit1.Tag + 1;

Edit1.Invalidate;
end;
Random Solutions  
 
programming4us programming4us