|
<br />
BOOL SearchFolder(CString folder)<br />
{<br />
CFileFind finder;<br />
CString strWildcard(folder);<br />
strWildcard += _T("\\*.*");
BOOL bWorking = finder.FindFile(strWildcard);<br />
CString str;<br />
while (bWorking){<br />
bWorking = finder.FindNextFile();<br />
if (finder.IsDots())<br />
continue;<br />
else if (finder.IsDirectory()){<br />
str = finder.GetFilePath();<br />
SearchFolder(str);<br />
}<br />
else{<br />
str=finder.GetFilePath();<br />
DoingFile(str);<br />
}<br />
}<br />
finder.Close();<br />
return TRUE;<br />
}<br />
Good luck.
|
|
|
|
|
Normally, I recommend using MFC classes whenever possible except for CFileFind, which I find to be abhorent. I'd also normally give you some hints and have you learn for yourself, but I don't feel like it, so here is a non-MFC program for you:
#define WIN32_LEAN_AND_MEAN
#include < windows.h>
#include < shlwapi.h>
#include < stdio.h>
#include < tchar.h>
#pragma comment(lib, "shlwapi.lib")
inline
bool IsDots(LPCTSTR pFileName)
{
int i = 0;
while (pFileName[i])
{
if (pFileName[i++] != '.')
return false;
}
return true;
}
bool Walk(LPCTSTR pDirToFind, LPTSTR pFinalPath)
{
bool foundDir = false;
WIN32_FIND_DATA findData;
HANDLE hFind = ::FindFirstFile(_T("*"), &findData);
if (hFind != INVALID_HANDLE_VALUE)
{
do
{
if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
if (::CompareString(LOCALE_USER_DEFAULT, NORM_IGNORECASE, findData.cFileName, -1, pDirToFind, -1) == CSTR_EQUAL)
{
::GetCurrentDirectory(MAX_PATH, pFinalPath);
PathAddBackslash(pFinalPath);
_tcscat(pFinalPath, findData.cFileName);
foundDir = true;
}
else if (!IsDots(findData.cFileName))
{
::SetCurrentDirectory(findData.cFileName);
foundDir = Walk(pDirToFind, pFinalPath);
::SetCurrentDirectory(_T(".."));
}
}
} while (!foundDir && ::FindNextFile(hFind, &findData));
::FindClose(hFind);
}
return foundDir;
}
int _tmain(int argc, TCHAR* argv[])
{
if (argc != 2)
{
_putts(_T("FindDir <<dir>>"));
return 1;
}
TCHAR finalPath[MAX_PATH];
if (!Walk(argv[1], finalPath))
{
_tprintf(_T("Directory \"%s\" could not be found\n"), argv[1]);
return 1;
}
_tprintf(_T("Directory path is: %s\n"), finalPath);
return 0;
}
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
I dont think its a nice idea to use SetCurrentDirectory().Which can reflect at a different place in your project.
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
A) You should NEVER assume what the directory is in your project.
B) Just call GetCurrentDirectory() before the call then restore it afterward. You could encapsulate it in a class (which I have.)
C) Alternatively, you could use the final directory buffer to build up the path as you go. It requires a little more parsing, but if you preserve the length to make it easier to strip the path back down, it's not difficult. (Yes, I've done it this way, especially in the DOS days.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Please advise me how to create a *.ini file in MFC & how to operate on this file.
I would like to make a data link in MFC, please show me how ?
|
|
|
|
|
Look up WritePrivateProfileString() and ReadPrivateProfileString()
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
|
I want to calculate the golden ratio (Phi) and (phi)... I know how to do the equation, pretty simple, but I want to make the program so it will output a load of numbers instead of like... .61803 but I want a longer number... how can I do this??
Actual Linux Penguins were harmed in the creation of this message.
|
|
|
|
|
Are you looking for a numeric C++ class that holds more than 64bit integer?
Kuphryn
|
|
|
|
|
maybe using long float my_variable;
|
|
|
|
|
I mean, can I somehow make a type MORE precise to calculate phi or Phi to the nth digit?? like somewhere about 100 or no?
Actual Linux Penguins were harmed in the creation of this message.
|
|
|
|
|
i made a dll in which
i added a microsoft web browser control in a dialogue
but it doesnt shows the dialogue box. but if i remove the web browser control
then it works well.
please suggest someway
|
|
|
|
|
I recommend using shdocvw.dll. Is what Internet Explorer uses to navigate. Is on windows/system32
|
|
|
|
|
I have made a window in Win32. I would like to somehow handle the minimize event, so I can do stuff when the user clicks the minimize button. Does anyone have any clue how to do this? Any help is appreciated.
-Dev578
|
|
|
|
|
Both of the links I posted to your previous question 'Running a program in the taskbar' show how to handle the minimize event (or, one way of doing it)
Did you look at these examples ??
There are plenty of other examples, you can search here, or google
In general terms, when designing (say a dialog app), you must set 'Minimise Box' under Dialogue Properties -> Styles.
You then write/modify the handler for the 'OnSysCommand' - an example of such is shown below :-
void CMBFGWMS1Dlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
// Decide if minimize state changed
bool bOldMin = bMinimized_;
if (nID == SC_MINIMIZE) {
bMinimized_ = true;
}
else if (nID == SC_RESTORE) {
bMinimized_ = false;
}
CDialog::OnSysCommand(nID, lParam);
if (bOldMin != bMinimized_) {
// Minimize state changed. Create the systray icon and do
// custom taskbar button handling.
SetupTrayIcon();
SetupTaskBarButton();
}
}
}
the line
nID == SC_MINIMIZE
is actually the bit that checks to see if the minimise button/request was activated (since there are a number of different requests that all come through OnSysCommand) - this is how the request is handed to your program ...
How about you try using one of the examples, and post some code back to CP if you want more help - its easier for us to work with 'posted code' than vapour ....
'G'
|
|
|
|
|
OnSize (with type == SIZE_MINIMIZED)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
And another way is to handle WM_NCLBUTTONDOWN or WM_NCLBUTTONUP messages and check wParam parameter for HTMINBUTTON value. You should read in MSDN for more information .
|
|
|
|
|
Hi,
I have a custom draw list box, I handle WM_DRAWITEM to draw the items but it seems that only the selected items are drawn. The others aren't being invalidated. Anyone know why?
cheers,
roel
|
|
|
|
|
Are you checking the item state and setting TextColor correctly? (DRAWITEMSTRUCT::itemState)
That's just a guess, without code it's hard to tell what's going wrong.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Thanks for your reply, after letting it rest and getting some sleep it only took me 10 minutes to find it Problem was that I was using WTL's CDC and not CDCHandle, CDC destroys the DC when it goes out of scope... Argh stupid me, I've made this mistakes dozens of times for fonts and cursors and bitmaps, just when I thought that I wouldn't make it again this shows up... Anyway thanks for your answer.
|
|
|
|
|
I inserted on a form a Picture with a static control and the resource is a bmp image. I put background color when I drawed it at (255,0,255), but I set up the static control as transparent and it draws the background color.
How can make it transparent ?
Thankx !!
|
|
|
|
|
not sure i understand could you explain more
are you trying to draw a transparent bitmap ?
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
exactly. and I put it into a CStatic control as a Bitmap file so it shows it, but the (255,0,255) color in the BMP file doesn't turn to transparent when it is showed into the dialog.
Thankx !!
|
|
|
|
|
I am trying to develop an NT Service, novice in the field and running into following problems.
Let me simplify all the steps to explain problem i am facing, please let me know if i am doing anything wrong
I create a NT Service using Visual Studio 6 ATL Com wizard without a single line of my own code added here. Only thing i change is remove command from Project/Settings/Custom Build that re-registers the service. After that I compile the project. Let say name of the service is MyService. I use following commands to register and unregister service.
MyService -Service
.. start and stop the service
MyService -Unregserver
after this unregserver command this service goes in "Diabled" mode as shown in SCM and now if i want to re-register the service i can "Service cannot be deleted" message box. To only way to register the service again is to logoff the box.
Since I haven't added any of my code in this test project, there shouldn't be case of any dangling handle.
Any ideas?
|
|
|
|
|
It seems your service uninstall handler is not exiting the application after it DeleteService().
And also are you keeping SCM open while doing all these?
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|