Delphi 子窗體中 為何 無法打開 文件打開對話框? |
答題得分者是:老大仔
|
flagshang
一般會員 ![]() ![]() 發表:5 回覆:6 積分:2 註冊:2008-03-30 發送簡訊給我 |
|
老大仔
尊榮會員 ![]() ![]() ![]() ![]() ![]() ![]() 發表:78 回覆:837 積分:1088 註冊:2006-07-06 發送簡訊給我 |
|
zhouying82
高階會員 ![]() ![]() ![]() ![]() 發表:150 回覆:272 積分:189 註冊:2004-03-16 發送簡訊給我 |
|
flagshang
一般會員 ![]() ![]() 發表:5 回覆:6 積分:2 註冊:2008-03-30 發送簡訊給我 |
感謝 老大仔 的代碼,感謝 zhouying82 的關注,補上我的代碼如下;
unit1是父窗體,unit3是子窗體,unit8是軟體開啟時的閃動窗體。 當通過unit1上的menu 打開unit3后,unit3上的代碼與 老大仔 的指教類似,但是想打開 圖片打開對話框,卻報錯,還請各位先進在指點,感恩。。。 project1 -------------------------------------------------------- program Project1; uses Forms, Unit1 in 'Unit1.pas' {Form1}, Unit3 in 'Unit3.pas' {Form3}, Unit8 in 'Unit8.pas' {SplashForm}; {$R *.res} begin Application.Initialize; Application.CreateForm(TForm1, Form1); Application.CreateForm(TSplashForm, SplashForm); Application.Run; end. -------------------------------------------------------- Unit1 ------------------------------------------------------- unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Menus, ComCtrls, jpeg, ExtCtrls; type TForm1 = class(TForm) MainMenu1: TMainMenu; Search1: TMenuItem; Edit1: TMenuItem; procedure Edit1Click(Sender: TObject); private { Private declarations } public { Public declarations } procedure aa(var xx: TWMGetMinMaxinfo); message WM_GetMinMaxinfo; end; var Form1: TForm1; implementation uses Unit3; {$R *.dfm} procedure TForm1.aa(var xx: TWMGetMinMaxinfo); begin with xx.MinMaxInfo^ do begin ptMinTrackSize := point(610,431); ptMaxTrackSize := point(610,431); end; end; procedure TForm1.Edit1Click(Sender: TObject); var form3:tForm3; begin Form3:=tForm3.create(self); form3.show; form3.WindowState:=wsMaximized; end; end. ------------------------------------------------------- Unit3 ------------------------------------------------------ unit Unit3; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, DBCtrls, Grids, DBGrids, DB, DBTables, StdCtrls, Buttons, ExtDlgs; type TForm3 = class(TForm) Button1: TButton; Image1: TImage; OpenPictureDialog1: TOpenPictureDialog; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form3: TForm3; implementation uses Unit1; {$R *.dfm} procedure TForm3.Button1Click(Sender: TObject); begin form3.OpenPictureDialog1.Execute; form3.Image1.Picture.LoadFromFile(openpicturedialog1.FileName); end; end. ------------------------------------------------------- unit8 ------------------------------------------------------ unit Unit8; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, jpeg; type TSplashForm = class(TForm) Timer1: TTimer; procedure Timer1Timer(Sender: TObject); procedure FormShow(Sender: TObject); private { Private-Deklarationen } public { Public-Deklarationen } end; var SplashForm: TSplashForm; implementation {$R *.DFM} procedure TSplashForm.Timer1Timer(Sender: TObject); begin Timer1.Enabled:=false; Close; end; procedure TSplashForm.FormShow(Sender: TObject); begin SetWindowPos(Handle,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE); end; end. ------------------------------------------------------ |
老大仔
尊榮會員 ![]() ![]() ![]() ![]() ![]() ![]() 發表:78 回覆:837 積分:1088 註冊:2006-07-06 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |