Beispiel #1
0
/*
 * TransferImage - transfer the image in the outlined box to the view window
 */
void TransferImage( HWND hwnd )
{
    POINT       topleft_desk;
    HDC         hdc;
    HDC         memdc;
    HBITMAP     oldbitmap;
    img_node    *node;

#ifdef __NT__
    SetDeskTopHook( NULL );
#endif
    redrawPrevRegion();

    GetCursorPos( &topleft_desk );
    node = SelectImage( hwnd );
    hdc = GetDC( NULL );
    memdc = CreateCompatibleDC( hdc );

    oldbitmap = SelectObject( memdc, node->handbitmap );
    PatBlt( memdc, topLeft.x, topLeft.y, snapWidth, snapHeight, BLACKNESS );

    SelectObject( memdc, node->hxorbitmap );
    BitBlt( memdc, topLeft.x, topLeft.y, snapWidth, snapHeight, hdc,
            topleft_desk.x, topleft_desk.y, SRCCOPY );
    ReleaseDC( NULL, hdc );
    SelectObject( memdc, oldbitmap );
    DeleteDC( memdc );
    ReleaseCapture();
    ShowWindow( HMainWindow, previousState );

#ifdef __NT__
    DestroyWindow( deskTopWindow );
#else
    InvalidateRect( node->viewhwnd, NULL, FALSE );
#endif
    RecordImage( hwnd );

    SetToolType( prevToolType );
    if( !DoKeepRect() ) {
        SetRectExists( FALSE );
    } else {
        SetRectExists( rectExists );
    }
#ifndef __NT__
    BlowupImage( node->hwnd, NULL );
#endif
    SetCursor( prevCursor );
    PrintHintTextByID( WIE_BMPSNAPPEDFROMDSKTOP, NULL );

} /* TransferImage */
Beispiel #2
0
/*
 * ClearImage - clear the XOR and the AND bitmaps
 */
void ClearImage( void )
{
    WPI_PRES            pres;
    WPI_PRES            xorpres;
    WPI_PRES            andpres;
    HDC                 xormemdc;
    HDC                 andmemdc;
    HBITMAP             oldxor;
    HBITMAP             oldand;
    img_node            *node;
    WPI_RECT            clear_area;
    IMGED_DIM           left;
    IMGED_DIM           top;
    IMGED_DIM           right;
    IMGED_DIM           bottom;
    int                 width;
    int                 height;

    node = GetCurrentNode();
    if( node == NULL ) {
        return;
    }

    if( DoesRectExist( &clear_area ) ) {
        SetRectExists( FALSE );
    } else {
        _wpi_setwrectvalues( &clear_area, 0, 0, node->width, node->height );
    }

    pres = _wpi_getpres( HWND_DESKTOP );
    xorpres = _wpi_createcompatiblepres( pres, Instance, &xormemdc );
    andpres = _wpi_createcompatiblepres( pres, Instance, &andmemdc );
    _wpi_releasepres( HWND_DESKTOP, pres );

    oldxor = _wpi_selectobject( xorpres, node->hxorbitmap );
    oldand = _wpi_selectobject( andpres, node->handbitmap );

    _wpi_getwrectvalues( clear_area, &left, &top, &right, &bottom );
    width = _wpi_getwidthrect( clear_area );
    height = _wpi_getheightrect( clear_area );

    _wpi_patblt( xorpres, left, top, width, height, WHITENESS );
    _wpi_patblt( andpres, left, top, width, height, BLACKNESS );

    _wpi_selectobject( xorpres, oldxor );
    _wpi_selectobject( andpres, oldand );
    _wpi_deletecompatiblepres( xorpres, xormemdc );
    _wpi_deletecompatiblepres( andpres, andmemdc );

    InvalidateRect( node->viewhwnd, NULL, TRUE );
    RecordImage( node->hwnd );
    BlowupImage( node->hwnd, NULL );
    PrintHintTextByID( WIE_AREACLEARED, NULL );

} /* ClearImage */
Beispiel #3
0
/*
 * FocusOnImage - Selects one of the mdi children.
 */
void FocusOnImage( HWND hwnd )
{
    char        current_file[ _MAX_PATH ];
    char        *text;

    if (activeImage) {
        RedrawPrevClip(activeImage->hwnd);
        SetRectExists( FALSE );
    }

    activeImage = SelectImage( hwnd );
    if (!activeImage) {
        WImgEditError( WIE_ERR_BAD_HWND, WIE_INTERNAL_001 );
        return;
    }
    ResetViewWindow( activeImage->viewhwnd );
    CreateDrawnImage( activeImage );

    SetMenus( activeImage );
    SetNumColours( 1<<(activeImage->bitcount) );

    SetHotSpot( activeImage );
    DisplayImageText( activeImage );
    CheckForUndo( activeImage );

    GetFnameFromPath( activeImage->fname, current_file );

    text = (char *)
        MemAlloc( strlen( IEAppTitle ) + strlen( current_file ) + 3 + 1 );
    if( text ) {
        strcpy( text, IEAppTitle );
        strcat( text, " - " );
        strcat( text, current_file );
        _wpi_setwindowtext( _wpi_getframe(HMainWindow), text );
        MemFree( text );
    }

#ifndef __OS2_PM__
    RedrawWindow( hwnd, NULL, NULL, RDW_UPDATENOW );
#endif
} /* FocusOnImage */
Beispiel #4
0
/*
 * FlipImage - flip the image along either the x-axis or the y-axis
 */
void FlipImage( WORD whichway )
{
    img_node    *node;
    short       width;
    short       height;
    short       destwidth;
    short       destheight;
    short       new_left;
    short       new_top;
    WPI_RECT    dims;
    HBITMAP     xorflip;
    HBITMAP     oldflip;
    HBITMAP     oldbitmap;
    HBITMAP     andflip;
    WPI_PRES    pres;
    WPI_PRES    mempres;
    HDC         memdc;
    WPI_PRES    flippres;
    HDC         flipdc;
    HCURSOR     prevcursor;
    IMGED_DIM   bottom;
    IMGED_DIM   left;
    IMGED_DIM   right;
    IMGED_DIM   top;

    node = GetCurrentNode();
    if( node == NULL ) {
        return;
    }

    PrintHintTextByID( WIE_FLIPPINGIMAGE, NULL );
    prevcursor = _wpi_setcursor( _wpi_getsyscursor( IDC_WAIT ) );

    if( !DoesRectExist( &dims ) ) {
        _wpi_setwrectvalues( &dims, 0, 0, (IMGED_DIM)node->width, (IMGED_DIM)node->height );
    }
    width = (short)_wpi_getwidthrect( dims );
    height = (short)_wpi_getheightrect( dims );

    pres = _wpi_getpres( HWND_DESKTOP );
    if( node->bitcount == 1 ) {
        xorflip = _wpi_createbitmap( width, height, 1, 1, NULL );
    } else {
#if 1
        xorflip = _wpi_createcompatiblebitmap( pres, width, height );
#else
        xorflip = _wpi_createbitmap( width, height, ColorPlanes, BitsPerPixel, NULL );
#endif
    }
    andflip = _wpi_createbitmap( width, height, 1, 1, NULL );

    mempres = _wpi_createcompatiblepres( pres, Instance, &memdc );
    flippres = _wpi_createcompatiblepres( pres, Instance, &flipdc );
    _wpi_releasepres( HWND_DESKTOP, pres );

    _wpi_getrectvalues( dims, &left, &top, &right, &bottom );
    _wpi_preparemono( flippres, BLACK, WHITE );

    oldbitmap = _wpi_selectobject( mempres, node->hxorbitmap );
    oldflip = _wpi_selectobject( flippres, xorflip );
    _wpi_bitblt( flippres, 0, 0, width, height, mempres, left, top, SRCCOPY );
    _wpi_selectobject( mempres, oldbitmap );
    _wpi_selectobject( flippres, oldflip );

    oldbitmap = _wpi_selectobject( mempres, node->handbitmap );
    oldflip = _wpi_selectobject( flippres, andflip );
    _wpi_bitblt( flippres, 0, 0, width, height, mempres, left, top, SRCCOPY );

    if( whichway == IMGED_FLIPVERT ) {
        destwidth = -1 * width;
        new_left = right - 1;
        new_top = top;
        destheight = height;
    } else {
        destwidth = width;
        new_left = left;
        new_top = bottom - 1;
        destheight = -1 * height;
    }

    _wpi_stretchblt( mempres, new_left, new_top, destwidth, destheight,
                     flippres, 0, 0, width, height, SRCCOPY );
    _wpi_selectobject( mempres, oldbitmap );
    oldbitmap = _wpi_selectobject( mempres, node->hxorbitmap );
    _wpi_selectobject( flippres, oldflip );
    oldflip = _wpi_selectobject( flippres, xorflip );
    _wpi_stretchblt( mempres, new_left, new_top, destwidth, destheight,
                     flippres, 0, 0, width, height, SRCCOPY );
    _wpi_selectobject( mempres, oldbitmap );
    _wpi_selectobject( flippres, oldflip );

    _wpi_deleteobject( xorflip );
    _wpi_deleteobject( andflip );
    _wpi_deletecompatiblepres( mempres, memdc );
    _wpi_deletecompatiblepres( flippres, flipdc );

    InvalidateRect( node->viewhwnd, NULL, TRUE );

    if( !DoKeepRect() ) {
        SetRectExists( FALSE );
    }
    RecordImage( node->hwnd );
    BlowupImage( node->hwnd, NULL );
    if( whichway == IMGED_FLIPHORZ ) {
        PrintHintTextByID( WIE_IMAGEREFLECTEDH, NULL );
    } else {
        PrintHintTextByID( WIE_IMAGEREFLECTEDV, NULL );
    }
    _wpi_setcursor( prevcursor );

} /* FlipImage */
Beispiel #5
0
/*
 * simpleRotate - simply rotate the image around the center of the given rectangle
 */
static void simpleRotate( img_node *node, WPI_RECT *rect, HBITMAP rotxorbmp,
                          HBITMAP rotandbmp, BOOL rectexists )
{
    WPI_POINT   topleft;
    WPI_POINT   centre_pt;
    WPI_PRES    pres;
    HDC         xordc;
    WPI_PRES    xorpres;
    HDC         anddc;
    WPI_PRES    andpres;
    HDC         rotxordc;
    WPI_PRES    rotxorpres;
    HDC         rotanddc;
    WPI_PRES    rotandpres;
    HBITMAP     oldxor;
    HBITMAP     oldand;
    HBITMAP     oldxorrot;
    HBITMAP     oldandrot;
    short       width;
    short       height;
    WPI_RECT    new_rect;
    IMGED_DIM   left;
    IMGED_DIM   top;
    IMGED_DIM   right;
    IMGED_DIM   bottom;

    width = (short)_wpi_getwidthrect( *rect );
    height = (short)_wpi_getheightrect( *rect );

    /*
     * PM NOTE:  The rectangle comes in with bottom = yTop and top = yBottom.
     * To use the same formula to calculate the center point and top left, we
     * use getwrectvalues.
     */
    _wpi_getwrectvalues( *rect, &left, &top, &right, &bottom );
    centre_pt.x = (width / 2) + left;
    centre_pt.y = (height / 2) + top;
    topleft.x = centre_pt.x - centre_pt.y + top;
    topleft.y = centre_pt.y - centre_pt.x + left;

    pres = _wpi_getpres( HWND_DESKTOP );
    xorpres = _wpi_createcompatiblepres( pres, Instance, &xordc );
    andpres = _wpi_createcompatiblepres( pres, Instance, &anddc );
    rotxorpres = _wpi_createcompatiblepres( pres, Instance, &rotxordc );
    rotandpres = _wpi_createcompatiblepres( pres, Instance, &rotanddc );
    _wpi_releasepres( HWND_DESKTOP, pres );

    _wpi_torgbmode( xorpres );
    _wpi_torgbmode( andpres );
    _wpi_torgbmode( rotxorpres );
    _wpi_torgbmode( rotandpres );

    oldxor = _wpi_selectobject( xorpres, node->hxorbitmap );
    oldand = _wpi_selectobject( andpres, node->handbitmap );
    oldxorrot = _wpi_selectobject( rotxorpres, rotxorbmp );
    oldandrot = _wpi_selectobject( rotandpres, rotandbmp );

    _wpi_getwrectvalues( *rect, &left, &top, &right, &bottom );
    _wpi_patblt( xorpres, left, top, width, height, WHITENESS );
    _wpi_patblt( andpres, left, top, width, height, BLACKNESS );

    _wpi_bitblt( xorpres, topleft.x, topleft.y, height, width, rotxorpres, 0, 0, SRCCOPY );
    _wpi_bitblt( andpres, topleft.x, topleft.y, height, width, rotandpres, 0, 0, SRCCOPY );

    _wpi_selectobject( xorpres, oldxor );
    _wpi_selectobject( andpres, oldand );
    _wpi_selectobject( rotxorpres, oldxorrot );
    _wpi_selectobject( rotandpres, oldandrot );
    _wpi_deletecompatiblepres( xorpres, xordc );
    _wpi_deletecompatiblepres( andpres, anddc );
    _wpi_deletecompatiblepres( rotxorpres, rotxordc );
    _wpi_deletecompatiblepres( rotandpres, rotanddc );

    InvalidateRect( node->viewhwnd, NULL, TRUE );
    RecordImage( node->hwnd );
    if( DoKeepRect() ) {
        if( rectexists ) {
            _wpi_setwrectvalues( &new_rect, topleft.x, topleft.y,
                                 topleft.x+height, topleft.y + width );
            SetDeviceClipRect( &new_rect );
        }
    } else {
        rectexists = rectexists;
        new_rect = new_rect;
        SetRectExists( FALSE );
    }

    BlowupImage( node->hwnd, NULL );

} /* simpleRotate */
Beispiel #6
0
/*
 * SetToolType - set the tool type
 */
int SetToolType( int toolid )
{
    HMENU       hmenu;
    int         i;
    int         prev_tool;
    img_node    *node;

    if( toolType == IMGED_CLIP ) {
        node = GetCurrentNode();
        if( node != NULL ) {
            RedrawPrevClip( node->hwnd );
            SetRectExists( FALSE );
        }
    }

    prev_tool = toolType;
    toolType = toolid;

    if( toolid == IMGED_PASTE || toolid == IMGED_SNAP ) {
        return( prev_tool );
    }

    if( HMainWindow == NULL ) {
        return( 0 );
    }
    hmenu = _wpi_getmenu( _wpi_getframe( HMainWindow ) );

    switch( toolid ) {
    case IMGED_FREEHAND:
        setTheCursor( PENCIL_CUR, NULL );
        break;
    case IMGED_LINE:
        setTheCursor( CROSS_CUR, NULL );
        break;
    case IMGED_HOTSPOT:
        setTheCursor( HOTSPOT_CUR, NULL );
        break;
    case IMGED_RECTO:
        setTheCursor( CROSS_CUR, NULL );
        break;
    case IMGED_RECTF:
        setTheCursor( CROSS_CUR, NULL );
        break;
    case IMGED_CIRCLEO:
        setTheCursor( CROSS_CUR, NULL );
        break;
    case IMGED_CIRCLEF:
        setTheCursor( CROSS_CUR, NULL );
        break;
    case IMGED_FILL:
        setTheCursor( FILL_CUR, NULL );
        break;
    case IMGED_BRUSH:
        setTheCursor( BRUSH_CUR, NULL );
        if( prev_tool != IMGED_PASTE && prev_tool !=IMGED_SNAP ) {
            WriteSetSizeText( WIE_BRUSHSIZEIS, ImgedConfigInfo.brush_size,
                              ImgedConfigInfo.brush_size );
        }
        break;
    case IMGED_CLIP:
        setTheCursor( CROSS_CUR, NULL );
        break;

    default:
        setTheCursor( PENCIL_CUR, NULL );
        toolType = IMGED_FREEHAND;
        break;
    }

    for( i = IMGED_CLIP; i <= IMGED_HOTSPOT; i++ ) {
#if 0
        if( _wpi_isitemenabled( hmenu, i ) ) {
            _wpi_checkmenuitem( hmenu, i, FALSE, FALSE );
        }
#else
        if( _wpi_isitemchecked( hmenu, i ) ) {
            _wpi_checkmenuitem( hmenu, i, FALSE, FALSE );
        }
#endif
    }
    _wpi_checkmenuitem( hmenu, toolType, TRUE, FALSE );

    SetDrawTool( toolType );
    return( prev_tool );

} /* SetToolType */
Beispiel #7
0
/*
 * DrawAreaWinProc - window procedure for the drawing area window
 *                 - this window is an MDI window
 */
MRESULT CALLBACK DrawAreaWinProc( HWND hwnd, WPI_MSG msg,
                                  WPI_PARAM1 wparam, WPI_PARAM2 lparam )
{
    static WPI_POINT    start_pt = { -1, -1 };
    static WPI_POINT    end_pt = { -1, -1 };
    static WPI_POINT    prev_pt = { -1, -1 };
    static WPI_POINT    new_pt = { -1, -1 };
    static WPI_POINT    pt1;
    static BOOL         flbuttondown = FALSE;
    static BOOL         frbuttondown = FALSE;
    static BOOL         fdraw_shape = FALSE;
    static BOOL         firsttime;
    static BOOL         wasicon;
    int                 mousebutton;
    WPI_POINT           pointsize;
    WPI_POINT           pt2;
#ifndef __OS2_PM__
    CREATESTRUCT        *cs;
    MDICREATESTRUCT     *mdi_cs;
    MINMAXINFO          *minmax;
#endif
    img_node            *node;
    int                 i;

    switch ( msg ) {
    case WM_CREATE:
#ifndef __OS2_PM__
        cs = (CREATESTRUCT __FAR *)lparam;
        mdi_cs = (MDICREATESTRUCT __FAR *)cs->lpCreateParams;
        node = (img_node *)mdi_cs->lParam;

        for( i = 0; i < node->num_of_images; i++ ) {
            node[i].hwnd = hwnd;
        }
        AddImageNode( node );
        CreateUndoStack( node );
        setTheCursor( -1, hwnd );
        wasicon = FALSE;
#endif
        firsttime = TRUE;
        i = i;
        return( 0 );

    case WM_MDIACTIVATE:
        if( IMGED_GET_MDI_FACTIVATE( hwnd, wparam, lparam ) ) {
            if( _wpi_isiconic( hwnd ) ) {
                wasicon = TRUE;
                break;
            } else {
                wasicon = FALSE;
                FocusOnImage( hwnd );
            }
        }
        return( 0 );

#ifndef __OS2_PM__
    case WM_GETMINMAXINFO:
        node = SelectImage( hwnd );
        if( node != NULL ) {
            minmax = (MINMAXINFO *)lparam;
            minmax->ptMinTrackSize.x = node->width +
                2 * _wpi_getsystemmetrics( SM_CXFRAME );
            minmax->ptMinTrackSize.y = node->height +
                2 * _wpi_getsystemmetrics( SM_CYFRAME ) +
                _wpi_getsystemmetrics( SM_CYCAPTION ) - 1;
        }
        break;
#endif

    case UM_SHOWVIEWWINDOW:
        ShowViewWindows( hwnd );
        return 0;

    case WM_SIZE:
        if ( _imgwpi_issizerestored( wparam ) ) {
            ResizeChild( lparam, hwnd, firsttime );
            firsttime = FALSE;
            if( wasicon ) {
                FocusOnImage( hwnd );
                wasicon = FALSE;
            }
#ifndef __OS2_PM__
        } else if ( _imgwpi_issizeminimized( wparam ) ) {
            node = SelectImage( hwnd );
            HideViewWindow( hwnd );
            DeleteActiveImage();
            ClearImageText();
            SendMessage( ClientWindow, WM_MDINEXT, (WPARAM)(LPVOID)hwnd, 0L );
            wasicon = TRUE;
#endif
        }
        return( 0 );

#ifndef __OS2_PM__
    case WM_CHAR:
        pointsize = GetPointSize( hwnd );
        if( LOWORD( wparam ) == ESC_CHAR ) {
            if( !(lparam & 0x40000000) ) {
                switch( toolType ) {
                case IMGED_PASTE:
                    fdraw_shape = FALSE;
                    flbuttondown = FALSE;
                    frbuttondown = FALSE;
                    DontPaste( hwnd, &pt1, pointsize );
                    break;

                case IMGED_LINE:
                case IMGED_RECTO:
                case IMGED_RECTF:
                case IMGED_CIRCLEO:
                case IMGED_CIRCLEF:
                case IMGED_CLIP:
                    if( !flbuttondown && !frbuttondown ) {
                        break;
                    }
                    fdraw_shape = FALSE;
                    flbuttondown = FALSE;
                    frbuttondown = FALSE;
                    if( toolType == IMGED_LINE ) {
                        OutlineLine( hwnd, &start_pt, &prev_pt, &new_pt, TRUE );
                    } else if( toolType == IMGED_CLIP ) {
                        OutlineClip( hwnd, &start_pt, &prev_pt, &new_pt, TRUE );
                        SetRectExists( FALSE );
                    } else {
                        OutlineRegion( hwnd, &start_pt, &prev_pt, &new_pt, TRUE );
                    }
                    break;
                default:
                    break;
                }
            }
        }
        return( 0 );
#endif

    case WM_MOUSEMOVE:
        pointsize = GetPointSize( hwnd );
#ifdef __OS2_PM__
        WinSetPointer( HWND_DESKTOP, hCursor[cursorIndex] );
#endif
        IMGED_MAKEPOINT( wparam, lparam, new_pt );

        switch( toolType ) {
        case IMGED_SNAP:
#ifndef __OS2_PM__
            OutlineSnap();
#endif
            break;

        case IMGED_PASTE:
            pt1.x = new_pt.x / pointsize.x;
            pt1.y = new_pt.y / pointsize.y;
            pt2.x = prev_pt.x / pointsize.x;
            pt2.y = prev_pt.y / pointsize.y;
            if( pt1.x != pt2.x || pt1.y != pt2.y ) {
                DragClipBitmap( hwnd, &pt1, pointsize );
            }
            SetPosInStatus( &new_pt, &pointsize, hwnd );
            break;

        case IMGED_FREEHAND:
        case IMGED_BRUSH:
            if( flbuttondown ) {
                Paint( hwnd, &prev_pt, &new_pt, LMOUSEBUTTON );
            } else if( frbuttondown ) {
                Paint( hwnd, &prev_pt, &new_pt, RMOUSEBUTTON );
            }
            SetPosInStatus( &new_pt, &pointsize, hwnd );
            break;

        case IMGED_LINE:
        case IMGED_RECTO:
        case IMGED_RECTF:
        case IMGED_CIRCLEO:
        case IMGED_CIRCLEF:
        case IMGED_CLIP:
            if( flbuttondown || frbuttondown ) {
                if( new_pt.x / pointsize.x != end_pt.x / pointsize.x ||
                    new_pt.y / pointsize.y != end_pt.y / pointsize.y ) {
                    if( toolType == IMGED_LINE ) {
                        OutlineLine( hwnd, &start_pt, &new_pt, &prev_pt, FALSE );
                    } else if( toolType == IMGED_CLIP ) {
                        OutlineClip( hwnd, &start_pt, &new_pt, &prev_pt, FALSE );
                    } else {
                        OutlineRegion( hwnd, &start_pt, &new_pt, &prev_pt, FALSE );
                    }
                    end_pt = new_pt;
                    SetSizeInStatus( hwnd, &start_pt, &new_pt, &pointsize );
                }
            } else {
                SetPosInStatus( &new_pt, &pointsize, hwnd );
            }
            break;

        case IMGED_FILL:
            SetPosInStatus( &new_pt, &pointsize, hwnd );
            break;

        default:
            SetPosInStatus( &new_pt, &pointsize, hwnd );
            break;
        }
        prev_pt = new_pt;
        return( 0 );

    case WM_LBUTTONDOWN:
    case WM_RBUTTONDOWN:
        pointsize = GetPointSize( hwnd );
        SetCapture( hwnd );
        if( msg == WM_LBUTTONDOWN ) {
            if( frbuttondown ) {
                break;
            }
#ifdef __OS2_PM__
            node = GetCurrentNode();
            if( hwnd != node->hwnd ) {
                break;
            }
#endif
            flbuttondown = TRUE;
            mousebutton = LMOUSEBUTTON;
        } else {
            if( flbuttondown ) {
                break;
            }
            node = GetCurrentNode();
            if( hwnd != node->hwnd ) {
                break;
            }
            frbuttondown = TRUE;
            mousebutton = RMOUSEBUTTON;
        }
        fdraw_shape = TRUE;
        IMGED_MAKEPOINT( wparam, lparam, start_pt );
        IMGED_MAKEPOINT( wparam, lparam, new_pt );

        switch( toolType ) {
        case IMGED_SNAP:
#ifndef __OS2_PM__
            TransferImage( hwnd );
#endif
            fdraw_shape = FALSE;
            flbuttondown = FALSE;
            frbuttondown = FALSE;
            break;

        case IMGED_FREEHAND:
        case IMGED_BRUSH:
            BeginFreeHand( hwnd );
            DrawSinglePoint( hwnd, &start_pt, mousebutton );
            break;

        case IMGED_LINE:
            IMGED_MAKEPOINT( wparam, lparam, end_pt );
            OutlineLine( hwnd, &start_pt, &new_pt, &prev_pt, TRUE );
            break;

        case IMGED_RECTO:
        case IMGED_RECTF:
        case IMGED_CIRCLEO:
        case IMGED_CIRCLEF:
            IMGED_MAKEPOINT( wparam, lparam, end_pt );
            OutlineRegion( hwnd, &start_pt, &new_pt, &prev_pt, TRUE );
            break;

        case IMGED_CLIP:
            IMGED_MAKEPOINT( wparam, lparam, end_pt );
            RedrawPrevClip( hwnd );
            OutlineClip( hwnd, &start_pt, &new_pt, &prev_pt, TRUE );
            break;

        case IMGED_FILL:
            FillArea( &start_pt, mousebutton );
            RecordImage( hwnd );
            break;

        case IMGED_HOTSPOT:
            SetIsSaved( hwnd, FALSE );
            prev_pt.x = start_pt.x / pointsize.x;
            prev_pt.y = start_pt.y / pointsize.y;
            SetNewHotSpot( &prev_pt );
            break;

        default:
            break;
        }
        prev_pt = new_pt;
        return 0;

    case WM_LBUTTONUP:
    case WM_RBUTTONUP:
        pointsize = GetPointSize( hwnd );
        IMGED_MAKEPOINT( wparam, lparam, end_pt );
        IMGED_MAKEPOINT( wparam, lparam, new_pt );
        if( msg == WM_LBUTTONUP ) {
            mousebutton = LMOUSEBUTTON;
        } else {
            mousebutton = RMOUSEBUTTON;
        }

        if( fdraw_shape ) {
            switch( toolType ) {
            case IMGED_PASTE:
                PasteImage( &start_pt, pointsize, hwnd );
                flbuttondown = FALSE;
                frbuttondown = FALSE;
                break;

            case IMGED_FREEHAND:
            case IMGED_BRUSH:
                if( flbuttondown || frbuttondown ) {
                    EndFreeHand( hwnd );
                    RecordImage( hwnd );
                }
                break;

            case IMGED_LINE:
                DrawLine( hwnd, &start_pt, &end_pt, mousebutton );
                RecordImage( hwnd );
                break;

            case IMGED_RECTO:
            case IMGED_RECTF:
            case IMGED_CIRCLEO:
            case IMGED_CIRCLEF:
                DisplayRegion( hwnd, &start_pt, &end_pt, mousebutton );
                RecordImage( hwnd );
                break;

            case IMGED_CLIP:
                SetClipRect( hwnd, &start_pt, &end_pt, pointsize );
                break;

            default:
                break;
            }
            fdraw_shape = FALSE;
        }
        ReleaseCapture();
        flbuttondown = FALSE;
        frbuttondown = FALSE;
        prev_pt = new_pt;
        return( 0 );

    case WM_PAINT:
        RepaintDrawArea( hwnd );
        return( 0 );

    case WM_QUERYENDSESSION:
    case WM_CLOSE:
        if( lastChanceSave( hwnd ) ) {
            CloseCurrentImage( hwnd );
            return( (MRESULT)1 );
        } else {
            return( (MRESULT)0 );
        }

#ifndef __OS2_PM__
    case WM_DESTROY:
        SetCursor( LoadCursor( NULL, IDC_ARROW ) );
        return( 0 );
#endif

    default:
        break;
    }
    return( _imgwpi_defMDIchildproc( hwnd, msg, wparam, lparam ) );

} /* DrawAreaWinProc */