|
OK... I must not be communicating clearly, so here is how I am currently interpreting your answers:
"There is no way to put a compile-time (ie, using the preprocessor) guard on a block of statements based on the type of a template parameter. If you want to execute code within a template for types with differing interfaces, you must either create specialized templates for each type, create multiple methods with unique signatures, or typecast the input to the appropriate type for each applicable section of code. Any of these methods will work, and there is no other way to accomplish the same thing."
Did I interpret your answers correctly, or is something above not true? Thanks,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Skippums wrote: Did I interpret your answers correctly?
Well almost. All I am saying is that if you are using a template that specifies its type as float or double you must ensure that the following code does not violate any of the rules concerning that type. In your code you are using the |= operator on a value, which really has no meaning for numerics, particularly floating point numbers. All you need to do within your template code is use acceptable operators to manipulate your data, or cast the items to a 'logical' type; for example any of the mathematical operators (+ - * /) should work fine regardless of the type of the numbers.
MVP 2010 - are they mad?
|
|
|
|
|
I'm having the same problem as Jeff.
Your answer that he is using the wrong operator misses the point.
I, for example, am trying to use the shift operators (<< or >>) in a numeric conversion.
The template also needs to take floats, and although I've used boost::is_integral to ensure that floats are not shifted, the compiler cannot see this runtime decision.
|
|
|
|
|
Ken Moynihan wrote: Your answer that he is using the wrong operator misses the point.
On the contrary, that is the point. If you wish to compile source code then that source must follow the rules of the language. If, at run time, you wish to overrirde or otherwise work around those rules by casting then you are free to do so.
It's time for a new signature.
|
|
|
|
|
I think communication has broken down here.
Thank you for taking the time to reply anyway.
|
|
|
|
|
kmoy007 wrote: I think communication has broken down here.
Obviously! Who are you and why are you responding?
It's time for a new signature.
|
|
|
|
|
Hi,
My application is using GDI+ to handle image as a background. It works OK under Windows XP. I found recently that it display very slow under Windows 7.
Gdiplus::Graphics gr(dc);
gr.SetPageUnit(Gdiplus::UnitPixel);
gr.DrawImage(pBmp, x1, y1, abs(x2-x1), abs(y2-y1));
What kind problem it could be? How can I solve it?
Thank you very much,
|
|
|
|
|
You might want to try updating your video board driver. Don't know for sure if it'll fix it, but this sounds like a typical driver issue.
L u n a t i c F r i n g e
|
|
|
|
|
Hi,
I replaced video card and its driver. It did not improve any. There might something wrong with Windows 7.
Damn Windwos 7,
Thanks your reply.
|
|
|
|
|
CODEPC wrote: Damn Windwos 7
L u n a t i c F r i n g e
|
|
|
|
|
Hi,
Is there a way to close a document without closing the application?
What I mean by this using a menu option, e.g. File -> Close, to invoke a file save if need be, and then clearing the view, but not closing the application?
Obviously I can write a function that will do this for me, but is there a standard CDocument member that will do this for me?
TIA
Tony
|
|
|
|
|
I think you should override the OnCloseDocument method,...Well,...Good luck!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi,
Thanks for that.
I have managed to achieve what I wanted, except for 1 remaining item.
Having succssfully closed the document, and my View has reverted to the original empty View, I find that I can open new files, except for the one that was just closed. I cannot open the file that was previously open until I have viewed a different file.
Is there a flag I need to reset, or function call I need to make so it is possible to open the fiel immediately after it has been closed?
I've managed to overcome that problem now by using the DocTemplate and Removing the document, but I now find that if I use this method, wi have to close my application multiple times dependent on how many times I have closed a document, e.g. close 2 documents and I have to close the application twice (press the application 'X' button twice). Any suggestions?
TIA
Tony
modified on Wednesday, January 27, 2010 10:24 AM
|
|
|
|
|
You didn't indicate if this is an MDI or SDI application, but either way there is a DeleteContents() method that's called automatically just before a document closes.
Perhaps that function may do what you need.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Hi Karl,
It's a SDI.
I am using DeleteContents() as part of my closure code, see below.........
if(TRUE == IsModified())
{
OnFileSave();
}
CDocTemplate* pDocTemplate = GetDocTemplate();
if(NULL != pDocTemplate)
{
pDocTemplate->RemoveDocument(this);
}
DeleteContents();
CString csUntitled;
csUntitled.LoadString(AFX_IDS_UNTITLED);
SetTitle(csUntitled);
UpdateAllViews(NULL);
AS I say, the only issue now is that I have to close mutliple times, once for each file opened.
Tony
|
|
|
|
|
I'm not sure if it could be part of your problem, however it probably is not a good idea to call RemoveDocument. In an SDI, there is only one document, and it lasts for the life of the program - it's never destroyed.
Of course, your DeleteContents is also responsible for resetting any document member data to it's original state.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Hi Karl,
If I remove the call to RemoveDocument, I'm left with not being able to reopen the last closed file - this is caused by the CDocTemplate::yesAlreadyOpen flag being set.
Is there a way to force this flag, or my DocTemplate, to be something that reflects that I have closed (hopefully!!) the last open file?
TIA
Tony
|
|
|
|
|
Haven't tried it, but perhaps
CloseAllDocuments(FALSE) will reset that flag. Check it out on MSDN[^]
In fact, calling CloseAllDocuments causes the call to DeleteContents.
Hope it helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
I tried that, and my application closed whether I set the flag TRUE or FALSE.
I guess I am missing something else.
Thanks for your help.
Tony
|
|
|
|
|
I have C++ Simple MAPI routines for sending emails. This works well for straight text emails. I have prepared a HMTL body for emailing but do not know how to flag the fact that the body is HTML to the client when using Simple MAPI.
Can this be done with Simple MAPI ?
If it can't be done using Simple MAPI how is it done using an alternative.
Let's start with Extended MAPI before moving on to something super sophisticated.
Try to keep it simple. I'm only looking at sending a single email body with simple HTML.
|
|
|
|
|
Some little help (?)
An email contains a header (from, to, ...) and a body and 0 or more attachments. Attachments have different mimetypes. A HTML-body is of type multipart/mixed. So your email contans a header, an empty body and 2 attachments both of type multipart/mixed, 1 attachment contains the text in plain ascii, the other one contains the HTML version of this text. multipart/mixed means for the email client: take the variant that suits best resulting in HTML in most email clients and in plain ascii if the client doesn't support HTML.
Hopefully weaponed with this knowledge you can find yor way in MAPI. If not: forget what i wrote.
|
|
|
|
|
Hi All,
I am using CFileDialog class in my application to browse a file. when i click on browse always by default application is opening desktop folder. I have one default path how to open that path instead of desktop.
Thanks in advance.
Regards,
anil
|
|
|
|
|
Set the lpstrInitialDir of the CFileDialog member m_ofn .
Read more here[^] and here[^].
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Wow Roger! There's documentation for these things? Who'd have thought.
OT: How are things going for you? It's been a long time.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|