Implement wxFontDialog::SetTitle() in wxMSW
Base class SetTitle() implementation didnd't work for this class as it used the (invalid) HWND of not yet existing dialog, so add a hook procedure for the common font dialog, similar to the existing one for wxColourDialog, which allows us to set the dialog title when the dialog is really created. Closes https://github.com/wxWidgets/wxWidgets/pull/865 Closes #18177.
This commit is contained in:
committed by
Vadim Zeitlin
parent
4430ab8661
commit
a02efd1fc7
@@ -49,10 +49,45 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog);
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// font dialog hook proc used for setting the dialog title if necessary
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
static
|
||||
UINT_PTR CALLBACK
|
||||
wxFontDialogHookProc(HWND hwnd,
|
||||
UINT uiMsg,
|
||||
WPARAM WXUNUSED(wParam),
|
||||
LPARAM lParam)
|
||||
{
|
||||
if ( uiMsg == WM_INITDIALOG )
|
||||
{
|
||||
CHOOSEFONT *pCH = (CHOOSEFONT *)lParam;
|
||||
wxFontDialog * const
|
||||
dialog = reinterpret_cast<wxFontDialog *>(pCH->lCustData);
|
||||
|
||||
::SetWindowText(hwnd, dialog->GetTitle().t_str());
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFontDialog
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxFontDialog::SetTitle(const wxString& title)
|
||||
{
|
||||
// Just store the title here, we can't set it right now because the dialog
|
||||
// doesn't exist yet -- it will be created only when ShowModal() is called.
|
||||
m_title = title;
|
||||
}
|
||||
|
||||
wxString wxFontDialog::GetTitle() const
|
||||
{
|
||||
return m_title;
|
||||
}
|
||||
|
||||
int wxFontDialog::ShowModal()
|
||||
{
|
||||
WX_HOOK_MODAL_DIALOG();
|
||||
@@ -71,6 +106,15 @@ int wxFontDialog::ShowModal()
|
||||
chooseFontStruct.hwndOwner = hWndParent;
|
||||
chooseFontStruct.lpLogFont = &logFont;
|
||||
|
||||
// Currently we only use the hook to set the title, so only set it up if
|
||||
// we really need to do this.
|
||||
if ( !m_title.empty() )
|
||||
{
|
||||
flags |= CF_ENABLEHOOK;
|
||||
chooseFontStruct.lCustData = (LPARAM)this;
|
||||
chooseFontStruct.lpfnHook = wxFontDialogHookProc;
|
||||
}
|
||||
|
||||
if ( m_fontData.m_initialFont.IsOk() )
|
||||
{
|
||||
flags |= CF_INITTOLOGFONTSTRUCT;
|
||||
|
||||
Reference in New Issue
Block a user