|
amitmistry_petlad wrote: when i wrote in the file it is like below
<filelist>
<listitem type="dir" order="0"> <path>C:\Documents and Settings\Amit\Desktop\MediaFiles\
You should really use a XML-Parser instead of code it by hand.
Try TinyXML[^] or CMarkup[^]
Are you sure your ConvertStringToWCHAR() is working as expected?
In the Debugger, DIRPATH and filename look the same?
You are setting pszText , but not setting the mask accordingly.
Are you sure LVM_INSERTITEM can cope with unicode? I am not, but I never tried. it.
Wouldn't it be easier to use the CListCtrl s member InsertItem() ?
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
jhwurmbach wrote: Are you sure your ConvertStringToWCHAR() is working as expected?
1)yes.ConvertStringToWCHAR() its working
jhwurmbach wrote: In the Debugger, DIRPATH and filename look the same?
2)yes. at the time of debugging i have checked it .both same .
jhwurmbach wrote: You are setting pszText, but not setting the mask accordingly.
is it must?
jhwurmbach wrote: Wouldn't it be easier to use the CListCtrls member InsertItem()?
i will try it out.
but i am using win32 .ok
jhwurmbach wrote: Are you sure LVM_INSERTITEM can cope with unicode? I am not, but I never tried. it.
that i dont know
|
|
|
|
|
amitmistry_petlad wrote: jhwurmbach wrote:
You are setting pszText, but not setting the mask accordingly.
is it must?
Thats how I read the doku.
In mask you set which of the items are to be regarded as valid.
amitmistry_petlad wrote: jhwurmbach wrote:
Wouldn't it be easier to use the CListCtrls member InsertItem()?
i will try it out.
but i am using win32 .ok
Win32. Ok, no MFC functions then.
pszText is of type LPTSTR , that does mean it is char* when UNICODE is not defined and wchar_t* when UNICODE is defined.
That corresponds to your logic?
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
what should i write instead here?
if(tmp.find("path") != -1)
{
tok = strtok_s(NULL,"<>",&token);
string filename=tok;
WCHAR* DIRPATH=util.ConvertStringToWCHAR(filename.c_str());
<code> LvItem.pszText=(LPWSTR)DIRPATH;</code>
SendMessage(hList,LVM_INSERTITEM,i,(LPARAM)&LvItem);
}
|
|
|
|
|
Are you compiling your project with UNICODE defined?
the std::string filename you use is certainly not Unicode-capable. You would need std::wstring.
Then your function ConvertStringToWCHAR is giving out a pointer. Hwo is owning the memory there? Who does delete it? Are you sure it is valid at the point of SendMessage?
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
ya i had checked. configuration property->general->Character Set Use Unicode Character Set.
even if i will not use string then also i can use tok.
so it is better to me to use tok.because its char *
2) when i select the path like.
c:\documents and setting\...\desktop
and when close the application it goes the properway in XML.
but when i reopen it the blank space of documents and settings will be deleted and the character has been shifted that place means the blank space is fill by the next char and when it comes at the end desktop,
it will display like desksquaresquaresquare
WCHAR* Utility::ConvertStringToWCHAR(string source)
{
try
{
WCHAR w_Out[MAX_PATH];
MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,source.c_str(),(int)(source.length() + 1),w_Out,MAX_PATH);
return w_Out;
}
catch(exception ex)
{
throw ex;
}
}
|
|
|
|
|
Your ConvertStringToWCHAR function returns a pointer to a stack-variable:
With the closing bracket of the try-block, w_Out goes out of scope. It is undefined what happens with the memory formerly being w_Out . So the pointer may or may not point to complete rubbish.
And the length-parameter for the int-string is surely source.length() , not lenght()+1 ? Since length() is giving the number of chars in the string.
Please chek the return-value from MultiByteToWideChar() , and output GetLastError when it is 0.
Also, you could try to call MultiByteToWideChar() with the last parameter ccWideChar being 0 , and glean from the return value how many wide chars you need to provide.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
please edit your message and put your codes samples withing a <pre></pre> tags block...
|
|
|
|
|
Hi..
I am creating an ActiveX control..and I have to set the Threading Model to both
'afxRegApartmentThreading' and 'afxRegFreeThreading' in the function
'AfxOleRegisterControlClass' in VC++ 6.0
But, the compiler gives an error...."'afxRegFreeThreading' : undeclared identifier"...
I have checked in MSDN...this 'afxRegFreeThreading' is a valid parameter..
Whats wrong here?
...A Programmer may or may not be the master of the programming language grammar...
|
|
|
|
|
Same question with little title
|
|
|
|
|
you asked this 2 hours ago[^].
you're not on a chat room, so please be patient. and if you don't get answers then, consider revising the question
|
|
|
|
|
Thnx a lot for the beautiful piece of advise...
...A Programmer may or may not be the master of the programming language grammar...
|
|
|
|
|
Have you included afxctl.h?
|
|
|
|
|
Hi,
Yes i have...thats the problem here
'afxctl.h' defines the following constants:
enum AFX_REG_FLAGS
{
afxRegDefault = 0x0000,
afxRegInsertable = 0x0001,
afxRegApartmentThreading = 0x0002,
};
This does not have the freethreading model constant...
If I pass 'afxRegApartmentThreading' as the parameter to the registering function then it works fine...but there's no constant for free threading model..
how can these be missing when MSDN articles say so..?
OR I am missing something here ? Help ...
Also, if the threading model is changed directly in the Registry..it works...n I can do the same using VC++ code...but I want to know where is the free threading model constant
Thanks in advance..
...A Programmer may or may not be the master of the programming language grammar...
|
|
|
|
|
Apparently that was added in a later MFC version, sorry.
It's there in MFC 7.xx ... You're probably on version 4.xx?
Mark
|
|
|
|
|
AbbyIndian wrote: Also, if the threading model is changed directly in the Registry..it works...n I can do the same using VC++ code...but I want to know where is the free threading model constant
Here's the (I think) relevant code from MFC (the pstrThreadingModel value you want is szBoth
which is defined as "static TCHAR szBoth[] = _T("Both");"):
if (nRegFlags & afxRegApartmentThreading)
pstrThreadingModel = szApartment;
if (nRegFlags & afxRegFreeThreading)
pstrThreadingModel = szFree;
if ((nRegFlags & (afxRegFreeThreading | afxRegApartmentThreading)) ==
(afxRegFreeThreading | afxRegApartmentThreading))
{
pstrThreadingModel = szBoth;
}
if (pstrThreadingModel != NULL)
{
HKEY hkeyInprocServer32;
bSuccess = (::RegOpenKeyEx(hkeyClassID, _T("InprocServer32"), 0, KEY_WRITE,
&hkeyInprocServer32) == ERROR_SUCCESS);
if (!bSuccess)
goto Error;
ASSERT(hkeyInprocServer32 != NULL);
bSuccess = (::RegSetValueEx(hkeyInprocServer32, _T("ThreadingModel"), 0,
REG_SZ, (const BYTE*) pstrThreadingModel,
(lstrlen(pstrThreadingModel)+1) * sizeof(TCHAR)) == ERROR_SUCCESS);
::RegCloseKey(hkeyInprocServer32);
}
|
|
|
|
|
Hi....
Thnx a lot for the help....That version thing finally cleared my doubt..
And thnx for that code snippet...I have also used a similar piece of code which I found in some cpp file in the MFC folder....
Thank you
...A Programmer may or may not be the master of the programming language grammar...
|
|
|
|
|
hello Gurus
plz tell me any site which explain
multi threading programming from basic.
thanks
Born To Code
|
|
|
|
|
|
Here[^] is one of the examples.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
|
Hi to All,
Could anyone help me, I don't know how to create compatible plug-in for windows media player & real player, Quick Time, etc., using visual c++? What should I do?
Advanced thanks
with regards
Ramana
A.Venkata Ramana
-- modified at 5:09 Tuesday 13th February, 2007
|
|
|
|
|
|
It looks like I chose the wrong time to work on this section of my progect. It clashes with the student's homework
Anyway, for the most part I have been able to enumerate just about everything I need, but I have a few problems.
1. I have the number of graphics cards, their Vendor names and current resolutions. But I have been unable to determine how much on-board memory they have.
2. I am unable to find any suitable method of enumerating the sound-cards.
|
|
|
|
|
I have to add a menu item on right clicking selected text, invoke my command handler and get the selected text, from any text document
1. How to add menu item to the existing windows generated menu
2. How to get the selected text to the menu handler program
Thanks
Anil
-- modified at 4:31 Tuesday 13th February, 2007
|
|
|
|