Example #1
0
void Tablet::on_activate( WPARAM wp, LPARAM lp )
{
	if ( context_handle_ )
	{
		DllWTEnable( context_handle_, GET_WM_ACTIVATE_STATE( wp, lp ) );
		
		if ( context_handle_ && GET_WM_ACTIVATE_STATE( wp, lp ) )
		{
			DllWTOverlap( context_handle_, TRUE );
		}
	}
}
Example #2
0
DIALOGPROC ColorDlgProc(
    HWND hwnd,
    UINT msg,
    WPARAM wParam,
    LONG lParam)
{
    switch (msg) {
        case WM_INITDIALOG:
            ColorInit(hwnd);

            /*
             * Return TRUE so that the dialog manager does NOT set the focus
             * for me.  This prevents the status window from initially having
             * the focus when the editor is started.
             */
            return TRUE;

        case WM_ACTIVATE:
            if (GET_WM_ACTIVATE_STATE(wParam, lParam))
                gidCurrentDlg = DID_COLOR;

            break;

        case WM_CTLCOLOR:
        case WM_CTLCOLORBTN:
        case WM_CTLCOLORDLG:
        case WM_CTLCOLORSTATIC:
            switch (GET_WM_CTLCOLOR_TYPE(wParam, lParam, msg)) {
                case CTLCOLOR_BTN:
                case CTLCOLOR_DLG:
                    return (BOOL)GetStockObject(LTGRAY_BRUSH);

                case CTLCOLOR_STATIC:
                    SetBkColor(GET_WM_CTLCOLOR_HDC(wParam, lParam, msg),
                            RGB_LIGHTGRAY);
                    return (BOOL)GetStockObject(LTGRAY_BRUSH);
            }

            return (BOOL)NULL;

        case  WM_PAINT:
            {
                HDC hdc;
                PAINTSTRUCT ps;

                hdc = BeginPaint(hwnd, &ps);
                DrawMarginBorder(hwnd, hdc);
                EndPaint(hwnd, &ps);
            }

            break;

        case WM_COMMAND:
            ColorProcessCommand(hwnd,
                    GET_WM_COMMAND_ID(wParam, lParam),
                    GET_WM_COMMAND_CMD(wParam, lParam));
            break;

        case WM_CLOSE:
            /*
             * The user closed the color palette from the system menu.
             * Hide the window (we don't actually destroy it so
             * that it will appear in the same spot when they show
             * it again).
             */
            ColorShow(FALSE);
            gfShowColor = FALSE;
            break;

        case WM_DESTROY:
            {
                RECT rc;

                /*
                 * Save the position of the color palette.
                 */
                GetWindowRect(hwnd, &rc);
                WriteWindowPos(&rc, FALSE, szColorPos);

                /*
                 * Null out the global window handle for the color palette
                 * for safety's sake.
                 */
                ghwndColor = NULL;
            }

            break;

        default:
            return FALSE;
    }

    return FALSE;
}
Example #3
0
WINDOWPROC ViewWndProc(
    HWND hwnd,
    UINT msg,
    WPARAM wParam,
    LONG lParam)
{
    switch (msg) {
        case WM_CREATE:
            {
                HMENU hmenu = GetSystemMenu(hwnd, FALSE);

                RemoveMenu(hmenu, 7, MF_BYPOSITION);    // Second separator.
                RemoveMenu(hmenu, 5, MF_BYPOSITION);    // First separator.

                RemoveMenu(hmenu, SC_RESTORE, MF_BYCOMMAND);
                RemoveMenu(hmenu, SC_SIZE, MF_BYCOMMAND);
                RemoveMenu(hmenu, SC_MINIMIZE, MF_BYCOMMAND);
                RemoveMenu(hmenu, SC_MAXIMIZE, MF_BYCOMMAND);
                RemoveMenu(hmenu, SC_TASKLIST, MF_BYCOMMAND);
            }

            return 0;

        case  WM_PAINT:
            {
                HDC hdc;
                PAINTSTRUCT ps;
                HBRUSH hbrOld;
                RECT rc;

                hdc = BeginPaint(hwnd, &ps);

                /*
                 * The view window should not be showing if there
                 * is not an image to view!
                 */
                if (gpImageCur) {
                    DrawMarginBorder(hwnd, hdc);

                    GetClientRect(hwnd, &rc);
                    hbrOld = SelectObject(hdc, ghbrScreen);
                    PatBlt(hdc, PALETTEMARGIN + 1, PALETTEMARGIN + 1,
                            rc.right - (PALETTEMARGIN * 2) - 2,
                            rc.bottom - (PALETTEMARGIN * 2) - 2,
                            PATCOPY);
                    SelectObject(hdc, hbrOld);

                    BitBlt(hdc, PALETTEMARGIN + gViewBackMargin,
                            PALETTEMARGIN + gViewBackMargin,
                            gcxImage, gcyImage, ghdcImage, 0, 0, SRCCOPY);
                }

                EndPaint(hwnd, &ps);
            }

            break;

        case WM_ACTIVATE:
            if (GET_WM_ACTIVATE_STATE(wParam, lParam))
                gidCurrentDlg = DID_VIEW;

            break;

        case WM_LBUTTONDOWN:
            SetScreenColor(gargbCurrent[giColorLeft]);
            break;

        case WM_CHAR:
            ViewChar(wParam);
            break;

        case WM_CLOSE:
            /*
             * The user closed the view window from the system menu.
             * Hide the window (we don't actually destroy it so
             * that it will appear in the same spot when they show
             * it again).
             */
            ViewShow(FALSE);
            gfShowView = FALSE;
            break;

        case WM_DESTROY:
            {
                RECT rc;

                /*
                 * Save the position of the toolbox.
                 */
                GetWindowRect(hwnd, &rc);
                WriteWindowPos(&rc, FALSE, szViewPos);

                /*
                 * Null out the global window handle for the view window
                 * for safety's sake.
                 */
                ghwndView = NULL;
            }

            break;

        default:
            return DefWindowProc(hwnd, msg, wParam, lParam);
    }

    return 0;
}
Example #4
0
WINDOWPROC MainWndProc(
    HWND hwnd,
    UINT msg,
    WPARAM wParam,
    LONG lParam)
{
    switch (msg) {
        case WM_CREATE:
            {
                RECT rc;

                /*
                 * Create the status window.
                 */
                CreateDialog(ghInst, MAKEINTRESOURCE(DID_STATUS),
                        hwnd, StatusDlgProc);

                /*
                 * Save away its height for sizing later (like when
                 * the app is minimized then restored).
                 */
                GetWindowRect(hwndStatus, &rc);
                gcyStatus = rc.bottom - rc.top;

                ghwndSubClient = CreateWindow(szSubClientClass, NULL,
                        WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
                        hwnd, NULL, ghInst, NULL);

                ghMenuMain = GetMenu(hwnd);
                LoadMenuBitmaps(ghMenuMain);
            }

            break;

        case WM_ACTIVATE:
            /*
             * If the main window is getting activated, there is no
             * currently active dialog.
             */
            if (GET_WM_ACTIVATE_STATE(wParam, lParam))
                gidCurrentDlg = 0;

            goto DoDefault;

        case WM_INITMENU:
            if (GetMenu(ghwndMain) == (HMENU)wParam)
                InitMenu((HMENU)wParam);

            break;

        case WM_MENUSELECT:
            if (GET_WM_MENUSELECT_FLAGS(wParam, lParam) &
                    (MF_POPUP | MF_SYSMENU))
                gMenuSelected = 0;
            else
                gMenuSelected = GET_WM_MENUSELECT_CMD(wParam, lParam);

            break;

        case WM_COMMAND:
            DialogMenu(GET_WM_COMMAND_ID(wParam, lParam));
            break;

        case WM_KEYDOWN:
            switch (wParam) {
                case VK_UP:
                case VK_DOWN:
                case VK_LEFT:
                case VK_RIGHT:
                    if ((GetKeyState(VK_SHIFT) & 0x8000) ||
                            (GetKeyState(VK_CONTROL) & 0x8000))
                        break;

                    /*
                     * Ignore it if we are not in a normal state
                     * (don't allow when dragging).
                     */
                    if (gState != STATE_NORMAL)
                        break;

                    /*
                     * Be sure any outstanding changes get applied
                     * without errors.
                     */
                    if (!StatusApplyChanges())
                        break;

                    /*
                     * Move the control in the specified direction.
                     */
                    MoveControl(wParam);
                    break;

                case VK_TAB:
                    if (GetKeyState(VK_CONTROL) & 0x8000)
                        break;

                    /*
                     * Ignore it if we are not in a normal state
                     * (don't allow when dragging).
                     */
                    if (gState != STATE_NORMAL)
                        break;

                    /*
                     * Be sure any outstanding changes get applied
                     * without errors.
                     */
                    if (!StatusApplyChanges())
                        break;

                    /*
                     * Is the shift key pressed also?
                     */
                    if (GetKeyState(VK_SHIFT) & 0x8000)
                        SelectPrevious();
                    else
                        SelectNext();

                    break;

                case VK_ESCAPE:
                    if ((GetKeyState(VK_SHIFT) & 0x8000) ||
                            (GetKeyState(VK_CONTROL) & 0x8000))
                        break;

                    /*
                     * Be sure any outstanding changes get applied
                     * without errors.
                     */
                    if (!StatusApplyChanges())
                        break;

                    if (gState == STATE_SELECTING)
                        OutlineSelectCancel();

                    /*
                     * Cancel any drag operation they might have been doing.
                     */
                    if (gState != STATE_NORMAL)
                        DragCancel();

                    break;

                case VK_RETURN:
                    if ((GetKeyState(VK_SHIFT) & 0x8000) ||
                            (GetKeyState(VK_CONTROL) & 0x8000))
                        break;

                    /*
                     * Be sure any outstanding changes get applied
                     * without errors.
                     */
                    if (!StatusApplyChanges())
                        break;

                    switch (gState) {
                        MPOINT mpt;
                        POINT pt;
                        DWORD dwPos;

                        case STATE_SELECTING:
                            /*
                             * In outline selection mode.  Map the
                             * location of the mouse at the time that
                             * the user pressed Enter into a point
                             * relative to the dialog client and complete
                             * the selection operation.
                             */
                            dwPos = GetMessagePos();
                            mpt = MAKEMPOINT(dwPos);
                            MPOINT2POINT(mpt, pt);
                            ScreenToClient(gcd.npc->hwnd, &pt);
                            OutlineSelectEnd(pt.x, pt.y);

                            break;

                        case STATE_DRAGGING:
                        case STATE_DRAGGINGNEW:
                            /*
                             * We are dragging something.  Map the
                             * location of the mouse at the time
                             * that the user pressed Enter into a
                             * point relative to the proper window
                             * and complete the drag operation.
                             */
                            dwPos = GetMessagePos();
                            mpt = MAKEMPOINT(dwPos);
                            MPOINT2POINT(mpt, pt);

                            /*
                             * The point must be changed to be relative to
                             * the window that the ending mouse up message
                             * would have come through, which will be the
                             * capture window for the drag.  This will be
                             * the dialog if we are adding a new control,
                             * or it will be the selected control if we are
                             * dragging an existing control.
                             */
                            ScreenToClient((gState == STATE_DRAGGING) ?
                                    gnpcSel->hwnd : gcd.npc->hwnd, &pt);

                            /*
                             * If the dialog is selected, map the points from
                             * the client area to the window.
                             */
                            if (gfDlgSelected)
                                MapDlgClientPoint(&pt, TRUE);

                            DragEnd(pt.x, pt.y);

                            break;
                    }

                    break;
            }

            break;

        case WM_NCCALCSIZE:
            /*
             * Save away what is going to be the new window position.
             */
            if (!IsIconic(hwnd) && !IsZoomed(hwnd))
                grcAppPos = *((LPRECT)lParam);

            /*
             * Now let the DefWindowProc calculate the client area normally.
             */
            goto DoDefault;

        case WM_MOVE:
            if (gfEditingDlg)
                RepositionDialog();

            break;

        case WM_SIZE:
            SizeRibbons(hwnd);

            /*
             * Did the app start minimized and is it being restored
             * for the first time?  If so, show the toolbox if
             * the user has requested it.
             */
            if (fStartAsIcon && !IsIconic(hwnd)) {
                if (gfShowToolbox)
                    ToolboxShow(TRUE);

                fStartAsIcon = FALSE;
            }

            break;

        case WM_SYSCOLORCHANGE:
            LoadSysColorBitmaps();
            break;

        case WM_CLOSE:
            if (ghwndTestDlg)
                DestroyTestDialog();

            if (DoWeSave(FILE_INCLUDE) == IDCANCEL ||
                    DoWeSave(FILE_RESOURCE) == IDCANCEL)
                break;

            /*
             * First destroy the Properties Bar.
             */
            DestroyWindow(hwndStatus);
            hwndStatus = NULL;

            DestroyWindow(hwnd);
            break;

        case WM_QUERYENDSESSION:
            if (ghwndTestDlg)
                DestroyTestDialog();

            if (DoWeSave(FILE_INCLUDE) == IDCANCEL ||
                    DoWeSave(FILE_RESOURCE) == IDCANCEL)
                return FALSE;
            else
                return TRUE;

        case WM_DESTROY:
            /*
             * Save the position of the app's window.
             */
            WriteWindowPos(&grcAppPos, IsZoomed(hwnd), szAppPos);

            WinHelp(hwnd, gszHelpFile, HELP_QUIT, 0L);
            FreeMenuBitmaps();
            PostQuitMessage(0);
            break;

        default:
            /*
             * Is this the registered help message from one of the common
             * dialogs?  If so, show the help for it.
             *
             * The check to be sure gmsgHelp is non-zero is just in
             * case the call to register the help message failed
             * (it will return zero) and there happens to be a zero
             * message that gets sent to this window somehow.
             */
            if (msg == gmsgHelp && gmsgHelp) {
                ShowHelp(FALSE);
                return 0;
            }

        DoDefault:
            return DefWindowProc(hwnd, msg, wParam, lParam);
    }

    return 0;
}
Example #5
0
LRESULT WINAPI
DefDlgProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)
{
    DLGPROC	f;
    LRESULT	rc;
    HBRUSH	hBrush;
    HFONT   hFont;
    RECT rcClient;
    HWND hWndChild, hWndFocus;
    DWORD dwStyle;
    WORD wTmp;
    HCLASS32 hDialog32;

    APISTR((LF_APICALL,"DefDlgProc(HWND=%x,UINT=%x,WPARAM=%x,LPARAM=%lx)\n",
            hDlg,iMessage,wParam,lParam));

    if (!IsWindow(hDlg)) {
        APISTR((LF_APIFAIL,"DefDlgProc: returns LRESULT 0\n"));
        return 0L;
    }

    if (iMessage == WM_CONVERT) {
        if (!lpDialogBinToNat) {
            hDialog32 = FindClass(TWIN_DIALOGCLASS,(HINSTANCE)0);
            lpDialogBinToNat = (WNDPROC)GetClassHandleLong(
                                   hDialog32,GCL_BINTONAT);
        }
        if (lpDialogBinToNat) {
            rc = lpDialogBinToNat(hDlg,iMessage,wParam,lParam);
            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc));
            return rc;
        } else {
            APISTR((LF_APIFAIL,"DefDlgProc: returns LRESULT 0\n"));
            return (LRESULT)0;
        }
    }

    if ( (f = (DLGPROC) GetWindowLong(hDlg,DWL_DLGPROC)) ) {
        rc = CallWindowProc(
#ifdef	STRICT
                 (WNDPROC)f,
#else
                 (FARPROC)f,
#endif
                 hDlg,iMessage,wParam,lParam);
    }
    else  rc = 0L;

    if (!IsWindow(hDlg)) {	/* dialog has been destroyed in the callback */
        APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc));
        return rc;
    }

    if(LOWORD(rc) == 0) {
        switch(iMessage) {
        case WM_ERASEBKGND:
            GetClientRect(hDlg, &rcClient);
            hBrush = (HBRUSH)SendMessage(hDlg,
                                         GET_WM_CTLCOLOR_MSG(CTLCOLOR_DLG),
                                         GET_WM_CTLCOLOR_MPS(
                                             (HDC)wParam,hDlg,CTLCOLOR_DLG));
            FillRect((HDC)wParam,&rcClient,hBrush);
            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT 1\n"));
            return (LRESULT)1;

        case WM_SHOWWINDOW:
            /* if we are hiding, save the focus */
            if (!wParam)
                SaveDlgFocus(hDlg);
            rc =  DefWindowProc(hDlg,iMessage,wParam,lParam);
            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc));
            return rc;

        case WM_SYSCOMMAND:
            if ((wParam & 0xfff0) == SC_MINIMIZE)
                SaveDlgFocus(hDlg);

            rc = DefWindowProc(hDlg,iMessage,wParam,lParam);
            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc));
            return rc;

        case WM_ACTIVATE:
            if GET_WM_ACTIVATE_STATE(wParam,lParam)
                RestoreDlgFocus(hDlg);
            else
                SaveDlgFocus(hDlg);
            break;

        case WM_SETFOCUS:
            if (!RestoreDlgFocus(hDlg))
                DlgSetFocus(GetFirstDlgTabItem(hDlg));
            break;

        case WM_CLOSE:
            hWndChild = GetDlgItem(hDlg, IDCANCEL);
            if (hWndChild) {
                dwStyle = GetWindowLong(hDlg,GWL_STYLE);
                if (dwStyle & WS_DISABLED) {
                    MessageBeep(0);
                } else
                    PostMessage(hDlg,WM_COMMAND,
                                GET_WM_COMMAND_MPS(IDCANCEL,
                                                   hWndChild,BN_CLICKED));
            }
            break;

        case WM_NCDESTROY:
            SetWindowWord(hDlg,DWW_STATUS,1);
            if ((hFont = (HFONT)GetWindowWord(hDlg, DWW_HFONT))) {
                DeleteObject(hFont);
                SetWindowWord(hDlg,DWW_HFONT,0);
            }
            DefWindowProc(hDlg,iMessage,wParam,lParam);
            break;

        case DM_SETDEFID:
            SetWindowWord(hDlg,DWW_DEFID,wParam);
            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT 1\n"));
            return (LRESULT)1;

        case DM_GETDEFID:
            wTmp = GetWindowWord(hDlg,DWW_DEFID);
            if (wTmp) {
                rc = MAKELRESULT(wTmp, DC_HASDEFID);
                APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc));
                return rc;
            } else {
                APISTR((LF_APIRET,"DefDlgProc: returns LRESULT 0\n"));
                return (LRESULT)0;
            }

        case WM_NEXTDLGCTL:
            hWndFocus = GetFocus();
            if (LOWORD(lParam)) {
                if (!hWndFocus)
                    hWndFocus = hDlg;
                hWndChild = (HWND)wParam;
            }
            else {
                if (!hWndFocus) {
                    /* set to the first tab item */
                    hWndChild = GetFirstDlgTabItem(hDlg);
                    hWndFocus = hDlg;
                }
                else {
                    if (!IsChild(hDlg,hWndFocus))
                        return (LRESULT)1;
                    hWndChild = GetNextDlgTabItem(hDlg,
                                                  hWndFocus,(BOOL)wParam);
                }
            }

            DlgSetFocus(hWndChild);
            CheckDefPushButton(hDlg,hWndFocus,hWndChild);

            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT 1\n"));
            return (LRESULT)1;

        case WM_GETFONT:
            rc = (LRESULT)GetWindowWord(hDlg,DWW_HFONT);
            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc));
            return rc;

        case WM_SETFONT:
            SetWindowWord(hDlg,DWW_HFONT,(HFONT)wParam);
            if (LOWORD(lParam))
                InvalidateRect(hDlg,NULL,TRUE);
            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",0));
            return 0L;

        case WM_VKEYTOITEM:
        case WM_COMPAREITEM:
        case WM_CHARTOITEM:
        case WM_INITDIALOG:
            break;

        case WM_MOUSEACTIVATE:

            rc = (LRESULT)MA_ACTIVATE;
            if ((int)(short)LOWORD(lParam) == HTCAPTION)
                rc = (LRESULT)MA_NOACTIVATE;
            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc));
            return rc;

#ifdef	TWIN32
        case WM_CTLCOLORMSGBOX:
        case WM_CTLCOLORBTN:
        case WM_CTLCOLORDLG:
        case WM_CTLCOLORSTATIC:
            rc =  GetStockObject(LTGRAY_BRUSH);
            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc));
            return rc;
#endif
        default:
            rc = DefWindowProc(hDlg,iMessage,wParam,lParam);
            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc));
            return rc;
        }
    }