CDC::Rectangle and client area
Lets say that place a rectangle border on the client area at
10,10,45,45. And lets say that client area is 200x200 or so. How can
I make the recangle border resize itself in proportion to the changes
of the client area? In other words, lets say I resize the client to
250x200 etc. How can I adjust the border of the rectangle to widen
itself? What would the formula look like to figure out the percentage
This is pretty simple arithmetic.
You have a rectangle which is 10,10, 45, 45. Therefore it is a 35x35 rectangle. It
represents 35/200 of the area, and it starts 10/...Getting CDC
I want to display something in the OnUpdate method, how do I get a handle to
the CDC from here?
> I want to display something in the OnUpdate method, how do I get a handle to
> the CDC from here?
This sounds like a beginner's mistake. You can call GetDC, but that is
poor design and probably won't work the way you intend.
Painting in OnUpdate will be lost after the window is minimized/restored
or covered/uncovered. The default OnUpdate solves this problem by
calling Invalidate(). Then the painting is done in the resulting
OnDraw,...CDC::arc() with big pen crash on win98
I've encountered a problem that occurs only under Win98:
I have a dc object and I'm trying to draw an arc (I'm using the CDC::arc()
I'm using a pen that has a big width.
The problem is that it crashes sometimes (only when the arc is big and only
a small part of it is displayed).
I tried to look in the knowledge base for this kind of bug and I found
something but it was a Win95 bug.
How can I know when the CDC::arc() function will crash? For example, I had a
problem when the bounding rectangle was bigger than 32767 (it crashed also
under Win98) but since I knew wh...which CDC
I am a bit confused as to which dc to call in the following situation. I
have a dialog app with a static control on it that I am using to paint a
graph on. I am doing the drawing in the lbuttondown function in the dialog
class. My qestion is how do I call the device context to paint on the
static control. Do I use the CClientDC dc(this); to get the device
context of the dialog and do the drawing using this dc, or do I call
CClinetDC dc(&m_myStaticControl); or dc = m_myStaticControl.GetDC(); to
get the dc of the control, and use it to do the drawing? Are all these ...HDC and CDC
I am attempting for the first time to use CreateDibSection and am puzzled as
to how to use HDC within the MFC framework. I can't see that CDC returns a
handle, so I am wondering if these two are mutually exclusive. Is there a
bridge between the handle and the class?
"Steve Russell" <firstname.lastname@example.org> wrote in message
> I am attempting for the first time to use CreateDibSection and am puzzled
> to how to use HDC within the MFC framework. I can't see that CDC returns
> handle, so I am wonderin...Strange CDC::MoveTo and CDC::MoveTo performance problem
Hi, I am writing a chart drawing program and encountered a strange
performance problem with CDC::MoveTo and CDC::LineTo function calls.
To avoid flickering, the program does the drawing on a memory device
context(m_DrawDC) and then BitBlt to the real display device. Here is the
void CView::OnDraw(CDC* pDC)
pDC->BitBlt(0, 0, ClientRect.Width(), ClientRect.Height(),
&m_DrawDC, 0, 0, SRCCOPY);
m_Dr...CDC:TextOut and Plus or Minus Sign
I am using MSVC 7.1.3088 on MS XP 5.1 service pack 2.
I am trying to write the plaus or misu sign to a display window using
CDC:TextOut. I can write the symbol to a character buffer using
sprintf(csText, "%s (%c%f %s)", csLabel, 177, fError, csUnits);
which gives me
"Elevation (=B17.926902 Meters)" in csText.
However, when I try to write it to the window using
TextOut(DeviceContext, (int)(pWindowPoint.x), (int)(pWindowPoint.y),
I get a rectangle where the =B1 (plus or minus) sign should be.
Is there a way I can write the PM sign to ...Pb CDC::Arc
I have a problem with this function of the GDI -> CDC::Arc.
The arc is drawn, but there is also a line joining the 2 extremities of
the arc. I don't want to have this line.
Thank you for your help,
Arc should not do this. Perhaps you could show the code where you are
drawing the arc?
Abstrakt Mekanik AB
"Christophe Jacquelin" <email@example.com> a �crit dans le message
> I have a problem with this function of the GDI -> CDC::Arc....trouble with CDC
I'm doing a program that needs to capture bitmaps off a window of another
program. I'm doing okay except I have an intermittent failure. I admit I'm
not testing for all the possible MFC error returns at this early stage, but
even I did I'm not sure how I'd deal with this error.
My piece of code looks like this.
void CMyDlg::GrabRect(CWnd *pWnd, CRect rc)
CDC * pSourceDc = pWnd->GetDC();
Sleep(50); // !!!!! need this or the crash happens almost right away
I'd like to select bitmaps into a device context
created by CreateCompatibleDC. My problem is
that if I select a bitmap stored in a CImageList,
the result from SelectObject is Null indicating
failure. But if I select a bitmap loaded with
LoadBitmap from a resource, I can select it
into the same DC without problems.
What am I doing wrong? Any suggestions
At the point where you select the bitmap, it needs to be a valid bitmap. You have not
shown the code you are using, so it is hard to tell what you have done.
On Fri, 5 Dec 2008 02:51:42 -0800 (PST), F...Transferring control of CClientDC to CDC
I have a class MSWinDisplayManager which I want to take a CClientDC
context so that it's member functions can perform drawing routines on
I want the class to have it's own CClientDC member which all the
have access to draw on. My constructor looks like this:
This is called by the user like:
then I want to do things like:
The problem I have is that private_win isn't getting control of the
Has anyone had problems with the screen flickering using the CDC member
fuction "TextOut", with an update rate of 1000 Hz using on-screen counters in
the View's OnDraw() function, or anything else ?
On Mon, 12 Mar 2007 02:13:18 -0700, C Hill MBSC
>Has anyone had problems with the screen flickering using the CDC member
>fuction "TextOut", with an update rate of 1000 Hz using on-screen counters in
>the View's OnDraw() function, or anything else ?
If I reca...CDC::SelectClipRgn
I have to draw a line (using MoveTo and LineTo) that has to be clipped to a
portion of the screen.
The starting and ending coordinates are on opposite ends outside the visible
Clipping it does the trick of showing only a portion of the line within the
area it is supposed to draw in.
When using a printer DC to print (standard print preview of an MDI
application) the clipping doesn't seem to work, so the line gets drawn all
over the place.. even outside the paper boundaries in print-preview.
What can I do about this?
It would be quite a hassle to have to calculate the 'inte...CDC same as CClientDC
Are they the same?
@~@ Might, Courage, Vision, SINCERITY.
/ v \ Simplicity is Beauty! May the Force and Farce be with you!
/( _ )\ (Xubuntu 8.04.1) Linux 22.214.171.124
^ ^ 12:38:01 up 4 days 21:28 3 users load average: 1.03 1.03 1.00
? ? (CSSA):
Not exactly, no. CClientDC is derived from CDC.
"Man-wai Chang ToDie (33.6k)" <firstname.lastname@example.org> wrote in message
&g...why i can not use CDC::TransparentBlt
I am using VC 6.0 sp6
the sdk is the most latest
but when i use CDC::TransparentBlt
the complier report error
the error message is:
G:\myproject\game004\Man.cpp(72) : error C2039: 'TransparentBlt' : is not a
member of 'CDC'
d:\program files\microsoft visual
studio\vc98\mfc\include\afxwin.h(636) : see declaration of 'CDC'
Error executing cl.exe.
Exactly what error do you get?
Nish [VC++ MVP]
"howyougen" <take..email@example.com> wrote in message
Ok this is really starting to mess things up for me and ive searched the msdn
library until my head hurts, so ive decided to ask you guys. Theres two
things im having problems with:
1) Copying an image to a temporary CDC, then stretching it onto another CDC.
For example this code generates runtime errors for me (while if i use
this->GetDC() it does not):
CDC dcImg, dcTemp;
dcTemp.StretchBlt(0, 0, 250, 250, &dcImg, 0, 0, 100, 100, SRCCOPY);
2) this->GetDC() will not let me change the brush, p...CDC::m_hAttribDC
I still have to see a purpose for this data member. With the exception
of CMetafileDC, m_hDC is always equals to m_hAttribDC. In my
applications, all it does is adding overhead in all the functions that
first check if (m_hDC == m_hAttrib) and then check if ( m_hAttrib !=
Does someone has a concrete example of where m_hAttribDC is actually
The attribute DC is also used for print previews. I assume you are doing
something really bizarre if you often need to check equality the way you
Abstrakt Mekanik AB
One of the common shapes that seems to be missing from the CDC members is
the arrow. Is there a good way to do arrows? I need to create arrows around
the circumference of a circle pointing toward the center of the circle. Any
hints on how this is best done?
www.Newsgroup-Binaries.com - *Completion*Retention*Speed*
Access your favorite newsgroups from home or on the road
I'm not sure if CDC has any line caps. In the past I used GDI+ to draw
arrows and different kind of line caps.
IMHO, the default line caps don't scale very well, so ...CDC/HDC????
I am trying to develop a print screen utility for a windows CE program.
I am writing it in Embedded VC++ and running into some weirdness.
My plan of action is to use GetClientRect() to find the location of the
window, then loop through each pixel in that region and perform a
GetPixel() to get the RGB value.
My problem is that I need a HDC in order to perform GetPixel(). I used
GetActiveWindow() to get an HWND, then used FromWindow() to get a CWnd
pointer. I then tried the following line to get an HDC.
When I compile though I get the following error.
how can I get (save) the current clip region of a CDC? There is no
corresponding method and ::GetClipRgn doesn't accept a CDC.
Daniel Lidstr�m wrote:
> how can I get (save) the current clip region of a CDC? There is no
> corresponding method and ::GetClipRgn doesn't accept a CDC.
CDC::GetClipBox( LPRECT lpRect )
Scott McPhillips [VC++ MVP]
On Tue, 27 Jan 2004 09:23:17 -0500, Scott McPhillips [MVP] wrote:
> Daniel Lidstr�m wrote:
>> how can I get (save) ...CDC::DrawEdge
What rectangle is used to draw a 3d edge by DrawEdge?
In my opinion DrawEdge() draws on the right and bottom sides always
one pixel less than the given rect which is not mentioned in the
documentation. But this would be the same behaviour as known from
FillRect() and FillSolidRect().
I made some lines around but *on* my window rectangle using LineTo()
and than I called DrawEdge with EDGE_SUNKEN and BF_RECT on exactly the
same rect. The top left corner is ok, DrawEdge draws onto the corner,
but the bottom right corner looks like this:
gw| g: grey
gw| w...Rotating text in a CDC
Is it possible to rotate text in a simple way inside a CDC object?
I added the next code in OnPaint for a CWnd object, but the text
still appears "normal". I tried setting the lfEscapament and lfOrientation
to 1, 9, 90, etc (both simultaneously), but nothing worked.
CPaintDC dc(this); // device context for painting
pNewFont = new CFont();
// Load the present font from the DC
pCurFont = dc.GetCurrentFont();
// Just change the orientation
I am using the CDC Class to print some data out that does
not utilize the CView class. The data is also tab
delimited. One thing I ran across is that if I spread the
data way out based on the tabs it truncates. I have
searched MSDN and I am sure I missed it. Is there a way
to set the device to "wrap" then set it back to "wrap"?
You can not make DC wrap your output. But you can make DrawString function
wrap the line with DT_WORDBREAK flag. To figure out where to print next
line, call DrawText with DT_CALCRECT flag to know the height of the printed
I presently work on an application which visualises measured data (that
are read from a file). This works fine, but when the window of my
program has to be redrawn, the displayed data get lost (of course).
Since the amount of these data is very high, I could not re-read all
data after calling OnDraw, so I need some sort of buffering (of the
I guess this buffering can be realised by means of the method
CreateCompatibleDC, but I don't know how???????
Maybe someone can give me a few advices....
Joseph M. Newcomer wrote:
> What I did in thi...CDC
My current application reads measuring data from a file and draws a diagram.
Since I don't want to lose this diagram in case the window has to be
re-drawn, I draw it to an "in-memory bitmap" and copy this bitmap to the
I use the following code for the creation of the bitmap:
CDC *dc = GetDC();
m_Bitmap.CreateCompatibleBitmap(dc, rect.Width(), rect.Height());
Unfortunately, the colors used to display the data, differ from their
For example, if I w...