|
GREETINGS!
virtual BOOL FindFile( LPCTSTR pstrName = NULL, DWORD dwUnused = 0 );
Specify full path in pstrName:
CFileFind hFile;
hFile.FindFile("C:\\Windows\\*.dll",0)
Than use hFile.FindNextFile();
Good luck!
LOVE & PEACE to everyone
|
|
|
|
|
Look for the example in MSDN for FindNextFile .
Mazy
"The more I search, the more my need
For you,
The more I bless, the more I bleed
For you."The Outlaw Torn-Metallica
|
|
|
|
|
Hi,
I need to be able to show and hide bitmaps in a dialog dynamically. Basically, I want to use the bitmaps to make a card game, but I need to be able to specify their (the cards) locations. I need to be able to do something of the following (yes, I know the following code wont do anything):
ShowBitmapXYZ(0,0);
Or something along those lines.
Thanks,
~ Selevercin
If you have a problem with my spelling, just remember that's not my fault. I [as well as everyone
else who learned to spell after 1976] blame it on
Robert A. Kolpek for U.S. Patent 4,136,395.
|
|
|
|
|
Draw your bitmap in a static control, use SetBitmap(), ShowWindow() and MoveWindow() to control which bitmap where
---
CPUA 0x5041
Sonork 100.11743 Chicken Little
Within you lies the power for good - Use it!
|
|
|
|
|
What does SetBitmap() do? Also, how can I display multiple copies of the same bitmap?
Thanks,
~ Selevercin
If you have a problem with my spelling, just remember that's not my fault. I [as well as everyone
else who learned to spell after 1976] blame it on
Robert A. Kolpek for U.S. Patent 4,136,395.
|
|
|
|
|
Selevercin wrote:
What does SetBitmap() do?
From MSDN:
CStatic::SetBitmap
HBITMAP SetBitmap( HBITMAP hBitmap );
Return Value
The handle of the bitmap previously associated with the static control, or NULL if no bitmap was associated with the static control.
Parameters
hBitmap
Handle of the bitmap to be drawn in the static control.
Remarks
Call this member function to associate a new bitmap with the static control.
The bitmap will be automatically drawn in the static control. By default, it will be drawn in the upper-left corner and the static control will be resized to the size of the bitmap.
You can use various window and static control styles, including the following:
SS_BITMAP Use this style always for bitmaps.
SS_CENTERIMAGE Use to center in the static control. If the image is larger than the static control, it will be clipped. If it is smaller than the static control, the empty space around the image will be filled by the color of the pixel in the upper left corner of the bitmap.
Selevercin wrote:
how can I display multiple copies of the same bitmap?
Use multiple static controls
---
CPUA 0x5041
Sonork 100.11743 Chicken Little
Within you lies the power for good - Use it!
|
|
|
|
|
Ok, my program is crashing on the code. This is what I have:
<code>
CStatic card;
HBITMAP hBitmap;
hBitmap = ::LoadBitmap(NULL, MAKEINTRESOURCE(IDB_2));
card.SetBitmap(hBitmap);
card.ShowWindow(SW_SHOW);
card.MoveWindow(100, 100, 23, 35, TRUE);
I know it is the SetBitmap() that is causing it, but what did I do wrong?
Thanks,
~ Selevercin
If you have a problem with my spelling, just remember that's not my fault. I [as well as everyone
else who learned to spell after 1976] blame it on
Robert A. Kolpek for U.S. Patent 4,136,395.
|
|
|
|
|
CStatic card;
card.Create(_T(""), SS_BITMAP, CRect (0,0,0,0), this, An_ID_That_Makes_Sense);
...
You have to create the window before you can SetBitmap() etc.
---
CPUA 0x5041
Sonork 100.11743 Chicken Little
Within you lies the power for good - Use it!
|
|
|
|
|
Ok, hopefully this is it. For some reason it is not showing it.
<code>
CStatic card;
HBITMAP hBitmap;
card.Create(_T(""), WS_CHILD | WS_VISIBLE | SS_BITMAP, CRect(23,35,100,100), this, 101);
hBitmap = ::LoadBitmap(NULL, MAKEINTRESOURCE(IDB_2));
card.SetBitmap(hBitmap);
card.ShowWindow(SW_SHOW);
card.MoveWindow(100, 100, 23, 35, TRUE);
Thanks,
~ Selevercin
If you have a problem with my spelling, just remember that's not my fault. I [as well as everyone
else who learned to spell after 1976] blame it on
Robert A. Kolpek for U.S. Patent 4,136,395.
|
|
|
|
|
I have just made a function that adds all the files from a folder and it's subfolders to a list, but whenever it gets to a filename with a foreign character in it (æøåöä etc.) it fails and the filename gets set to three random characters and a null. How can i add support for foreign characters?
Tkanks!
|
|
|
|
|
Perhaps if you explained a little bit more in specific how you got the names it would be possible to answer? Maybe also how and exactly where (in what API) you function fails.
I know for sure that the Win32 API function family FindFirstFile & co. works as expected even with Swedish characters, why I obviously question your bad results re. e.g. "å".
|
|
|
|
|
Here's the function:
void AddFilesFromFolder(ITEMIDLIST *pIdl)
{
if (pIdl)
{
IShellFolder *pBrowse = NULL;
LPENUMIDLIST pFolder = NULL;
LPMALLOC pMalloc = NULL;
ITEMIDLIST *pNewId = NULL;
ITEMIDLIST *pFullId;
STRRET strDispName;
STRRET strPrev;
LVITEM lvItem;
char szFolderPath[MAX_PATH+1];
DWORD pActual = 0;
DWORD dwAttrib;
IShellFolder *CurrentFolder;
if (SHGetDesktopFolder(&CurrentFolder) == NOERROR)
{
SHGetMalloc(&pMalloc);
CurrentFolder->BindToObject(pIdl, NULL, IID_IShellFolder, (LPVOID*)&pBrowse);
pBrowse->GetDisplayNameOf(pIdl, SHGDN_INFOLDER, &strDispName);
if (pBrowse->EnumObjects(NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN, &pFolder) == NOERROR)
{
SHGetPathFromIDList(pIdl, szFolderPath);
pMalloc->Alloc((unsigned long)pNewId);
lvItem.mask = LVIF_IMAGE | LVIF_TEXT;
while (pFolder->Next(1, &pNewId, &pActual) != S_FALSE)
{
dwAttrib = SFGAO_FOLDER;
pBrowse->GetAttributesOf(1, (LPCITEMIDLIST*)&pNewId, &dwAttrib);
if (!(dwAttrib & SFGAO_FOLDER))
{
memset(strDispName.cStr, 0, MAX_PATH+1);
pBrowse->GetDisplayNameOf(pNewId, SHGDN_INFOLDER, &strDispName);
PathCombine(gszPath, szFolderPath, strDispName.cStr);
if (strDispName.cStr[3] == '\0')
{
showstr(gszPath, &gszMsgBuff[strlen(gszMsgBuff)], 120);
gszMsgBuff[strlen(gszMsgBuff)] = 13;
gszMsgBuff[strlen(gszMsgBuff)] = 10;
}
if (FindHeader() != -1)
{
GetID3();
FillInfo();
ListAddItem();
}
pBrowse->GetDisplayNameOf(pNewId, SHGDN_INFOLDER, &strPrev);
}
if (dwAttrib & SFGAO_FOLDER)
{
UINT cb1 = GetSize(pIdl) - sizeof(pIdl->mkid.cb);
UINT cb2 = GetSize(pNewId);
pFullId = (LPITEMIDLIST)pMalloc->Alloc(cb1 + cb2);
if (pFullId)
{
CopyMemory(pFullId, pIdl, cb1);
CopyMemory(((LPSTR)pFullId) + cb1, pNewId, cb2);
AddFilesFromFolder(pFullId);
}
}
}
pMalloc->Free(pNewId);
pMalloc->Release();
gbFileOpen = true;
pFolder->Release();
}
CurrentFolder->Release();
}
}
}
I got the initial PIDL from the SHBrowseForFolder function.
|
|
|
|
|
Without event looking at or trying to understand this code, why in the [warm place] would anyone ever want to write this amount of code just to iterate a directory tree?! This looks like "MS Malicious" at best.
If you are only handling filesystems, use FindFirstFile & co. It's much cleaner and probably an order of magnitude faster (I could be wrong, but in this case it seems unlikely). Let me know if you want some example code.
|
|
|
|
|
Is it possible to add all the files in a folder + the filess in the folder's subfolders etc. without that much code? in that case i would very much like some sample code.
|
|
|
|
|
redeemer wrote:
Is it possible to add all the files in a folder + the filess in the folder's subfolders etc. without that much code?
Use SHGetPathFromIdList() to get the name of the directory from its PIDL. Then use FindFirstFile/FindNextFile to get the names of the files in that dir.
If you want to stick with the shell interfaces, use CComPtr to manage the interface reference counts for you.
BTW in your original code, I think your bug is in your handling of STRRET structs. You can't assume the string is in the .cStr member.
--Mike--
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
Like the Google toolbar? Then check out UltraBar, with more features & customizable search engines!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Once you get a hold of the directory name you can try something like the following. This code is quite bloated, but typing it from memory I can probably be glad that it went through a compiler and worked!
void DoDir(const char* szDir)
{
WIN32_FIND_DATA fd;
string sTmp(szDir);
sTmp += "\\*";
HANDLE hFind = FindFirstFile(sTmp.c_str(), &fd);
if (hFind == INVALID_HANDLE_VALUE) {
cout << "Invalid dir " << szDir << endl;
return;
}
cout << "Directory " << szDir << endl;
do {
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
const char* psz = fd.cFileName;
if (psz[0] == '.' &&
((psz[1] == '.' && psz[2] == '\0') || psz[1] == '\0'))
{
continue;
}
string sNewDir(szDir);
sNewDir += '\\';
sNewDir += fd.cFileName;
DoDir(sNewDir.c_str());
}
else {
cout << setw(9) << (int)fd.nFileSizeLow
<< " " << fd.cFileName << endl;
}
} while (FindNextFile(hFind, &fd));
FindClose(hFind);
}
|
|
|
|
|
I am using CFtpConnection::SetCurrentDirectory() before transferring files to a website. My problem is that when I try to set the directory on a server that has case sensitive directories CFtpConnection::SetCurrentDirectory() fails.
I have made sure that the directory being passed into CFtpConnection::SetCurrentDirectory() is correct but the functions fails. Has anyone else seen this or am I doing it incorrectly.
Thanks in advance.
***********************
Tony Fontenot
Recreational Solutions
tony@recsolutions.com
***********************
|
|
|
|
|
Please tell me how can I change the caption of a window at runtime.
Thanks
|
|
|
|
|
Use SetWindowText API or CWnd::SetWindowText method
|
|
|
|
|
|
You can't.
You need to associate the icon with a window at runtime. You do this by calling SetClassLong with the GCL_HICON and GCL_HICONSM flags.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
What do i then pass in the third parameter?
|
|
|
|
|
Check the "System Menu" checkbox for your dialog's properties in the resource editor. Then, in your dialog's OnInitDialog() handler, do this:
SetIcon (AgxGetApp()->LoadIcon (IDR_MYICON), TRUE);
where IDR_MYICON is your icon's resource id.
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hi,
Does anyone know if there is a way to force the set container to resort a series of elements? I have written a Strict Weak Ordering predicate to initially sort my objects on multiple parameters in the object, but when I update parameters in the object, I would like them to be resorted in the set.
I have looked at the sort function, but it requires a RandomAccessIterator, and I am not sure how to get one of those from my set.
My only other idea is to remove and reinsert these items into the set. I wuld prefer to do the sort in place if that is possible though.
Any help or insight would be appreciated.
Thank you
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Donno if it could help, but a vector iterator is a RandomAccessIterator, so u can add ur elements in a vector, then apply the sort algorithm
Papa
|
|
|
|
|