|
Thanks.I got the point.
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 have list box.When I fill it for second time I want previous items deleted and new ones shown.I use ResetContent but items do not deleted.I use this code:
m_listgrowp.ResetContent();
for(int i=0;i<(int)strSidArray.GetCount();i++)
m_listgrowp.AddString(strSidArray.GetAt(i));
strSidArray.RemoveAll();
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
|
|
|
|
|
Set breakpoint to line "m_listgrowp.ResetContent()", Type "ERR,hr" in watch window. You will see the GetLastError() string message. May be, it will help you.
|
|
|
|
|
Thanks.I'll do it.
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 have written some code to save a CString to a file with the WriteFile API function (I prever to use the API function and not the CFile member functions).
CString str = _T("HI");
if (!WriteFile(hFile, str, str.GetLength(), &dwWrittenBytes, NULL) ||
dwWrittenBytes != (DWORD) str.GetLength())
{
AfxMessageBox(_T("Could not write to file."), MB_OK | MB_ICONEXCLAMATION);
return FALSE;
}
On Windows XP (or other Windows Systems) it works fine, but when I use the code in Embedded Visual C++ 3.0 in the Emulator I have to change the code like the following, to get the same result as under WinXP.
CString str = _T("HI");
if (!WriteFile(hFile, str, str.GetLength() * 2, &dwWrittenBytes, NULL) ||
dwWrittenBytes != (DWORD) str.GetLength() * 2)
{
AfxMessageBox(_T("Could not write to file."), MB_OK | MB_ICONEXCLAMATION);
return FALSE;
}
I have to write twice as much characters (str.GetLength() * 2) to get the same result! Is that something with Unicode? Can anyone explane me that? And, how I have to write this function that it works under both systems (XP and CE)?
(When I debug the code in Embedded VC++ 3.0 and I look the memory where the string in CString is saved, every second character is 0, like 'H|I|' --> | is for 0.)
--
Nice greets, Daniel.
|
|
|
|
|
Third parameter of WriteFile is buffer size in bytes. sizeof(char) in UNICODE is 2. In both cases you should write:
WriteFile(hFile, str, str.GetLength() * sizeof(TCHAR), ...
|
|
|
|
|
Thanks!
--
Nice greets, Daniel.
|
|
|
|
|
Putting a recent file list into my MFC-based app was a no-brainer, but there's something I'm having trouble with.
If I select a file from the Recent list that's currently open, MFC magically avoids calling OnOpenDocument() in my doc class. While this is desirable behavior in most cases, for my particular app I need to reopen the file instead.
Any ideas on how to tweak the behavior?
|
|
|
|
|
Override the CWinApp::OpenDocumentFile ?
Steve S
[This signature space available for rent]
|
|
|
|
|
Sounds good, except I can't figure out how to access the doc class from scope of the app. Is there a good way to do this?
|
|
|
|
|
Generally in situations like this, I use the "Star Wars" approach.
Use the source, Luke.;)
Without looking, I'd guess that the CWinApp version trawls through the registered document templates, and asks each of them to do it. So what you'd probably want to do is create an overridden version in a CxxxxDocTemplate derived class, that instead of activating the window, closes then reloads the document. Of course, you don't want to do that if it's an SDI app.
Steve S
[This signature space available for rent]
|
|
|
|
|
Duh, it never occurred to me to look into overriding the doc template. Maybe that's a sign I should go to sleep.
Looks like I could override CDocTemplate::MatchDocType to lie in its return value about a document being open, but that sounds kind of dangerous.
Unfortunately for me, the actual decision whether or not to open a file lies in a CDocManager class, which sits out reach in the MFC dll. Sounds like I might have to look into another solution after all. Maybe maintain the Recent list myself?
|
|
|
|
|
I think it's also possible to replace the CDocManager with a derived one too!
Steve S
[This signature space available for rent]
|
|
|
|
|
Here goes, I created an MFC dll, I then added a dialog added a class to it, then tried to compile it. I get the following two errors:
--------------------Configuration: ALSTG - Win32 Debug--------------------
Compiling...
ALSTGPlug.cpp
c:\documents and settings\darroll\my documents\myprojects\told\alstg\alstgplug.h(21) : error C2065: 'IDD_FOUS21' : undeclared identifier
c:\documents and settings\darroll\my documents\myprojects\told\alstg\alstgplug.h(21) : error C2057: expected constant expression
Error executing cl.exe.
ALSTG.dll - 2 error(s), 0 warning(s)
What am I missing? Thanks in advance.
Darroll
Not one person lives in the present. Only the past. I can prove it.
|
|
|
|
|
is "IDD_FOUS32" defined in resource.h? Is resource.h included in the the alstgplug.h file (and/or the ALSTGPlug.cpp file [but only if this include is "above" the alstgplug.h file] )
Hope that helps....
Just trying to keep the forces of entropy at bay
|
|
|
|
|
Bingo, just needed to include the resource.h file.
Thank you!
Not one person lives in the present. Only the past. I can prove it.
|
|
|
|
|
I want to view / edit the properties of a file programmatically. By properties, I mean the properties you see under right click / properties / summary tab (title, author, summary, etc). I've been searching MSDN but no luck so far.
Any suggestions ?
|
|
|
|
|
GetFileAttributes / SetFileAttributes
GetFileSize
GetFileType
GetFileInformationByHandle (could be the best one to research?)
Just trying to keep the forces of entropy at bay
|
|
|
|
|
Thanks, not really what I'm looking for.
It's amazing that I've been searching for hours now and couldn't find any info on this. I was hoping for a simple API function.
|
|
|
|
|
That stuff only normally appears if it's a compound file (OLE "document"). I think there's a sample on MSDN that deals with examining these. Try looking for properties and "structured storage" or some such.
Steve S
[This signature space available for rent]
|
|
|
|
|
I don't think its as simple as you think, i've been meaning to go through this for a while and do somthing similar (get the Map NetworkDrive dialog), heres what i have found so far, you need to get a IContextMenu handle and then fill a CMININVOKECOMMANDINFO structure like bellow. You need to fill in the correct verb, in the code (snipped from seashell project - see shell extentions section in CP.) bellow it sets the verb by T2CA(MAKEINTRESOURCE(iCmd - IDM_SHELLCTXFIRST)); SHELLCTXFIRST = 2000, the iCmd is the cmd id returned by the context menu command. I'm presuming that the value of iCmd will not change per platform.
If you can find the value of iCmd that is the verb "properties" then i think you could bring up that dialog.
To Get IContextMenu you call IShellFolder::GetUIObjectOf.. see msdn.
00336 CMINVOKECOMMANDINFO cmi;
00337 cmi.cbSize = sizeof(cmi);
00338 cmi.fMask = 0;
00339 cmi.hwnd = m_hWnd;
00340 cmi.lpVerb = T2CA(MAKEINTRESOURCE(iCmd - IDM_SHELLCTXFIRST));
00341 cmi.lpParameters = NULL;
00342 cmi.lpDirectory = NULL;
00343 cmi.nShow = SW_SHOWNORMAL;
00344 cmi.dwHotKey = 0;
00345 cmi.hIcon = NULL;
00346 m_lpcm->InvokeCommand(&cmi);
Asim Hussain
e: asim@jawache.net
w: www.jawache.net
|
|
|
|
|
|
Which API ? The Windows C/C++ API docs are at msdn.microst.com. although docs on API style message loop programming is thin on the ground, and in C especially so.
Christian
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Sorry, it is C Library Manual, just like Java API docs.
|
|
|
|
|