|
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
|
|
|
|
|
What I meant was if you expose the "get text width" functionality via a method, you could determine the width outside of the tree control. This may not be necessary in your application if you need to compute the text width only while drawing (i.e. the only object interested in the text width is the tree control itself).
Did you mean have a method that returns the size of the text being passed?
Yes.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hi!
Thanks for replying. I will have to bother you one more time.
Is there any way to convert the rect of the tree item and the string length to some common unit and compare the two? I have to chop off my std::string and display it on 2 or 3 lines based on the current width of the the tree ctrl. So, I need to calculate it before DrawText().
Thanks for all your help.
NC
|
|
|
|
|
NC wrote:
Is there any way to convert the rect of the tree item and the string length to some common unit and compare the two?
Not that I know of. There is a neat function PathCompactPath that automatically compresses file paths, given a device context, but this is different from what you want to do.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Thanks for all your help. I did look at PathCompactPath() and like you seed, I cannot use that.
If you think of a way to do this, please do let me know.
Thanks so much,
NC
|
|
|
|
|
hi,
I have an ArrayList in a fuction. in it i want add some Double object, but always take the same result,
C2664: 'System::Collections::ArrayList::Add' : cannot convert parameter 1 from 'double __gc *' to 'System::Object __gc *'
if i do the same with a String there is any problem, so what i must do? please help,
Thanks in advance
Salamanca 2002 Capital Cultural Europea, Visitala
|
|
|
|
|
I think you've got to box the double, i.e. push it into an Object before insertion. Why don't you try at the C# forum?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
how can i push it into an object?
I put the question here because this is VC++ not C#, maybe VC++ managed code questions are similar to C#, but... if here is like OT, i put it in the other forum.
Salamanca 2002 Capital Cultural Europea, Visitala
|
|
|
|
|
Try with Object obj=__box(myDouble) . We warned I'm no managed C++ expert
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|