|
FreeCastle wrote: I get the client rectangle in the OnSize message handler, and then compute the new dimensions of the two lines
No need to get the client rect in the OnSize handler. the cx and cy will give you the width and height of the window.
FreeCastle wrote: All I do then in the OnSize()-method is a call to Invalidate
No need to call Invalidate in OnSize Handler
FreeCastle wrote: the dimensions of the two lines are computed correctly for 100% sure
Pls provide some code, to figure out the problem
Do your Duty and Don't expect the Result Rate this Post, if I helped You
|
|
|
|
|
Yes I know that cx and cy will also work. But I wanted to be completely sure, so I used GetClientRectangle. The result is anyway the same.
When I don't call "Invalidate" in the OnSize Handler then my dialog won't clear out the old contents (this will be then first done when I hide and show it again).
Here is some example code (all placed in my simple dialog class):
I have the following attributes:
<br />
Graphics* m_Canvas;
RECT m_rcRect;
And the following methods:
<br />
OnPaint() <br />
{<br />
drawLines();<br />
CDialog::OnPaint();<br />
}<br />
<br />
OnSize(UINT nType,int cx, int cy)<br />
{<br />
CDialog::OnSize(nType,cx,cy);<br />
<br />
m_rcRect.bottom = cy;<br />
m_rcRect.right = cx;<br />
<br />
Invalidate();<br />
}<br />
<br />
drawLines()<br />
{<br />
static bool bFirstCall = true;<br />
static Pen pen(Color::Red);<br />
<br />
if (bFirstCall == true) {<br />
m_Canvas = ::new Graphics(m_hWnd);<br />
bFirstCall = false;<br />
}<br />
<br />
m_Canvas->DrawLine(&pen,10,10,m_rcRect.right-10-10,10);<br />
m_Canvas->DrawLine(&pen,10,10,10,m_rcRect.bottom-10-10);<br />
}<br />
|
|
|
|
|
Do as below,
OnPaint(..)
{
CPaintDC dc(this);
DrawLines(&dc);
}
OnSize()
{
}
DrawLines(CDC* pDC)
{
Graphics g(pDC->m_hDC);
Pen pen(Color::Red);
CRect rc; GetClientRect(rc);
g.DrawLine(&pen, 10, 10, rc.Width() - 20, 10);
g.DrawLine(&pen, 10, 10, 10, rc.Height() - 20);
}
Do your Duty and Don't expect the Result Rate this Post, if I helped You
|
|
|
|
|
Ahhh thank you, that works. But anyway I have to put an Invalidate() into the OnSize handler, because without that I see the changes only after hiding and showing again the dialog.
I don't really understand why this has to be done by a HDC, but the main thing is that it works. But there is one question open to me. In my "real" application I also do some transformations on the Graphics object (you know, for e.g. having a real local coordinate system and so on). Actually those transformations have only to be done when the dialog is showed the first time, and each time when the dialog is resized. But with that solution I also would have to make those transformations each time I draw my graphical objects. I don't really know, but I think this slows the performance a little bit down (and performance is important to me in this app). So is there a way to just recreate the Graphics object when the windows is resized (so that I don't have to perform all the time those transformations)?
Anyway... thank you a lot!!
|
|
|
|
|
FreeCastle wrote: But anyway I have to put an Invalidate() into the OnSize handler, because without that I see the changes only after hiding and showing again the dialog.
That's because only the new part of the window is invalidated (marked for repainting) during a resize. To force the entire window to be repainted when the size changes, invalidating on
WM_SIZE is fine.
FreeCastle wrote: I don't really understand why this has to be done by a HDC
Why what needs to be done with an HDC?
If you want to keep a Graphics object (associated with a HDC for the window) around for the life
of the window then you may want to consider using CS_OWNDC in the window class. See the
RegisterClass API for details (AfxRegisterClass for MFC).
Mark
"If you can dodge a wrench, you can dodge a ball."
|
|
|
|
|
Hello everybody,
Does anybody here has a complete program of Circle Equation?
Please help.Thanks.
|
|
|
|
|
faridah_hani wrote: Does anybody here has a complete program of Circle Equation?
See here[^]
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Can you not draw a circle using Ellipse() ?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Can you explain what do you need,exactly about "complete program of Circle Equation"
|
|
|
|
|
who can tell me more information about windows recycle bin?
I don't know the INFO2 data structure.
Thanks!
|
|
|
|
|
apoluo wrote: tell me more information about windows recycle bin
Recycle Bin is a virtual folder.
It is a Namespace Shell Extension (NSE). My Documents, My Music, and My Pictures all are NSE. This are some virtual representation to some location. That is, if you save any file in My Documents then the file will be originaly saved in C:\My Documents and not in the Desktop/My Documents (that is, C:\Documents and settings\user name\Desktop). Foe more information, refer Shell Extensions and Namespace Extensions.
apoluo wrote: I don't know the INFO2 data structure
I Have no idea abt this structure, may be its a user defined one.
Do your Duty and Don't expect the Result Rate this Post, if I helped You
|
|
|
|
|
It is related to OS.
The windows recycle rename the file in it ,the real name of file is recorded in INFO2, my recent work is about this.But I have no idea about it .
|
|
|
|
|
|
|
When I link my application in VS2005 with the lua library compiled with the same parameters (code generated MTd) I get the following error:
c1xx : error C3174: module attribute was not specified
fatal error LNK1250: failed to merge IDL content
Please, Can anybody help me?
marcof
|
|
|
|
|
abac_mefisto wrote: c1xx : error C3174: module attribute was not specified
Error description[^] for this describes about missing module attribute. Have you checked it ?
|
|
|
|
|
Thank you for your hint; where do I have to set the module attribute, in the source code or through properties of the project ?; for the lua library?
What do you mean underneath writing Notifier using ATL.
Hope to hear you again
Marco
marcof
|
|
|
|
|
abac_mefisto wrote: where do I have to set the module attribute
I guess, compiler should tell you that. For whihc clss/structure/interface error is appearing.
abac_mefisto wrote: What do you mean underneath writing Notifier using ATL.
Its my signature, about my article.
|
|
|
|
|
Thankyou for the hint. Where do I change the module attribute, in the source code or from properties of the project? for the lua library ? It seems that the acceptable attributes are dll, exe or server not library.
Hope to hear you again
Marco
marcof
|
|
|
|
|
Hi,
I need to paint background of a CWnd derived class. how to do that ??
thanks
Today is a gift, that's why it is called the present.
|
|
|
|
|
I'm not sure about your intention. But, doesn't WM_PAINT solve your purpose ? What do you mean by background of a window ?
|
|
|
|
|
prasad_som wrote: doesn't WM_PAINT solve your purpose ?
Its better to draw background color in WM_ERASEBKGND message handler
Do your Duty and Don't expect the Result Rate this Post, if I helped You
|
|
|
|
|
Did you refered WM_CTLCOLOR and WM_ERASEBKGND
Do your Duty and Don't expect the Result Rate this Post, if I helped You
|
|
|
|
|
yes I tried in OnEraseBkgnd but no use
BOOL CClrCatalogWnd::OnEraseBkgnd(CDC* pDC)
{
if(m_hbrBackground)
DeleteObject(m_hbrBackground);
m_hbrBackground = CreateSolidBrush(RGB(100,100,100));
pDC->SelectObject(m_hbrBackground);
return CWnd::OnEraseBkgnd(pDC);
}
What to do in OnCtlColor??
Today is a gift, that's why it is called the present.
|
|
|
|
|
Change the implementation as below
BOOL CClrCatalogWnd::OnEraseBkgnd(CDC* pDC)
{
if(m_hbrBackground)
DeleteObject(m_hbrBackground);
m_hbrBackground = CreateSolidBrush(RGB( m_nSliderPos, m_nSliderPos, m_nSliderPos));
CRect rc; GetClientRect( rc );
::FillRect(pDC->m_hDC, rc, m_hbrBackground);
return TRUE;
}
narayanagvs wrote: What to do in OnCtlColor??
if nCtlColor is equal to CTLCOLOR_DLG, then you have to return the HBRUSH to paint the dialog.
It seems that you are changing the background color, depending on the slider value, if so, just return TRUE in OnEraseBkgnd(..) and do the above implementation in OnPaint handler
Do your Duty and Don't expect the Result Rate this Post, if I helped You
|
|
|
|