IssacJones
asked on
How to get a transparent rectangle in a view
Hiya
I have an MFC SDI application. In the View I want to draw a rectangle with a black border. However, I want the inside of the rectangle to be empty i.e. transparent. That is, I want to be able to put the rectangle over other shapes in the View and they will appear through the rectangle.
I have tried it so far using
pDC->SetBkMode(TRANSPARENT );
pDC->Rectangle(100,-100,40 0,-400);
and nothing covered in the rectangle comes through.
John
I have an MFC SDI application. In the View I want to draw a rectangle with a black border. However, I want the inside of the rectangle to be empty i.e. transparent. That is, I want to be able to put the rectangle over other shapes in the View and they will appear through the rectangle.
I have tried it so far using
pDC->SetBkMode(TRANSPARENT
pDC->Rectangle(100,-100,40
and nothing covered in the rectangle comes through.
John
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You could use a combination of MoveTo (moves cursor to a point without drawing a line) and DrawTo (draws line from where the cursor was up to the new point).
The advantage of this technique is that it copes with any shape not just rectangles.
The advantage of this technique is that it copes with any shape not just rectangles.
ASKER
Hiya Zoppo
Sorry you were right, I didn't use SelectStockObject.
now that I have it works ok.
John
Sorry you were right, I didn't use SelectStockObject.
now that I have it works ok.
John
ASKER
Nope, that doesn't work. The rectangle is complely black.
By the way, the rectangle covers a bitmap. Would that make a difference?
John