H
Hilton
Hi,
Using CF 1.0:
I writing a test for a larger project. The test is to have my C# code call
a C DLL and have the C DLL do a FillRect on my control. Are there any
examples of how to do this on the web? The C# code is:
void Fill ()
{
IntPtr hWnd = GetHWnd (this.button1);
GraphicsEx gex = GraphicsEx.FromHwnd (hWnd);
Rectangle r = this.button1.ClientRectangle;;
IntPtr hdc = gex.GetHdc ();
Function2 (hdc, ref r);
gex.Dispose ();
}
The C code is:
extern "C" __declspec(dllexport) int __cdecl Function1(int a, int b)
{
return a+b*b;
}
// Do I need to use CDC or can I use some non-MFC stuff?
extern "C" __declspec(dllexport) void __cdecl Function2(CDC *pCDC, RECT
*pRect)
{
CBrush brush;
brush.CreateSolidBrush (RGB(255,255,0));
pCDC->FillRect (pRect, &brush);
}
Function1 works correctly (FYI), Function2 crashes.
Thanks,
Hilton
Using CF 1.0:
I writing a test for a larger project. The test is to have my C# code call
a C DLL and have the C DLL do a FillRect on my control. Are there any
examples of how to do this on the web? The C# code is:
void Fill ()
{
IntPtr hWnd = GetHWnd (this.button1);
GraphicsEx gex = GraphicsEx.FromHwnd (hWnd);
Rectangle r = this.button1.ClientRectangle;;
IntPtr hdc = gex.GetHdc ();
Function2 (hdc, ref r);
gex.Dispose ();
}
The C code is:
extern "C" __declspec(dllexport) int __cdecl Function1(int a, int b)
{
return a+b*b;
}
// Do I need to use CDC or can I use some non-MFC stuff?
extern "C" __declspec(dllexport) void __cdecl Function2(CDC *pCDC, RECT
*pRect)
{
CBrush brush;
brush.CreateSolidBrush (RGB(255,255,0));
pCDC->FillRect (pRect, &brush);
}
Function1 works correctly (FYI), Function2 crashes.
Thanks,
Hilton