none
How to custom the button controls' display style , like CBitmapButton in wince6.0? RRS feed

  • Question

  • Hello everyone,

    How could we custom the button style in WINCE6.0, as give it a image to display?

    Thanks,

    Yanbin Yue


    gg

    Thursday, April 18, 2013 9:30 AM

Answers

All replies

  • You'd either (see http://msdn.microsoft.com/en-us/library/ee499091(v=winembedded.60).aspx)

    - Create a owner-drawn button (by specifying the BS_OWNERDRAW style)
    - Use window procedure subclassing and handle all relevant Messages (WM_PAINT, mouse button messages..) yourself.

    There are a good number of samples on CodeProject showing how to create such a bitmap button.
    This (http://www.codeproject.com/Articles/12525/CUniButton-Universal-Button-for-Pocket-PC) sample might be helpful to start with.

    Michael


    MVP Windows Embedded

    • Marked as answer by Yanbin Yue Friday, April 19, 2013 5:42 AM
    Thursday, April 18, 2013 7:09 PM
    Moderator
  • Thanks for your reply.

    Is there only this one method? Handle all Messages ourselves is very complex.....


    gg

    Friday, April 19, 2013 3:46 AM
  • If you want to create customized control, every possible approach (owner-draw, custom control, subclassing existing controls) requires a certain level of windows message handling when using native code.

    If using managed code (.NET Compact Framework), things would be ways easier. A sample how to do that can be found here: http://msdn.microsoft.com/en-us/library/ms172532(v=vs.90).aspx


    MVP Windows Embedded

    Friday, April 19, 2013 6:59 AM
    Moderator
  • We only could use the native code. So It looks we could only to do this with handling the windows message.

    The button class has drawitem interface and owner-draw property. And how about CProgressCtrl  CScrollBar and so on, which control has not owner-draw property?


    gg

    Friday, April 19, 2013 7:31 AM
  • It seams you're using MFC. In this case, the CBitmapButton class is available in the MFC implementation for Windows Embeddded CE (see http://msdn.microsoft.com/en-us/library/80a966hh(v=vs.90).aspx), You should not need to implement that yourself. 

    For all other controls (CProgressCtrl ...), you'd need to subclass the control (the MFC does that for you) and handle WM_PAINT (override the OnPaint method) plus related messages to get the control state (progress state...) need to properly draw he control. The most complex control to implement is probably the scroll bar.

    Windows Embedded CE also offers a way of skinning the entire UI (see http://msdn.microsoft.com/en-us/library/ee500211.aspx ). If you need to customize more or less every control available, this is something you may want to consider.


    MVP Windows Embedded

    • Marked as answer by Yanbin Yue Monday, April 22, 2013 2:27 AM
    Friday, April 19, 2013 12:49 PM
    Moderator
  • Thanks very a lot.

    I think we do need the skinning way.


    gg

    Monday, April 22, 2013 2:29 AM