in Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp [1853:1986]
static LRESULT CALLBACK WndProc(
__in HWND hWnd,
__in UINT uMsg,
__in WPARAM wParam,
__in LPARAM lParam
) {
#pragma warning(suppress:4312)
auto pBA = reinterpret_cast<PythonBootstrapperApplication*>(::GetWindowLongPtrW(hWnd, GWLP_USERDATA));
switch (uMsg) {
case WM_NCCREATE: {
LPCREATESTRUCT lpcs = reinterpret_cast<LPCREATESTRUCT>(lParam);
pBA = reinterpret_cast<PythonBootstrapperApplication*>(lpcs->lpCreateParams);
#pragma warning(suppress:4244)
::SetWindowLongPtrW(hWnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(pBA));
break;
}
case WM_NCDESTROY: {
LRESULT lres = ThemeDefWindowProc(pBA ? pBA->_theme : nullptr, hWnd, uMsg, wParam, lParam);
::SetWindowLongPtrW(hWnd, GWLP_USERDATA, 0);
return lres;
}
case WM_CREATE:
if (!pBA->OnCreate(hWnd)) {
return -1;
}
break;
case WM_QUERYENDSESSION:
return IDCANCEL != pBA->OnSystemShutdown(static_cast<DWORD>(lParam), IDCANCEL);
case WM_CLOSE:
// If the user chose not to close, do *not* let the default window proc handle the message.
if (!pBA->OnClose()) {
return 0;
}
break;
case WM_DESTROY:
::PostQuitMessage(0);
break;
case WM_PAINT: __fallthrough;
case WM_ERASEBKGND:
if (pBA && pBA->_suppressPaint) {
return TRUE;
}
break;
case WM_PYBA_SHOW_HELP:
pBA->OnShowHelp();
return 0;
case WM_PYBA_DETECT_PACKAGES:
pBA->OnDetect();
return 0;
case WM_PYBA_PLAN_PACKAGES:
pBA->OnPlan(static_cast<BOOTSTRAPPER_ACTION>(lParam));
return 0;
case WM_PYBA_APPLY_PACKAGES:
pBA->OnApply();
return 0;
case WM_PYBA_CHANGE_STATE:
pBA->OnChangeState(static_cast<PYBA_STATE>(lParam));
return 0;
case WM_PYBA_SHOW_FAILURE:
pBA->OnShowFailure();
return 0;
case WM_COMMAND:
switch (LOWORD(wParam)) {
// Customize commands
// Success/failure commands
case ID_SUCCESS_RESTART_BUTTON: __fallthrough;
case ID_FAILURE_RESTART_BUTTON:
pBA->OnClickRestartButton();
return 0;
case IDCANCEL: __fallthrough;
case ID_INSTALL_CANCEL_BUTTON: __fallthrough;
case ID_CUSTOM1_CANCEL_BUTTON: __fallthrough;
case ID_CUSTOM2_CANCEL_BUTTON: __fallthrough;
case ID_MODIFY_CANCEL_BUTTON: __fallthrough;
case ID_PROGRESS_CANCEL_BUTTON: __fallthrough;
case ID_SUCCESS_CANCEL_BUTTON: __fallthrough;
case ID_FAILURE_CANCEL_BUTTON: __fallthrough;
case ID_CLOSE_BUTTON:
pBA->OnCommand(ID_CLOSE_BUTTON);
return 0;
default:
pBA->OnCommand((CONTROL_ID)LOWORD(wParam));
}
break;
case WM_NOTIFY:
if (lParam) {
LPNMHDR pnmhdr = reinterpret_cast<LPNMHDR>(lParam);
switch (pnmhdr->code) {
case NM_CLICK: __fallthrough;
case NM_RETURN:
switch (static_cast<DWORD>(pnmhdr->idFrom)) {
case ID_FAILURE_LOGFILE_LINK:
pBA->OnClickLogFileLink();
return 1;
}
}
}
break;
case WM_CTLCOLORSTATIC:
case WM_CTLCOLORBTN:
if (pBA) {
HBRUSH brush = nullptr;
if (pBA->SetControlColor((HWND)lParam, (HDC)wParam, &brush)) {
return (LRESULT)brush;
}
}
break;
}
if (pBA && pBA->_taskbarList && uMsg == pBA->_taskbarButtonCreatedMessage) {
pBA->_taskbarButtonOK = TRUE;
return 0;
}
return ThemeDefWindowProc(pBA ? pBA->_theme : nullptr, hWnd, uMsg, wParam, lParam);
}