|
OK, thank you for this hint!
The fact that the CFont pFont looses scope at the end of this OnButton() function was the fault. After declaring the CFont pFont as a private member variable of my dilog everythings ok!
|
|
|
|
|
confused:hi all,
i want my application to run when it is scheduled..else it just sits idle in task bar..i can do everything else than scheduling as windows task scheduler does..can anyone help..me completing my work..any help and pointers are thouroughly appreciated..
thanks in advance..
Himanshu
|
|
|
|
|
SetWaitableTimer() CreateWaitableTimer()
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
:(thanks ted..but that doesn't solve my problem..because if user will exit the process manually it will stop..and i don't want that..i want it to run in back..and do the job when it is scheduled to..even if user exits it from the system tray..can it be done..
thanks for help..
cheers
Himanshu
|
|
|
|
|
If you don't want to allow the user to stop it, write it as a service, or possibly make use of the 'AT' command for scheduling a task, but there again the user could stop this as well!
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
Hi,
when using std::less for a type where it's not defined (complex<double> in this case) like this:
template <class FLOAT>
int Foo(FLOAT & a, FLOAT & b)
{
std::less _less;
if ( _less(a,b)) {
...
}
}
I get the error:
C:\Programme\DevStudio6\VC98\INCLUDE\functional(86) : error C2784: 'bool __cdecl std::operator <(const class std::multimap<_K,_Ty,_Pr,_A> &,const class std::multimap<_K,_Ty,_Pr,_A> &)' : could not deduce template argument for 'const class std::multimap<_K,_Ty,_Pr,_A> &' from 'const class std::complex<double>'
C:\Programme\DevStudio6\VC98\INCLUDE\functional(86) : while compiling class-template member function 'bool __thiscall std::less<class std::complex<double> >::operator ()(const class std::complex<double> &,const class std::complex<double> &)
const'
now I wonder - how comes multimap into the game??
|
|
|
|
|
Hi,
how can I call a template member function, where the template parameters can not be deduced from the parameter list?
I have the following:
class CFoo
{
template<class FLOAT, int OP>
void Bar(FLOAT & a, FLOAT & b)
{ ... }
}; the following doesn't work.:
CFoo foo;
float a, b;
foo.Bar<float, 1>(a,b);
Any ideas?
Peter
So many people long for eternity that don't know what to do on a rainy sunday afternoon. [sighist] | [Agile Programming] [doxygen] If you look for evil in me you will find it whether it's there or not.
|
|
|
|
|
I was stuck in the same problem for some time one week ago...
I'd posted a question here and a lot of answers came to me, the reason it's a compiler limitation...
the compiler need the function definition and it's declaration to be in the same file...
I know this is not the better thing to do and that's not very clean, but it's the only way to make it work...
hope this helps...
|
|
|
|
|
|
Thanks!
took a bit of juggling around with forward decls, but works like a charm...
So many people long for eternity that don't know what to do on a rainy sunday afternoon. [sighist] | [Agile Programming] [doxygen] If you look for evil in me you will find it whether it's there or not.
|
|
|
|
|
I'm just curious. There seems to be no float/double version of the _wtoi(wide-character string to an integer) function. Is there such a function and if not why?
And the living obscurely rejoice at the news of a death, in the knowledge that it's not us, that we are still in the game.
Andrew Greig
|
|
|
|
|
This function available in VC++ 7.0. I think Latest platform SDK will solve your problem.
|
|
|
|
|
Do you know what it is called? _ttof? _wtof?
And the living obscurely rejoice at the news of a death, in the knowledge that it's not us, that we are still in the game.
Andrew Greig
|
|
|
|
|
|
Thank you
And the living obscurely rejoice at the news of a death, in the knowledge that it's not us, that we are still in the game.
Andrew Greig
|
|
|
|
|
Hi sorry for the long code snippet...i didnt know where the error could possibly be thus the long extract.;p..anyway the code below attempts to draw 2 axes and label them.However, both x&y axis label appears twice.One set with a smaller font and right escapement, the other set with bigger font and failed escapement(the text is not rotated).
Does anyone know why?I've flipped through books but nothing seemed wrong to me.
CPen axisPen (PS_SOLID, 2, RGB(0,0,0));<br />
CFont axisXFnt,axisYFnt;<br />
CPen *pOldPen;<br />
CFont *pOldFont;<br />
LOGFONT lf;<br />
TEXTMETRIC tm;<br />
int fontSize=8;<br />
<br />
ZeroMemory(&lf, sizeof(lf));<br />
lstrcpy(lf.lfFaceName,"Arial");<br />
lf.lfHeight=fontSize;<br />
axisXFnt.CreateFontIndirect(&lf);<br />
<br />
pDC->GetTextMetrics(&tm);<br />
int charWidth = tm.tmAveCharWidth;<br />
<br />
m_AxisXName="Values";<br />
m_AxisYName="Time";<br />
<br />
pOldPen = pDC->SelectObject(&axisPen);<br />
pDC->MoveTo(m_origin);<br />
pDC->LineTo(m_endPoint);<br />
<br />
pDC->MoveTo(m_origin);<br />
pDC->LineTo(m_endPoint2);<br />
pDC->SelectObject(pOldPen);<br />
<br />
pOldFont = (CFont*) pDC->SelectObject(&axisXFnt);<br />
pDC->SetTextAlign(TA_CENTER|TA_BOTTOM);<br />
pDC->TextOut((graphRect.Width() / 2) - ((m_AxisXName.GetLength() / 3)*charWidth),graphRect.top+15,m_AxisXName);<br />
<br />
lf.lfEscapement=900;<br />
axisYFnt.CreateFontIndirect(&lf);<br />
pDC->SelectObject(&axisYFnt);<br />
pDC->SetTextAlign(TA_BOTTOM|TA_CENTER);<br />
pDC->TextOut(graphRect.left+10,((graphRect.Height() / 2) + ((m_AxisYName.GetLength() / 3)*charWidth)),m_AxisYName);<br />
pDC->SelectObject(pOldFont);
-forgive me, im a newb-
|
|
|
|
|
Some notes:
When rotating a font, you also need to set the lfOrientation = 900 in the LOGFONT structure.
Personally, I never rely on the GDI o correctly position text for me. I use GetTextExtent() and calculate the exact position the text should be displayed and pass the start coordinates in to TextOut().
Drawing twice: Is this being done in an OnDraw() function? If it is you need to call Validate() or use a CPaintDC() oobject which automatically validates the client area after the DC is released.
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
thks
I didnt know how to use GetTextExtent().I'll read up on it.
Anyway the codes are contained in a function of a separate class which are called by the OnPaint() function of my CDialog class. Is it counted? When should i call Validate() then?
Anyway do u know the difference between Validate() and InValidate()?
once again,thks
|
|
|
|
|
If its in your on paint and your not using a CPaintDC object then you must call Validate() at the end of the procedure otherewise windows will send you another WM_PAINT message, and then another until the area is validated or is obscured completely by another window. CPaintDC does a validate() call for you automatically in its destructor, but if your using GetDC()/ReleaseDC() in the OnPaint, you need to call it.
Validate() syas to windows, this window is upto date and does not need to be-redrawn
Invalidate() says to windows that this window (or a rectangle of it) needs to be re-drawn. Windows will queue a WM_PAINT message for the window which had an invalidate() call on it.
GetTextExtent() is a function to be called on the DC
CString text = "I want to know my length!";
CSize textSize = pDC->GetTextExtent(text, text.GetLength());
textSize.cx = length of text in pixels for the current output font
textSize.cy = Height of text in pixels for the current output font
With this info you could centre you text using
CRect window;
GetWindowRect(&window);
x = (window.Width() - textSize.cx) / 2;
y = 500;
pDC->TextOut(x, y, text, text.GetLength());
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
hey thks lot...i finally know the difference
and yes, i did a GetDC()/ReleaseDC() in my OnPaint() but when i typed
Validate() at the end of it all...and error of "undeclared identifier" was returned?
|
|
|
|
|
i tried Validate(pDC) and this->Validate().
All of them gave me the same error msg(undeclared identifier)...
Should i place it before or after ReleaseDC() anyway?
thks.
|
|
|
|
|
Ooops,
sorry its:
ValidateRect()
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
it's ok;)
i called ValidateRect(graphRect) jus before ReleaseDC()...where graphRect is a CRect...is that right?
|
|
|
|
|
Thats should work ik. But just 1 small possible danger. If the update rectangle for the WM_PAINT call (which comes in a PAINTSTRUCT) is slightly larger than your graphRect then this could cause additional WM_PAINT messages to be sent to you. I usually do:
void X::OnPaint()
{
CDC pDC = GetDC();
pDC_>ReleaseDC();
CPaintDC dc;
}
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
i put "CPaintDC dc" but an error was returned stating no appropriate default constructor available, so i tried "CPaintDC dc(this)" n it complied successfully but it wiped out all i've drawn earlier.
here's my code...
void CGrapDlg::OnPaint()
{
CWnd* graphFrame = (CWnd*)GetDlgItem(IDC_GRAPH_FRAME);
CDC* pDC = graphFrame->GetDC();
plotGraph.Plot(pDC);
ReleaseDC(pDC);
CPaintDC dc(this);
}
have a nice weekend n thks
|
|
|
|