Click here to Skip to main content
15,904,935 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Help!! How to change the ListBox and EditBox background & text color without using MFC!! Thanks.. Pin
Kurt10-May-00 1:35
Kurt10-May-00 1:35 
GeneralBand Pin
Member 23759-May-00 16:07
Member 23759-May-00 16:07 
GeneralRe: Band Pin
Alex Gorev10-May-00 4:19
Alex Gorev10-May-00 4:19 
QuestionLPCOLESTR? Pin
Alain Royer9-May-00 10:33
Alain Royer9-May-00 10:33 
AnswerRe: LPCOLESTR? Pin
Alex Gorev9-May-00 11:01
Alex Gorev9-May-00 11:01 
AnswerRe: LPCOLESTR? Pin
Dundas TCP/IP Support9-May-00 11:29
Dundas TCP/IP Support9-May-00 11:29 
GeneralMetafile output on Win98 problem Pin
Chris Losinger9-May-00 9:27
professionalChris Losinger9-May-00 9:27 
GeneralRe: Metafile output on Win98 problem Pin
Gert Boddaert10-May-00 3:17
Gert Boddaert10-May-00 3:17 
Chris,

Had the same problem. It's a memory alignment thing. (prints fine on NT but had a problem on 95/98)
Sorry to mail a bulk of code like this.

Cheers,

GBO.
---
// Try something like this:
// excerpt from my GO++ extension code.
// I do not load the MetaFile from file, but from memory
// (it is embedded in my DLLs)
BOOL CGoSchemeMetaPict::DrawObject(CDC* pDC)
//:draw this metafile
{
if (!CGoObject::IsVisible()) return TRUE;

// allow for the MetaFileName() function to be overriden and actually
// change the name behind our backs!

if (myResID == 0)
{
TRACE0("CGoMetaFile with no ResourceID\n");
CGoObject::DrawObject(pDC); // call the base class default draw
return TRUE;
}

CGoAppMixIn* theApp = (CGoAppMixIn*) AfxGetApp();
CGoView* pView;
if (m_pDocument) pView = m_pDocument->GetCurrentDrawView();
else pView = m_pView;
int nScale = 100;
if (pView) nScale = pView->GetScale();

// only use the bitmap cache if the scale factor is 1:1 or smaller. If we are
// scaling things larger, draw the metafile directly.
CRect devRect = GetBoundingRect();
/* if (bPrintPreview)
{
CDC* pATC = CDC::FromHandle(pDC->m_hAttribDC);
pATC->LPtoDP(&devRect);
}
else
{
pDC->LPtoDP(&devRect);
}
*/ //GBO: does not work now ??

// for Win32 functions
HDC hDCDrawSurf = pDC->GetSafeHdc( );
LPENHMETAHEADER pemh;

if (hEnhMetaFile == NULL)
{
HRSRC HResourceInfo =
::FindResource( HCallingModule, // module handle
MAKEINTRESOURCE(myResID), // pointer to resource name
(LPCSTR) "WMFRES" // pointer to resource type
);
if (HResourceInfo == NULL)
{
DWORD error = ::GetLastError();
_ASSERT(NULL);
AfxMessageBox("HResourceInfo == NULL for MetaFileResource!");
return FALSE;
}
HGLOBAL HData = LoadResource( HCallingModule, // resource-module handle
HResourceInfo // resource handle
);
if (HData == NULL)
{
DWORD error = ::GetLastError();
_ASSERT(NULL);
AfxMessageBox("HData == NULL for MetaFileResource!");
return FALSE;
}

void* pMapFile = HData;
pemh = (LPENHMETAHEADER) HData;
DWORD uiSize = 0;

// CHECK FOR WMF FORMAT
//
// If it has an ALDUS header skip it
// Notice: APMSIZE is used because the HANDLE and RECT of the structure
// depends on the environment
//
if (*((LPDWORD)pemh) == ALDUS_ID)
{
ALDUSMFHEADER *pAldusMFHeader;
METAHEADER *pMFHeader; // Set pointers on the resource bloc
pAldusMFHeader=(ALDUSMFHEADER *) HData; // Points to the beginning of ALDUS METAHEADER
pMFHeader=(METAHEADER *)(pAldusMFHeader+1); // Points to the beginning of METAHEADER
// the Pointer + 1 -> 4 bytes further
// these 4 bytes == ALDUS_ID
// Keeps a copy of the ALDUSMETAHEADER
memcpy(&m_AldusMFHeader,pAldusMFHeader,sizeof(ALDUSMFHEADER));
_ASSERT(pMFHeader->mtType == 1); // in memory!
hEnhMetaFile = ::SetWinMetaFileBits(
pMFHeader->mtSize * 2L, // was 2?
// is size in WORDS
// Unsigned word (= 16 bits or 2 bytes).
(const unsigned char*)pMFHeader,//m_pMFBits,
NULL, //hDCDrawSurf, // was NULL
NULL);

if (hEnhMetaFile == NULL)
{
DWORD error = ::GetLastError();
_ASSERT(NULL);
CString errorrep(_T(""));
char temp[48];
::ZeroMemory(temp, 48);
_itoa(error, temp, 10);
errorrep = CString("UNSUPPORTED FORMAT or SEVERE ERROR for MetaFileResource! Error = ");
errorrep += CString(temp);
errorrep += CString("\nuiSize*2L = ");
_itoa(uiSize*2L, temp, 10);
errorrep += CString(temp);
errorrep += CString("\nhDCDrawSurf = ");
_itoa( (__int32) hDCDrawSurf, temp, 10);
errorrep += CString(temp);
AfxMessageBox(errorrep);
// UNSUPPORTED FORMAT
return FALSE;
}
}
else
{
// CHECK FOR EMF FORMAT
uiSize = pemh->nBytes;

hEnhMetaFile = ::SetEnhMetaFileBits (
uiSize, // buffer size
(PBYTE)pMapFile+pemh->offDescription+pemh->nDescription // buffer that contains enhanced metafile data
);
if (hEnhMetaFile == NULL)
{
DWORD error = ::GetLastError();
_ASSERT(NULL);
char temp[48];
::ZeroMemory(temp, 48);
_itoa(error, temp, 10);
CString errorrep("UNSUPPORTED FORMAT or SEVERE ERROR for MetaFileResource! Error = ");
errorrep += CString(temp);
AfxMessageBox(errorrep);
// UNSUPPORTED FORMAT
return FALSE;
}
}
}

int saved = pDC->SaveDC();

// TODO: add draw code for native data here
if (hEnhMetaFile != NULL)
{
BOOL Answer = ::PlayEnhMetaFile(hDCDrawSurf, hEnhMetaFile, &devRect );
if (Answer != TRUE)
{
DWORD error = ::GetLastError();
_ASSERT(NULL);
AfxMessageBox("PlayEnhMetaFile Failed for MetaFileResource!");
}
}
else
{
_ASSERT(NULL);
AfxMessageBox("hEnhMetaFile == NULL && hMetaFile == NULL for MetaFileResource!");
}

pDC->RestoreDC(saved); // reset DC

return TRUE;
}

QuestionHow to call a com object's method that takes VARIANT * parameters? Pin
plu9-May-00 6:55
plu9-May-00 6:55 
AnswerRe: How to call a com object's method that takes VARIANT * parameters? Pin
Member 10549-May-00 8:29
Member 10549-May-00 8:29 
QuestionHow to call other class functions from another class Pin
olive9-May-00 4:14
olive9-May-00 4:14 
GeneralDisplaying the Property Sheet for a file Pin
magesh9-May-00 2:42
magesh9-May-00 2:42 
GeneralRe: Displaying the Property Sheet for a file Pin
Mike Dunn9-May-00 15:51
Mike Dunn9-May-00 15:51 
GeneralRe: Displaying the Property Sheet for a file Pin
magesh9-May-00 19:24
magesh9-May-00 19:24 
GeneralRe: Displaying the Property Sheet for a file Pin
magesh9-May-00 19:25
magesh9-May-00 19:25 
GeneralRe: Displaying the Property Sheet for a file Pin
Brian Hart25-Jun-00 13:37
Brian Hart25-Jun-00 13:37 
GeneralRemoving caption bar in toolbar Pin
Andrebon9-May-00 2:20
Andrebon9-May-00 2:20 
GeneralRe: Removing caption bar in toolbar Pin
Cristi Posea9-May-00 4:38
Cristi Posea9-May-00 4:38 
GeneralControls Pin
Ravi8-May-00 23:25
Ravi8-May-00 23:25 
GeneralRe: Controls Pin
Mike Dunn9-May-00 15:58
Mike Dunn9-May-00 15:58 
QuestionHow to use ActiveX without dialog ? Pin
Member 36018-May-00 15:02
Member 36018-May-00 15:02 
AnswerRe: How to use ActiveX without dialog ? Pin
Hussam Ahmad8-May-00 21:30
Hussam Ahmad8-May-00 21:30 
GeneralRe: How to use ActiveX without dialog ? Pin
Kurt10-May-00 1:48
Kurt10-May-00 1:48 
QuestionIs there any way of printing a pdf file? Pin
Erich J. Ruth8-May-00 14:45
sussErich J. Ruth8-May-00 14:45 
GeneralTest Only -Pls Ignore Pin
Anthony Mai8-May-00 13:35
Anthony Mai8-May-00 13:35 

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.