Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Robert, you can do that using a dialog template. </p> <p>First you must store the template as a resource in your app, then load the template using the <a href="http://msdn.microsoft.com/en-us/library/ms646839%28v=vs.85%29.aspx" rel="noreferrer"><code>TOpenFilename</code></a> structure (don't worry by the name, is the same for open and save dialogs) and finally call the <a href="http://msdn.microsoft.com/en-us/library/ms646928%28v=vs.85%29.aspx" rel="noreferrer"><code>GetSaveFileName</code></a> function passing the <code>TOpenFilename</code> structure.</p> <p>check this sample </p> <p>Create a resource file (calledSaveDialog.rc) with the dialog template (look the MyCheckBox added)</p> <pre><code>MYSAVEFILE DIALOG -1, 1, 300, 60 STYLE DS_3DLOOK | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS CAPTION "" FONT 8, "Tahoma" { CONTROL "MyCheckBox", 666, "button", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 84, 19, 60, 12 } </code></pre> <p>this is the source code</p> <pre><code>Uses CommDlg; var lpofn : TOpenFilename; lpstrFile: Array[0..MAX_PATH-1] of Char; {$R *.dfm} {$R SaveDialog.Res} function _lpfnHook(hdlg: HWND; uiMsg:UINT;wParam:WPARAM;lParam:LPARAM): UINT stdcall; begin Result:=0; case uiMsg of // Set the initial state of mycheckbox to checked WM_INITDIALOG : CheckDlgButton(hdlg,666,BST_CHECKED); WM_COMMAND : case wParam of 666: begin if (IsDlgButtonChecked(hdlg,666)=BST_CHECKED) then ShowMessage('MyCheckBox was checked') else if (IsDlgButtonChecked(hdlg,666)=BST_UNCHECKED) then ShowMessage('MyCheckBox was unchecked'); end; end; end; end; procedure TFrmMain.Button1Click(Sender: TObject); begin ZeroMemory(@lpofn,sizeof(lpofn)); lpofn.lStructSize := SizeOf(lpofn); lpofn.hwndOwner := Handle; lpofn.hInstance := hInstance; //set the filter name lpofn.lpstrFilter := 'All files (*.*)'#0'*.*'#0#0; lpofn.lpstrTitle := 'Save As'; lpofn.lpstrFile := lpstrFile; lpofn.nMaxFile := MAX_PATH; //Set the template Name lpofn.lpTemplateName :='MYSAVEFILE'; //set the callback function lpofn.lpfnHook := _lpfnHook; lpofn.Flags := OFN_EXPLORER or OFN_CREATEPROMPT or OFN_HIDEREADONLY or OFN_PATHMUSTEXIST or OFN_ENABLEHOOK or OFN_ENABLETEMPLATE; //execute the dialog if GetSaveFileName(lpofn) then ShowMessage(lpofn.lpstrFile); end; </code></pre> <p>and this is the output</p> <p><img src="https://i.stack.imgur.com/9W7XB.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload