// JP opened flex table

Click to See Complete Forum and Search --> : Doubt in GDI


pgnanaprakash
November 12th, 2003, 02:46 AM
Hi all,

Currently i am doing project for desinging graphics application with the help of GDI objects using MFC. In this application i use two tools like Unfilled rectangle and filled rectangle with different line stlyes. While selecting the unfilled rectangle, the rectangle will be drawn with current brush object. But i need to draw the rectangle with transparent brush. How can i do it. I can acheive it through the Draw3dRect function, but it doesn't support the differnt line stlyes. So please help me to solve this problem.

Prakash

Doctor Luz
November 12th, 2003, 03:36 AM
You can draw the unfiled rectangle, for example, with MoveTo and LineTo (with the rectangle corners as parameters). That will mantain the current pen.

bubu
November 12th, 2003, 10:46 PM
Change the fill style using GDI:

I'm not sure this code will work as is. I know little C++ and I'm posting the part of my VB code with a bit of C++ translation:


This is the code use to set the line style of a given HDC


long lColor = RGB(255,0,0); // Red line color

long lStyle = 1; // Dashed line
// lStyle can be:
// lSOLID = 0
// lDASH = 1
// lDOT = 2
// lDASHDOT = 3
// lDASHDOTDOT = 4
// lNONE = 5
// lINSIDEFRAME = 6

// Define line thickness
long lTickness = 1;

// hdc = given Device Context

// Change line draw style
long TmpObj = CreatePen(lStyle, lTickness, lColor);
DeleteObject SelectObject(hdc, TmpObj);



This is the code use to set the fill style of a given HDC


long lColor = RGB(0,0,255); // Green fill color
long TmpObj; // Hold the brush object

long fStyle; // Hold the fill style to be set. Can be:

// Polygon fill styles
// fHorizontal = 0
// fVertical = 1
// fFDIAGONAL = 2
// fBDIAGONAL = 3
// fCROSS = 4
// fDIAGCROSS = 5
// fSOLID = 6
// fTRANSPARENT = 1234

// If we are setting the fill style no to Solid, use the CreateHatchBrush() API
// to create fancy line styles
if (fStyle != fSOLID)
{
// Fancy fill
TmpObj = CreateHatchBrush(fStyle, fColor);
}
else
{
// Solid fill
TmpObj = CreateSolidBrush(fColor);
}

// Aply the new style and delete the old object
DeleteObject SelectObject(hdc, TmpObj)


Hope you got it!

//JP added flex table