Delphi Combobox在Win7中放置在状态栏中时的下拉行为

Delphi Combobox在Win7中放置在状态栏中时的下拉行为,delphi,windows-7,combobox,delphi-xe,Delphi,Windows 7,Combobox,Delphi Xe,我有一个Delphi应用程序,它放置了combobox。最近在迁移到Win7之后,注意到combobox下拉列表的行为很有趣。它在XP中工作正常,在XP中,从状态栏rectange下拉组合框。但在Windows7中,组合框下拉区域在顶部屏幕上闪烁显示。必须按住鼠标键才能显示,但这不允许选择任何项目 不确定是否有其他人也经历过同样的经历?请告知在Win 7中需要进行哪些特殊处理,以便将combobox下拉列表放置在状态栏中时能够完美工作 备注:表单上的Combobox在Win7中正常运行。仅当co

我有一个Delphi应用程序,它放置了combobox。最近在迁移到Win7之后,注意到combobox下拉列表的行为很有趣。它在XP中工作正常,在XP中,从状态栏rectange下拉组合框。但在Windows7中,组合框下拉区域在顶部屏幕上闪烁显示。必须按住鼠标键才能显示,但这不允许选择任何项目

不确定是否有其他人也经历过同样的经历?请告知在Win 7中需要进行哪些特殊处理,以便将combobox下拉列表放置在状态栏中时能够完美工作

备注:表单上的Combobox在Win7中正常运行。仅当combobox位于状态栏内时,才会显示上述行为

感谢您的评论和/或建议

谢谢

演示代码:

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.

我认为您需要的是一个塞子,以便事件处理程序知道何时停止绘制画布或何时不执行

或者你可以试试这个,它对我有用(Windows8上的DelphiXE,将combobox放在状态栏中,并将其行为更改为“下拉”项目列表)


哪个德尔福版本?谢谢大卫。这是Delphi XE-Update 1I无法复制您的问题(XE Update 1,W764-SP1)。我观察到的唯一异常是难以说服IDE让状态栏成为组合框的父对象。谢谢Sertac。我在W7 Pro 64位SP1上创建了一个演示应用程序。它表现出与上述相同的行为。评论区不允许我发布所有代码。所以,用演示代码更新我的问题。@user-我的建议是,不要试图在绘制周期中修改控件的位置。将组合框放置在其他位置。您可以在创建组合框时应用初始位置。如果框的位置也取决于状态栏的大小,那么您可能希望使用状态栏的OnResize事件。
procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar; Panel: TStatusPanel; const Rect: TRect);
begin
  if Panel = StatusBar1.Panels[0] then
    with ComboBox1 do
    begin
      if Top = Rect.Top then Exit; //add this 
      Top := Rect.Top;
      Left := Rect.Left;
      Width := Rect.Right - Rect.Left - 5;
      Height := Rect.Bottom - Rect.Top - 10;
    end
end;