Re: Custom Controls with DLLImports in VS 2005
- From: "Peter Foot [MVP]" <feedback@xxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 23 Aug 2005 16:15:40 +0100
You can alter your code so that the P/Invokes are only called on the device.
e.g. using
if(System.Environment.OSVersion.Platform==PlatformID.WindowsCE)
{
//do device specific stuff
}
to exclude the calls from the desktop, or you could use an alternative e.g.
desktop p/invoke. You can simplify this slightly by using a static boolean
which is set once on initialisation e.g.
private static bool isDevice =
(System.Environment.OSVersion.Platform==PlatformID.WindowsCE);
If the P/Invokes occur during property setter/getters you can disable these
from appearing in the designer, if they are called within OnPaint,
OnParentChanged etc you'll need to wrap them as shown above.
Peter
--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com | http://www.peterfoot.net
"DanielF" <DanielF@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:72B96282-4911-4AA1-B9C5-03991BD3A151@xxxxxxxxxxxxxxxx
>I am trying to port some existing CF custom controls to VS 2005. I have
>read
> the article "Creating Custom Controls for MS .NET CF in VS 2005" which was
> helpful, but it does not deal with DLLImports. I have created the .xmta
> file
> to deal with the design attributes that are required and have installed
> the
> control into the toolbox, but still have errors when I drag-n-drop the
> control onto a form. It complains about the DLLImports and then crashes
> VS. I
> have searched this Newsgroup but no joy. Does anyone know how to deal with
> this issue? Is there an attribute that needs to be added to handle this or
> do
> you have to code around each and every reference to the DLLImport
> functions?
> Any help will be appreciated.
.
- Follow-Ups:
- Re: Custom Controls with DLLImports in VS 2005
- From: DanielF
- Re: Custom Controls with DLLImports in VS 2005
- References:
- Custom Controls with DLLImports in VS 2005
- From: DanielF
- Custom Controls with DLLImports in VS 2005
- Prev by Date: RE: clearcommerror native exception?
- Next by Date: Re: Infrared / Bluetooth / Wireless Support
- Previous by thread: Custom Controls with DLLImports in VS 2005
- Next by thread: Re: Custom Controls with DLLImports in VS 2005
- Index(es):