Home > Back-end >  Delphi2010 environment, click BitBtn2 button to close (release) memory frame1 BitBtn1 button to call
Delphi2010 environment, click BitBtn2 button to close (release) memory frame1 BitBtn1 button to call

Time:11-15

I have more than 10 buttons, each button are called independent frame, now when I click the BitBtn2 button closure BitBtn1 frame1 button calls, and so on,,
Whenever I click on the button, besides the button calls frame, all of the other frame have closed, and release the memory,
It is said that need to use sendmessage (WM_CLOSE, 0, 0) method is shut, than direct nil, free better,
Seek expert advice, complete code, I am a little white, write too simple, I also don't understand, had better use D2010,

Here's what I call frame code,
Procedure TForm1. LoadFrameByClassName (FrameClassName: TMyFrame);
The begin
If Assigned (Ffrm) and (not SameText (FrameClassName ClassName, FCurrentfrmClass)) then
FreeAndNil (Ffrm);//sametext determine whether two strings, the same is case-insensitive, FreeAndnil release form
Ffrm:=FrameClassName. Create (nil);
Ffrm. Parent:=Panel3;
FCurrentfrmClass:=FrameClassName ClassName.
end;

Procedure TForm1. BitBtn1Click (Sender: TObject);
The begin
Self. LoadFrameByClassName (TIWFrame1);
end;
  • Related