procedure TMainForm.FileOpenItemClick(Sender: TObject); var s,extt,sfile,s1,s2:string; jj: TJPEGImage; bb:TBitMap; Child: TMDIChild; begin s2:=LastSavingDir; delete(s2,length(s2),1); od1.InitialDir :=s2; if od1.Execute then begin //0 jj:= TJPEGImage.Create ; bb:=TBitMap.Create ; try if od1.FileName =' then exit; s:=od1.FileName ; sfile:=ExtractFileName(s); extt:=ExtractFileExt(s); if tabcontrol1.Tabs.IndexOf(sfile)>=0 then exit;
DealTabAdd(sfile); FIsOpen:=false; if LowerCase(extt)='.bmp' then begin//1
Child := TMDIChild.Create(Application); Child.Caption :=sfile; with Child do begin//22 image1.picture.LoadFromFile(s); s1:=IntToStr(MainForm.MDIChildCount); edtindex.Text :=s1; edtpath.Text :=s; edtmodify.Text :='; end;//22 end;//1 if LowerCase(extt)='.jpg' then begin//2 jj.LoadFromFile(s); bb.Assign(jj); Child := TMDIChild.Create(Application); Child.Caption :=sfile; with Child do begin//33 s1:=IntToStr(MainForm.MDIChildCount); image1.picture.Bitmap.Assign(bb); edtindex.Text :=s1; edtpath.Text :=s; edtmodify.Text :='; end;//33 end;//2
补充: 我用BIOS大哥给我的代码实现MDI背景,如下: PROCEDURE TMainForm.ClientWndProc(VAR Message: TMessage); VAR CanvasClient:TCanvas; begin with Message do case Msg of WM_ERASEBKGND: begin CanvasClient:=Tcanvas.Create; CanvasClient.Handle:=GetDC(self.ClientHandle); CanvasClient.StretchDraw(rect(0,0,clientwidth,clientheight),image1.Picture.bitmap); CanvasClient.Free; end; else Result := CallWindowProc(FPrevClientProc, ClientHandle, Msg, wParam, lParam); end; end;