Search code examples
c++buildervclsetfocusprintdialogc++builder-10.4-sydney

Set focus to the OK button in the TPrintDialog


Is it possible to set focus to the OK button in the TPrintDialog when it opens?


Solution

  • In the TPrintDialog::OnShow event, you can manually set focus to the OK button like this:

    void __fastcall TMyForm::PrintDialogShow(TObject *Sender)
    {
        HWND btnOK = GetDlgItem(PrintDialog->Handle, IDOK);
        ::SetFocus(btnOK);
    }