I have a Delphi application which has placed combobox. Recently after migrating to Win 7, notice behavior of combobox drop down is funny. It works fine as expected in XP where combobox dropdown from status bar rectange. But in Windows 7, Combobox drop down area is shown at top screen with flickering. One will have to keep the mouse button down to keep that shown, but that doesn't allow selecting any item.
Not sure if any other has experienced the same? Please advise what special handling need to be done in Win 7 for the combobox drop down to work perfectly when placed inside Status bar.
PS: Combobox placed on form behaves normally in Win7. Above cited behavior is only shown when combobox is placed inside status bar.
Appreciate your comments and/or suggestions.
Thanks.
Demo Code:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
StatusBar1: TStatusBar;
ComboBox1: TComboBox;
procedure FormCreate(Sender: TObject);
procedure StatusBar1DrawPanel(StatusBar: TStatusBar; Panel: TStatusPanel;
const Rect: TRect);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
Style, idx: Integer;
begin
StatusBar1.Panels[0].Style := psOwnerDraw;
ComboBox1.Parent := StatusBar1;
Style := GetWindowLong(ComboBox1.Handle, GWL_EXSTYLE);
Style := Style - WS_EX_STATICEDGE;
SetWindowLong(ComboBox1.Handle, GWL_EXSTYLE, Style);
for idx := 1 to 20 do
ComboBox1.Items.Add(Format('Test Item %d',[idx]));
end;
procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar; Panel: TStatusPanel;
const Rect: TRect);
begin
if Panel = StatusBar1.Panels[0] then
with ComboBox1 do
begin
Top := Rect.Top;
Left := Rect.Left;
Width := Rect.Right - Rect.Left - 5;
Height := Rect.Bottom - Rect.Top - 10;
end
end;
end.