Customize Rubberband

Discussion created by krfournier on Jul 14, 2010
Latest reply on Jul 15, 2010 by kirkktx
I have a client that has impaired vision. He has difficulty seeing the 1-pixel inverted rectangle used to render the rubberband.

Is it possible to customize this to any degree? In a perfect world, I'd like a solid border with a translucent fill.

I've tried using IDisplayFeeback, but it will not erase previous rectangles (see attached). Furthermore, it will not make the fill translucent. I'd be okay not using the fill if I could make the line thicker, but no matter what I do to the ISimpleLineSymbol, it is always rendered at a thickness of 1 pixel.

I tried doing it all myself using IScreenDisplay and the WindowDC, but anything I draw is instantly erased. So, I tried using OnAfterScreenDraw, but nothing ever appears.

I'm out of ideas.

Any help would be greatly appreciated.

Code to create the rubberband symbol:

// create the symbol used for rubberbands
CComPtr<ISimpleFillSymbol> pFill = NULL;
if( SUCCEEDED(pFill.CoCreateInstance(CLSID_SimpleFillSymbol)) && pFill )
    CComPtr<IRgbColor> pColor = COLORREFToIColor( GetSysColor(COLOR_HIGHLIGHT) );
    if( pColor )
        pColor->put_Transparency( 63 );

        CComPtr<IRgbColor> pColorLine = COLORREFToIColor( 0 );
        if( pColorLine )
            CComPtr<ISimpleLineSymbol> pLine = NULL;
            if( SUCCEEDED(pLine.CoCreateInstance(CLSID_SimpleLineSymbol)) && pLine )
                pLine->put_Color( pColorLine );
                pFill->put_Outline( pLine );
            pFill->put_Color( pColor );
            if( SUCCEEDED(pFill->QueryInterface(IID_ISymbol, (void**)&m_pRubberbandSymbol)) && m_pRubberbandSymbol )

Code to draw the rectangle manually during mouse move event:

void CBGMapCtrl::OnTrackEnvelope( CPoint point )
    // create the envelope
    CBGEnvelope rcTrack;
    if( rcTrack.Create() )
        // create the rectangle based on the starting point and current mouse point
        rcTrack.CopyRect( CRect(m_ptTrackStart, point) );

        // make sure the rectangle is in map coordinates
        rcTrack.ToMapSpace( m_pMapControl );

        // get the active view
        CComPtr<IActiveView> pActiveView = NULL;
        if( SUCCEEDED(m_pMapControl->get_ActiveView(&pActiveView)) && pActiveView )
            // draw rectangle
            CComPtr<IScreenDisplay> pScreenDisplay = NULL;
            if( SUCCEEDED(pActiveView->get_ScreenDisplay(&pScreenDisplay)) && pScreenDisplay )
                pScreenDisplay->StartDrawing( NULL, esriViewNone );
                pScreenDisplay->SetSymbol( m_pRubberbandSymbol );
                pScreenDisplay->DrawRectangle( rcTrack );

Note: CBGEnvelope is a wrapper around CRect and IEnvelope. I can provide code for this if requested, but I don't think it's relevant.