|
Got it! Thanks man!
Pankaj
Without struggle, there is no progress
|
|
|
|
|
Hi
I'm trying to set item image with this code:
CImageList m_ImageList;
m_ImageList.Create(IDB_BITMAP1,18,10,(COLORREF)0xFFFFFF);
int nCount = m_ImageList.GetImageCount();//after that nCount == 7
m_Tree.SetImageList(&m_ImageList,TVSIL_NORMAL);
m_Tree.InsertItem( "text", 1, 1 );
, but it doesn't work properly. New added item has empty image(white) and looks like it would be shifted on the right (by the image width). I don't have the faintest idea what is wrong.
thanks for any help
|
|
|
|
|
|
Your m_imageList seems to be local variable, despite the m_ prefix. It's destroyed as soon as program leaves the scope; tree control is left with invalid image list handle.
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
Great thanks
Of course solution was really simple and my mistake was really stupid but the most stupid errors are the most difficult to solve out.
|
|
|
|
|
hello
in my programm im lookin for some system information
how do i get information about:
the installed windows service pack
and the rights of the loged in windows user
(e.g. admin, power user)
I use VC++ 6 and W2k
|
|
|
|
|
can we call dynamic_cast in OnInitDialog
|
|
|
|
|
SPGV wrote:
can we call dynamic_cast in OnInitDialog
dynamic_cast is a C++ cast operator. You may use it anywhere in your C++ program [It has nothing to do with MFC or CDialog]
Read my article [URL below] for more info on C++ cast operators.
http://www.codeproject.com/managedcpp/castingbasics.asp
Regards,
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Yes, assuming that RTTI is enabled in project settings (it's not by default in VC6).
What kind of problems are you experiencing?
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
|
Tomasz Sowinski wrote:
it's not by default in VC6
Guess what! It's not by default in VC7 too. Default compiler option is /GR- for MFC projects. My mistake was that I've done all my recent casting stuff on MC++ projects which have /GR and not /GR-
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Nishant S wrote:
Guess what! It's not by default in VC7 too.
I like that. If you want to use dynamic_cast and typeid, you'll better find some good reason and know what you're doing
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
Hi,
I'm not sure if this is the right place to be asking this question, but if its not I'd be grateful if someone could suggest a good site to go to.
I am using eMbedded Visual C++ and created an application using the AppWizard (exe). It uses shared dlls. My problem is that I am not sure how to add the dlls to my installer package, and which dlls to add. When I was debugging the application on a mobile device it downloaded mfcce300d.dll to the device. I have tried adding this to the installer package but when I try and run the application after installation it says that there is a library or component missing. Any ideas anyone?
Thanks,
Graham
|
|
|
|
|
MFCCE300d.dll is the debugging version of the MFCCE300 library (hence the trailing 'd') and is only used when you run the debug version of your app. MFCCE300.dll is the release version and already exists on the device; you don't have to install it yourself.
You can use the dependency walker http://www.dependencywalker.com [^] to determine which DLLs your app uses (even for CE applications).
Google for EZSetup to find a free and open source simple CE installation package. See http://www.pocketpcdn.com/articles/ezsetup.html[^] for an article.
VictorV
|
|
|
|
|
I have a program that search text files in a path that user define.When I click search button it start searching,but the program freeze.So I decide to put this function in a thread.
First:Is that good idea to put it in a thread and does it solve the problem of freezing?I read in MSDN that in worker thread when controlling function exists the thread terminate.My controlling function is recursive function brcause I want to search through directories so is that caused error?
Second:My controling function begins like this:
<br />
UINT FindFile(LPVOID chPath)<br />
{<br />
<br />
CString strWildcard = (CString&)(chPath);<br />
<br />
if (strWildcard == "")<br />
return 1;<br />
<br />
CFileFind finder;<br />
<br />
strWildcard += _T("\\*.*");<br />
It always afetr CFileFind finder line,thrown an unhandled error.Any idea?
Third:How can I access my controls in my dialog inside my controlling funcion?Shoud it be ALWAYS a global function?
Thanks a lot
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Probably you're having problems with chPath. I guess you should change (CString & ) to (LPCTSTR), but you didn't post your call to AfxBeginThread.
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
CString str;
m_editpath.GetWindowText(str);
AfxBeginThread(FindFile,(LPVOID &)str);
Well,I change CString & to LPCSTR.I debug it and "strWildcard" is like this:
{0x003869e8 "îþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþ"} ATL::CStringT<char,strtraitmfc<char,atl::chtraitscrt<char>
But there is no difference.the problem happend at CFindFile line.Not at "strWildcard" line.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Your problem is quite interesting. First of all, you're passing a reference to local CString, which is destroyed as soon as you leave the scope. So, depending on timing issues, your FindFile function may get correct string or not.
Easiest (but not elegant) way to solve this problem is to use global variable. You may also allocate a CString on the heap and pass a CString pointer to AfxBeginThread. In this case, FindFile would have to delete the string after it's no longer used.
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
Tomasz Sowinski wrote:
You may also allocate a CString on the heap and pass a CString pointer to AfxBeginThread.
Whats that?
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
I'm writing this right here in webpage, so take it with a grain of salt:
CString *pStr = new CString;
m_edit.GetWindowText(*pStr);
AfxBeginThread(ThreadFunc, pStr);
...
UINT ThreadFunc(LPVOID p)
{
CString *pStr = (CString *)p;
FindFile(*pStr);
delete pStr;
}
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
Ohhhhh,thats perfect.It works.
Now I have another questions.How can I figure out the function finish to kill thread?Does thread kill authomaticly after function finish?
I want to update my controls in dialog box during the execution of thread,So I need to access them in my GLOBAL function. Whats the trick for that?Something like a search of windows.It update list control each time it found the new file.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Mazdak wrote:
Does thread kill authomaticly after function finish?
Yes, thread terminates automatically when controlling function finishes.
Mazdak wrote:
I want to update my controls in dialog box during the execution of thread
What kind of updating it is? Do you just want to add file names to some list control?
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
Tomasz Sowinski wrote:
Do you just want to add file names to some list control?
Yes.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Just pass the dialog pointer to thread function instead of string. You'll be able get window text and add items to list as well.
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
Thank you very much man.You teach me a lot today.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|