|
|
|
@ -29,26 +29,22 @@
|
|
|
|
|
#include <windows.h> |
|
|
|
|
#include "StaticDialog.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StaticDialog::~StaticDialog() |
|
|
|
|
{ |
|
|
|
|
if (isCreated()) |
|
|
|
|
{ |
|
|
|
|
// Prevent run_dlgProc from doing anything, since its virtual
|
|
|
|
|
::SetWindowLongPtr(_hSelf, GWLP_USERDATA, (LONG_PTR) NULL); |
|
|
|
|
::SetWindowLongPtr(_hSelf, GWLP_USERDATA, NULL); |
|
|
|
|
destroy(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void StaticDialog::destroy() |
|
|
|
|
{ |
|
|
|
|
::SendMessage(_hParent, NPPM_MODELESSDIALOG, MODELESSDIALOGREMOVE, (WPARAM)_hSelf); |
|
|
|
|
::SendMessage(_hParent, NPPM_MODELESSDIALOG, MODELESSDIALOGREMOVE, reinterpret_cast<WPARAM>(_hSelf)); |
|
|
|
|
::DestroyWindow(_hSelf); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
POINT StaticDialog::getTopPoint(HWND hwnd, bool isLeft) const |
|
|
|
|
{ |
|
|
|
|
RECT rc; |
|
|
|
@ -65,7 +61,6 @@ POINT StaticDialog::getTopPoint(HWND hwnd, bool isLeft) const
|
|
|
|
|
return p; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void StaticDialog::goToCenter() |
|
|
|
|
{ |
|
|
|
|
RECT rc; |
|
|
|
@ -81,7 +76,6 @@ void StaticDialog::goToCenter()
|
|
|
|
|
::SetWindowPos(_hSelf, HWND_TOP, x, y, _rc.right - _rc.left, _rc.bottom - _rc.top, SWP_SHOWWINDOW); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void StaticDialog::display(bool toShow) const |
|
|
|
|
{ |
|
|
|
|
if (toShow) |
|
|
|
@ -113,7 +107,6 @@ void StaticDialog::display(bool toShow) const
|
|
|
|
|
Window::display(toShow); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HGLOBAL StaticDialog::makeRTLResource(int dialogID, DLGTEMPLATE **ppMyDlgTemplate) |
|
|
|
|
{ |
|
|
|
|
// Get Dlg Template resource
|
|
|
|
@ -151,11 +144,11 @@ void StaticDialog::create(int dialogID, bool isRTL, bool msgDestParent)
|
|
|
|
|
{ |
|
|
|
|
DLGTEMPLATE *pMyDlgTemplate = NULL; |
|
|
|
|
HGLOBAL hMyDlgTemplate = makeRTLResource(dialogID, &pMyDlgTemplate); |
|
|
|
|
_hSelf = ::CreateDialogIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, (LPARAM)this); |
|
|
|
|
_hSelf = ::CreateDialogIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, reinterpret_cast<LPARAM>(this)); |
|
|
|
|
::GlobalFree(hMyDlgTemplate); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
_hSelf = ::CreateDialogParam(_hInst, MAKEINTRESOURCE(dialogID), _hParent, dlgProc, (LPARAM)this); |
|
|
|
|
_hSelf = ::CreateDialogParam(_hInst, MAKEINTRESOURCE(dialogID), _hParent, dlgProc, reinterpret_cast<LPARAM>(this)); |
|
|
|
|
|
|
|
|
|
if (!_hSelf) |
|
|
|
|
{ |
|
|
|
@ -167,10 +160,9 @@ void StaticDialog::create(int dialogID, bool isRTL, bool msgDestParent)
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// if the destination of message NPPM_MODELESSDIALOG is not its parent, then it's the grand-parent
|
|
|
|
|
::SendMessage(msgDestParent?_hParent:(::GetParent(_hParent)), NPPM_MODELESSDIALOG, MODELESSDIALOGADD, (WPARAM)_hSelf); |
|
|
|
|
::SendMessage(msgDestParent ? _hParent : (::GetParent(_hParent)), NPPM_MODELESSDIALOG, MODELESSDIALOGADD, reinterpret_cast<WPARAM>(_hSelf)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INT_PTR CALLBACK StaticDialog::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) |
|
|
|
|
{ |
|
|
|
|
switch (message) |
|
|
|
@ -179,7 +171,7 @@ INT_PTR CALLBACK StaticDialog::dlgProc(HWND hwnd, UINT message, WPARAM wParam, L
|
|
|
|
|
{ |
|
|
|
|
StaticDialog *pStaticDlg = reinterpret_cast<StaticDialog *>(lParam); |
|
|
|
|
pStaticDlg->_hSelf = hwnd; |
|
|
|
|
::SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)lParam); |
|
|
|
|
::SetWindowLongPtr(hwnd, GWLP_USERDATA, static_cast<LONG_PTR>(lParam)); |
|
|
|
|
::GetWindowRect(hwnd, &(pStaticDlg->_rc)); |
|
|
|
|
pStaticDlg->run_dlgProc(message, wParam, lParam); |
|
|
|
|
|
|
|
|
|