SlideShare une entreprise Scribd logo
1  sur  44
Five Things Every Win32
Developer Should Know

Raymond Chen
(raymondc@microsoft.com)
FUN412
Windows User Experience
Microsoft Corporation
Five Topics
 Performance
   What you learned in school is wrong
   Playing friendly with others
 User interface issues
   The many faces of large fonts
   Parent and owner windows (review)
   Asynchronous input and synchronized input
Community Resources At PDC
 Other talks
   FUN319: Power-Aware Applications
   (Thu 5:15pm – note room change)
     An important “tax”
   FUN421: Garbage Collection Inside Out
   (Fri 1pm)
     Memory from the managed perspective
 Fundamentals Track lounge
   I’ll be there all day today
 Ask The Experts: System Internals
Talks You May Have Missed
(watch the DVD)
  FUN405: Programming with
  Concurrency, Part 2
    The dangers of trying too hard
  FUN307: Test Automation and
  Accessibility
Community Resources After PDC
 MSDN dev center:
 http://msdn.microsoft.com/windowsxp/
 Newsgroups:
 microsoft.public.win32.programmer.*
 Forums: forums.microsoft.com/msdn/
   New forum category: Windows Vista Development
 Essays on Win32:
 http://blogs.msdn.com/oldnewthing
Five Topics
 Performance
 What  you learned in school is
   wrong
   Playing friendly with others
 User interface issues
   The many faces of large fonts
   Parent and owner windows (review)
   Asynchronous input and synchronized input
Performance Bottlenecks
 CPU speed is no longer the limiting factor
 Latency is what kills you
 (May not be true but it’s “true enough”)
Typical Latencies
 WAN (1e9-2e9)
 Floppy, CD-ROM (1e9)
 LAN (1e7-1e8)
 Hard drive (1e7)

 Main memory (25-50)
 L2 cache (6-10)
 L1 cache (1-2)
 CPU (1)
Pointers Are Expensive
 Pointers by their nature point elsewhere
 Not in the same cache line
 Usually not even on the same page
 CPUs and OSs don’t predict pointers well
 It’s the page faults, stupid (especially at
 startup)
 The Common Language Runtime (CLR)
 knows this
O(n) Can Beat O(log n)
 How big is n anyway?
 A simple array maximizes value from each
 page fault (every byte is used)
 Also friendlier to cache lines and L2
 Linked lists, binary trees cost the most
 (only a few bytes used)
 A factor of 100 is hard to overcome
 The CLR Base Class Library (BCL) knows
 this
Five Topics
 Performance
   What you learned in school is wrong
 Playing     friendly with others
 User interface issues
   The many faces of large fonts
   Parent and owner windows (review)
   Asynchronous input and synchronized input
What If Two Programs Did This?
 You aren’t the only program running.
 We’re all in this together.
Polling
 Prevents CPU from sleeping, monitor from
 blanking, drive from spinning down, etc.
 Keeps pages present
 Effect is magnified on Terminal Servers
The Thread Pool
 Use WT_EXECUTELONGFUNCTION as
 necessary.
 Clean up behind yourself
   If you create windows, destroy them.
   If you initialize COM, uninitialize it.
 Don’t leave unfinished business
   ShellExecuteEx DDE (use
   SEE_MASK_FLAG_DDEWAIT)
   SendMessageCallback
Remote Desktop /
Terminal Services
 Your video card is very slow
 Disable animations
 (SPI_GETxxxANIMATION)
 Suppress unnecessary background
 operations
 Very similar to power management
Adapt to Hardware Capabilities
 Scale features up or down based on
 hardware
   Don’t need to cater to baseline machine
   Set defaults intelligently
 New for Windows Vista™: IWinsat
 The mechanism Windows uses to decide
 whether to enable visual effects
 To appear in Beta 2
 winsatfb@microsoft.com
Hardware Metrics
 Graphics capability
 Gaming capability
 System memory bandwidth
 Processor throughput
   Based on realistic computations
 Disk sequential read throughput

 Computed on first boot, on hardware
 change, and on demand (e.g. app setup)
 Calibrate against actual hardware
Five Topics
 Performance
   What you learned in school is wrong
   Playing friendly with others
 User interface issues
 The    many faces of large fonts
   Parent and owner windows (review)
   Asynchronous input and synchronized input
The Many Faces Of Large
Fonts
 Large font scheme
 High DPI
Large Font Scheme
 The size of screen
 elements
   Caption, menu,
   message box,
   status bar, icon
   labels
 No effect on
 anything else
High DPI
 Changes the mapping between point
 and pixels
 Affect all point-based computations
 (primarily fonts and consequently
 dialog boxes)
Visual Comparison
Bitmap Scaling In Dialogs




SS_BITMAP         SS_BITMAP |      SS_BITMAP |
              SS_REALSIZECONTROL SS_CENTERIMAGE
 No scaling        Stretched        Centered
Dealing With High DPI
 Font metrics scale non-linearly
   Visually inspect your dialogs
 Bitmaps need to be adjusted
   Author for common DPI (96, 120, 144, 192)
   Stretch or center static images if no perfect
   match available
   Stretching down is better than stretching up
 “High DPI is the new multimon”
High-DPI Devices




Sony VAIO U71
                                     Toshiba M200                         IBM T221:
•   6”
                                     •   12”                              •   24”
•   800x600
                                     •   1400x1050                        •   3840x2400
•   ≈166 DPI
                                     •   ≈144 DPI                         •   ≈200 DPI
•   ≈US$2700
                                     •   ≈US$2400                         •   ≈US$8000


    Source: PRS325: Windows Presentation Foundation ("Avalon"): Advanced Graphics (Part 1): “2D, 3D and
    Text”
High DPI In Windows Vista
 “Large font scheme” is gone
 DWM emulates 96 DPI by default
  Will stretch your output to actual DPI
  Opt out via SetProcessDPIAware
  (recommended, but requires thorough testing)
 Windows Presentation Foundation already
 designed to be DPI-agnostic
  pixel-based objects (bitmaps and videos
  mostly) still require attention
Guidance for Windows Vista™
PRS319: Building Applications That
 Look Great in Windows Vista™
  In room 152, next!
  New common controls (including Task Dialog)
  Client glass
  The Aero philosophy
  Designing for the new “look”
Five Topics
 Performance
   What you learned in school is wrong
   Playing friendly with others
 User interface issues
   The many faces of large fonts
 Parent  and owner windows
   (review)
   Asynchronous input and synchronized input
Parents And Owners
 Child windows are constrained by
 their parent
 Ownership is a relationship among
 top-level windows
 Most window-creation functions take a
 “parent or owner, depending” parameter
 Other UI functions take an owner
Parent/Owner Confusion
 GetParent() returns parent or owner
 GetAncestor() is clearer
 Documentation often casual about
 distinction between parent and owner
Parent And Owner Diagrams
          Visual                                 Window tree

                                                   Desktop
          Desktop

notepad
                                     find          notepad          simple
 edit        find
          edit      OK            edit      OK       edit
                         simple




                                                     Owner “tree”

                                                 notepad       simple

                                                  find
Reparenting And Orphans
 Only top-level windows can be owners
 If you pass a child window as owner, its
 top-level parent is used instead
 Consequently, reparenting a child window
 abandons its owned windows
HWND SetWindowOwner(HWND hwnd, HWND hwndOwner)
{
assert(!(GetWindowStyle(hwnd) & WS_CHILD));
assert(!(GetWindowStyle(hwndOwner) & WS_CHILD));
return (HWND)SetWindowLongPtr(hwnd,
             GWLP_HWNDPARENT, (LONG_PTR)hwndOwner);
}
Pitfalls Of Ownership
 Multiple visible top-level unowned windows
 on a single thread = red flag
 Choosing a random window as owner is
 not a solution
 Cross-thread ownership leads to input
 synchronization
Five Topics
 Performance
   What you learned in school is wrong
   Playing friendly with others
 User interface issues
   The many faces of large fonts
   Parent and owner windows (review)
 Asynchronous   input and
   synchronized input
16-Bit: Synchronous Input
 Input is globally serialized
 Shared keyboard, mouse state
 One focus window, one active window,
 one capture, one caret, one input queue
 Changes to focus, etc. are synchronous
32-Bit: Asynchronous Input
  Input is per-thread
  Separate keyboard, mouse state
  Each thread gets its own focus window,
  active window, capture, caret
  Changes to focus are asynchronous with
  respect to windows from other threads
> as if it were the only thread in the system
AttachThreadInput
 Indicates that two threads want to return to
 the old 16-bit style of synchronized input
 Your fates are intertwined
Synchronous Focus
 A has focus, B calls SetFocus(hwndB)
 B must wait for A to release focus since
 input is now synchronous
 If A is hung, then B hangs too
Synchronous Input
 In the queue are two input messages, first
 a message for A, then a message for B.
 B calls GetMessage – sees message for A
 and says “I can’t process my input until A
 processes its input first”
 If A is hung, then B never processes input
The Life Of An Input Message
             Input Queue A    Message Queue A   Thread A



Raw Input    Input Queue B    Message Queue B   Thread B




                              Message Queue C   Thread C

            Input Queue C+D

                              Message Queue D   Thread D
Behind Your Back
 Owner/owned windows are implicitly
 attached
 Parent/child windows are implicitly
 attached
 Journal hooks are the wildcard
Dealing With Input Synchronization

  Keep slow operations off the UI thread
  Avoid cross-thread ownership
      Thread 1                  Thread 1

     Main window    Thread 2   Main window   Thread 2
                   Progress     Progress      Work
       Work




      Back to                    Back to
      normal                     normal


           Avoid                  Prefer
Final Notes
 Evaluation forms
 Fundamentals Track Lounge
 Ask the Experts
 Q&A
© 2005 Microsoft Corporation. All rights reserved.
This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

Contenu connexe

Tendances

Chap 6 : classes et interfaces
Chap 6 : classes et interfacesChap 6 : classes et interfaces
Chap 6 : classes et interfacesAziz Darouichi
 
MachineLlearning introduction
MachineLlearning introductionMachineLlearning introduction
MachineLlearning introductionThe IOT Academy
 
Python avancé : Ensemble, dictionnaire et base de données
Python avancé : Ensemble, dictionnaire et base de donnéesPython avancé : Ensemble, dictionnaire et base de données
Python avancé : Ensemble, dictionnaire et base de donnéesECAM Brussels Engineering School
 
Devoxx France 2023 - Les nouveautés de Java 19 et 20
Devoxx France 2023 - Les nouveautés de Java 19 et 20Devoxx France 2023 - Les nouveautés de Java 19 et 20
Devoxx France 2023 - Les nouveautés de Java 19 et 20Jean-Michel Doudoux
 
resume algo 2023.pdf
resume algo 2023.pdfresume algo 2023.pdf
resume algo 2023.pdfsalah fenni
 
Real-world Reinforcement Learning
Real-world Reinforcement LearningReal-world Reinforcement Learning
Real-world Reinforcement LearningMax Pagels
 
Why GC is eating all my CPU?
Why GC is eating all my CPU?Why GC is eating all my CPU?
Why GC is eating all my CPU?Roman Elizarov
 
Aggregate functions
Aggregate functionsAggregate functions
Aggregate functionssinhacp
 
Java - Exception Handling
Java - Exception HandlingJava - Exception Handling
Java - Exception HandlingPrabhdeep Singh
 
SQL Functions and Operators
SQL Functions and OperatorsSQL Functions and Operators
SQL Functions and OperatorsMohan Kumar.R
 
라이트,라이트맵,라이트프로브,누가가장가볍고이쁠까
라이트,라이트맵,라이트프로브,누가가장가볍고이쁠까라이트,라이트맵,라이트프로브,누가가장가볍고이쁠까
라이트,라이트맵,라이트프로브,누가가장가볍고이쁠까GukHwan Ji
 
How to optimize background processes - when Sylius meets Blackfire
How to optimize background processes - when Sylius meets BlackfireHow to optimize background processes - when Sylius meets Blackfire
How to optimize background processes - when Sylius meets BlackfireŁukasz Chruściel
 
Apprentissage supervisé.pdf
Apprentissage supervisé.pdfApprentissage supervisé.pdf
Apprentissage supervisé.pdfhanamettali
 

Tendances (20)

Chap 6 : classes et interfaces
Chap 6 : classes et interfacesChap 6 : classes et interfaces
Chap 6 : classes et interfaces
 
MachineLlearning introduction
MachineLlearning introductionMachineLlearning introduction
MachineLlearning introduction
 
Python avancé : Ensemble, dictionnaire et base de données
Python avancé : Ensemble, dictionnaire et base de donnéesPython avancé : Ensemble, dictionnaire et base de données
Python avancé : Ensemble, dictionnaire et base de données
 
Devoxx France 2023 - Les nouveautés de Java 19 et 20
Devoxx France 2023 - Les nouveautés de Java 19 et 20Devoxx France 2023 - Les nouveautés de Java 19 et 20
Devoxx France 2023 - Les nouveautés de Java 19 et 20
 
resume algo 2023.pdf
resume algo 2023.pdfresume algo 2023.pdf
resume algo 2023.pdf
 
Real-world Reinforcement Learning
Real-world Reinforcement LearningReal-world Reinforcement Learning
Real-world Reinforcement Learning
 
Java EE _ JSTL (1).pdf
Java EE _ JSTL (1).pdfJava EE _ JSTL (1).pdf
Java EE _ JSTL (1).pdf
 
Why GC is eating all my CPU?
Why GC is eating all my CPU?Why GC is eating all my CPU?
Why GC is eating all my CPU?
 
Aggregate functions
Aggregate functionsAggregate functions
Aggregate functions
 
Java - Exception Handling
Java - Exception HandlingJava - Exception Handling
Java - Exception Handling
 
SQL Functions and Operators
SQL Functions and OperatorsSQL Functions and Operators
SQL Functions and Operators
 
라이트,라이트맵,라이트프로브,누가가장가볍고이쁠까
라이트,라이트맵,라이트프로브,누가가장가볍고이쁠까라이트,라이트맵,라이트프로브,누가가장가볍고이쁠까
라이트,라이트맵,라이트프로브,누가가장가볍고이쁠까
 
Teste baseado em modelos
Teste baseado em modelosTeste baseado em modelos
Teste baseado em modelos
 
Clustering
ClusteringClustering
Clustering
 
Object oriented programming With C#
Object oriented programming With C#Object oriented programming With C#
Object oriented programming With C#
 
Polymorphisme
PolymorphismePolymorphisme
Polymorphisme
 
How to optimize background processes - when Sylius meets Blackfire
How to optimize background processes - when Sylius meets BlackfireHow to optimize background processes - when Sylius meets Blackfire
How to optimize background processes - when Sylius meets Blackfire
 
Formation traitement d_images
Formation traitement d_imagesFormation traitement d_images
Formation traitement d_images
 
Algorithme knn
Algorithme knnAlgorithme knn
Algorithme knn
 
Apprentissage supervisé.pdf
Apprentissage supervisé.pdfApprentissage supervisé.pdf
Apprentissage supervisé.pdf
 

En vedette

中3女子でもわかる constexpr
中3女子でもわかる constexpr中3女子でもわかる constexpr
中3女子でもわかる constexprGenya Murakami
 
применение солнечной энергии для теплоснабжения объектов
применение солнечной энергии для теплоснабжения объектовприменение солнечной энергии для теплоснабжения объектов
применение солнечной энергии для теплоснабжения объектовIngvar Lav
 
Cong nghe fpga bao cao
Cong nghe fpga   bao caoCong nghe fpga   bao cao
Cong nghe fpga bao caoTuanutehy
 
Curiosity a Marson
Curiosity a MarsonCuriosity a Marson
Curiosity a Marsontothandras
 
Traffic_Exchange_Blueprint
Traffic_Exchange_BlueprintTraffic_Exchange_Blueprint
Traffic_Exchange_BlueprintTookins1949224
 
Современные материалы для пассивного дома
Современные материалы для пассивного домаСовременные материалы для пассивного дома
Современные материалы для пассивного домаIngvar Lav
 
Marketing communications for start ups - anthony de kerf - marketing camp
Marketing communications for start ups - anthony de kerf - marketing campMarketing communications for start ups - anthony de kerf - marketing camp
Marketing communications for start ups - anthony de kerf - marketing campPaul Wcislo
 
Town Hall with Congressman Patrick McHenry 2012
Town Hall with Congressman Patrick McHenry 2012Town Hall with Congressman Patrick McHenry 2012
Town Hall with Congressman Patrick McHenry 2012CongressmanPatrickMcHenry
 
Fod pre installation guide (5)
Fod pre installation guide (5)Fod pre installation guide (5)
Fod pre installation guide (5)JoeyAunan
 

En vedette (20)

中3女子でもわかる constexpr
中3女子でもわかる constexpr中3女子でもわかる constexpr
中3女子でもわかる constexpr
 
применение солнечной энергии для теплоснабжения объектов
применение солнечной энергии для теплоснабжения объектовприменение солнечной энергии для теплоснабжения объектов
применение солнечной энергии для теплоснабжения объектов
 
Australia animals
Australia animalsAustralia animals
Australia animals
 
Cong nghe fpga bao cao
Cong nghe fpga   bao caoCong nghe fpga   bao cao
Cong nghe fpga bao cao
 
Curiosity a Marson
Curiosity a MarsonCuriosity a Marson
Curiosity a Marson
 
Traffic_Exchange_Blueprint
Traffic_Exchange_BlueprintTraffic_Exchange_Blueprint
Traffic_Exchange_Blueprint
 
Mengelola beban
Mengelola bebanMengelola beban
Mengelola beban
 
Современные материалы для пассивного дома
Современные материалы для пассивного домаСовременные материалы для пассивного дома
Современные материалы для пассивного дома
 
Bunono Chilldren
Bunono ChilldrenBunono Chilldren
Bunono Chilldren
 
Export
ExportExport
Export
 
Aventura
AventuraAventura
Aventura
 
งานPbl 3
งานPbl 3งานPbl 3
งานPbl 3
 
Spyware
Spyware Spyware
Spyware
 
Deferred Action Elegibility
Deferred Action ElegibilityDeferred Action Elegibility
Deferred Action Elegibility
 
Renungan NATAL
Renungan NATALRenungan NATAL
Renungan NATAL
 
Deferred Action Elegibility
Deferred Action ElegibilityDeferred Action Elegibility
Deferred Action Elegibility
 
งาน Pbl 1
งาน Pbl 1งาน Pbl 1
งาน Pbl 1
 
Marketing communications for start ups - anthony de kerf - marketing camp
Marketing communications for start ups - anthony de kerf - marketing campMarketing communications for start ups - anthony de kerf - marketing camp
Marketing communications for start ups - anthony de kerf - marketing camp
 
Town Hall with Congressman Patrick McHenry 2012
Town Hall with Congressman Patrick McHenry 2012Town Hall with Congressman Patrick McHenry 2012
Town Hall with Congressman Patrick McHenry 2012
 
Fod pre installation guide (5)
Fod pre installation guide (5)Fod pre installation guide (5)
Fod pre installation guide (5)
 

Similaire à Five Things Every Win32 Developer Should Know

Windows 7 @Microsoft CTD
Windows 7 @Microsoft CTDWindows 7 @Microsoft CTD
Windows 7 @Microsoft CTDAbhishek Sharma
 
The nitty gritty of game development
The nitty gritty of game developmentThe nitty gritty of game development
The nitty gritty of game developmentbasisspace
 
High DPI for desktop applications
High DPI for desktop applicationsHigh DPI for desktop applications
High DPI for desktop applicationsKirill Grouchnikov
 
Peyton jones-2011-parallel haskell-the_future
Peyton jones-2011-parallel haskell-the_futurePeyton jones-2011-parallel haskell-the_future
Peyton jones-2011-parallel haskell-the_futureTakayuki Muranushi
 
Simon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSimon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSkills Matter
 
Casual Engines 2009
Casual Engines 2009Casual Engines 2009
Casual Engines 2009David Fox
 
Creating Multiscreen Apps using Adobe Flash Platform
Creating Multiscreen Apps using Adobe Flash PlatformCreating Multiscreen Apps using Adobe Flash Platform
Creating Multiscreen Apps using Adobe Flash PlatformHemanth Sharma
 
Yahoo! On Microsoft .NET 3.0 and Microsoft Expression
Yahoo! On Microsoft .NET 3.0 and Microsoft ExpressionYahoo! On Microsoft .NET 3.0 and Microsoft Expression
Yahoo! On Microsoft .NET 3.0 and Microsoft Expressiongoodfriday
 
Microsoft windows operating concept
Microsoft windows operating conceptMicrosoft windows operating concept
Microsoft windows operating conceptMi L
 
Windows 7 V2 Vineet
Windows 7 V2   VineetWindows 7 V2   Vineet
Windows 7 V2 Vineettechnext1
 
Prasentation Managed DirectX
Prasentation Managed DirectXPrasentation Managed DirectX
Prasentation Managed DirectXA. LE
 
13.30 hr Hebinck
13.30 hr Hebinck13.30 hr Hebinck
13.30 hr HebinckThemadagen
 
Windows 7 For Developers
Windows 7 For DevelopersWindows 7 For Developers
Windows 7 For Developersrsnarayanan
 
Dev-In-Town: Windows 7 by Jabez Gan
Dev-In-Town: Windows 7 by Jabez GanDev-In-Town: Windows 7 by Jabez Gan
Dev-In-Town: Windows 7 by Jabez GanQuek Lilian
 

Similaire à Five Things Every Win32 Developer Should Know (20)

Windows 7 @Microsoft CTD
Windows 7 @Microsoft CTDWindows 7 @Microsoft CTD
Windows 7 @Microsoft CTD
 
The nitty gritty of game development
The nitty gritty of game developmentThe nitty gritty of game development
The nitty gritty of game development
 
High DPI for desktop applications
High DPI for desktop applicationsHigh DPI for desktop applications
High DPI for desktop applications
 
CLI313
CLI313CLI313
CLI313
 
Peyton jones-2011-parallel haskell-the_future
Peyton jones-2011-parallel haskell-the_futurePeyton jones-2011-parallel haskell-the_future
Peyton jones-2011-parallel haskell-the_future
 
Simon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSimon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelism
 
Casual Engines 2009
Casual Engines 2009Casual Engines 2009
Casual Engines 2009
 
PyCon 2011: IronPython Command Line
PyCon 2011:  IronPython Command LinePyCon 2011:  IronPython Command Line
PyCon 2011: IronPython Command Line
 
Creating Multiscreen Apps using Adobe Flash Platform
Creating Multiscreen Apps using Adobe Flash PlatformCreating Multiscreen Apps using Adobe Flash Platform
Creating Multiscreen Apps using Adobe Flash Platform
 
Yahoo! On Microsoft .NET 3.0 and Microsoft Expression
Yahoo! On Microsoft .NET 3.0 and Microsoft ExpressionYahoo! On Microsoft .NET 3.0 and Microsoft Expression
Yahoo! On Microsoft .NET 3.0 and Microsoft Expression
 
INTRO TO COMPUTER
INTRO TO COMPUTERINTRO TO COMPUTER
INTRO TO COMPUTER
 
Microsoft windows operating concept
Microsoft windows operating conceptMicrosoft windows operating concept
Microsoft windows operating concept
 
Windows 7 V2 Vineet
Windows 7 V2   VineetWindows 7 V2   Vineet
Windows 7 V2 Vineet
 
Windows 7 V2
Windows 7 V2Windows 7 V2
Windows 7 V2
 
Prasentation Managed DirectX
Prasentation Managed DirectXPrasentation Managed DirectX
Prasentation Managed DirectX
 
windows 7
windows 7windows 7
windows 7
 
Basic computerskills
Basic computerskillsBasic computerskills
Basic computerskills
 
13.30 hr Hebinck
13.30 hr Hebinck13.30 hr Hebinck
13.30 hr Hebinck
 
Windows 7 For Developers
Windows 7 For DevelopersWindows 7 For Developers
Windows 7 For Developers
 
Dev-In-Town: Windows 7 by Jabez Gan
Dev-In-Town: Windows 7 by Jabez GanDev-In-Town: Windows 7 by Jabez Gan
Dev-In-Town: Windows 7 by Jabez Gan
 

Dernier

Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 

Dernier (20)

Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 

Five Things Every Win32 Developer Should Know

  • 1. Five Things Every Win32 Developer Should Know Raymond Chen (raymondc@microsoft.com) FUN412 Windows User Experience Microsoft Corporation
  • 2. Five Topics Performance What you learned in school is wrong Playing friendly with others User interface issues The many faces of large fonts Parent and owner windows (review) Asynchronous input and synchronized input
  • 3. Community Resources At PDC Other talks FUN319: Power-Aware Applications (Thu 5:15pm – note room change) An important “tax” FUN421: Garbage Collection Inside Out (Fri 1pm) Memory from the managed perspective Fundamentals Track lounge I’ll be there all day today Ask The Experts: System Internals
  • 4. Talks You May Have Missed (watch the DVD) FUN405: Programming with Concurrency, Part 2 The dangers of trying too hard FUN307: Test Automation and Accessibility
  • 5. Community Resources After PDC MSDN dev center: http://msdn.microsoft.com/windowsxp/ Newsgroups: microsoft.public.win32.programmer.* Forums: forums.microsoft.com/msdn/ New forum category: Windows Vista Development Essays on Win32: http://blogs.msdn.com/oldnewthing
  • 6. Five Topics Performance What you learned in school is wrong Playing friendly with others User interface issues The many faces of large fonts Parent and owner windows (review) Asynchronous input and synchronized input
  • 7. Performance Bottlenecks CPU speed is no longer the limiting factor Latency is what kills you (May not be true but it’s “true enough”)
  • 8. Typical Latencies WAN (1e9-2e9) Floppy, CD-ROM (1e9) LAN (1e7-1e8) Hard drive (1e7) Main memory (25-50) L2 cache (6-10) L1 cache (1-2) CPU (1)
  • 9. Pointers Are Expensive Pointers by their nature point elsewhere Not in the same cache line Usually not even on the same page CPUs and OSs don’t predict pointers well It’s the page faults, stupid (especially at startup) The Common Language Runtime (CLR) knows this
  • 10. O(n) Can Beat O(log n) How big is n anyway? A simple array maximizes value from each page fault (every byte is used) Also friendlier to cache lines and L2 Linked lists, binary trees cost the most (only a few bytes used) A factor of 100 is hard to overcome The CLR Base Class Library (BCL) knows this
  • 11. Five Topics Performance What you learned in school is wrong Playing friendly with others User interface issues The many faces of large fonts Parent and owner windows (review) Asynchronous input and synchronized input
  • 12. What If Two Programs Did This? You aren’t the only program running. We’re all in this together.
  • 13. Polling Prevents CPU from sleeping, monitor from blanking, drive from spinning down, etc. Keeps pages present Effect is magnified on Terminal Servers
  • 14. The Thread Pool Use WT_EXECUTELONGFUNCTION as necessary. Clean up behind yourself If you create windows, destroy them. If you initialize COM, uninitialize it. Don’t leave unfinished business ShellExecuteEx DDE (use SEE_MASK_FLAG_DDEWAIT) SendMessageCallback
  • 15. Remote Desktop / Terminal Services Your video card is very slow Disable animations (SPI_GETxxxANIMATION) Suppress unnecessary background operations Very similar to power management
  • 16. Adapt to Hardware Capabilities Scale features up or down based on hardware Don’t need to cater to baseline machine Set defaults intelligently New for Windows Vista™: IWinsat The mechanism Windows uses to decide whether to enable visual effects To appear in Beta 2 winsatfb@microsoft.com
  • 17. Hardware Metrics Graphics capability Gaming capability System memory bandwidth Processor throughput Based on realistic computations Disk sequential read throughput Computed on first boot, on hardware change, and on demand (e.g. app setup) Calibrate against actual hardware
  • 18. Five Topics Performance What you learned in school is wrong Playing friendly with others User interface issues The many faces of large fonts Parent and owner windows (review) Asynchronous input and synchronized input
  • 19. The Many Faces Of Large Fonts Large font scheme High DPI
  • 20. Large Font Scheme The size of screen elements Caption, menu, message box, status bar, icon labels No effect on anything else
  • 21. High DPI Changes the mapping between point and pixels Affect all point-based computations (primarily fonts and consequently dialog boxes)
  • 23. Bitmap Scaling In Dialogs SS_BITMAP SS_BITMAP | SS_BITMAP | SS_REALSIZECONTROL SS_CENTERIMAGE No scaling Stretched Centered
  • 24. Dealing With High DPI Font metrics scale non-linearly Visually inspect your dialogs Bitmaps need to be adjusted Author for common DPI (96, 120, 144, 192) Stretch or center static images if no perfect match available Stretching down is better than stretching up “High DPI is the new multimon”
  • 25. High-DPI Devices Sony VAIO U71 Toshiba M200 IBM T221: • 6” • 12” • 24” • 800x600 • 1400x1050 • 3840x2400 • ≈166 DPI • ≈144 DPI • ≈200 DPI • ≈US$2700 • ≈US$2400 • ≈US$8000 Source: PRS325: Windows Presentation Foundation ("Avalon"): Advanced Graphics (Part 1): “2D, 3D and Text”
  • 26. High DPI In Windows Vista “Large font scheme” is gone DWM emulates 96 DPI by default Will stretch your output to actual DPI Opt out via SetProcessDPIAware (recommended, but requires thorough testing) Windows Presentation Foundation already designed to be DPI-agnostic pixel-based objects (bitmaps and videos mostly) still require attention
  • 27. Guidance for Windows Vista™ PRS319: Building Applications That Look Great in Windows Vista™ In room 152, next! New common controls (including Task Dialog) Client glass The Aero philosophy Designing for the new “look”
  • 28. Five Topics Performance What you learned in school is wrong Playing friendly with others User interface issues The many faces of large fonts Parent and owner windows (review) Asynchronous input and synchronized input
  • 29. Parents And Owners Child windows are constrained by their parent Ownership is a relationship among top-level windows Most window-creation functions take a “parent or owner, depending” parameter Other UI functions take an owner
  • 30. Parent/Owner Confusion GetParent() returns parent or owner GetAncestor() is clearer Documentation often casual about distinction between parent and owner
  • 31. Parent And Owner Diagrams Visual Window tree Desktop Desktop notepad find notepad simple edit find edit OK edit OK edit simple Owner “tree” notepad simple find
  • 32. Reparenting And Orphans Only top-level windows can be owners If you pass a child window as owner, its top-level parent is used instead Consequently, reparenting a child window abandons its owned windows HWND SetWindowOwner(HWND hwnd, HWND hwndOwner) { assert(!(GetWindowStyle(hwnd) & WS_CHILD)); assert(!(GetWindowStyle(hwndOwner) & WS_CHILD)); return (HWND)SetWindowLongPtr(hwnd, GWLP_HWNDPARENT, (LONG_PTR)hwndOwner); }
  • 33. Pitfalls Of Ownership Multiple visible top-level unowned windows on a single thread = red flag Choosing a random window as owner is not a solution Cross-thread ownership leads to input synchronization
  • 34. Five Topics Performance What you learned in school is wrong Playing friendly with others User interface issues The many faces of large fonts Parent and owner windows (review) Asynchronous input and synchronized input
  • 35. 16-Bit: Synchronous Input Input is globally serialized Shared keyboard, mouse state One focus window, one active window, one capture, one caret, one input queue Changes to focus, etc. are synchronous
  • 36. 32-Bit: Asynchronous Input Input is per-thread Separate keyboard, mouse state Each thread gets its own focus window, active window, capture, caret Changes to focus are asynchronous with respect to windows from other threads > as if it were the only thread in the system
  • 37. AttachThreadInput Indicates that two threads want to return to the old 16-bit style of synchronized input Your fates are intertwined
  • 38. Synchronous Focus A has focus, B calls SetFocus(hwndB) B must wait for A to release focus since input is now synchronous If A is hung, then B hangs too
  • 39. Synchronous Input In the queue are two input messages, first a message for A, then a message for B. B calls GetMessage – sees message for A and says “I can’t process my input until A processes its input first” If A is hung, then B never processes input
  • 40. The Life Of An Input Message Input Queue A Message Queue A Thread A Raw Input Input Queue B Message Queue B Thread B Message Queue C Thread C Input Queue C+D Message Queue D Thread D
  • 41. Behind Your Back Owner/owned windows are implicitly attached Parent/child windows are implicitly attached Journal hooks are the wildcard
  • 42. Dealing With Input Synchronization Keep slow operations off the UI thread Avoid cross-thread ownership Thread 1 Thread 1 Main window Thread 2 Main window Thread 2 Progress Progress Work Work Back to Back to normal normal Avoid Prefer
  • 43. Final Notes Evaluation forms Fundamentals Track Lounge Ask the Experts Q&A
  • 44. © 2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.