xinyan's WebLog

  • web cast link and source code

    The link to my web cast on custom control in Visual Studio for devices is:

    http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032284322&Culture=en-US

    and you can get the source code used in the demo from: http://www.msnusers.com/xinyanblog/Documents/CustomControlWalkThrough.zip

    Thanks

    Xin

  • up-coming web cast

    I will present a web-cast on how to create custom control in Visual Studio 2005. The link is:

    http://msevents.microsoft.com/cui/WebCastEventDetails.aspx?EventID=1032284322&EventCategory=4&culture=en-US&CountryCode=US

    See you there!

     

  • how to trouble shoot custom control design-time issues

    When doing custom control development, here are some frequent design-time issues:

    1. Why my custom controls are added to the form designer as an empty box?

    Most likely your custom control is device specific (the assembly that your custom control resides uses P/Invoke, or references another assembly that uses P/Invoke). In Visual Studio 2005 .net Compact Framework designer, once we detected a custom control is device specific, it will be replaced with an empty box because this custom control is regarded as dangerous to be created in the design-time (Creating this custom control in design-time may cause P/Invoke code to be executed. Most of the P/Invoke calls are specific to WinCE OS, and will fail during design-time.).

    If your custom control is safe to be created in design-time, you will need to add “DesktopCompatibility” design-time attribute on this custom control to mark is to be desktop compatible. You can take a look at the links to my previous blog on how to do it. It’s pretty easy.

    2. Why some properties are missing in the property browser?

    Same as 1). Try adding “DesktopCompatible” design-time attribute.

    3. Why my design-time components, such as designer, editor or type converter are not being used in design-time?

    There could be many reasons for this. For example, the design-time assembly can not be loaded, or the design-time components throws exceptions. Debugger will help you to figure this out. Attaching debugger is a relative straight forward step. First, start another Visual Studio instance, select “Tools / Attach to process” menu, set the code type to “Common Language Runtime”. This will enable you to debug managed code. If the code you want to debug involves both managed and native code, you can check both “Common Language Runtime” and “Native” to enable both managed and native debugging.

    Once the debugger is attached, you can browse to your source code and set break points. If the corresponding module hasn’t been loaded yet, the break points will appear to be disabled. This is ok. The debugger will automatically enable them once the module is loaded. If not, check Tools\Options page, select "Debugging" on the left side and uncheck "Enable Just My Code (Managed only)" option.

    In many cases you will need to debug why exception happens. All you need is to attach the debugger before the exception and set the debugger to catch any exceptions being thrown. To do this, select “Debug\Exceptions” from the menu and check the specific exceptions you want to catch. Often I started with catching every managed exception. Once I know what exception it is, I can narrow the scope of the catching to that one.

    After attaching the debugger and setting up exception catching, run your test scenario and it will break into debugger once an exception is thrown. Remember, some exceptions are expected (Visual Studio itself uses exceptions internally to communicate success / failure status). So be sure to locate the right exception you want to debug.

  • some resources on smart device custom control

    In the past few months I gave a talk in MEDC 2005, did a web cast in MSDN and wrote an article in sys-con.com. All these are about creating custom controls for .Net Compact Fraemwork in Visual Studio 2005. The following topics are coverred:

    - Why you need design-time attributes?

    - How to add design-time attributes to custom control?

    - What is design-time metadata assemblies?

    - What are the cool things you can do to your custom control by using design-time attributes?

    The link to my demo code and walk-through document can be found here: http://blogs.msdn.com/vsdteam/archive/2005/07/20/Amit_Chopra.aspx

    The link to my article on sys-con.com can be found here: http://symbian.sys-con.com/read/113332.htm

    Thanks

    Xin

  • Toolbox in Whidbey SmartDevice applications

    Whidbey SmartDevice WinForm designer has much better support for adding your custom control to the toolbox. Unlike Everret (Visual Studio 2003) that requires developer to create a design time assembly in addition to the runtime assembly, in Whidbey we eliminated the need for design time assembly completely.

    Add your custom control type to the toolbox? There are 2 ways:

    1. Simply build your project that contains UserControl, custom component or custom control. It will show up in the toolbox automatically and ready to be dropped to the designer.

    2. From toolbox window, select "Choose Items" and browse to the assembly containing the custom control. After clicking OK, the types from the assembly you choose will be added to the toolbox.

    Note controls / components compiled against .Net Compact Framework v1.0 will only show up in projects targetting .Net Compact Framework v1.0. Controls / components compiled against .Net Compact Framework v2.0 will only show up for projects targeting .net Compact Framework v2.0.

  • Whidbey Beta 1 is on the way!

    After couple of months intense work, we are almost done with Whidbey Beta 1. Check out these new features related to smart device programing!

    - Create C#/VB.Net for Pocket PC 2003 and Windows CE (target .Net Compact Framework V2.0) and SmartPhone 2003 (target .Net Compact Framework V1.0).

    - Better managed designer support. Controls are now WYSIWYG with device specific appearance. Custom control, inheritted form and user control are supported.

    - Platform switching and unsupported control conversion. You can switch the project between platforms. Designer will help you detect and convert controls that are not unsupported on a platform.

    Stay tuned!

  • another tip - creating a maximized form on Pocket PC

    Do you know how to create a maximized form (a form without title and occupies the whole screen area) in a Pocket PC application using .Net Compact Framework 1.1?

    There are couple properties you need to set to get it work. First, make sure the following properties are set inside InitializeComponent() or form's constructor:

            form.Menu = null;

            form.FormBorderStyle = FormBorderStyle.None;

    Secondly, in form.Load event handler, set form.WindowState = FormWindowState.Maximized

    This will give you a maximized form. Here is sample code:

    public class Form1 : System.Windows.Forms.Form

    {

    public Form1()

    {

    InitializeComponent();

    }

    protected override void Dispose( bool disposing )

    {

    base.Dispose( disposing );

    }

    #region Windows Form Designer generated code

    private void InitializeComponent()

    {

    this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;

    this.Text = "Form1";

    this.Load += new System.EventHandler(this.Form1_Load);

    }

    #endregion

    private void Form1_Load(object sender, System.EventArgs e)

    {

    this.WindowState = FormWindowState.Maximized;

    }

    }

    Hope this helps.

  • Tip of the day

    Are you developing Pocket PC application using .Net Compact Framework 1.0? If so, do you know how to enable or disable the smart minimize button on a form?

    By default, a form will use the smart minize button ( the X button). This button doesn't close the form but minimizes it. If you disable the smart minimize button, the OK button will be shown. Once you click it, your form will be closed.

    In .Net Compact Framework, smart minimize button is controled by Form.MinimizeBox property. Setting it to true (default) will enable the smart minimize button, means clicking it will minimize the form. Setting it to false will disable smart minimize button, means clicking it will close the form.

     

  • Blog #1

    Hi, I am a developer in Visual Studio for Smart Devices team. I am working on managed designers - platform specific design time support for windows form controls and designer extensibility support are my main focus area.

    We have been working very hard for the last year to prepare for our next release. There are tons of excting new features and I eager to show them off. Stay tuned for MDC 2004 (http://www.microsoftmdc.com/)!

    While working on the next release, I am also very interested to hear from customers who have been using Visual Studio 7.1. Let us know what you like and what you don't and we will make the next release a great tool for you!


© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker