|
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;
}
|
|
|
|
|
I have a foxpro component that take two VARIANT* as parameters. How do I populate these two parameters and
call IDispatch::....?
|
|
|
|
|
Well it depends on what you want to put in the variant... but first you would do something like this...
VARIANT v1,v2;
VariantInit(&v1);
VariantInit(&v2);
then depending on what you are putting in there you have to fill in the vt...
v1.vt = VT_BSTR; // for a bstr
v1.vt = VT_I2; // for an int
v1.vt = VT_I4; // for a long etc...
then you would call your method
yourobj->yourmethod(&v1,&v2);
|
|
|
|
|
Hi:I try to call function from other classes in here and get some problem.
All the necessary include files I put already.
I have the following functions that I want to call on other class. MY QUESTION
IS HOW TO IMPLEMENT THESE FUNCTIONS ON OTHER CLASS... SEE MY PSEUDOCODE....
I try some of them but mostly not working.
1) istream& loser.ReadFrom(istream& in, char* format ) ; --->read from cin
2) bool Ticket::Search( int* array, int item ,int elementsInArray );--> search
how many balls are matched
3) Ticket HistoryFile::GetMatch( Ticket& searchItem ); --> see if the date
of cin and from the file is match
the pseudocode to call those functions to other class:
read from cin -->istream& loser.ReadFrom(istream& in, char* format )
see if the date match --> Ticket HistoryFile::GetMatch( Ticket& searchItem);
if date on cin & date on file is same ---->if (ticket == ticket &);
match how many balls are match -->bool Ticket::Search( int*
array, int item ,int elementsInArray ); cout << "You match : " << ;else
null ticket ---> ticket.ticket( );endifThe following is my code:
void Pureluck::Run( ){
istream& loser.ReadFrom( ); --> //will give me this error
Error: PURELUCK.H(92,24):Too few parameters in call to 'Ticket::ReadFrom(istream
&,char *)'
then if I put --> loser.ReadFrom(istream &, char * ); //---> will give me
this errorError: PURELUCK.H(92,29):Improper use of typedef 'istream'
all the rest of message are mostly: Expression syntax.
winners.GetMatch( loser& searchItem ); //search for match date
if (ticket == searchItem) // if found match {
Ticket::Search( int* array, int item ,int elementsInArray )//find
out how many match } else {
Ticket::Ticket( ); //not found become null ticket }
endif; */}//endfn RunPlease let me knowThank's
|
|
|
|
|
Hi,
How do I display the same Property Sheet that is shown when we select 'Properties' from the context menu on a file in Windows Explorer. I want to display the properties of a file, but do not want to create a dialog template of my own and populate the dialog with all the information. I want to reuse the resource that Explorer uses. Is this possible?
Thanks in advance,
Magesh
|
|
|
|
|
Call ShellExecute() on the file, with a verb of "properties"
--Mike--
|
|
|
|
|
I tried the following code fragment from the WM_LBUTTONDOWN handler of an SDI app
ShellExecute(this->GetSafeHwnd(), "properties", "c:\\temp\\sharedfile.txt", NULL, "c:\\temp", SW_SHOW);
This call returns the error code SE_ERR_NOASSOC (0x1f) and does not display the property sheet for the file. What's wrong with this code?
|
|
|
|
|
I tried the following code fragment from the WM_LBUTTONDOWN handler of an SDI app
ShellExecute(this->GetSafeHwnd(), "properties", "c:\\temp\\sharedfile.txt", NULL, "c:\\temp", SW_SHOW);
The file exists in the specified directory.
This call returns the error code SE_ERR_NOASSOC (0x1f) and does not display the property sheet for the file. What's wrong with this code?
|
|
|
|
|
Dear Magesh,
In the forum, you posted:
"This call returns the error code SE_ERR_NOASSOC (0x1f) and does not display the property sheet for the file. What's wrong with this code?"
I'm not sure, but I think that the "properties" and some other new verbs are only available on Windows 2000. The only ones available for Windows 95/98/NT are "open" "explore" and "print." (I think.)
Cheers,
Brian Hart
|
|
|
|
|
I want remove caption bar in Toolbar(Floating).
I try to modify stlyle of Toolbar with ModifyStyle() method
but, failed.
ModifyStyle( WS_CAPTION, NULL ) -> this is I called Method
Thanks for reading this message!
|
|
|
|
|
When the toolbar is floating there are in fact 3 (three!) windows on top of each other.
The first one is a CMiniDockFrameWnd, the second one is a CDockBar, and finaly there is the CToolBar.
So you cannot change the style of the miniframe by calling ModifyStyle for the toolbar. In fact, it is also very complicated to remove the miniframe's caption.
If you really need this, in my article "CSizingControlBar..." in the Docking Windows section here, you will find how to do it, but be warned: this is a side feature in that library, and I didn't documented it.
|
|
|
|
|
How to put selected color(Not certain whether to use resources or some other way) in to CListCtrl's second column. The selected color should be from CColorPicker(combo like CColorDialog).
|
|
|
|
|
Check out this article of mine:
http://www.codeproject.com/listctrl/lvcustomdraw.asp
|
|
|
|
|
Hello All !
I want to write an application use ActiveX, but I do not want insert in Dialog. And I think that to do this by two way:
1. Use dialog and insert ActiveX normal, but set Dialog for hide. (Application base on Dialog, only one Dialog)
2. Maybe use only ActiveX in project ?!
Need some help. Thank you very much!
|
|
|
|
|
Hello!
Here is a way to do it.
1- Add the ActiveX to your project and you will get a .h and .cpp file that descripes the control.
2- Let us say the class is CMyCoontrol
CMyControl ctrlActiveX;
if(!ctrlActiveX.Create(NULL, WS_CHILD, CRect(0,0,0,0),
AfxGetApp ()->GetMainWnd(), WM_USER + 9999, NULL,
FALSE, NULL))
{
AfxMessageBox("Could not create object");
return FALSE;
}
// Control is created successfully do your work here
......
|
|
|
|
|
Hi
just add the ActivX to your project (Project / Add to project / Components / ActiveX. This will create a cpp and a header file and you can just call Create(..).
No need for a dialog at all.
Kurt
|
|
|
|
|
Is there any way of printing an adobe pdf file using vc++ 6.0?
Any response any one can give me will be greatly appreciated.
Sincerely,
Erich J. Ruth
|
|
|
|
|
I have been posting answers in CodeGuru and now I want to become a frequenter of CodeProject.
--Anthony Mai
|
|
|
|
|
Hi.
I created a cd player of my own using MCI. It is working fine on windows 9x.
I noticed a strange behaviour on windows 2000:
If i run my player and there is no CD in the drive, my app successfully open the cd device (MCI_OPEN),
but from this point windows explorer cannot access the cd drive even if I insert a data cd.
If I run my player and a cd is present in the drive everything works fine..
Any Idea?
Yaron
Yaronmiz@clockwise3d.com
|
|
|
|
|
Hi
I noticed that when I run MS CDPlayer and the cd device is already opened by another application,
the CD Player waits untill the device is free, and then take the control over it.
I wonder how are they doing it? Is it by polling and checking the MCI_SYSINFO or Is there any
notification from windows that the CD device is available for MCI_OPEN?
Hope you have any idea.
Yaron
|
|
|
|
|
There is anyone that can help me know how to implement application like microsoft money ?
I would like to know how it's developed and if there is something tools that can help me to develop like this.
Thanks
Antonio Patarozzi
|
|
|
|
|
Hi,
I wanted to know if there is a way to cause every application (installed on my computer, even those I didn't develop) to load a specific dll...
thx
Jonathan
|
|
|
|
|
Jonathan,
I found this on Deja, but not much else. Maybe someone else will have more hands-on experience with this:
>>
Hi, All!
I have following problem: When user executes particular process(console) I need insert my DLL into this process as soon as possible. I need this for NT and 98.
There are several ways to do this but none of them doesn't give full = solution.
1. Use hooks(SetWindowsHookEx). This is nice solution that works on both systems, but my hook DLL will be loaded to target process, only when one of the events i'm hooking occurs. And this is too late for me.
2. There is some registry key where I can put name of my DLL and it will be loaded to every process. Two disadvantages: works on NT only and reboot is needed.
3. Use technique used by Richter in his book using CreateRemoteThread. This one is good, but still works only on NT.
Does anybody knows other usefull technique for doing this.
Regards, Dennis
<<
|
|
|
|
|
This can not be done. And whatever your legitimate purpose is, there must be a better approach to implement it.
And your request sounds and smells suspiciously like a virus project: It fits the definition of a computer virus
|
|
|
|
|
I agree about the suspiscious smell
Actually I think it sounds and smells more like a Worm !
(technically different animals)
Unfortunatly I believe it can be done under some circumstances.
1. Using IE 4+ with low security settings,
2. Lack of a good firewall
3. Silly user,
I'm unsure how possible it is with WinNT and W2K
but it sure works with Win98.
But as to posting how it is done,
No I won't unless the person wishing to do so,
Contacts me and explains why they wish to do it,
with a legit reason etc. And then I'll only tell them
which MS-Press books to buy
Regardz
|
|
|
|
|