|
I use this recursive funtion. basically is loops through the directory and copies files. if it finds a directory then it calls the function with that directory.
hope it helps.
OldFilesMask: the directory that contains the files. in the format of "C:\Directory\*".
NewFilesDirectory: the directory the files are being copied to. in the format of "E:\Directory"
void CCustomerDlg::CopyDiskFiles(CString OldFilesMask, CString NewFilesDirectory)
{
CString strOldSearchFile, strOldFile, strNewFile, strNewSearchFile;
CString strNewMask, strFileName, strMessage, strTemp;
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
int iSlash;
hFind = FindFirstFile(OldFilesMask, &FindFileData);
while (hFind != INVALID_HANDLE_VALUE)
{
strFileName.Format("%s", FindFileData.cFileName);
if (strFileName != "." && strFileName != "..")
{
strOldFile = OldFilesMask;
iSlash = strOldFile.ReverseFind('\\');
strOldFile.Delete(iSlash, strOldFile.GetLength() - iSlash);
strNewMask.Format("\\%s", strFileName);
strOldFile.Insert(iSlash, strNewMask);
strNewFile.Format("%s\\%s", NewFilesDirectory, strFileName);
if (FindFileData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)
{
strOldFile = OldFilesMask;
CreateDirectory(strNewFile, NULL);
iSlash = strOldFile.ReverseFind('\\');
strOldFile.Delete(iSlash, strOldFile.GetLength() - iSlash);
strNewMask.Format("\\%s\\*", strFileName);
strOldFile.Insert(iSlash, strNewMask);
CopyDiskFiles(strOldFile, strNewFile, Product);
}
else
{
if (!CopyFile(strOldFile, strNewFile, FALSE))
{
strMessage.Format("Copy: '%s' to '%s' failed.", strOldFile, strNewFile);
AfxMessageBox(strMessage);
}
}
}
if (!FindNextFile(hFind, &FindFileData))
{
if (GetLastError () == ERROR_NO_MORE_FILES)
break;
}
}
FindClose(hFind);
}
Not much error checking but it fits my need. it may need some minor changes for your needs.
good luck
***********************
Tony Fontenot
Recreational Solutions
tony@recsolutions.com
***********************
|
|
|
|
|
http://www.codeproject.com/shell/cshellfileop.asp
The above link provides wrapper for the shell function, which can optionally display the progress bar similar to windows while copying files. Its a wrapper for existing Shell API.
Hope this helps.
Cheers
Kannan
|
|
|
|
|
I want to be able to create a CToolbar control on the fly by reading from a text file. The text file will tell me the number of buttons, the name for each of the button, the bmp file that has the bitmap for each button (or the image id and a bmp file with an image list).
I have to be able to read this file and create the toolbar in my SDI MFC app. Can someone, please show me, how I could form the imagelist from these bitmap files?
Thanks
S
|
|
|
|
|
Use ImageList_LoadImage to load image from file into imagelist. There's no MFC wrapper over this function, so you'll also have to use CImageList::operator HIMAGELIST().
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Thanks .. it worked.
|
|
|
|
|
Does anyone know any function in VC++ that can let me access or read or write data from or to COM port??
|
|
|
|
|
Yes, WriteFile and ReadFile will do the trick. It is here on msdn:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcecomm/htm/serial_8.asp?frame=true
This goes through opening, configuration, reading and writing.
|
|
|
|
|
Does anyone know any function in VC++ that can let me access or read or write data from or to COM port??
|
|
|
|
|
I have SDI form view based app. There is a dialog bar, and in the main frame I have a list box.
The list box is linked to a logging class who's base class is CListBox. In the constructor of the log class, I Create() the list box. So, in order to use my log class, I have to initilize the log class in CMainFrame, since the Create() function requires a pointer the the parent window "this" in this case. However, I need access to the log class from CApp.
- Confused MFC novice,
John
|
|
|
|
|
Use this...
CListBox& lbx = static_cast<CMainFrame *>(AfxGetMainWnd())->m_yourListBox;
... or this, assuming that listbox has a well-known id:
CListBox& lbx = *(static_cast<CListBox *>(AfxGetMainWnd()->GetDlgItem(IDC_YOURLISTBOX));
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi all,
I'm looking at trying to write an application to iterate through all the menus in an application. Basically, this would form part of a test suite type of thing that I could build on for my applications. I also thought it would be useful as a kind of demo tool to automate actions and so wanted to make it as generic as possible (ie: just using Win32 commands to analyze the application).
I need to be able to iterate through a running application because the menus may be dynamically altered at startup (this happens in our apps), so iterating through the resources of the exe is not good enough.
This is all pretty easy for standard apps where the menu is not dockable, but GetMenu(HWND) doesn't appear to work on MS Apps as the menu is off sub windows etc...
So far, I've been unable to figure out a way to automatically recognize the menu for these apps. We've tried sending an ALT-F message to the windows in the app to get it to popup the File menu, but that only seems to work in the standard menu apps too.
Has anyone done this before?, or have any ideas on how to recognise a window with the main menu?
Paul
All round software nice guy....
|
|
|
|
|
MS Office 'menus' are not menus at all- they use custom window classes (MsoCommandBar) to implement "cool" look and docking. The only reference I've found in MSDN is in AccessibleObjectFromWindow docs located in Platform SDK: Accessibility - it seems that you can get a IDispatch interface for a command bar.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
How can I use a CFileDialog as one of the pages in the property sheet.
|
|
|
|
|
Have data in ascii representation and need to convert to float equivalent. Not atof, that will convert ascii chars like "1234.567" to a float... I need to know how to take things like "=..." and "...." to their float value. Any ideas?
Aaron
|
|
|
|
|
Please!!!!!
atof();
Carlos Antollini.
|
|
|
|
|
I don't understand what you're asking. "=" has no float equivalent. atof() is what you should use.
Unless you're asking for the ASCII value of a character? In that case:
int ch = '=';
--Mike--
http://home.inreach.com/mdunn/
Push the button, Frank.
|
|
|
|
|
Hi there,
I was wondering if anyone here would know whether all those C++ Microsoft certifications for MCSD and MCDBA will be retired when the new .NET stuff rolls in, in the near future.
|
|
|
|
|
I doubt it - more likely they will add new subjects and retire old ones, just like MCSE does.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
The question is not if they will be retired but when will they be retired.
I've had to upgrade my MCSD after the old exams were retired and I expect to do it again sometime in the next two years. It's one way for Microsoft to get developers to use their tools and software.
|
|
|
|
|
Hi there,
When you are using Visual C++ and add Dialog box through the resources tab, how can you specify the exact width and height of the dialog box?
|
|
|
|
|
You should be able to just size the dialog by dragging the edges. If you want to enter the exact width and height, you might need to edit the resource file (*.rc) and scroll down to the dialog section, and enter your values there. hope it helps,
Jake
|
|
|
|
|
If you mean how to you set the exact size in pixels, you can't. Dialogs use DLU (dialog units) which are independent of pixels.
You can call SetWindowPos() in OnInitDialog() to set the size in pixels, but be aware the result will look awful in font sizes other than the ones you use.
--Mike--
http://home.inreach.com/mdunn/
Push the button, Frank.
|
|
|
|
|
I have a very particular problem that I need some help with. My problem
is that I am creating a regular MFC DLL that displays a dialog which
then does some work based on user input. I need to create an ActiveX
control (in this case Snowbound Software's Rastermaster OCX) on this
dialog at runtime. No matter how I've tried to approach this problem it
just does not seem to want to work. It seems to bomb in the
InitControlContainer() function in the MFC source file OCCCONT.CPP, where
it goes to make the call to
m_pCtrlCont = afxOccManager->CreateContainer(this);
I've tried this using other ActiveX controls and have gotten the same problem
so I do not believe it's a problem with the snowbound control in particular.
Can anyone please tell me if I'm just doing something wrong, or if what I'm
attempting to do is just simply not possible?
Any help will be GREATLY appreciated! Thanks!
X 10
|
|
|
|
|
And with this in the initinstance?
AfxEnableControlContainer();
Carlos Antollini.
|
|
|
|
|
I am making sure to call AfxOleInit() and AfxEnableControlContainer() in my App's InitInstance. Then in the constructor for my dialog I create a new object of the ActiveX control type which I then call the Create() member on in the dialog's OnInitDialog() function. For some reason after the call to create the control object's HWND is still NULL. It keeps failing on an assertion error in "Winocc.cpp" which I think is a result of trying to call a method on this object with a NULL hwnd.
The error as reported by the VC++ debug window is as follows:
Loaded 'C:\WINNT\system32\OLE32.DLL', no matching symbolic information found.
CoCreateInstance of OLE control {B2D168E0-5597-101D-843A-DA16297B4C87} failed.
>>> Result code: 0x800401f0
>>> Is the control is properly registered?
I'm pretty sure the control is registered however as I ran a successful call to regsvr32 on it.
|
|
|
|