E error2002 Unregistered / Unconfirmed GUEST, unregistred user! 2005-04-28 #1 程序中需要动态设置播放窗口大小,可是这个mediaplayer 9 的 大小变不了,aligen=alclient 或者 更改 width height都不能 像其他控件那样改变大小
E error2002 Unregistered / Unconfirmed GUEST, unregistred user! 2005-04-28 #2 程序中需要动态设置播放窗口大小,可是这个mediaplayer 9 的 大小变不了,aligen=alclient 或者 更改 width height都不能 像其他控件那样改变大小
D dawnsong Unregistered / Unconfirmed GUEST, unregistred user! 2005-04-28 #3 自己得到其Handle,然后调用SetWindowPos BOOL SetWindowPos(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx,//[in] Specifies the new width of the window, in pixels. int cy,//[in] Specifies the new height of the window, in pixels. UINT uFlags );
自己得到其Handle,然后调用SetWindowPos BOOL SetWindowPos(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx,//[in] Specifies the new width of the window, in pixels. int cy,//[in] Specifies the new height of the window, in pixels. UINT uFlags );
E error2002 Unregistered / Unconfirmed GUEST, unregistred user! 2005-04-28 #4 我可能没说清,我开发一个程序,嵌入一个TWindowsMediaPlayer 控件,动态创建后,放在一个Panel上,然后想改变其大小 请 dawnsong 说详细些好吗?
D dawnsong Unregistered / Unconfirmed GUEST, unregistred user! 2005-04-28 #5 procedure TForm1.FormCreate(Sender: TObject); begin wmp :=TWindowsMediaPlayer.Create(Self); wmp.Parent :=Panel1; wmp.Align :=alClient;//关键在此处 {我也试着改了下Width和Height,确实不管用,但上面Align就可以了,应该解决问题了} wmp.Show; end; procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin wmp.Destroy; end; procedure TForm1.FormDblClick(Sender: TObject); begin Panel1.Left :=10; Panel1.Top :=10; Panel1.Width :=Self.Width-20; Panel1.Height:=Self.Height-20; end;
procedure TForm1.FormCreate(Sender: TObject); begin wmp :=TWindowsMediaPlayer.Create(Self); wmp.Parent :=Panel1; wmp.Align :=alClient;//关键在此处 {我也试着改了下Width和Height,确实不管用,但上面Align就可以了,应该解决问题了} wmp.Show; end; procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin wmp.Destroy; end; procedure TForm1.FormDblClick(Sender: TObject); begin Panel1.Left :=10; Panel1.Top :=10; Panel1.Width :=Self.Width-20; Panel1.Height:=Self.Height-20; end;
E error2002 Unregistered / Unconfirmed GUEST, unregistred user! 2005-04-28 #6 谢谢dawnsong ,答案已经很接近了,但是我想要的是,播放窗口 初始化完后,再动态创建TWindowsMediaPlayer,这样动态创建的 大小我无法改变,关键在此,再帮着想想办法,呵呵
D dawnsong Unregistered / Unconfirmed GUEST, unregistred user! 2005-04-28 #7 不懂何意,不妨把代码发过来,我试着改改dawnsong@sohu.com
D dawnsong Unregistered / Unconfirmed GUEST, unregistred user! 2005-04-28 #8 全部程序如下,运行没问题,我已测试过了。 2年前我倒也做过你这样的项目,呵呵,不过代码都丢了 type TfrmMain = class(TForm) MainMenu1: TMainMenu; N41: TMenuItem; N42: TMenuItem; N43: TMenuItem; N3: TMenuItem; H1: TMenuItem; A1: TMenuItem; procedure N43Click(Sender: TObject); procedure N42Click(Sender: TObject); procedure N41Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); private { Private declarations } panels :array of TPanel; wmps :array of TWindowsMediaPlayer; procedure CreateMediaPlayers;overload; procedure CreateMediaPlayers(const ACount:Integer);overload; procedure FreeMediaPlayers; procedure ArrangePanels; public { Public declarations } end; var frmMain: TfrmMain; implementation {$R *.dfm} procedure TfrmMain.CreateMediaPlayers; var i :Integer; begin for i:=Low(panels) to High(panels)do begin panels :=TPanel.Create(Self); panels.Parent :=Self; panels.Name :=Format('idPanel%d',[i+1]); panels.Caption:=Format('第%d号播放器',[i+1]); end; ArrangePanels; for i:=Low(wmps) to High(wmps)do begin wmps :=TWindowsMediaPlayer.Create(panels); wmps.Name :=Format('idWmp%d',[i+1]); wmps.Parent :=panels; wmps.Align :=alClient; wmps.Show; end; end; procedure TfrmMain.CreateMediaPlayers(const ACount:Integer); begin FreeMediaPlayers; SetLength(panels,ACount); SetLength(wmps,High(panels) -Low(panels) +1); CreateMediaPlayers; end; procedure TfrmMain.FreeMediaPlayers; var i :Integer; begin for i:=Low(panels) to High(wmps)do if Assigned(wmps) then wmps.Destroy; for i:=Low(wmps) to High(panels)do if Assigned(panels) then panels.Destroy; end; procedure TfrmMain.ArrangePanels; var i,j :Integer; x :Integer; begin x := Round(Sqrt(High(panels))); for i:=Low(panels) to High(panels)do begin panels.Align :=alNone; panels.Width :=panels.Parent.ClientWidth div x -4; panels.Height:=panels.Parent.ClientHeight div x -4; end; for j:=0 to x-1do for i:=0 to x-1do begin panels[j + x *i].Left :=(i mod x) *(panels[j + x *i].Width +2); panels[j + x *i].top :=j *(panels[j + x *i].Height +2); end; end; procedure TfrmMain.FormClose(Sender: TObject; var Action: TCloseAction); begin FreeMediaPlayers; end; procedure TfrmMain.N41Click(Sender: TObject); begin CreateMediaPlayers(4); end; procedure TfrmMain.N42Click(Sender: TObject); begin CreateMediaPlayers(9); end; procedure TfrmMain.N43Click(Sender: TObject); begin CreateMediaPlayers(16); end; end.
全部程序如下,运行没问题,我已测试过了。 2年前我倒也做过你这样的项目,呵呵,不过代码都丢了 type TfrmMain = class(TForm) MainMenu1: TMainMenu; N41: TMenuItem; N42: TMenuItem; N43: TMenuItem; N3: TMenuItem; H1: TMenuItem; A1: TMenuItem; procedure N43Click(Sender: TObject); procedure N42Click(Sender: TObject); procedure N41Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); private { Private declarations } panels :array of TPanel; wmps :array of TWindowsMediaPlayer; procedure CreateMediaPlayers;overload; procedure CreateMediaPlayers(const ACount:Integer);overload; procedure FreeMediaPlayers; procedure ArrangePanels; public { Public declarations } end; var frmMain: TfrmMain; implementation {$R *.dfm} procedure TfrmMain.CreateMediaPlayers; var i :Integer; begin for i:=Low(panels) to High(panels)do begin panels :=TPanel.Create(Self); panels.Parent :=Self; panels.Name :=Format('idPanel%d',[i+1]); panels.Caption:=Format('第%d号播放器',[i+1]); end; ArrangePanels; for i:=Low(wmps) to High(wmps)do begin wmps :=TWindowsMediaPlayer.Create(panels); wmps.Name :=Format('idWmp%d',[i+1]); wmps.Parent :=panels; wmps.Align :=alClient; wmps.Show; end; end; procedure TfrmMain.CreateMediaPlayers(const ACount:Integer); begin FreeMediaPlayers; SetLength(panels,ACount); SetLength(wmps,High(panels) -Low(panels) +1); CreateMediaPlayers; end; procedure TfrmMain.FreeMediaPlayers; var i :Integer; begin for i:=Low(panels) to High(wmps)do if Assigned(wmps) then wmps.Destroy; for i:=Low(wmps) to High(panels)do if Assigned(panels) then panels.Destroy; end; procedure TfrmMain.ArrangePanels; var i,j :Integer; x :Integer; begin x := Round(Sqrt(High(panels))); for i:=Low(panels) to High(panels)do begin panels.Align :=alNone; panels.Width :=panels.Parent.ClientWidth div x -4; panels.Height:=panels.Parent.ClientHeight div x -4; end; for j:=0 to x-1do for i:=0 to x-1do begin panels[j + x *i].Left :=(i mod x) *(panels[j + x *i].Width +2); panels[j + x *i].top :=j *(panels[j + x *i].Height +2); end; end; procedure TfrmMain.FormClose(Sender: TObject; var Action: TCloseAction); begin FreeMediaPlayers; end; procedure TfrmMain.N41Click(Sender: TObject); begin CreateMediaPlayers(4); end; procedure TfrmMain.N42Click(Sender: TObject); begin CreateMediaPlayers(9); end; procedure TfrmMain.N43Click(Sender: TObject); begin CreateMediaPlayers(16); end; end.
E error2002 Unregistered / Unconfirmed GUEST, unregistred user! 2005-04-30 #10 问题已解决,谢谢dawnsong参与,你的例子可能是mediaplayer 6.4的吧? http://www.delphibbs.com/delphibbs/dispq.asp?lid=1850558
问题已解决,谢谢dawnsong参与,你的例子可能是mediaplayer 6.4的吧? http://www.delphibbs.com/delphibbs/dispq.asp?lid=1850558
D dawnsong Unregistered / Unconfirmed GUEST, unregistred user! 2005-04-30 #11 呵呵,问题解决了 我是在Win Xp +Windows MEdiaPlayer 10下测试的,仅仅导入了一下MediaPlayer10的Dll,然后动态创建的