奇怪的问题,请高人指点(系统、消息、菜单)(200)

  • 主题发起人 delphibbs_Lee
  • 开始时间
D

delphibbs_Lee

Unregistered / Unconfirmed
GUEST, unregistred user!
以下工程在Win2K或者WinXP的桌面主题为Windows经典时,Form2的菜单可以正常刷新,但是在WinXP显示为XP风格时不可以正常刷新。在 http://bbs.2ccc.com/topic.asp?topicid=318199 有该问题的完整代码(附件)本人之前一直用Win2K,最近发现该问题无法解答,望高人指点。工程为Delphi7编译。 由于不可以添加附件,省略部分IDE自行产生文件:program Project1;uses Forms, Unit1 in 'Unit1.pas' {Form1}, Unit2 in 'Unit2.pas' {Form2};{$R *.res}begin Application.Initialize; Application.CreateForm(TForm1, Form1); Application.Run;end./////////////////////////////////////////////////////////////////////////////unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) btn1: TButton; procedure btn1Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); private public { Public declarations } end;var Form1: TForm1;implementationuses Unit2;{$R *.dfm}procedure TForm1.btn1Click(Sender: TObject);begin //点击按钮创建另一个窗体 Form2 := TForm2.Create(Self); Form2.ParentWindow := Handle; //设置该行就是想配合Unit2中CreateParam创建一个 Z-Pos 位于Form1之上的窗体 //如果没有Form2的Param.Style := Param.Style + WS_POPUP;行则Form2是 //嵌入在Form1中的 //之前在windows经典风格中始终可以正常工作,在XP风格就不可以了 Form2.Show;end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);begin if Form2 <> nil then FreeAndNil(Form2);end;end.///////////////////////////////////////////////////////////////////////////////object Form1: TForm1 Left = 366 Top = 164 Width = 335 Height = 201 Caption = 'Form1' Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] OldCreateOrder = False OnClose = FormClose PixelsPerInch = 96 TextHeight = 13 object btn1: TButton Left = 104 Top = 60 Width = 75 Height = 25 Caption = 'btn1' TabOrder = 0 OnClick = btn1Click endend//////////////////////////////////////////////////////////////////////////unit Unit2;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Menus;type TForm2 = class(TForm) mm1: TMainMenu; mnia1: TMenuItem; mnib1: TMenuItem; mnic1: TMenuItem; mniddd1: TMenuItem; procedure FormPaint(Sender: TObject); private { Private declarations } public procedure CreateParams(var Param: TCreateParams); override; end;var Form2: TForm2;implementation{$R *.dfm}procedure TForm2.CreateParams(var Param: TCreateParams);begin inherited; Param.Style := Param.Style + WS_POPUP;end;procedure TForm2.FormPaint(Sender: TObject);begin //end;end.///////////////////////////////////////////////////////////////////////////////object Form2: TForm2 Left = 192 Top = 145 Width = 573 Height = 348 Caption = 'Form2' Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] Menu = mm1 OldCreateOrder = False OnPaint = FormPaint PixelsPerInch = 96 TextHeight = 13 object mm1: TMainMenu Left = 176 Top = 84 object mnia1: TMenuItem Caption = 'aaaaaa' object mnib1: TMenuItem Caption = 'b' end end object mnic1: TMenuItem Caption = 'cccccc' object mniddd1: TMenuItem Caption = 'ddd' end end endend//////////////////////////////////////////////////////////////////以上
 
用frame看看。
 
帮你测试了,确实不可以。楼上的方法确实很不错。
 
procedure TForm1.FormCreate(Sender: TObject);var form2 : TForm; i : Integer;begin for i :=1 to 10 do begin form2 := TForm.Create(Self); form2.ParentWindow := Handle; form2.Show; end;end;在我这里好使呀
 
感谢你的测试
 

Similar threads

I
回复
0
查看
615
import
I
I
回复
0
查看
445
import
I
S
回复
0
查看
692
SUNSTONE的Delphi笔记
S
顶部 底部