|
AFAIK this is the only solution. I don't think it's weird cause you only want to change the module state during the function call, and then set it back to the main application. And adding one line of code isn't too bad, is it ?
We are men. We are different. We have only one word for soap. We do not own candles. We have never seen anything of any value in a craft shop. We do not own magazines full of photographs of celebrities with their clothes on. - Steve
|
|
|
|
|
In the begining of every function that uses an MFC method which in turn uses this DLL's own resources ?
I think it sounds terrible Having to remember to do this, and having other people rememebr to do this. Not to mention having my code cluttered by this line all the time...
I want my module to always use the same AFX_MODULE_THINGY, why can't the AFX methods do AfxGetStaticModuleState() , that is my question actually. Why did they leave it this way ?
|
|
|
|
|
ohadp wrote:
I want my module to always use the same AFX_MODULE_THINGY, why can't the AFX methods do AfxGetStaticModuleState(), that is my question actually. Why did they leave it this way ?
Unfortunately (?) I was never a part of the development teams that invented MFC and the related techniques.
So I fear this is a question I can't answer you - I just take it as is, and every time my DLL does some weird things the 'AFX_MODULE_THINGY' is the first thing that comes to me. Hope you'll reach that state soon, too.
We are men. We are different. We have only one word for soap. We do not own candles. We have never seen anything of any value in a craft shop. We do not own magazines full of photographs of celebrities with their clothes on. - Steve
|
|
|
|
|
ohadp wrote:
There is no other solution except for placing this in all my methods that perform MFC calls ?
No, it is only needed by those functions that load resources from the DLL. Your DLL can use MFC all day long, but if it ever needs to load one of its own resources, it must use the AFX_MANAGE_STATE() macro.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi All,
I was trying to make a code similar to this work.
template <class t=""> class myclass
{
private:
t num;
public:
myclass() {}
~myclass() {}
};
class myclass1
{
public:
void abc(myclass <class t="">* obj)
{
}
};
int main(int argc, char* argv[])
{
myclass <int> obj;
myclass1 obj1;
obj1.abc(&obj);
return 0;
}
My basic idea is to have a template class myclass (which will take structure as template parameter). Now have another class myclass1 which will have a function taking this template class as one parameter. I want to make this member function of class myclass1 generic. i.e depending on the object of class myclass I create, this function should work.
Am getting compilation error.
Can we do such a thing at all with templates?
Thanks
Rajdeep
|
|
|
|
|
Can we do such a thing at all with templates?
Yup, I think you may be having problems with your syntax though. You need to specify a type parameter for template declarations and instanciations. Also you will need to make myClass1 a template class or derive myclass from a base and pass that to your function. Otherwise the compiler will not be able to figure out the type of the pointer.
template<class T>
class MyClass
{
private:
T Num_;
}
template<class T>
class MyClass1
{
public:
void abc(MyClass<T>* obj)
{
}
}
myClass<int> obj;
myClass1<int> obj1;
obj1.abc(&obj);
Good luck, templates are great stuff once they 'click'. Have a look for some introductory articles, bound to be some around here.
Ryan
|
|
|
|
|
You can make 'abc' a template function,
#include <iostream>
template <class t> class myclass
{
private:
t num;
public:
myclass( t n ) : num ( n ) {}
~myclass() {}
void Fn ()
{
std::cout << num << std::endl ;
}
};
class myclass1
{
public:
template <typename T> void abc(myclass <T>* obj)
{
obj->Fn () ;
}
};
int main()
{
myclass <int> obj ( 10 ) ;
myclass <double> objd ( 3.14159 ) ;
myclass1 obj1;
obj1.abc(&obj);
obj1.abc(&objd);
return 0;
}
There's no need to use pointers in abc, it would be preferable to use references, the functionality here doesn't change.
Paul
|
|
|
|
|
Hi, All...
I am writing a COM container using MFC OLE classes. The purpose of the
container is to display and/or print MS Word doc as portion of a bigger
display/plot. For this I am trying to get the Enhance Metafile representation of the word doc file using MSWord as COM Server. I have had limited success in the sense that only first page of the document is visible in the metafile.
Here is what I have tried:
CMyContainerDoc* pDoc = new CMyContainerDoc; //derived from
COleDocument
CMyCtrlItem* pCtrlItem = new CMyCtrlItem(pDoc); //derived from
COleClientItem
pCtrlItem->CreateFromFile("mytestfile.doc"); //path and name of a MS
word file
CSize clientSize;
BOOL bRet = pCtrlItem->GetCachedExtent(&clientSize, DVASPECT CONTENT);
HDC hDC = ::CreateEnhMetaFile(NULL, "c:\\drawtest.emf", 0, NULL);
CDC::FromHandle(hDC)->HIMETRICtoLP(&clientSize);
CRect rect( 0, 0, clientSize.cx, clientSize.cy);
pCtrlItem->Draw(CDC::FromHandle(hDC), &rect, DVASPECT CONTENT);
HENHMETAFILE hMetaFile = CloseEnhMetaFile( hDC );
DeleteEnhMetaFile( hMetaFile);
This results in just the first page of document to be represented in the
metafile.
How could I get the whole document in the metafile?
2. Alternatively, I tried to use GetData function of IDataObject
interface .
It returns success status code, but when I try to use the metafile
handle, returned through STGMEDIUM structure, it still contains only the first page.
Here is the relevant code:
FORMATETC fmtetc;
fmtetc.cfFormat = CF METAFILEPICT;
fmtetc.dwAspect = DVASPECT CONTENT;
fmtetc.ptd = NULL;
fmtetc.tymed = TYMED MFPICT;
fmtetc.lindex = -1;
STGMEDIUM stgMed;
memset(&stgMed, 0, sizeof(stgMed));
LPDATAOBJECT lpDataObject = 0;
pCtrlItem->m lpObject->QueryInterface(IID IDataObject,
(void**)&lpDataObject);
sc = lpDataObject->GetData( &fmtetc, &stgMed );
LPMETAFILEPICT pMF = (LPMETAFILEPICT)GlobalLock(stgMed.hEnhMetaFile);
//Draw the picture.
HDC hDC2 = ::CreateEnhMetaFile(NULL, "c:\\testGetdata.emf", 0, NULL);
BOOL bRetPlay = PlayMetaFile(hDC2, pMF->hMF);
GlobalUnlock(stgMed.hEnhMetaFile);
ReleaseStgMedium(&stgMed);
HENHMETAFILE hMetaFile = CloseEnhMetaFile( hDC2 );
DeleteEnhMetaFile( hMetaFile );
Here again, the metafile testGetData.emf contains just the first page of
the document.
Is there something I am missing here? Or if there is another better way
of achieving the intended results.
any suggestion appriciated !
Thanks in Advance
Vishal
|
|
|
|
|
|
Probably a bad idea...you should look into shell programming probably...
If nothing in there will solve your issue...then get the bitmap your user has set as a background, draw on it, save a new bmp (background w/ your text on it) and set it as the new background. If there not using any bmp for backgrounds, then make them
How do I print my voice mail?
|
|
|
|
|
|
Soliant wrote:
the OS version on your desktop, I wonder how they do that ?
Use Spy and figure out if it's a window or not...it could be using Active desktop (which i am not familiar with) or just a transparent window like you suggest.
How do I print my voice mail?
|
|
|
|
|
Try and check out GetDesktopWindow followed by GetWindowDC and DrawText
"It was when I found out I could make mistakes that I knew I was on to something."
-Ornette Coleman
"Philosophy is a study that lets us be unhappy more intelligently."
-Anon.
|
|
|
|
|
How about redrawing your text in a timer loop?
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hi
I have a binary file which is the result of writing an array of type double without formatting it to a text representation. Now I want to read the contents of this file and put them back to an array of type double. Could someone tell me how I can accomplish this? I have tried using ifstream opened in binary mode, and then I read the contents using >> operator, but it doesn't seem to work (all the array contents are still zeroes).
Thanks!
|
|
|
|
|
Post the code you've done so far.
Kuphryn
|
|
|
|
|
Hi,
Thanks for the reply. I managed to get it done using a similar way as described in the code below:
//Samples.dbs contains two double numbers in binary format
std::vector<double> vTest(2, 0.0);
std::ifstream fFile("Samples.dbs");
fFile.read((char*)&vTest[0], sizeof(double));
fFile.read((char*)&vTest[1], sizeof(double));
fFile.close();
If there are any better way to do this, I would be most grateful to know. Thanks!
|
|
|
|
|
Interesting.
You can try STL.
// Something like this
istream_iterator<<double>> streamDouble(file);
std::copy(streamDouble, istream_iterator<<double>>(), std::back_insert(vectorData));
You got the idea.
Kuphryn
|
|
|
|
|
I am trying to find samples and guides for miniport developement but neither Baker nor Oney cover this topic much in their books. Somebody pleasssseee HELP!!!
Hope to hear something... Thanks.
Ken
|
|
|
|
|
You will find little help regarding Drivers here, checkout microsoft newsgroup at msnews.microsoft.com and there are forum for DDK.
regards.
I'll write a suicide note on a hundred dollar bill - Dire Straits
|
|
|
|
|
|
Guys,
Thanks for your response. I really appreciate that.
Ken
|
|
|
|
|
How do i edit a txt file in a shell application :
eg.
In the first line of the names.txt = john
I want to edit that to be johnny replacing john
|
|
|
|
|
use iostreams. Read the file into a string array, then perform your changes, and finally, write the file back out again.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hi All,
Anyone knows how to safely "Unplug or Eject Hardware" without having to click that green arrow icon on the system tray? I want to write an application using some window API to do it.
Normally that icon appear when i plug in my USB storage.
I have searched the web, some people use DeviceIOControl to eject, but it doesn't really remove the device as when i click the icon and "Stop USB Storage Device - Drive G:"
Can anyone enlighten me please? I refuse to believe that i cannot do this using some window APIs... Thanks!!
|
|
|
|