|
|
Hi Noname,
this will help u
http://www.codeproject.com/cpp/data_conversions.asp
Regards,
Vinay Charan.
|
|
|
|
|
CString::GetBuffer(...);
CString csStr = _T( "Somestring" );
LPCTSTR szBuff = (LPCTSTR)csStr;
LPTSTR szBuff1 = csStr.GetBuffer();
LPTSTR and LPCTSTR are WCHAR* and CONST WCHAR* type respectively.
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
wchar_t *pwsz1=NULL;
CString str;
str="Hi";
pwsz1=str.AllocSysString();
-------------------------------------
WCHAR pwsz[1024];
CString Test2="Hi";
MultiByteToWideChar( CP_ACP,0,Test2,-1,pwsz,sizeof( pwsz));
------------------------------------
WCHAR* pwsz2;
CString Test3="Hi";
pwsz2=new (WCHAR);
MultiByteToWideChar( CP_ACP, 0, Test3,-1, pwsz2, sizeof( pwsz2 ) );
whitesky
|
|
|
|
|
NoName II wrote: how to convert CString to const WCHAR *
mbstowcs
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
SupportCRY- Child Relief and You
|
|
|
|
|
Hi, there,
I would like to realize a function that can create a folder called "data" in a directory if it doesn't exist. Here is my code:
CString strPath ="D:\\temp";
SetCurrentDirectory(strPath);
CFileFind ff;
BOOL btmp1 = ff.FindFile("data");
if(btmp1)
{
BOOL btmp2 = ff.FindNextFile();
if(!ff.IsDirectory())
{ //*************************//
if(!CreateDirectory(LPCTSTR(strPath+"\\data"), NULL))
{
ff.Close();
return FALSE;
}
}
}
else
{
if(!CreateDirectory(LPCTSTR(strPath+"\\data"), NULL))
{
ff.Close();
return FALSE;
}
}
ff.Close();
return TRUE;
Then I noticed a strange thing. If there is a file in "D:\\temp" named data, the CreateDirectory function after //***// part always fails. Please note that the existing data is a file without extension, not a folder. So I added a line to the //***// part:
CFile::Rename(strPath+"\\data", strPath+"\\data.bak");
then the CreateDirectory function can succeed and the folder data is created. Sadly, I won't be able to change the file data.bak to data anymore because there is a folder with the same name.
How could this happen? Or is it because I missed anything ? Your help will be greatly appreciated.
David
|
|
|
|
|
David L.S. wrote: I would like to realize a function that can create a folder called "data" in a directory if it doesn't exist. Here is my code:
Instead of CFIleFind for Checking existence of Folder or File, why not you use Direct api PathFileExists()
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
SupportCRY- Child Relief and You
|
|
|
|
|
So what are you expecting CreateDirectory() to do when a file named c:\temp\data already exists?
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Hi,
Thanks for your answers. I now know the reason I couldn't do that. Thanks anyway.
David
-- modified at 22:04 Friday 26th May, 2006
|
|
|
|
|
I've developed a single document application and I use Dialog bars.
I've derived a class from CDialogBar in order to map OnCtlColor and
I use that class as base class.
Then I've derived a class (from my base class)for any dialog bar and
I use its instances in CMainFrame instead of default CDialogBar instance
created by Visual Studio.
I've written a specific class for any dialog bar in order to manage
its events in that class instead of in CMainFrame class.
(Otherwise, having many dialog bars CMainframe class becomes a very
big and complex class).
My problem is the following:
Visual Studio allows me to create methods for any event of my dialog
bar in the specific class but at runtime that methods are never called.
It seems that there is no real association between UI controls and methods
written in my class (and added with class wizard).
All works if I copy that methods and the related MESSAGE_MAP code
in CMainframe class.
Why my classes doesn't catch dialog bars event while CMainframe do it ??
Thanks a lot.
|
|
|
|
|
Visual Studio 7.0 I presume? It's full of such bugs and once in a while I think of rolling back to my favorite 6.0.
|
|
|
|
|
Is there a way for me to post a windows authentication/login dialog -- get the user to enter his username and password?
I don't want access to this information, I would just like him to re-authenticate himself to me.
I would like to use this to block access to part of my application unless he completes this re-authentication.
Where would I look for this?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc.</A>
|
|
|
|
|
Hi
I liked your way of thinking
and tried a little
tye this
system("C:\\WINNT\\system32\\rundll32.exe user32.dll,LockWorkStation");
Regards
Anil
|
|
|
|
|
Peter Weyzen wrote: ...I would just like him to re-authenticate himself to me.
Do you really think this is a good idea? Users typicaly don't like to repeat themselves. I think it would be a better design if your application checked the security level/group membership of the logged-in user to determine what features to turn on/off.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Well, David -- thanks for your concern...
But, I'd like to find out how to do this.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc.</A>
-- modified at 14:13 Friday 26th May, 2006
|
|
|
|
|
Then I suggest you look into LogonUser() . It validates the user name and password and returns True if they are valid.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Thanks for the clue.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc.</A>
|
|
|
|
|
I need to debug a function defined in a statically linked library attaching to a process compiled with that library. I have two .bsc's, one for the library and one for the .exe. I have tried changing the name of the .lib bsc to the exe .bsc, but doing this way I can't set breakpoints in the function of the library that I need to debug.
|
|
|
|
|
.bsc doesn't have anything to do with debugging. this is the browse information for symbols which Visual studio uses for locating symbol defenitions inside the source code.
To debug what u need is the .pdf file. you have to compile both the library and exe. if the pdb file time stamp is same that of lib, then you can break into the code.
you can chk whther the symbol files loaded correctly by pressing ctrl + alt + u inthe debug mode.
cheers...milton kb
|
|
|
|
|
hi all
what is the easisest way to add tooltip support to my edit boxes in MFC application ?
thank you.
|
|
|
|
|
i use this way for button listbox and now edit and it work
<code>
m_tooltip.Create(this);
SetToolTip(_T("Hello"));
void CAnswerView::SetToolTip(LPTSTR ToolTip)
{
TOOLINFO ti;
ti.cbSize = sizeof(TOOLINFO);
ti.lpszText = ToolTip;
ti.hinst = AfxGetInstanceHandle();
ti.hwnd = m_Edit2.m_hWnd;
ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
ti.uId = (UINT) m_Edit2.m_hWnd;
m_tooltip.SendMessage(TTM_ADDTOOL, 0, (LPARAM) &ti);
}
whitesky
|
|
|
|
|
doesnt work
I have VS2005
|
|
|
|
|
|
I have VS 2003 and VS 2005 installed.
its working fine with both version of windows.
SaRath
"DM/b>on't blindly follow rules you read somewhere without verifying that it makes sense for your situation!"
|
|
|
|
|
realy,
I test my code in vs2005 for buttons and it work but i dont test this code for edit in vs2005
whitesky
|
|
|
|