2012-08-01

【Delphi】在對話視窗內加入檢查盒(checkbox)

 
procedure TForm1.Button1Click(Sender: TObject);
var
    AMsgDialog: TForm;
    ACheckBox: TCheckBox;
begin
    AMsgDialog := CreateMessageDialog('This is a test message.', mtWarning, [mbYes, mbNo]);
    ACheckBox := TCheckBox.Create(AMsgDialog) ;
    with AMsgDialog do
     try
         Caption := 'Dialog Title' ;
         Height := 169;
         with ACheckBox do
         begin
             Parent := AMsgDialog;
             Caption := 'Don''t show me again.';
             Top := 121;
             Left := 8;
         end;

         if (ShowModal = ID_YES) then
         begin
             if ACheckBox.Checked then
             begin
                 //... 如果勾選了 checkbox 要做的事
             end;
         end;
     finally
         Free;
     end;
end;
 

沒有留言:

張貼留言