|
CComPtr m_pBody;
But... isn't CComPtr a templated class? What would I use as the template type?
Adam
cabadam@houston.rr.com
|
|
|
|
|
Hi.
Does anyone know of a way to emphasize or highlight specific items in a list box, and/or in the list portion of a combo box?
eg: The list box contains a number of items, all of which must be visible, but only some of which are "valid" selections for the user (invalid items can be selected, but have different effects). I need a visible difference between valid & invalid choices within the box (different text color, check mark, etc).
I would rather not get into owner drawn, since that is completely new to me.
Thanks.
Wayne Janaway
|
|
|
|
|
|
I need to copy entire directory including subdirectories and files to
some destination. What is easiest way to do this?
Bad judgement gives Good experience;
Good judgement comes with Bad experience
|
|
|
|
|
Probably could be done better, but it worked for what I needed at the time.
#include <io.h>
#include <list>#include <string>
#include <windows.h>
#include <shlwapi.h>
void CopyFolder(TCHAR* szSource, TCHAR* szTarget);
void CreatePath(TCHAR* szPath);
std::list<tchar*> SourceFolders;
std::list<tchar*> TargetFolders;
std::list<tchar*>::iterator SourceItr;
std::list<tchar*>::iterator TargetItr;
int main(int argc, char* argv[])
{
TCHAR szSource[_MAX_PATH] = "C:\\Source";
TCHAR szTarget[_MAX_PATH] = "C:\\Target";
CopyFolder(szSource, szTarget);
return 0;
}
void CopyFolder(TCHAR* szSource, TCHAR* szTarget)
{
CreatePath(szTarget);
SourceFolders.push_back(szSource);
TargetFolders.push_back(szTarget);
TCHAR szCurDir[_MAX_PATH];
GetCurrentDirectory( _MAX_PATH, szCurDir );
SetCurrentDirectory( SourceFolders.back() );
WIN32_FIND_DATA FindData;
HANDLE hFile;
if( ( hFile = FindFirstFile( "*.*", &FindData ) ) != INVALID_HANDLE_VALUE )
{
do
{
if( !strcmp(FindData.cFileName, ".") || !strcmp(FindData.cFileName, "..") )
continue;
if( FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
{
TCHAR szTemp[_MAX_PATH];
strcpy(szTemp, SourceFolders.back());
strcat(szTemp, "\\");
strcat(szTemp,FindData.cFileName);
TCHAR szTemp2[_MAX_PATH];
strcpy(szTemp2, TargetFolders.back());
strcat(szTemp2, "\\");
strcat(szTemp2,FindData.cFileName);
BOOL bTest = CreateDirectory(szTemp2,NULL);
CopyFolder(szTemp, szTemp2);
}
else
{
TCHAR szNewFile[_MAX_PATH + _MAX_FNAME];
TCHAR szOldFile[_MAX_PATH + _MAX_FNAME];
strcpy(szNewFile, TargetFolders.back());
strcat(szNewFile, "\\");
strcat(szNewFile, FindData.cFileName);
strcpy(szOldFile, SourceFolders.back());
strcat(szOldFile, "\\");
strcat(szOldFile, FindData.cFileName);
if( !CopyFile(szOldFile, szNewFile, FALSE ) )
DWORD dwErr = GetLastError();
}
}while( FindNextFile(hFile, &FindData) );
}
SourceFolders.pop_back();
TargetFolders.pop_back();
if( SourceFolders.size() )
SetCurrentDirectory( SourceFolders.back() );
}
void CreatePath(TCHAR* szPath)
{
TCHAR szTempPath[_MAX_PATH];
strcpy(szTempPath,szPath);
TCHAR* pszFind;
std::list<tchar*> Path;
while( !PathIsDirectory(szTempPath) )
{
TCHAR* szTemp = new TCHAR[_MAX_PATH];
strcpy(szTemp, szTempPath);
Path.push_back(szTemp);
pszFind = strrchr(szTempPath, '\\');
int iPos = pszFind- (szTempPath + 1);
strncpy(szTempPath,szPath,iPos+1);
szTempPath[iPos+1] = '\0';
}
while( Path.size() )
{
CreateDirectory(Path.back(),NULL);
Path.pop_back();
}
|
|
|
|
|
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?
|
|
|
|
|