Click here to Skip to main content
15,885,546 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: What functions are there to read from files? Pin
abc8764-Jan-04 19:54
abc8764-Jan-04 19:54 
GeneralThanks, but I would like to know which SYSTEM-LEVEL functions Pin
obe4-Jan-04 21:34
obe4-Jan-04 21:34 
GeneralRe: Thanks, but I would like to know which SYSTEM-LEVEL functions Pin
jan larsen6-Jan-04 2:00
jan larsen6-Jan-04 2:00 
GeneralRe: Thanks, but I would like to know which SYSTEM-LEVEL functions Pin
obe6-Jan-04 8:58
obe6-Jan-04 8:58 
GeneralRe: Thanks, but I would like to know which SYSTEM-LEVEL functions Pin
jan larsen6-Jan-04 21:12
jan larsen6-Jan-04 21:12 
GeneralRe: Thanks, but I would like to know which SYSTEM-LEVEL functions Pin
obe7-Jan-04 7:34
obe7-Jan-04 7:34 
AnswerRe: What functions are there to read from files? Pin
Bob Stanneveld4-Jan-04 23:08
Bob Stanneveld4-Jan-04 23:08 
GeneralUsing PageSetup Dialog is giving memory error Pin
Anonymous4-Jan-04 10:21
Anonymous4-Jan-04 10:21 
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 -//
GeneralRe: Using PageSetup Dialog is giving memory error Pin
Anonymous4-Jan-04 13:50
Anonymous4-Jan-04 13:50 
QuestionHow do I pass a value to a class? Pin
DanYELL4-Jan-04 7:17
DanYELL4-Jan-04 7:17 
AnswerRe: How do I pass a value to a class? Pin
Nick Parker4-Jan-04 8:01
protectorNick Parker4-Jan-04 8:01 
GeneralRe: How do I pass a value to a class? Pin
DanYELL4-Jan-04 8:33
DanYELL4-Jan-04 8:33 
GeneralRe: How do I pass a value to a class? Pin
Bo Hunter4-Jan-04 8:38
Bo Hunter4-Jan-04 8:38 
GeneralRe: How do I pass a value to a class? Pin
Bob Stanneveld4-Jan-04 23:16
Bob Stanneveld4-Jan-04 23:16 
AnswerRe: How do I pass a value to a class? Pin
Michael Dunn4-Jan-04 8:56
sitebuilderMichael Dunn4-Jan-04 8:56 
AnswerRe: How do I pass a value to a class? Pin
Bo Hunter4-Jan-04 9:05
Bo Hunter4-Jan-04 9:05 
GeneralRe: How do I pass a value to a class? Pin
DanYELL4-Jan-04 9:43
DanYELL4-Jan-04 9:43 
GeneralRe: How do I pass a value to a class? Pin
PJ Arends4-Jan-04 10:07
professionalPJ Arends4-Jan-04 10:07 
GeneralRe: How do I pass a value to a class? Pin
DanYELL4-Jan-04 15:04
DanYELL4-Jan-04 15:04 
GeneralRe: How do I pass a value to a class? Pin
Tim Smith4-Jan-04 15:41
Tim Smith4-Jan-04 15:41 
AnswerRe: How do I pass a value to a class? Pin
Shenthil4-Jan-04 20:52
Shenthil4-Jan-04 20:52 
Questionwhat is the definitive version of VC++ Pin
Ger Hayden4-Jan-04 7:15
Ger Hayden4-Jan-04 7:15 
AnswerRe: what is the definitive version of VC++ Pin
User 66584-Jan-04 7:58
User 66584-Jan-04 7:58 
AnswerRe: what is the definitive version of VC++ Pin
Michael Dunn4-Jan-04 8:57
sitebuilderMichael Dunn4-Jan-04 8:57 
Generalinvalid integer constant expression Pin
ABean4-Jan-04 6:47
ABean4-Jan-04 6:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.