|
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!!
|
|
|
|
|
You will need the DDK to get the docs, headers, and libs.
The relevant functions are CM_Locate_DevNode() , CM_Query_And_Remove_SubTree() , and CM_Request_Device_Eject()
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
Pinky, are you pondering what I'm pondering?
I think so Brain, but how will we fit the hamster inside the accordion?
|
|
|
|
|
I added an Edit Box to my Dialog. i'd like it only accept numeric input. when a non-numeric key is pressed a warning dialog will apear. i mean, just after press the key, not after my button 'Subject' is pressed, the dialog appears.
Hello World
|
|
|
|
|
If you only want it to accept 0-9 you can set it's style as "Numeric" in the resource editor.
Shuang. Wu wrote:
when a non-numeric key is pressed a warning dialog will apear
This isn't a good design idea. It would get pretty annoying having to close a dialog everytime you press an incorrect key. Setting the edit's style as numeric will produce a beep when an invalid key is pressed.
- Aaron
|
|
|
|