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:
parent
4430ab8661
commit
a02efd1fc7
@ -124,6 +124,7 @@ wxMSW:
|
||||
- Fix positioning windows at positions >= SHORT_MAX (Cătălin Răceanu).
|
||||
- Honour alignment flags for multiline buttons using custom colours too.
|
||||
- Support MSVC auto-linking when using monolithic build too (PB).
|
||||
- Implement wxFontDialog::SetTitle() (Vitaly Stakhovsky).
|
||||
- Fix build in ANSI (non-Unicode) mode.
|
||||
|
||||
wxOSX:
|
||||
|
@ -25,8 +25,12 @@ public:
|
||||
: wxFontDialogBase(parent, data) { Create(parent, data); }
|
||||
|
||||
virtual int ShowModal() wxOVERRIDE;
|
||||
virtual void SetTitle(const wxString& title) wxOVERRIDE;
|
||||
virtual wxString GetTitle() const wxOVERRIDE;
|
||||
|
||||
protected:
|
||||
wxString m_title;
|
||||
|
||||
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxFontDialog);
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user