Click here to Skip to main content
15,900,816 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalgethostbyname failed in Window XP Pin
lauch24-Jan-04 19:34
lauch24-Jan-04 19:34 
GeneralRe: gethostbyname failed in Window XP Pin
Roger Wright4-Jan-04 20:42
professionalRoger Wright4-Jan-04 20:42 
GeneralRe: gethostbyname failed in Window XP Pin
lauch24-Jan-04 21:31
lauch24-Jan-04 21:31 
GeneralCPropertySheet failing to create Pin
Kibble4-Jan-04 18:41
Kibble4-Jan-04 18:41 
GeneralRe: CPropertySheet failing to create Pin
valikac5-Jan-04 4:53
valikac5-Jan-04 4:53 
Generali learn c++ Pin
than naing nge4-Jan-04 18:35
sussthan naing nge4-Jan-04 18:35 
GeneralRe: i learn c++ Pin
Selvam R4-Jan-04 18:47
professionalSelvam R4-Jan-04 18:47 
GeneralRe: i learn c++ Pin
abc8764-Jan-04 20:03
abc8764-Jan-04 20:03 
GeneralRe: i learn c++ Pin
jhwurmbach4-Jan-04 21:54
jhwurmbach4-Jan-04 21:54 
GeneralRe: i learn c++ Pin
Balkrishna Talele4-Jan-04 23:48
Balkrishna Talele4-Jan-04 23:48 
Generalcompliler cannot open 'include file' Pin
mapledrops4-Jan-04 18:06
sussmapledrops4-Jan-04 18:06 
GeneralRe: compliler cannot open 'include file' Pin
Selvam R4-Jan-04 18:52
professionalSelvam R4-Jan-04 18:52 
Generalcompliler cannot open 'include file' Pin
Anonymous4-Jan-04 18:04
Anonymous4-Jan-04 18:04 
GeneralRe: compliler cannot open 'include file' Pin
abc8764-Jan-04 19:58
abc8764-Jan-04 19:58 
QuestionWhat functions are there to read from files? Pin
obe4-Jan-04 11:31
obe4-Jan-04 11:31 
AnswerRe: What functions are there to read from files? Pin
alex.barylski4-Jan-04 16:38
alex.barylski4-Jan-04 16:38 
GeneralRe: What functions are there to read from files? Pin
obe4-Jan-04 19:23
obe4-Jan-04 19:23 
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 -//

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.