LRESULT CALLBACK MainWndProc()

in src/native/windows/apps/prunmgr/prunmgr.c [1669:1771]


LRESULT CALLBACK MainWndProc(HWND hWnd, UINT uMsg,
                             WPARAM wParam, LPARAM lParam)
{
    switch (uMsg) {
        case WM_CREATE:
            if (bEnableTry) {
                if (_currentEntry && _currentEntry->lpConfig) {
                    BOOL isRunning = _currentEntry->stServiceStatus.dwCurrentState == SERVICE_RUNNING;
                    apxManageTryIconW(hWnd, NIM_ADD, NULL,
                                      _currentEntry->lpConfig->lpDisplayName,
                                      isRunning ? hIcoRun : hIcoStop);
                }
                else {
                    apxManageTryIconW(hWnd, NIM_ADD, NULL,
                                      apxLoadResourceW(IDS_APPLICATION, 0),
                                      NULL);
                }
            }
            else
                ShowServiceProperties(hWnd);

        break;
        case WM_COMMAND:
            switch (LOWORD(wParam)) {
                case IDM_TM_CONFIG:
                    ShowServiceProperties(hWnd);
                break;
                case IDM_TM_ABOUT:
                    apxAboutBox(hWnd);
                break;
                case IDM_TM_EXIT:
                    SendMessage(hWnd, WM_CLOSE, 0, 0);
                break;
                case IDM_TM_START:
                    if (!_propertyOpened)
                        apxProgressBox(hWnd, apxLoadResourceW(IDS_HSSTART, 0),
                                       _currentEntry->lpConfig->lpDisplayName,
                                       __startServiceCallback, NULL);
                break;
                case IDM_TM_STOP:
                    if (!_propertyOpened)
                        apxProgressBox(hWnd, apxLoadResourceW(IDS_HSSTOP, 0),
                                       _currentEntry->lpConfig->lpDisplayName,
                                       __stopServiceCallback, NULL);
                break;
                case IDM_TM_PAUSE:
                    if (!_propertyOpened)
                        apxProgressBox(hWnd, apxLoadResourceW(IDS_HSPAUSE, 0),
                                       _currentEntry->lpConfig->lpDisplayName,
                                       __pauseServiceCallback, NULL);
                break;
                case IDM_TM_RESTART:
                    if (!_propertyOpened)
                        apxProgressBox(hWnd, apxLoadResourceW(IDS_HSRESTART, 0),
                                       _currentEntry->lpConfig->lpDisplayName,
                                       __restartServiceCallback, NULL);
                break;
                case IDM_TM_DUMP:
                    signalService(_currentEntry->szServiceName);
                break;
                case IDMS_REFRESH:
                    if (bEnableTry &&
                        (_currentEntry = apxServiceEntry(hService, TRUE)) != NULL) {
                        BOOL isRunning = _currentEntry->stServiceStatus.dwCurrentState == SERVICE_RUNNING;
                        apxManageTryIconW(hWnd, NIM_MODIFY, NULL,
                                          _currentEntry->lpConfig->lpDisplayName,
                                          isRunning ? hIcoRun : hIcoStop);
                    }
                break;

            }
        break;
        case WM_TRAYMESSAGE:
            switch (lParam) {
                case WM_LBUTTONDBLCLK:
                    ShowServiceProperties(hWnd);
                break;
                case WM_RBUTTONUP:
                    _currentEntry = apxServiceEntry(hService, TRUE);
                    createRbuttonTryMenu(hWnd);
                break;
            }
        break;
        case WM_QUIT:
            return DefWindowProc(hWnd, uMsg, wParam, lParam);
        break;
        case WM_DESTROY:
            if (bEnableTry)
                apxManageTryIconA(hWnd, NIM_DELETE, NULL, NULL, NULL);
            /* Setting this to false ensures that the process closes down
             * cleanly when the configuration window is open and the process
             * is closed via MQ,
             */
            bEnableTry = FALSE;
            PostQuitMessage(0);
        break;
        default:
            return DefWindowProc(hWnd, uMsg, wParam, lParam);
        break;
    }

    return FALSE;
}