|
I've had the same problem in the past when registering the same extension from different programs (or the same prorgam at different locations). Try looking for the occurrences of .spt and related identifiers (Spt.Document , stuff like that) in the registry and deleting them.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I know it has been a while, but did you ever find out what the problem was? I am having the same problem.
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
I'm using the following command in my program to close the CD Tray.
::mciSendString("set CDAudio door closed", NULL, 0, NULL)
But the problem is, after closing the CD tray the program is waiting for the CD to be read by windows (i.e. open a autorun file etc.). During this time the program appears to be hung. I was using the same API call in my VB version of the program. It did not have this problem. The app should only wait like this if I had used "notif" or "wait" parameters, right?
What am I missing here?
|
|
|
|
|
What is the reason to have most of ATL source code in .h files? Is there any disadvantage to having template functions in .cpp files? Can anyone point me to good articles on this topic?
|
|
|
|
|
Satheesh wrote:
What is the reason to have most of ATL source code in .h files?
IIRC, this is just so that the functions will be automatically inlined (where possible, of course).
Peace!
-=- James.
|
|
|
|
|
You can't have template functions in CPP.
Now the standard does have the 'extern' keyword to provide the ability to place template functions in CPP files, however, nobody supports this element of the standard.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Tim Smith wrote:
You can't have template functions in CPP.
Meaning "Templated Functions"? So I cannot declare them in a CPP file, or I cannot specialize the template in a CPP file? I am asking because I am under the impression that specializing an STL template (like std::vector) creates templated functions (like vector::push_back), and while I do not do it personally (I use typedefs in .H files), I have seen code that specializes templates in CPP files like this:
<br />
std::vector< DWORD > vecDWORDs;<br />
<br />
vecDWords.push_back( 0xFF );<br />
vecDWORDs.push_back( 0xFFFFFFFF );<br />
Or am I misunderstanding you (or templates, for that matter)?
Peace!
-=- James.
|
|
|
|
|
Ok, let me clarify. What you can't do is define a template in an H file, then implement the methods of that template in a CPP file and THEN try to use those routines in another CPP file.
So, you can define templates in a CPP file just fine. But the methods can not be used in a second CPP file. That is why template methods are commonly found in the H file as inline methods.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Tim Smith wrote:
Ok, let me clarify. What you can't do is define a template in an H file [...]
OK, now I get it. I do not think I have ever tried that particular scenario, which explains my ignorance of it.
Thanks for clearing that up for me.
Peace!
-=- James.
|
|
|
|
|
Is that 'export' or 'extern'?
|
|
|
|
|
DOH, you are probably right.
I'm getting old.
The mind is umm... what is it... umm... just on the tip...
What was I talking about?
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
I am trying to place on of these on a dialog, and it works (somewhat), but here is the interesting thing: the CHtmlEditCtrl class has a protected destructor(!).
Private and protected destructors force you to allocate an object on the heap (or by some other custom method, which I think is a bad idea in this case). OK, fine, I have it allocated off of the heap, but I cannot deallocate/destroy the damn thing, and it does not nuke itself when it gets it's DestroyWindow(...) method called (which is where most CWnd-derived classes that destroy themselves actually destroy themselves, so I leak that object!)
Is there something that I am missing here? There is no exposed method that "self-destructs" the object. So I am at a lost as to explain why in the hell this thing has a protected destructor!
Peace!
-=- James.
|
|
|
|
|
It's a weird thing, kinda shocks me too. For a quick fix, derive from CMyHtmlEditCtrl from CHtmlEditCtrl and use this instead. But this of course doesn't explain why the dtor was protected in the first place.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi,
I have a MFC program that I want to make it to take a path instead of a filename for its calling argument. Something like: AppName c:\docs\SupportFilePath
I noticed that the default action for having an argument in MFC program is it goes to Document::OnOpenFile(). Is there a way to prevent onOpenFile be called, but instead, get a hold of this argument in CMainFrame::CMainFrame()?
Here's what I've figured so far... Is the following an effecient way of getting a hold of the argument and passing it to CMainFrame??
(Inside CApp::InitInstance()
<br />
...<br />
CMainFrame* pMainFrame = new CMainFrame;<br />
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))<br />
return FALSE;<br />
m_pMainWnd = pMainFrame;<br />
<br />
CCommandLineInfo cmdInfo;<br />
<br />
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNew;<br />
<br />
pMainFrame->setCustomPath(cmdInfo::m_strFileName);<br />
<br />
ParseCommandLine(cmdInfo);<br />
<br />
if (!ProcessShellCommand(cmdInfo))<br />
return FALSE;<br />
What do you think?
|
|
|
|
|
I'd say this is fine
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Jerry Wang wrote:
CCommandLineInfo cmdInfo;
// still show initial new document window
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNew;
// pass cmdInfo file path to CMainFrame
pMainFrame->setCustomPath(cmdInfo::m_strFileName);
ParseCommandLine(cmdInfo);
Hmmmm... I am under the impression that you need to call ParseCommandLine(...) first in order to populate the fields you are manipulating (like cmdInfo::m_strFileName)? Then you can change the m_nShellCommand value to prevent the app from opening the file...?
Peace!
-=- James.
|
|
|
|
|
I think you are right. I wasn't too sure what ParseCommandLine did. Thank you both!
|
|
|
|
|
Hi!
I have to calculate the number of characters an HTREEITEM of tree ctrl can hold. I am not sure what functions can help me with this. I would appreciate any suggestions on this.
Thanks,
NC
|
|
|
|
|
NC wrote:
the number of characters an HTREEITEM of tree ctrl can hold
A HTREEITEM is a handle to a tree item. Like all Windows handles, it is a 32 bit unsigned quantity. Perhaps you meant to ask something else?
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Ravi Bhavnani wrote:
Perhaps you meant to ask something else?
Yes I did. I meant, the number of charaters each item(line) in a tree ctrl can hold. I want to calculate the number of characters that the tree ctrl can display on a single line.
Sorry for the confusion, I hope this is clear.
Thanks,
NC
|
|
|
|
|
NC wrote:
Yes I did. I meant, the number of charaters each item(line) in a tree ctrl can hold. I want to calculate the number of characters that the tree ctrl can display on a single line.
Can you get the tree control's client area, take into account the item's indentation (get the tree item's label rect basically), and use CDC::GetTextExtent(...), or a similar function, to determine that? (Note, of course, that this will only get you a solid value if you are using a monospace font, like Courier New.)
Peace!
-=- James.
|
|
|
|
|
The text size of each column for a tree control entry is theoretically unlimited.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hi!
Thanks for replying. Here is what I want to do, check the width of the tree ctrl and based on that figure out how much of my std::string variable(which could be very long) to display. I am not sure how to convert the length of the string to pixels.
Are there any functions that will help me here?
Thanks so much,
NC
|
|
|
|
|
Yes, you can use DrawText() using the tree control's DC to determine the exact width of the string to be displayed. If you're using MFC, I'd subclass CTreeCtrl and turn this into a method - eg: CMyTreeCtrl::getTextWidth (CString& strDisplay) - that you can conveniently call from anywhere once the tree control is constructed (and has a DC!).
Use the DT_CALCRECT flag to calculate the bounds used by the text. The call will automagically use the correct font currently in use by the tree control.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hi!
Thanks again for replying. I am new to a lot of this, so I need a little more info.
I have my tree ctrl subclassed. And I am drawing some stuff in custom draw. I looked up DrawText() and seems like I should be able to use it to do what I want. But, I am not sure what you meant by
Ravi Bhavnani wrote:
turn this into a method - eg: CMyTreeCtrl::getTextWidth (CString& strDisplay)
Did you mean have a method that returns the size of the text being passed?
Thanks for all your help,
NC
|
|
|
|