|
Thanks for your help. A little trial and error finally got me what I was looking for
|
|
|
|
|
Hi,
I want my program to search if a program is installed or not , from the registry(???).How can i do that(i use MFC)??
|
|
|
|
|
One solution is to check the registry key in the uninstall section. If the registry key is not found, the MFC function should return NULL. Better yet, use a Win32 API registry function including RegOpenKey().
LONG RegOpenKey(HKEY hKey, LPCTSTR lpSubKey, PHKEY phkResult);
Kuphryn
|
|
|
|
|
Could you tell me how can i check the registry key in the uninstall section?If you have an example send it to me.
Sory And Thanks!
|
|
|
|
|
Maybe I'm just not good at finding things on MSDN, and my help doesn't list anything in the index about NM_TREEVIEW Anyway, how do I get information from a CTreeCtrl when I handle the CLickTree?
I have:
void CMyDlg::OnClickTree(NMHDR* pNMHDR, LRESULT* pResult)
{
int iRoot = iTheRootOfItemClicked;
int iSub = iSubIndexOfItem;
int iItem = iTheIndexOfTheItem;
}
How do I get that info or am I supposed to do this some other way???
There's honorable mentions of TV_ITEM things and
HTREEITEM, but all I get is:
HTREEITEM Handle to an item in a tree-view control.
Somehow that doesn't help me much.
Nitron
_________________________________________--
message sent on 100% recycled electrons.
|
|
|
|
|
Try searching on NMTREEVIEW -- this is what I found:
typedef struct tagNMTREEVIEW {
NMHDR hdr;
UINT action;
TVITEM itemOld;
TVITEM itemNew;
POINT ptDrag;
} NMTREEVIEW, FAR *LPNMTREEVIEW;
That's the structure -- you should be able to cast the pNMHDR to a NMTREEVIEW pointer, and then get the struct member of NMTREEVIEW that you want...
Once you get the tvitem you want, use the tvitem.hItem (which is an HTREEITEM) and then use the CTreeCtrl member functions to get the properties of the item you need...
"If at any time I announce that a nation or kingdom is to be uprooted, torn down and destroyed, and if that nation I warned repents of its evil, then I will relent and not inflict on it the disaster I had planned. And if at another time I announce that a nation or kingdom is to be built up and planted, and if it does evil in my sight and does not obey me, then I will reconsider the good I had intended to do for it." -- Jeremiah 18:7-10 (God, commenting on the value of the United Nations)
|
|
|
|
|
Chris Hambleton wrote:
Once you get the tvitem you want, use the tvitem.hItem (which is an HTREEITEM) and then use the CTreeCtrl member functions to get the properties of the item you need...
um, I think this is what I don't know how to do
Say I have a tree:
- Root1
|
|-- SubRoot1
| |
| |- Item1
| |- Item2 <-- And I click on this one...
| |- Item3
|
|-- SubRoot2
|
|- Item1
|- Item2
How would I be able to say:
You Clicked 1.1.2
Nitron
_________________________________________--
message sent on 100% recycled electrons.
|
|
|
|
|
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
|
|
|
|