|
Does anybody know the way to get rid of the thick (client?) border around the edit portion of combo box? Regular methods (that work with other controls) seem to have no effect.
Trying to make a property list control.
Thanx,
Dejan,
Melbourne
|
|
|
|
|
The example of a code, which one is fine draws on a screen, but is absolutely failed to print (except for a framework of an rectangle).
CTestView::OnDraw(...)
{
CBitmap m_bitmap;
m_bitmap.LoadBitmap(IDB_ ...);
CBrush m_brush;
m_brush.CreatePatternBrush(&m_bitmap);
CBrush * pSysBrush = pDC->SelectObject(&m_brush);
pDC->Rectangle(0, 0, 300, 300);
pDC->SelectObject(pSysBrush);
}
How to make correctly?
|
|
|
|
|
When you print you'll be working with a much bigger DC than on the screen. It probably printed a dot somewhere near the top. You need to query the printer DC to find out it's size and then scale the bitmap accordingly.
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.
|
|
|
|
|
I want to add a Capture Video ActiveX in my program.
When I add the ActiveX in my mainframe (CMyAppDlg) and that I use the associated functions with this activeX, I don`t have any problem.
But I want to add this ActiveX in a modeless windows created by a item menu. The problem is when I include this ActiveX in my modeless windows and that I call the associated functions to the ActiveX, I have a Assertion Error: "Debug Assertion Failed!" in the file "Winocc.cpp" for each call of a function of this ActiveX.
So, I don't know why the ActiveX work in my mainframe but doesn't work in the modeless Windows since I use the same code in the two manner?
Thanks for your help!
Francis B.
|
|
|
|
|
I'm having the same problem with a different ActiveX control I'm using
in a modeless dialog from within a DLL. For some reason it seems as though
the ActiveX control is not being created properly during the call to
Create(). Mine always has a NULL hWnd after the call to create so whenever
a method on the control object gets called it bombs out with that same
assertion error you're getting because the control has actually not been
created properly. I wish I had a solution for you, this one is driving
me crazy!
|
|
|
|
|
Alright, I have created an SDI app and, using Navigate2() have loaded a page. I have used the OnDocumentComplete() to allow me to know when it is done loading. How can I get the source code for that page?
Thanks!
Adam
cabadam@houston.rr.com
|
|
|
|
|
CComPtr<ihtmlelement> m_pBody;
CComPtr<iwebbrowser2> spBrowser;
HRESULT hr = QueryControl(__uuidof(spBrowser), reinterpret_cast<void**>(&spBrowser));
if( SUCCEEDED(hr) )
{
CComPtr<idispatch> pDisp;
if( SUCCEEDED(spBrowser->get_Document(&pDisp)) && pDisp )
{
HRESULT hr = pDisp.QueryInterface(&m_pDoc);
if( SUCCEEDED(hr) && m_pDoc )
{
if( SUCCEEDED(m_pDoc->get_body(&m_pBody)) && m_pBody )
return TRUE;
}
}
}
return FALSE;
|
|
|
|
|
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.
|
|
|
|
|