|
Hi all,
Is it feasible/possible/desirable to call a .NET DLL from an unmanaged VC6 MFC application?
TIA.
|
|
|
|
|
VC6?
More difficult.
With any recent version (Compiler version 7.1 = VC2003 is much much better than the braindead VC6 one!), you could quite simply devise a Bridge-DLL containing managed C++-code.
In VC6, this doesn't work. You probably could produce the Bridge-DLL with VC2003 and use it from your VC6 project....
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
Thanks for the info. That's not so good (for me!). How about accessing a VC6 MFC DLL from C# .NET?
|
|
|
|
|
I must admit I never did so.
I don't think it works, as the DLL and the application would link to different versions of the same classes.
But maybe this[^] can help you?
[edit]
A COM-Wrapper to the .NET-Part is a way in which you can access the managed code from VC6.
[/edit]
I am by no means an expert, just a user of Bridges devised by others. Sorry.
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
I think that a bridge DLL is what I need. Thanks for the help.
|
|
|
|
|
Steve_Harris wrote: I think that a bridge DLL is what I need.
Not when you are tied to VC6.
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
This [^] looks promising on the road of Yes/Yes/Yes.
[added]
of course I missed,
Steve_Harris wrote: VC6
(I got only VS )in your request. Uhm, as already pointed out by jhwurmbach, the road seems much more difficult then
[/added]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
modified on Thursday, January 10, 2008 11:00:39 AM
|
|
|
|
|
A bridging COM dll is the way to go but you probably won't be able to write it in VC6. From the VC6 side tlaking to a COM Dll is fine and from the .NET side COM Interop works really well but somewhere along the line you've got to write the COM interop code with a newer Visual Studio.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Yeah, I gathered that. If I could find some code that largely reproduced CScrollView in .NET, and let me show pages on-screen whose dimensions were lifted from the current printer settings, then I could go about updating the MFC code, but I've yet to find something that does that. *Sigh*
|
|
|
|
|
Hello,
I'm very interested in using Richard Stringer's Printing Class Library ( http://www.codeproject.com/KB/printing/printlib.aspx )to generate simple financial paper reports (numbers in a grid, essentially). This library, while very advanced, appears to be incapable of displaying multiple pages, or wrapping data onto a new page.
Has anyone had any success in using these classes to print multiple pages? Could someone suggest a class for printing arbitrarily lengthed financial data, complete with print preview?
Thanks a lot,
Sternocera
|
|
|
|
|
I have the code to read xml.where i used xml parser to read and write.but i am unable to update attribute in xml.plz do the needful.
my code is..
try
{
MSXML2::IXMLDOMProcessingInstructionPtr pPI = NULL;
MSXML2::IXMLDOMDocument2Ptr pXMLDoc = NULL;
MSXML2::IXMLDOMNodePtr pNode = NULL;
MSXML2::IXMLDOMNodeListPtr pXMLDomNodeList = NULL;
MSXML2::IXMLDOMNodePtr pRootNode= NULL;
EVAL_HR(CoInitialize(NULL));
// Create MSXML DOM object
EVAL_HR(pXMLDoc.CreateInstance(("Msxml2.DOMDocument.4.0")));
// Step 1: Creating the Processing Instruction
pPI = pXMLDoc->createProcessingInstruction
("xml", "version='1.0' encoding='UTF-8'");
_variant_t vNullVal;
vNullVal.vt = VT_NULL;
pXMLDoc->insertBefore(pPI, vNullVal);
// ---------------------------------------------
// Step 2: Creating the Root Element
_variant_t varNodeType((short)MSXML2::NODE_ELEMENT);
pRootNode= pXMLDoc->createNode(varNodeType,
("Root"),(""));
pXMLDoc->appendChild(pRootNode);
// ------------------------------------------
// Step 3: Creating Attribute Node
MSXML2::IXMLDOMNodePtr pAttNode= NULL;
// Step 4: Creating attribute name element
MSXML2::IXMLDOMAttributePtr pattIdAttr = NULL;
pattIdAttr= pXMLDoc->createAttribute(("Name"));
pattIdAttr->nodeTypedValue = ("Namevalue");
pAttNode->attributes->setNamedItem(pattIdAttr);
//doc.DocumentElement.AppendChild(newElem);
//xe.Element("address").SetElement("city", "MANCHESTER");
pXMLDoc->save("D:\\Book1.xml");
}
catch(...)
{
}
CoUninitialize();
thanking you
sharan
Hi,,
I am sharan.Working as a software Engineer in Indo-Fuji Software Company located in BTM Layout.Bangalore.India.
I have Completed my B.E(COmputers)in 2006.ANd I am having 2 years of Exp in VC++.
thanking you
sharan
|
|
|
|
|
I see no error checking. Could any of the methods you are calling be returning an error status?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
sharanu wrote: pAttNode->attributes->setNamedItem(pattIdAttr);
The above line is wrong, since pAttNode is NULL .
I changed that line with
pRootNode->attributes->setNamedItem(pattIdAttr);
and the file was correctly created (with the attribute added to the root element).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
i am using freeimage and see the code
fipImage m_image;
BYTE *byte= m_image.getScanLine(somevlaue);
Now do not want to use the freeimage can any one help me
(please not use MFC)that I have a bitmap file and get
the same byte pointer of Scanline of bitmap image
Trioum
|
|
|
|
|
|
I'd give you some sample code if you can provide more specifics.
Are the "bitmap" files always .BMP files or do you want to support
other file types?
Can you use ATL or only straight Win32 APIs?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
at present I am using only .bmp files then will use other file format
(i.e.jpeg ,png gif,tga etc).
I am using only plan sdk (win32 only).
Trioum
|
|
|
|
|
For BMP files, here's a simple method...
HBITMAP hBitmap = (HBITMAP)::LoadImage(NULL, _T("C:\\Some.bmp"), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE);
if (hBitmap)
{
DIBSECTION DibSection;
::GetObject(hBitmap, sizeof(DibSection), &DibSection);
LONG scanline = ...;
BYTE *pScanlineBytes;
if (DibSection.dsBmih.biHeight > 0)
pScanlineBytes = (BYTE*)DibSection.dsBm.bmBits + (DibSection.dsBm.bmWidthBytes * ((DibSection.dsBm.bmHeight - 1) - scanline));
else
pScanlineBytes = (BYTE*)DibSection.dsBm.bmBits + (DibSection.dsBm.bmWidthBytes * scanline);
::DeleteObject(hBitmap);
}
For other file formats, you need to either parse the file yourself and provide any
decompression necessary, or you can use a third-party library. For Win32 in C++
you can use GDI+ to load png, jpeg, tiff, gif, exif, and bmp. If you want to use
GDI like the code above once the image is loaded, then the GDI+ Bitmap::GetHBITMAP()
method will give you a DIBSection handle (HBITMAP) from a GDI+ Bitmap object.
If you can use C++, I would recommend using the ATL CImage class. It will handle all the
image types that GDI+ handles, and has simple methods for accessing scanlines as I've
demonstrated above.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
Sure - I'll send an email.
You may want to remove your email from your post to avoid
extra spam
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi everybody,
In MFC the new frames,views and controls appears in there own way.
So it seems ugly for the user if the new window opens under blitting...
I used the technique of LockWindowUpdate, which works great ... Under XP
Under Windows Vista this don't seem to work, the new frame opens in 2-4 steps
which seems very ugly
Does anyone knows this effect? Maybe also the correct technique to work around the problem?
Big thanks in advance
|
|
|
|
|
Hi, i am using FindWindow() function to get the handle of a dialog in one process from some other process. Can anybody tell is that correct or any problem in using the handle of a window in one process from some other process.
Thanks
|
|
|
|
|
A handle is actually a memory address. The handle (AKA: memory address) which you get from another process may be invalid to current process, because each process has its own view to memory (memory paging issue).
Maxwell Chen
|
|
|
|
|
I disagree. A window handle is unique on the system. You can post messages to the window whose that handle is assigned. At the end PostMessage is an IPC mechanism.
BTW handles technically are not memory addresses.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
CPallini wrote: I disagree. A window handle is unique on the system. You can post messages to the window whose that handle is assigned. At the end PostMessage is an IPC mechanism.
There is a translation mechanism.
CPallini wrote: BTW handles technically are not memory addresses.
The type void* is memory address.
typedef void* HANDLE;
Maxwell Chen
|
|
|
|