|
Thanks again for taking the time to reply everytime
Would you like to continue the discussion in email?
At any case - what I actually want to do is override the DirectX function calls so that my code will intercept every reading from the disk and modify the data that is being read...
|
|
|
|
|
Hi
C functions like fgets() and fscanf() can do the trick for you.
Besides that, you can also use the MFC class CFile and it's derived classes to do some file I/O.
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
After calling PageSetupDlg() about three or four times I get an "Out of Memory" error.
My App is MDI with Multiple Document views.
I am storing the PAGESETUPDLG structure in the view class so that each time a new view is created, each view will have it's own page setup values.
The problem seems to be that if the PAGESETUPDLG devmode and devnames are not set to NULL either before or after calling PageSetupDlg(), then the memory error occurs.
I tried creating a dmOrientation variable so that I could store the paper orientation for each view but it won't compile. (See how below. It's commented out.)
I tried creating a DEVMODE and DEVNAMES structure but this didn't help. (See how below. It's commented out.)
My questions are:
How can I store the PageSetupDlg() values for each view?
Am I doing something wrong? (See partial code below)
//- Begin part of h file -//
// MyView.h : header file
//
/////////////////
// CMyView view
class CMyView : public CView
{
protected:
CMyView(); // protected constructor used by dynamic creation
DECLARE_DYNCREATE(CMyView)
// Attributes
public:
PAGESETUPDLG psd; // common dialog box structure
// short myOrientation;
// DEVMODE myDevMode;
// DEVNAMES myDevName;
LOGFONT mylf; // logical font structure
//- End part of the h file -//
//- Begin part of the cpp file -//
// CMyView.cpp : implementation file
//
#include "stdafx.h"
#include "MyApp.h"
#include "MyAppDoc.h"
#include "MyView.h"
#include "resource.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////
// CMyView
IMPLEMENT_DYNCREATE(CMyView, CView)
CMyView::CMyView()
{
//Page Setup
// myDevMode = (HANDLE)NULL; //don't forget to free or store hDevMode
// myOrientation = DMORIENT_PORTRAIT; //Selects the orientation of the paper.
// This member can be either DMORIENT_PORTRAIT (1)
// or DMORIENT_LANDSCAPE (2)
// psd = {0}; //doesn't compile
psd.lStructSize = sizeof(PAGESETUPDLG);
psd.hDevMode = (HANDLE)NULL; //don't forget to free or store hDevMode
psd.hDevNames = (HANDLE)NULL; //don't forget to free or store hDevNames
// psd.hInstance = (HANDLE)hInst;
psd.lCustData = (LPARAM)NULL;
psd.hPageSetupTemplate = (HGLOBAL)NULL;
psd.Flags = PSD_INTHOUSANDTHSOFINCHES | PSD_MARGINS;
psd.rtMargin.top = 1000;
psd.rtMargin.left = 1000;
psd.rtMargin.right = 1000;
psd.rtMargin.bottom = 1000;
// Initialize LOGFONT
mylf.lfHeight = 12; // LONG lfHeight;
mylf.lfWidth = 0; // LONG lfWidth;
mylf.lfEscapement = 0; // LONG lfEscapement;
mylf.lfOrientation = 0; // LONG lfOrientation;
mylf.lfWeight = 0; // LONG lfWeight;
mylf.lfItalic = 0; // BYTE lfItalic;
mylf.lfUnderline = 0; // BYTE lfUnderline;
mylf.lfStrikeOut = 0; // BYTE lfStrikeOut;
// BYTE lfCharSet;
// BYTE lfOutPrecision;
// BYTE lfClipPrecision;
// BYTE lfQuality;
mylf.lfPitchAndFamily = 0;
// BYTE lfPitchAndFamily;
lstrcpy(mylf.lfFaceName,"Arial");
// CHAR lfFaceName[LF_FACESIZE];
}
/////////////////
// CMyView Printing
void CMyView::OnFilePageSetup()
{
psd.hwndOwner = GetSafeHwnd( );
// psd.hDevMode = (HANDLE)myDevMode; //don't forget to free or store hDevMode
// psd.hDevMode = (HANDLE)NULL; // don't forget to free or store hDevMode
// psd.hDevNames = (HANDLE)NULL; // don't forget to free or store hDevNames
// psd.hDevMode.dmFields = DM_ORIENTATION;
// psd.hDevMode.dmOrientation = myOrientation; //doesn't compile
psd.hInstance = (HANDLE)hInst;
psd.lCustData = (LPARAM)NULL;
psd.hPageSetupTemplate = (HGLOBAL)NULL;
if(PageSetupDlg(&psd) == TRUE) {
// myOrientation = psd.hDevMode.dmOrientation;
// myDevMode = (HANDLE)psd.hDevMode;
psd.hDevMode = (HANDLE)NULL;
psd.hDevNames = (HANDLE)NULL;
}
}
//- end of part of cpp file -//
|
|
|
|
|
Oops.
Forgot that there was another function in CMyView::OnFilePageSetup().
After the user chooses OK the following function is called.
AfxGetApp()->SelectPrinter(psd,hDevNames, psd.hDevMode,TRUE);
When this function is commented out, there is no memory error. However, the landscape/portrait is not implemented when Print Preview is called.
|
|
|
|
|
I want to pass the CString name to a class. I have this:
void CForm3Page1::OnName()
{
CFormatname Dlg("ralph");
if (Dlg.DoModal() == IDOK)
{
}
}
and my class looks like this:
private:
CString thename;
public:
CFormatname(CWnd* pParent = NULL, CString); // standard constructor
CFormatname::CFormatname(CString name, CWnd* pParent /*=NULL*/)
: CDialog(name, CFormatname::IDD, pParent)
{
//{{AFX_DATA_INIT(CFormatname)
//}}AFX_DATA_INIT
thename = name;
}
But it doesn't work. I keep getting the errors:
C:\Formatname.h(25) : error C2548: 'CFormatname::CFormatname' : missing default parameter for parameter 2
C:\Formatname.h(15) : see declaration of 'CFormatname'
and other errors. I have looked in this book for quite some trying to
mimic this example. How do I pass a CString to a class?
Please any response any one can give me will be greatly appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
DanYELL wrote:
CFormatname(CWnd* pParent = NULL, CString); // standard constructor
CString is a data type, it has to be followed with a variable that represents it:
CFormatname(CWnd* pParent = NULL, CString myStr);
- Nick Parker My Blog
|
|
|
|
|
Even with that change, I still get this error:
C:\Formatname.h(25) : error C2548: 'CFormatname::CFormatname' : missing default parameter for parameter 2
and it's this line
CFormatname(CWnd* pParent = NULL, CString mystr); // standard constructor
???
|
|
|
|
|
Try
CFormatname(CWnd* pParent = NULL, CString myStr = NULL);
Thank You
Bo Hunter
|
|
|
|
|
Bo Hunter wrote:
CFormatname(CWnd* pParent = NULL, CString myStr = NULL);
Since myStr is not a pointer and NULL is a void pointer 0, the default argument isn't correct, but should be CFormatname(CWnd* pParent = NULL, CString myStr = "");.
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
|
On my machine once you start default parameters from there
on out has to have defaults as well. Is this correct?
Thank You
Bo Hunter
|
|
|
|
|
Still stumped. I call the class like so:
CFormatname Dlg("ralph");
The constructor is:
CFormatname(CWnd* pParent = NULL, CString mystr = NULL); // constructor
and
CFormatname::CFormatname(CWnd* pParent /*=NULL*/, CString mystr)
: CDialog(CFormatname::IDD, pParent, mystr)
{
//{{AFX_DATA_INIT(CFormatname)
//}}AFX_DATA_INIT
thename = mystr;
}
and the errors are:
C:\Formatname.h(25) : error C2440: 'default argument' : cannot convert from 'const int' to 'class CString'
No constructor could take the source type, or constructor overload resolution was ambiguous
C:\Formatname.h(25) : error C2548: 'CFormatname::CFormatname' : missing default parameter for parameter 2
C:\Formatname.cpp(20) : error C2661: 'CDialog::CDialog' : no overloaded function takes 3 parameters
What perplexes me is the information that is added to the class by
Visual C++. It automatically adds 'CWnd* pParent /*=NULL*/'
and 'CFormatname::IDD' and I try to ignore those parameters and
mimic what I see in books, but it doesn't work.
Please, please, please any response anyone can give me will be
greatly appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
The constructor you supplied is expecting the first parameter to be a CWnd*, and you are passing a string. Either change the constructor
CFormatname(CString mystr, CWnd* pParent = NULL) or pass in a NULL pointer
CFormatname Dlg(NULL, "ralph");
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Seems so obvious now (and it works). I appreciate the reply. I kept
wanting to ignore the 'CWnd* pParent = NULL' part.
One last question. For this part of the constructor:
CFormatname::CFormatname(CWnd* pParent /*=NULL*/, CString mystr)
: CDialog(CFormatname::IDD, pParent)
{
//{{AFX_DATA_INIT(CFormatname)
//}}AFX_DATA_INIT
name = mystr;
}
what exactly is CFormatname::IDD? What am I passing to CDialog?
pParent is just NULL and I know what :: means, but CFormatname::IDD
doesn't make sense.
|
|
|
|
|
The IDD is the ID of the dialog. It is defined as a const in the class's H file.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Try This:
CFormatname(CString name,CWnd* pParent = NULL); // standard constructor
Shenthil
|
|
|
|
|
I have been using the introductory edition of MS VC++ 6.0 that came with Ivor Hortons book. What is the current latest version?
Ger
|
|
|
|
|
VC++ .NET 2003
modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
In a library that I downloaded I get an error on this line:
#if WIN32 && defined(_MSC_VER) && DEBUG
The sample app that came with the library compiles fine but when I use the library in my app it fails. I belive VC define those variables. So, its probably a configuration thing that I'm missing. (I compiled both projects in the Debug Configuration.)
Thanks for any ideas,
Albert
|
|
|
|
|
AFAIK it is complaining about DEBUG. VC defines _DEBUG (note the underscore). maybe the library or sample supplied defines DEBUG itself?
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Thanks, that was it. DEBUG was defined in the sample program's project.
|
|
|
|
|
I was wondering if there is a way to set the timeout for connecting? My app directly calls connect and if the server is OK then it will connect alright. If for example the address is wrong and it does not connect, it will hang there for many seconds.
One more thing, I am using WSAevents to signal read and etc. This is fine for me. However, I have a problem with using shutdown. It does not gracefully call the FD_CLOSE so that I can formally call closesocket. Has anyone seen this problem?
THanks in advance!
|
|
|
|
|
I have a class derived from CToolBar in a CFrame window. My problem is that I don't know how to tell if the user has closed the toolbar with the close button while it is floating. I have tried providing a OnClose message handler but it never gets called.
Any help would be greatly appreciated.
Thanks in advance.
|
|
|
|
|
Maybe handle the WM_SYSCOMMAND message, looking for the SC_CLOSE command.
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|