|
NMTREEVIEW* pNMTV = (NMTREEVIEW*)pNMHDR;
HTREEITEM hItemNew = pNMTV->itemNew.hItem;
HTREEITEM hItemsParent = m_wndTree.GetParentItem(hItemNew);
HTREEITEM hItemsParentsParent = m_wndTree.GetParentItem(hItemsParent);
Shog9
------
And on the pedestal, these words appear:
"My name is Ozymandias, King of Kings,
Look on my Works, ye Mighty, and despair!"
Nothing beside remains.
|
|
|
|
|
Of these STL containers, which ones will naturally sort their contents as you push them on?
Vector, List, Set, Map
Thanks
Appreciate your help,
ns
|
|
|
|
|
set
-c
Support regime change. Vote.
|
|
|
|
|
set and map (the ordering in the latter is done by the key).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for letting me know its sorted on the key.I was wondering....
Appreciate your help,
ns
|
|
|
|
|
Hi gurus,
Suppose you have some classes like these:
class BaseClass<br />
{<br />
public: virtual long getValue() {return 0;}<br />
};<br />
<br />
class SubClass1 : public BaseClass<br />
{<br />
public: virtual long getValue() {return 1;}<br />
};<br />
<br />
class SubClass2 : public BaseClass<br />
{<br />
};<br />
<br />
void SomeFun (BaseClass *someInstance)<br />
{<br />
}<br />
<br />
int main (int argc, char **argv)<br />
{<br />
BaseClass baseInstance;<br />
SubClass1 subInstance1;<br />
SubClass2 subInstance2;<br />
<br />
SomeFun (&baseInstance);<br />
SomeFun (&subInstance1);<br />
SomeFun (&subInstance2);<br />
}
In other words, in SomeFun I want to find out which implementation of getValue is used by the given instance. I don't want to actually call someInstance->getValue, but I just want to find out which method would be called if I would call it.
I tried to find the address of the method by using
&someInstance->getValue
and
someInstance->getValue
but the first one doesn't compile, and the second one gives a warning and doesn't work.
Notice I don't want to use something like
pMethod = BaseClass::getValue;
or
pMethod = SubClass1::getValue;
since I don't know who has inherited from my BaseClass, nor which instance is given as argument to me. I just want to know: the class of which an instance is given to me, has it overruled the virtual method getValue or not?
Of course a solution could be to add another virtual method, something like:
bool iHaveOverruledGetValue();
which should be implemented by each subclass (if they have overruled the getValue method, but that doesn't seem like a good solution either.
Anyone suggestions ?
Enjoy life, this is not a rehearsal !!!
|
|
|
|
|
Patje wrote:
Of course a solution could be to add another virtual method
IMHO, that seems like the best approach, both from an OO standpoint and a maintainability one. otherwise, with the pointer idea, you're writing code that is at best confusing and at worst non-portable.
-c
Support regime change. Vote.
|
|
|
|
|
You can create a switch statement and try dynamic_cast but that requries RTTI to be enabled.
I would just add a virtual method.
Todd Smith
|
|
|
|
|
is there a way to stop this from open when a certain condition is met?
I'm trying to do this in the OnDropdown section of code and anything I do dosen't stop the dropdown from opening.
Thanks for your help,
Jim
|
|
|
|
|
I assume it's for a combox box, why can't you just disable the control ?
the OnDropDown is the callback.
Max.
|
|
|
|
|
Here is what the code looks like. I couldn't find anything that would just quite without displaying that drop down.
void CAMID::OnDropdownMSel()
{
CComboBox *pMSelBox = (CComboBox *) GetDlgItem(IDC_MISSION_SEL);
if(HostStruct.bFreeze == false)
{//warn user...and quit dropdown
MessageBox("blah blah blah", "Warning!", MB_OK);
}
else
{
//drop down box
}
|
|
|
|
|
I have strings (numeric) of various lengths:
"123"
"2345"
"5"
"99999"
etc. I need to make them all as long as the longest one "99999", so they should look like "00123", "00005", etc.
If these strings are stored in an array A[], then how can I do this padding? I will be knowing the biggest strings length.
I need to automate this process.
for ( int i = 0; i
|
|
|
|
|
use CStrings if u can
CString urString;
in the loop:
urString = a [i];
CString t( '0', numberOfSpaceNeeded );
t += urString;
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Amazing! Thanks! I didnt know CString had such a handy constructor.....
Appreciate your help,
ns
|
|
|
|
|
You could format the number with the approprite lenghth
CString aString;
aString.Format( "%7i", 123 );
|
|
|
|
|
Maximilien wrote:
CString aString;<br />
aString.Format( "%7i", 123 );
You forgot the zero:
aString.Format("%07i", 123);
|
|
|
|
|
|
I write a class which kicks off a thread in constructor and terminated it in destroyer. This thread has a message queue, and in the switch-case, calls the class' member functions or member variables. And so far, I got the following reward :
illegal call of non-static member function
In my point of view, It's reasonable to use massage queue to manage member functions and member variables. it sounds good but I kick a stone, tell me why and how to make a difference.
Thanks
Extreme programming. Do the No.1
|
|
|
|
|
a thread function (the one that you use to start the thread) cannot be a member function of a class, unless that function is static.
-c
Support regime change. Vote.
|
|
|
|
|
why??? why must be static? u mean serval instances have only one thread function? then once again, how to call a member funtion in a thread function?
What's happening in backyard?
thanks
Extreme programming. Do the No.1
|
|
|
|
|
stevenson wrote:
why??? why must be static?
the thread proc can't be a non-static member function because there is no way to provide the "this" pointer to provide an object context for that member function to be called from. it's like this:
int i = CString::GetLength();
GetLength makes no sense without an actual CString object. a static member function doesn't require an actual object instance, so you can use it as a thread proc.
you can pass an object into the thread proc and use it indirectly:
volatile dataStruct data;
data.pMyObject = &TheObjectIWantToUse;
AfxBeginThread(ThreadProc, (void *)&data, THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);
...
UINT ThreadProc(void *p)
{
dataStruct *pData = (dataStruct *)p;
now you can use pData->pMyObject;
}
-c
Support regime change. Vote.
|
|
|
|
|
Hi,
I have launch the hh.exe ( help viewer) via CreateProcess(). I am trying to close this window when my main program exits. How do I do that?
Here's a snip of my code...
bSuccess = CreateProcess ("C:\\WINDOWS\\HH.EXE"," NATURAL.CHM",
NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS,
NULL, NULL, &si, &ppi );
helphnd = ppi.hProcess;
CloseHandle ( ppi.hThread );
CloseHandle ( ppi.hProcess );
The code is written as part of defining a 'Help' menuitem. Quite new to the idea of process, copy this idea from FAQ in this website. If CloseHandle is executed right after CreateProcess, that means the process should have finish and return to the executing program, therefore closehandle would do the cleaning up? Now, I am executing something in the ::OnCloseDocument(), how do I check whether the help program is still running,so that I wouldn't be trying to close the program?
|
|
|
|
|
unsigned long status;
int rv = GetExitCodeProcess(ppi.hProcess, &status);
Todd Smith
|
|
|
|
|
THanks for the reply. It's this function just checking whether the process is closed? How to close the process then?
|
|
|
|
|