MSDOTnet.org Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Painting in a DLL

 
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> Compact Framework
Author Message
Hilton



Joined: 08 Aug 2007
Posts: 56

PostPosted: Fri Feb 01, 2008 10:19 pm    Post subject: Painting in a DLL Reply with quote

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

Archived from group: microsoft>public>dotnet>framework>compactframework
Back to top
View user's profile Send private message
Hilton



Joined: 08 Aug 2007
Posts: 56

PostPosted: Fri Feb 01, 2008 11:16 pm    Post subject: Re: Painting in a DLL Reply with quote

OK, silly me, figured it out.
Back to top
View user's profile Send private message
Hilton



Joined: 08 Aug 2007
Posts: 56

PostPosted: Sat Feb 02, 2008 4:02 am    Post subject: Re: Painting in a DLL Reply with quote

Hi,

OK, so I have managed to do a new Control() and have my DLL written in C
paint it yellow. Woohoo. OK, now any ideas how I can do a "new Bitmap()"
and get my DLL to paint it yellow?

This is CF 1.0 so things are very limited. I'm trying CreateCompatibleDC
and Select Object etc, but not making too much progress. OpenNETCF's
GraphicsEx and BitmapEx have kinda helped, but not entirely.

Help!

Hilton

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
How To Stop All Painting I was wondering if there is any simple way to stop all painting in .net. I have written several custom controls and forms which perform quite a few complex tasks during the form resize such as positioning themselves and rescaling underlying bitmaps and re

Painting in Thread not working Hi, I have created a simple ticker control that seems to work fine on it's own but as soon as I put another control on teh form with it (media player active-x control) it does not show up. The thread is being executed the text just isn't being painted on

Addative / Subtractive Painting of a Region I'd like to allow users to paint over an image using a circle of a given size so that I can 'cut' out the painted area. I've tried using on mouse move which gives an impression of what I require but this leaves the interior of the

Detect the change on a control's parent painting? Hello, I want to detect when my control's parent redraws itself. I know that this will cause a repaint in my control but I want to detect this before a paint event occurs in my control... Does anybody know if any event is fired in my control (before paint

Formatting grid I have a datagrid on my page which when displaying 10+ records looks great. However if there are less than 10 records the rows expand in an effort to fit making the grid look awfull. Is there some way around this ? Thanks in Advance
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> Compact Framework All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group