1 / 33

What's New with user32 and comctl32 in Win32

PC43. What's New with user32 and comctl32 in Win32. Raymond Chen Programmer Microsoft Corporation. Eight Things You Didn't Know You Had And one essay. Double-buffered painting Cross-fade animation helpers List view tiles List view grouping Cue banners and empty text

rafi
Télécharger la présentation

What's New with user32 and comctl32 in Win32

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. PC43 What's New with user32 and comctl32 in Win32 Raymond Chen Programmer Microsoft Corporation

  2. Eight Things You Didn't Know You HadAnd one essay • Double-buffered painting • Cross-fade animation helpers • List view tiles • List view grouping • Cue banners and empty text • Images next to menu items • Icon scaling • Foreground activation is like love

  3. Double-Buffering Helpers • // WM_CREATE • BufferedPaintInit(); • // WM_DESTROY • BufferedPaintUnInit(); • // WM_PAINT • hdc = BeginPaint(hwnd, &ps); • hBuffer = BeginBufferedPaint(…, &hdc); • PaintContent(hwnd, hdc); • EndBufferedPaint(hBuffer, TRUE); • EndPaint(hwnd, &ps);

  4. demo Double Buffering

  5. Double-Buffering Traps • Not filling your background • Not suppressing WM_ERASEBKGND • Remote Desktop / Terminal Services

  6. Advanced Double-Buffering • BP_BUFFERFORMAT • BP_PAINTPARAMS • dwFlags • prcExclude • pBlendFunction • GetBufferedPaintBits() • BufferedPaintSetAlpha()

  7. Cross-Fade Animation Helpers • // WM_PAINT • if (!BufferedPaintRenderAnimation(…)) { • parms.dwDuration = ANIMATION_DURATION; • hBuffer=BeginBufferedAnimation(…, • &hdcFrom, &hdcTo); • if (hdcFrom) paint into hdcFrom; • if (hdcTo) paint into hdcTo; • EndBufferedAnimation(hBuffer, TRUE); • }

  8. Painting With Cross-Fades • Identify and isolate states • Draw based on state as parameter • Maintain last-drawn and current states • BufferedPaintStopAllAnimations

  9. Animating And Not Animating • // WM_PAINT • if (!BufferedPaintRenderAnimation(…)) { • parms.dwDuration = ANIMATION_DURATION; • if (m_curState == m_drawnState) • parms.dwDuration = 0; • hBuffer=BeginBufferedAnimation(…, • &hdcFrom, &hdcTo); • if (hdcFrom) • PaintState(hdcFrom, m_drawnState); • if (hdcTo) • PaintState(hdcTo, m_curState); • EndBufferedAnimation(hBuffer, TRUE); • m_drawnState = m_curState; • }

  10. demo Cross Fade Animation

  11. Oops: Windows 7 Content • Windows 7 animation engine • Windows 7: New Text and Graphics APIs • You just missed it • But you can still catch the hands-on lab

  12. List View Tiles • Richer item view than icon and label • Easier to read than report view but takes up more space • ListView_SetView(LV_VIEW_TILE)

  13. demo List View Tiles

  14. Controlling List View Tiles • Specify how many additional lines of text you want to display in the tile • For each item, specify which columns you want to show as additional text • Usually the same for each item • Optionally set fixed tile size and margins

  15. demo List View Tiles: Round 2

  16. List View Extended Tiles • They don’t work • Sorry

  17. Windows XP List View Grouping • Create groups (ListView_InsertGroup) • Put each item into a group (iGroupId) • Turn on grouping (ListView_EnableGroupView)

  18. demo List View Grouping

  19. Grouping Traps • Don’t forget to assign items to groups • Create groups before adding items to them • Don't give two groups the same ID

  20. Windows Vista List View Grouping • Group subtitles (LVGF_SUBTITLE) • Group footers (LVGF_FOOTER) • Collapsible groups (LVGS_COLLAPSIBLE) • Group command links (LVN_LINKCLICK) • Enumerating group contents (LVNI_SAMEGROUPONLY | LVNI_VISIBLEORDER)

  21. demo List View Grouping:Round 2

  22. Grouping Insanity • Prerequisites for group descriptions • Group header image list • Group must have a title image • Group header must be centered • If you know what’s good for you • Don’t actually use a title image

  23. demo List View Grouping:The Insanity

  24. Cue Banners • EM_SETCUEBANNER • CB_SETCUEBANNER

  25. Empty Text • LVN_GETEMPTYMARKUP

  26. Alpha-Blended Menu Bitmaps • MENUITEMINFO.hbmItem and MIIM_BITMAP • 32bpp PARGB format supported in Vista via DIBSECTION • Don’t forget to DeleteObject it

  27. demo Menu Bitmaps

  28. Icon Scaling • LoadIconWithScaleDown implement a new scaling algorithm • Icon must include images at sizes 16, 32, 48, 256 • LoadImage/Icon still use old algorithm • SHDefExtractIcon uses new algorithm

  29. Foreground Activation Is Like Love • You can share it with others • You cannot steal it • SetForegroundWindow • AllowSetForegroundWindow • CoAllowSetForegroundWindow

  30. Evals & Recordings Please fill out your evaluation for this session at: This session will be available as a recording at: www.microsoftpdc.com

  31. Q&A Please use the microphones provided

  32. © 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

More Related