|
Hi All,
I had created dll using C#.
I tried to test all the functions using VB.net. The functions are doing what I want them to do.
Now, I want to use it my C++ program. C++ using VS 6.0. Not with C++.Net.
I tried to insert it from COM but that's it. I'm stuck. Dont' know further steps to call those functions from that dll.
May I please know how to use dll that was created by C# in C++ MFC project.
Thank you very much for your time to answer my question.
|
|
|
|
|
.NET dll are refered to as Assemblies and does not act as your convensional dll as you know it. .NET Assemblies are self-describing and contains meta-data that defines the the assembly - this is why .NET assemblies are not registered within the windows registry. The meta-data is why in a .NET application when you add a refrence, theres 2 tabs: .NET Assemblies and COM imports.
OK, your how?
In your C# dll, during design in VS, Edit the AssemblyInfo.cs file. the file contains instruction how to expose your assembly to COM. theres a tag named [assembly: ComVisible(false)] where the default is to not expose classes. set this flag to true.
Piece
PS: You should rather research the .NET assemblies before you use it in your C++ code. There are a few conceptual differences that cannot be said in a paragraph.
|
|
|
|
|
I have written a 6502 assembler/diassembler but here is something that has me stumped. I want the disassembler routine to create a new document in which to place it's output. I use a public function in the App class to call OnFileNew(). The new document is created, but not activated, so the disassembler sends it's output to the document that was active when it was called. When the disassembler exits the new document IS active. In other words: I press the disassemble button, a new child window appears but the output from the disassembler goes into the window under it. When the disassembler exits and I type on the keyboard, the keystrokes go into the new child window, the one I wanted to display the output from the disassembler.
Could anyone out there show me a code fragment that creates a new document and makes it active please?
I program for fun.
|
|
|
|
|
How do you choose which window to write to? or which document/view to write to?
Looks to me that you create the new document/view successfully, but you are still targetting the older (current) document/view... If that's the case, look for how to enumerate documents in the MDI app and then you can direct your output to the write document...
gmileka
|
|
|
|
|
I was wondering if anyone here has ever run across this problem. I have a COM DLL that builds and links properly within the IDE. I can register this DLL manually with regsvr32.exe and it will be fine. If the IDE tries to register it it never returns until I find the process in process manager and kill it.
Any ideas?
test
|
|
|
|
|
Is there any difference in the way that the ide IDE is calling regsvr32 vs. the way that you are calling it?
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Hi David,
No, that's jsut it. The IDE does it as a bost build process invoking the -s flag for silence with no message boxes. I should mention that this COM DLL calls functions from 2 other MFC DLL's that are created in this project.
Dave
test
|
|
|
|
|
So what happens if you remove the -s switch? Does the IDE report anything at that point?
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
I got a static text
(OnTimer() fuction)
...
...
m_seconds = m_seconds + 1 ;
m_SsecondsStr.Format("%2d:%2d", (int) m_seconds/60, (int) m_seconds%60);
as an output it give me " 0: 1" ," 0: 2",..." 0:10",..
How i have to type the "%2d:2d" so the output will be
"00:01","00:02",..."00:10" ... ?
|
|
|
|
|
Immunity18 wrote:
m_SsecondsStr.Format("%2d:%2d", (int) m_seconds/60, (int) m_seconds%60);
Use:
m_SsecondsStr.Format("%02d:%02d", (int) m_seconds/60, (int) m_seconds%60);
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Hi,
how can i load a Bitmap (.bmp) into an array? i want to use the array for a little image processing task...i want to test some filters!!
i know i could use cximage ...but i dont want to use it now!
greets
|
|
|
|
|
a .BMP is a BITMAPFILEHEADER followed by a DIB. a DIB is a BITMAPINFOHEADER followed by an optional palette or a BITFIELD array, followed by the pixels. the pixels are stored top-down (unless the height is negative!), in rows padded so that each row is a multiple of 4 bytes wide - possibly compressed with RLE. 24 and 32-bit bit pixels are stored in BGR order. there are also 7 or 8 different bit depth options to mess with.
getting your array of pixels is a simple matter of parsing all of that !
use a toolkit
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
sounds easy *lol*
what about:
<br />
BOOL LoadBitmapFile(CString filepath)<br />
{<br />
<br />
if (m_hbm != NULL)
{<br />
SelectObject(m_dc.m_hDC, m_hbm_default);<br />
DeleteObject(m_hbm);<br />
}<br />
<br />
m_hbm = (HBITMAP)LoadImage(NULL, filepath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); <br />
<br />
if (m_hbm == NULL)
return FALSE; <br />
<br />
m_hbm_default = (HBITMAP)SelectObject( m_dc.m_hDC , m_hbm);<br />
<br />
GetObject(m_hbm, sizeof(DIBSECTION), &m_dib);<br />
<br />
<br />
return TRUE;<br />
}
|
|
|
|
|
i believe that gives you a DIB at whatever bit-depth your video card is running at. so, you still need to be aware of DIB oarsing, and bit-depth issues.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Do you have any sampel to load a bitmap to an array?
|
|
|
|
|
|
hi,
its your lib? looks nice...
what about?
mfcapp\mfcappview.cpp(238) : error C2668: 'pow' : ambiguous call to overloaded function
hm
|
|
|
|
|
surfman19 wrote: mfcapp\mfcappview.cpp(238) : error C2668: 'pow' : ambiguous call to overloaded function
MFCApp was built with VC6. that's probably a VS03 or VS05 error.. just add (double) in front of the pow or in front of the parameters
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
hi....
i use visual studio 2005! i built the lib now i want to use the lib in an new mfc project!
what can i do with?
c:\dokumente und einstellungen\gerald\desktop\mfcapp\jpeglib\jmorecfg.h(161) : error C2371: 'INT32' : redefinition; different basic types
c:\programme\microsoft platform sdk for windows server 2003 r2\include\basetsd.h(62) : see declaration of 'INT32'
c:\dokumente und einstellungen\gerald\desktop\mfcapp\jpeglib\jmorecfg.h(215) : warning C4005: 'FAR' : macro redefinition
c:\programme\microsoft platform sdk for windows server 2003 r2\include\windef.h(145) : see previous definition of 'FAR'
c:\imgtest\imgtest\imgtestdlg.cpp(130) : warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data
|
|
|
|
|
ok i changed it to:
#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */
#include <basetsd.h>
//typedef long INT32;
#endif
<br />
int width = 256;<br />
int height = 256;<br />
BYTE * RGBbuffer = ReadJPEGFile("C:\\codeworx.bmp",&width,&height);<br />
imgtestdlg.cpp(213) : error C3861: 'ReadJPEGFile': identifier not found
hm?
-- modified at 15:13 Monday 15th May, 2006
|
|
|
|
|
I'm new to MATLAB programming. I currently use MATLAB v6.1(R12) on
MS WINXP SP2 with MS Visual C++ (6.0). I created a section of a
program within the Visual C++ environment and inserted a function
M-file into this program using the MATLAB Visual Studio Add-in. The
function M-file is to produce graphical output based on the values of
arrays which are to be initialized in the C++ environment. The
resulting program shows no compile errors.
The problem begins when the program is executed. It seems unable to
use the arrays intialized within the Visual C++ environment and
returns the error: "variable x is undefined". I don't understand why
this is so as the arrays have been initialized and passed
(mwArray(n_,_n,_name). I would appreciate it if someone could
provide assistance urgently.
Thank you
ATBU
|
|
|
|
|
Hi. I am writing picture editor which will work with all file types, that are used by Bitmap class. The program will use filters and other functions that will be alterring image.
I wrote a function to check if everything is ok and I can go on with my work, but I came to a problem.
The function below is just inverting pixels in Image and it works well... but only with 24Bpp>= images. What do I have to do, so that it will work with 8 and 16 Bpp Images ?
Thank you for any help!
Bitmap * bitmap.
{
UINT* pixels;
BitmapData bitmapData;
Rect rect(0, 0, pImg->GetWidth(), pImg->GetHeight());
pImg->LockBits(
&rect,
ImageLockModeWrite | ImageLockModeRead,
PixelFormat24bppRGB ,
&bitmapData);
pixels = (UINT*)bitmapData.Scan0;
int stride = bitmapData.Stride;
byte * p = (byte *)(void *)pixels;
int nOffset = stride - pImg->GetWidth() *3;
int nWidth = pImg->GetWidth() * 3;
for(int y=0;y < pImg->GetHeight();++y)
{
for(int x=0; x < nWidth; ++x )
{
p[0] = (byte)(255-p[0]);
++p;
}
p += nOffset;
}
pImg->UnlockBits(&bitmapData);
}
Cheers!
|
|
|
|
|
u need to do many reserches before u write code above.
the part which edits bitmap is less than 1/1000000000000000000000000000 of whole program which can edits "with all file types".
I suggest u stop now.
|
|
|
|
|
But you don't have to mess up with file types do you?
From what I know Bitmap class does everything for you. You just put
Bitmap bitmap("Filename") ;
And that's all, isn't it ?
I will do this editor for file types that are associated with Bitmap class, and they are(according to MSDN):
BMP, GIF, JPEG, PNG, TIFF, Exif, WMF, and EMF
The access to all pixels is not the same for all those file types(Of course depending on pixel depth)
So now my problem is only with different functions for different pixel depths images.
ps. I can't stop , as it's my school project. Thx for your reply though.
|
|
|
|
|
hi all
please look at 2 situations below
Items in underline outline the difference between both samples
1)
CString sPath = _T("c:\\file.txt");
FILE *pFile;
if( 0 != fopen_s( &pFile,(LPCSTR)sPath.GetBuffer(0),"w+b") )
throw _T("Error creating new file");
2)
FILE *pFile;
if( 0 != fopen_s( &pFile,"c:\\file.txt","w+b") )
throw _T("Error creating new file");
Problem is that 2- nd sample works fine, when 1- st throws exception.
Why ?
thank you in advance
-- modified at 12:13 Monday 15th May, 2006
|
|
|
|