Raymond Chen Programmer Microsoft Corporation PC43.

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

Transcript of Raymond Chen Programmer Microsoft Corporation PC43.

Page 1: Raymond Chen Programmer Microsoft Corporation PC43.

What's New with user32 and comctl32 in Win32

Raymond ChenProgrammerMicrosoft Corporation

PC43

Page 2: Raymond Chen Programmer Microsoft Corporation PC43.

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

Eight Things You Didn't Know You HadAnd one essay

Page 3: Raymond Chen Programmer Microsoft Corporation PC43.

Double-Buffering Helpers

// WM_CREATEBufferedPaintInit();

// WM_DESTROYBufferedPaintUnInit();

// WM_PAINT

hdc = BeginPaint(hwnd, &ps);hBuffer = BeginBufferedPaint(…, &hdc);PaintContent(hwnd, hdc);EndBufferedPaint(hBuffer, TRUE);EndPaint(hwnd, &ps);

Page 4: Raymond Chen Programmer Microsoft Corporation PC43.

Double Buffering

demo

Page 5: Raymond Chen Programmer Microsoft Corporation PC43.

Not filling your background Not suppressing WM_ERASEBKGND Remote Desktop / Terminal Services

Double-Buffering Traps

Page 6: Raymond Chen Programmer Microsoft Corporation PC43.

BP_BUFFERFORMAT BP_PAINTPARAMS

dwFlags prcExclude pBlendFunction

GetBufferedPaintBits() BufferedPaintSetAlpha()

Advanced Double-Buffering

Page 7: Raymond Chen Programmer Microsoft Corporation PC43.

Cross-Fade Animation Helpers

// WM_PAINTif (!BufferedPaintRenderAnimation(…)) { parms.dwDuration = ANIMATION_DURATION; hBuffer=BeginBufferedAnimation(…, &hdcFrom, &hdcTo); if (hdcFrom) paint into hdcFrom; if (hdcTo) paint into hdcTo; EndBufferedAnimation(hBuffer, TRUE);}

Page 8: Raymond Chen Programmer Microsoft Corporation PC43.

Identify and isolate states Draw based on state as parameter Maintain last-drawn and current states BufferedPaintStopAllAnimations

Painting With Cross-Fades

Page 9: Raymond Chen Programmer Microsoft Corporation PC43.

Animating And Not Animating

// WM_PAINTif (!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;}

Page 10: Raymond Chen Programmer Microsoft Corporation PC43.

Cross Fade Animation

demo

Page 11: Raymond Chen Programmer Microsoft Corporation PC43.

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

Oops: Windows 7 Content

Page 12: Raymond Chen Programmer Microsoft Corporation PC43.

Richer item view than icon and label Easier to read than report view but takes

up more space ListView_SetView(LV_VIEW_TILE)

List View Tiles

Page 13: Raymond Chen Programmer Microsoft Corporation PC43.

demo List View Tiles

Page 14: Raymond Chen Programmer Microsoft Corporation PC43.

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

Controlling List View Tiles

Page 15: Raymond Chen Programmer Microsoft Corporation PC43.

demo List View Tiles: Round 2

Page 16: Raymond Chen Programmer Microsoft Corporation PC43.

They don’t work Sorry

List View Extended Tiles

Page 17: Raymond Chen Programmer Microsoft Corporation PC43.

Create groups (ListView_InsertGroup) Put each item into a group (iGroupId) Turn on grouping

(ListView_EnableGroupView)

Windows XP List View Grouping

Page 18: Raymond Chen Programmer Microsoft Corporation PC43.

List View Grouping

demo

Page 19: Raymond Chen Programmer Microsoft Corporation PC43.

Don’t forget to assign items to groups Create groups before adding items to them Don't give two groups the same ID

Grouping Traps

Page 20: Raymond Chen Programmer Microsoft Corporation PC43.

Group subtitles (LVGF_SUBTITLE) Group footers (LVGF_FOOTER) Collapsible groups (LVGS_COLLAPSIBLE) Group command links (LVN_LINKCLICK) Enumerating group contents

(LVNI_SAMEGROUPONLY | LVNI_VISIBLEORDER)

Windows Vista List View Grouping

Page 21: Raymond Chen Programmer Microsoft Corporation PC43.

demo List View Grouping: Round 2

Page 22: Raymond Chen Programmer Microsoft Corporation PC43.

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

Grouping Insanity

Page 23: Raymond Chen Programmer Microsoft Corporation PC43.

demo List View Grouping: The Insanity

Page 24: Raymond Chen Programmer Microsoft Corporation PC43.

EM_SETCUEBANNER CB_SETCUEBANNER

Cue Banners

Page 25: Raymond Chen Programmer Microsoft Corporation PC43.

LVN_GETEMPTYMARKUP

Empty Text

Page 26: Raymond Chen Programmer Microsoft Corporation PC43.

MENUITEMINFO.hbmItem and MIIM_BITMAP 32bpp PARGB format supported in

Vista via DIBSECTION Don’t forget to DeleteObject it

Alpha-Blended Menu Bitmaps

Page 27: Raymond Chen Programmer Microsoft Corporation PC43.

Menu Bitmaps

demo

Page 28: Raymond Chen Programmer Microsoft Corporation PC43.

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

Icon Scaling

Page 29: Raymond Chen Programmer Microsoft Corporation PC43.

Foreground Activation Is Like Love

You can share it with others You cannot steal it

SetForegroundWindow AllowSetForegroundWindow CoAllowSetForegroundWindow

Page 30: Raymond Chen Programmer Microsoft Corporation PC43.

Evals & Recordings

Please fill

out your

evaluation for

this session at:

This session will be available as a recording at:

www.microsoftpdc.com

Page 31: Raymond Chen Programmer Microsoft Corporation PC43.

Please use the microphones provided

Q&A

Page 32: Raymond Chen Programmer Microsoft Corporation PC43.

© 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.

Page 33: Raymond Chen Programmer Microsoft Corporation PC43.