[Windows]Êtes-vous DPI-aware ?

Informations pour bien débuter en PureBasic
Mesa
Messages : 1126
Inscription : mer. 14/sept./2011 16:59

[Windows]Êtes-vous DPI-aware ?

Message par Mesa »

Vous avez remarqué que de plus en plus d'applications présentent des défauts d'affichage : Bouton trop petit, texte qui déborde de son gadget, défaut de layout (non-alignement des gadgets), etc.

Ces défauts n'apparaissent qu'avec XP, Vista et suivant.

Ceci est dû à la valeur DPI de l'affichage : Dot Per Inch = points par pouce = ppp.
C'est en relation avec la grosseur physique d'un point d'écran qui prend en compte les dimensions physique de l'écran ainsi que sa géométrie (4:3, 16:9, 16:10).
Elle est finalement assez complexe à calculer en millimètre.
Voir ici http://fr.wikipedia.org/wiki/D%C3%A9fin ... %C3%A9cran

Simplement, pour une résolution donnée, par ex 1024pointsx768points, on comprend que pour un écran de 14 pouces, le point sera plus petit que pour un écran 60 pouces ! On a le même nombre de points sur des surfaces d'affichages différentes.

Alors le système d'exploitation le prend en compte...mais si le programmeur a créé un logiciel pour un dpi standard de 96 ppp alors que l'utilisateur utilise un réglage d'affichage à 192 ppp soit un grandissement de 200%, il va y avoir plein des problèmes, des "artéfactes".


Microsoft est parfaitement au courant (à lire)
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
"An application that is not DPI-aware but is running on a high-DPI display setting can suffer from many visual artifacts, including incorrect scaling of UI elements, clipped text, and blurry images. By adding support in your application for DPI awareness, you guarantee that the presentation of your application's UI is more predictable, making it more visually appealing to users."

Bref, il faut que votre application soit "dpi-aware"
  • Feature Windows XP Windows Vista Windows 7
    Control Panel setting of DPI Yes Yes Yes
    Custom DPI settings Yes Yes Yes
    DPI virtualization No Yes Yes
    API to declare DPI awareness No Yes Yes
    APIs to retrieve system metrics and DPI Yes Yes Yes
    Reboot/log off to apply changes to DPI setting Reboot Reboot Log off
    Per user DPI setting No No Yes
    DPI auto-configuration out of the box No No Yes
"When you install Windows 7 onto a computer that supports extended display identification data (EDID), Windows 7 automatically configures the computer with an optimal high-DPI setting to make best use of the display’s physical DPI, except in the cases where the display's effective resolution is less than 1024 x 768."
Ici, Windows 7 change de lui-même le dpi en fonction de votre écran. Il est probable que la majorité des W7 ne soit plus en 96 dpi, le standard.

"Writing a DPI-aware application is the key to making a UI look consistently good across a wide variety of high-DPI display settings."
The following table shows a list of features related to high DPI that are supported by each platform.
  • Feature Windows XP Windows Vista Windows 7
    Control Panel setting of DPI Yes Yes Yes
    Custom DPI settings Yes Yes Yes
    DPI virtualization No Yes Yes
    API to declare DPI awareness No Yes Yes
    APIs to retrieve system metrics and DPI Yes Yes Yes
    Reboot/log off to apply changes to DPI setting Reboot Reboot Log off
    Per user DPI setting No No Yes
    DPI auto-configuration out of the box No No Yes

Vista introduit la DPI Virtualization= grossissement du pixel mais cela donne un effet de flou et des applications anciennes ont des problèmes de compatibilités.
Quelques problèmes rencontrés :
• Clipped UI elements or text
• Incorrect font size
• Incorrect layout
• Blurred UI elements
• Pixelated text and bitmaps
• Misalignment of coordinate space affecting input
• Partial rendering of a full-screen application
• Incorrect use of effective resolution

Comment rendre une application dpi-aware : https://msdn.microsoft.com/en-us/librar ... s.85).aspx
The following table provides a list of the key DPI issues and their most common causes and solutions.
Issue Most common cause Solution to investigate
Clipped UI elements or text UI elements are not resizing based on the GetTextExtent function.
Scaling text

Tableau
  • Incorrect font size Fonts are being created with hard-coded pixel sizes. Scaling text

    Incorrect layout Main window is not resizing correctly based on DPI. Scaling layout

    Blurred UI elements Application is not declared DPI-aware, and DPI virtualization is enabled. DPI virtualization
    Declaring DPI awareness

    Pixelated text Application is using bitmap-based fonts. Scaling text

    Misalignment of coordinate space affecting input Application is not declared DPI-aware, and DPI virtualization is enabled. DPI virtualization
    Declaring DPI awareness

    Partial rendering of a full-screen application Application is not declared DPI-aware, and is using a mix of virtualized and non-virtualized metrics. DPI virtualization
    Declaring DPI awareness
    Determining the DPI scale factor

    Incorrect use of effective resolution Application is not declared DPI-aware and is using virtualized system metrics. DPI virtualization
    Declaring DPI awareness
    Determining the DPI scale factor
    Handling Minimum Effective Resolution
Existing Win32 Applications
To make your existing application DPI-aware, do the following:
1. Test your application at high DPI and write down all issues found.
2. Search the source code for common DPI coding issues.
3. Do an analysis on the cost of making the application fully DPI-aware.
4. List all required high-DPI assets, such as toolbars, buttons, and icons.
5. Fix issues found in step 1 by using the corresponding solution to the issue.
6. Declare your application DPI-aware.
7. Verify that all issues have been fixed. If not, repeat the preceding steps.
New Win32 Applications
To make your new application DPI-aware, do the following:
1. Declare your application DPI-aware.
2. Familiarize yourself with the coding techniques.
3. List all required high-DPI assets, such as toolbars, buttons, and icons.
4. Write your application.
5. Integrate the new assets from step 3.
6. Test your application for DPI compatibility.
7. Verify that all DPI issues have been resolved. If not, repeat the preceding steps.
Addressing High-DPI Issues
There are several techniques you can use to resolve high-DPI issues in your application. These techniques include:
• Declaring DPI awareness
• Using system metrics to calculate layout
• Determining the DPI scale factor
• Scaling text
• Scaling graphics
• Scaling layout
• Handling minimum effective resolution



Bref, c'est compliqué.
Dans un premier temps, il faudrait prendre des précautions.
Pour les boutons, laisser 1 cm d'espace avant et après le texte et un bon ½ cm en haut et en bas.
Ne pas créer des menus trop longs.
Laisser de l'air entre les gadgets, ne jamais coller 2 boutons par exemple.
Éviter de mettre des gadgets sur plusieurs colonnes ou alors complètement coller à la bordure gauche et droite de la fenêtre.
Utiliser peu de gadget.

Sinon, il faut coder.
Une solution multiplatforme de Feak: Excellente (à garder)
http://purebasic.developpez.com/sources ... sizeGadget

Au départ c'est un code qui prend en compte la police de l'OS mais il permet de rendre une application "dpi-aware" de fait.


Pour le dpi-aware API
http://www.purebasic.fr/english/viewtop ... 3%A5gensen

Avant de découvrir le code de freak par hasard, j'avais développé le mien qui n'est pas multiplateforme mais prend en compte un peu plus de gadget, le voici dans le post suivant.

Mesa.
Mesa
Messages : 1126
Inscription : mer. 14/sept./2011 16:59

Re: [Windows]Êtes-vous DPI-aware ?

Message par Mesa »

fitSizeGadget.pbi

Code : Tout sélectionner

;Code SROD
;Code Mesa

;EnableExplicit



Procedure.l GetTextWidthPix(NumGadget, espace=1)
  Protected result, hdc, tm.TEXTMETRIC, abc.ABC, overhang, hFont, char,lpSize.SIZE 
  ;espace : null-terminated + pour la checkbox par exemple, il faut ajouter la largeur d'un espace au texte 
  hDC = GetDC_(GadgetID(NumGadget))
  hFont = SendMessage_(GadgetID(NumGadget),#WM_GETFONT,0,0)
  If hFont And hDC
    SelectObject_(hDC,hFont)
  EndIf
  GetTextExtentPoint32_(hDC, GetGadgetText(NumGadget), Len(GetGadgetText(NumGadget)) + espace, lpSize)
  ;Ajustement qui depend du type de font; raster ou true/open type.
  GetTextMetrics_(hdc, tm)
  ;*sz\cy=tm\tmHeight-tm\tmInternalLeading ;on peut enlever le internal leading height
  If tm\tmOverhang ;Raster font.
    lpSize\cx + tm\tmOverhang
  Else
    char = Asc(Right(GetGadgetText(NumGadget),1))
    GetCharABCWidths_(hdc, char, char, abc) 
    overhang = abc\abcC
    If overHang < 0
      lpSize\cx - overHang
    EndIf
  EndIf
  
  SelectObject_(hdc, hFont)
  ReleaseDC_(GadgetID(NumGadget), hdc)
  result=lpSize\cx
  
  ProcedureReturn result
EndProcedure

Procedure.l GetTextHeightPix(NumGadget, espace=8)
  Protected result, hdc, tm.TEXTMETRIC, abc.ABC, overhang, hFont, char, lpSize.SIZE
  ; pourquoi 8 ????? 
  hDC = GetDC_(GadgetID(NumGadget))
  hFont = SendMessage_(GadgetID(NumGadget),#WM_GETFONT,0,0)
  If hFont And hDC
    SelectObject_(hDC,hFont)
  EndIf
  GetTextExtentPoint32_(hDC, GetGadgetText(NumGadget), Len(GetGadgetText(NumGadget)), lpSize)
  ;Ajustement qui depend du type de font; raster ou true/open type.
  GetTextMetrics_(hdc, tm)
  ;*sz\cy=tm\tmHeight-tm\tmInternalLeading ;on peut enlever le internal leading height
  If tm\tmOverhang ;Raster font.
    lpSize\cx + tm\tmOverhang
  Else
    char = Asc(Right(GetGadgetText(NumGadget),1))
    GetCharABCWidths_(hdc, char, char, abc) 
    overhang = abc\abcC
    If overHang < 0
      lpSize\cx - overHang
    EndIf
  EndIf
  
  SelectObject_(hdc, hFont)
  ReleaseDC_(GadgetID(NumGadget), hdc)
  result=lpSize\cy + espace
  
  ProcedureReturn result
EndProcedure

Procedure.l GetHigherTextInListWidthPix(NumGadget)
  Protected result, hdc, tm.TEXTMETRIC, abc.ABC, overhang, hFont, char, Max, n, i, lg, lpSize.SIZE
  ;espace : null-terminated + pour la checkbox par exemple, il faut ajouter la largeur d'un espace au texte 
  hDC = GetDC_(GadgetID(NumGadget))
  hFont = SendMessage_(GadgetID(NumGadget),#WM_GETFONT,0,0)
  If hFont And hDC
    SelectObject_(hDC,hFont)
  EndIf
  n=0 
  Max=0
  For i=0 To CountGadgetItems(NumGadget)-1
    GetTextExtentPoint32_(hDC, GetGadgetItemText(NumGadget,i), Len(GetGadgetItemText(NumGadget,i)) , lpSize)
    
    If lpSize\cy>Max
      Max=lpSize\cy
      n=i
    EndIf
    
  Next i
  lpSize\cy=Max
  
  SelectObject_(hdc, hFont)
  ReleaseDC_(GadgetID(NumGadget), hdc)
  result=lpSize\cy
  
  ProcedureReturn result
EndProcedure  

Procedure.l GetLongerTextInListWidthPix(NumGadget)
  Protected result, hdc, tm.TEXTMETRIC, abc.ABC, overhang, hFont, char, Max, n, i, lg, lpSize.SIZE
  ;espace : null-terminated + pour la checkbox par exemple, il faut ajouter la largeur d'un espace au texte 
  hDC = GetDC_(GadgetID(NumGadget))
  hFont = SendMessage_(GadgetID(NumGadget),#WM_GETFONT,0,0)
  If hFont And hDC
    SelectObject_(hDC,hFont)
  EndIf
  n=0 
  Max=0
  For i=0 To CountGadgetItems(NumGadget)-1
    GetTextExtentPoint32_(hDC, GetGadgetItemText(NumGadget,i), Len(GetGadgetItemText(NumGadget,i)) , lpSize)
    
    If lpSize\cx>Max
      Max=lpSize\cx
      n=i
    EndIf
    
  Next i
  lpSize\cx=Max
  ;Ajustement qui depend du type de font; raster ou true/open type.
  GetTextMetrics_(hdc, tm)
  ;*sz\cy=tm\tmHeight-tm\tmInternalLeading ;on peut enlever le internal leading height
  If tm\tmOverhang ;Raster font.
    lpSize\cx + tm\tmOverhang
  Else
    char = Asc(Right(GetGadgetItemText(NumGadget,n),1))
    GetCharABCWidths_(hdc, char, char, abc) 
    overhang = abc\abcC
    If overHang < 0
      lpSize\cx - overHang
    EndIf
  EndIf
  
  SelectObject_(hdc, hFont)
  ReleaseDC_(GadgetID(NumGadget), hdc)
  result=lpSize\cx
  
  ProcedureReturn result
EndProcedure  

Procedure.l FitGadget(NumGadget, En_Longueur.b=#True, En_Hauteur.b=#True, Option.l=-1)
  Protected  DC, tm.TEXTMETRIC, abc.ABC, overhang, hFont, char, ncm.NONCLIENTMETRICS
  Protected Hauteur_case_a_cocher, rc.RECT,sz.SIZE, os, bordure, marge, handleimagelist, okBOOL
  Protected old$, min, max
  Protected BCM_FIRST, BCM_GETIDEALSIZE, BCM_GETTEXTMARGIN, MCM_FIRST, MCM_GETCALENDARBORDER,CBEM_GETIMAGELIST
  Protected pImageInfo.IMAGEINFO
  
  Select GadgetType(NumGadget)
    Case #PB_GadgetType_Button ;================ 
      BCM_FIRST            = $1600
      BCM_GETIDEALSIZE     = (BCM_FIRST + $0001) 
      If SendMessage_(GadgetID(NumGadget),BCM_GETIDEALSIZE,0,sz) = #True
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , sz\cx,sz\cy)
      EndIf
      
    Case #PB_GadgetType_Option ;================
      ncm\cbSize = SizeOf(NONCLIENTMETRICS)
      SystemParametersInfo_(#SPI_GETNONCLIENTMETRICS, SizeOf(NONCLIENTMETRICS), @ncm, 0)
      DC = GetDC_(0)
      Hauteur_case_a_cocher=Abs(ncm\lfMessageFont\lfheight); c'est aussi sa longueur
      ; GetDeviceCaps_(DC, #LOGPIXELSY)
      ReleaseDC_(0, DC)
      BCM_FIRST            = $1600
      BCM_GETTEXTMARGIN    = BCM_FIRST + $0005
      SendMessage_(GadgetID(NumGadget),BCM_GETTEXTMARGIN,0,rc)
      ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , rc\left+rc\right+Hauteur_case_a_cocher+GetTextWidthPix(NumGadget, 1),GetTextHeightPix(NumGadget,0))
      
    Case #PB_GadgetType_CheckBox ;================
      ncm\cbSize = SizeOf(NONCLIENTMETRICS)
      SystemParametersInfo_(#SPI_GETNONCLIENTMETRICS, SizeOf(NONCLIENTMETRICS), @ncm, 0)
      DC = GetDC_(0)
      Hauteur_case_a_cocher=Abs(ncm\lfMessageFont\lfheight); c'est aussi sa longueur
      ; GetDeviceCaps_(DC, #LOGPIXELSY)
      ReleaseDC_(0, DC)
      BCM_FIRST            = $1600
      BCM_GETTEXTMARGIN    = BCM_FIRST + $0005
      SendMessage_(GadgetID(NumGadget),BCM_GETTEXTMARGIN,0,rc)
      ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , rc\left+rc\right+Hauteur_case_a_cocher+GetTextWidthPix(NumGadget, 1),GetTextHeightPix(NumGadget,0))
      
    Case #PB_GadgetType_Calendar ;================
      SendMessage_(GadgetID(NumGadget),#MCM_GETMINREQRECT,0,rc)
      
      ;        If option= #PB_Calendar_Borderless 
      ;         ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , rc\Right,rc\bottom)
      ;         
      ;       Else
      os=OSVersion()
      If  os=#PB_OS_Windows_Vista Or os=#PB_OS_Windows_Server_2008 Or os= #PB_OS_Windows_7 Or os=#PB_OS_Windows_Future
        MCM_FIRST               = $1000
        MCM_GETCALENDARBORDER   = MCM_FIRST + 31
        bordure= SendMessage_(GadgetID(NumGadget),MCM_GETCALENDARBORDER,0,0)
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , rc\Right+bordure,rc\bottom+bordure)
      Else
        
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , rc\Right+4,rc\bottom+4)
      EndIf
      ;EndIf
      ;========================================================================  
    Case #PB_GadgetType_ComboBox ;================
      CBEM_GETIMAGELIST=1027
      marge=4
      ;Image presente ?
      handleimagelist= SendMessage_(GadgetID(NumGadget),CBEM_GETIMAGELIST ,0,0)
      If handleimagelist
        ;Retrieves information about an image. 
        okBOOL= ImageList_GetImageInfo_(handleimagelist,1,pImageInfo)
        marge+pImageInfo\rcImage\right+4
        If GetTextHeightPix(NumGadget)>pImageInfo\rcImage\bottom
          ;longueur dropdown =26
          ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , 26+marge+GetLongerTextInListWidthPix(NumGadget),GetTextHeightPix(NumGadget))
        Else
          ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , 26+marge+GetLongerTextInListWidthPix(NumGadget),0) 
        EndIf
      Else
        
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , 26+marge+GetLongerTextInListWidthPix(NumGadget),0);GetTextHeightPix(NumGadget)
      EndIf
      
    Case #PB_GadgetType_Date ;================
      ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , 26+GetTextWidthPix(NumGadget),GetTextHeightPix(NumGadget))
      
    Case #PB_GadgetType_Editor ;================
      marge=4
       
      ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , marge+GetLongerTextInListWidthPix(NumGadget),(CountGadgetItems(NumGadget)-1)*GetHigherTextInListWidthPix(NumGadget)) 
      
    Case #PB_GadgetType_String ;================
      marge=SendMessage_(GadgetID(NumGadget),#EM_GETMARGINS,0,0)
      ;Returns the width of the left margin in the LOWORD, And the width of the right margin in the HIWORD.
      ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , 4+(marge & $FFFF)+((marge >> 16) & $FFFF)+GetTextWidthPix(NumGadget),GetTextHeightPix(NumGadget)) 
      
    Case #PB_GadgetType_Text ;================
      ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , GetTextWidthPix(NumGadget,0),GetTextHeightPix(NumGadget,0)) 
      
    Case #PB_GadgetType_HyperLink ;================
      If option=#PB_HyperLink_Underline
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , GetTextWidthPix(NumGadget,0),GetTextHeightPix(NumGadget)) 
      Else
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , GetTextWidthPix(NumGadget,0),GetTextHeightPix(NumGadget,0))  
      EndIf
      
    Case #PB_GadgetType_Spin ;================
      old$=GetGadgetText(NumGadget)
      min=GetGadgetAttribute(NumGadget, #PB_Spin_Minimum);#PB_Spin_Maximum
      SetGadgetText(NumGadget, Str(min))
      min=GetTextWidthPix(NumGadget,0)
      
      max=GetGadgetAttribute(NumGadget, #PB_Spin_Maximum)
      SetGadgetText(NumGadget, Str(max))
      max=GetTextWidthPix(NumGadget,0)
      
      SetGadgetText(NumGadget, old$)
      marge=20
      If max>=min
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , marge+max,GetTextHeightPix(NumGadget))
      Else
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , marge+min,GetTextHeightPix(NumGadget))  
      EndIf 
      
      Case #PB_GadgetType_ButtonImage ;================ 
      If option <> -1
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , ImageWidth(option),ImageHeight(option))  
      EndIf 
      
      ;Case #PB_GadgetType_Image;no effects ;================
            
      ;Case #PB_GadgetType_IPAddress;There's a bug somewhere ;================
      ;old=GetGadgetState(NumGadget)
      ;SetGadgetState(NumGadget, MakeIPAddress(192, 192, 192, 192))
      ;ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , GetTextWidthPix(NumGadget),GetTextHeightPix(NumGadget))  
      ;SetGadgetState(NumGadget, old)  
      
    Case  #PB_GadgetType_ListView ;================
      marge=28
      min=SendMessage_(GadgetID(NumGadget),#LB_GETITEMHEIGHT,0,0)
      ;ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , marge+GetLongerTextInListWidthPix(NumGadget),CountGadgetItems(NumGadget)*GetTextHeightPix(NumGadget))         
      If option = -1 ; all
        ;ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , marge+GetLongerTextInListWidthPix(NumGadget),CountGadgetItems(NumGadget)*GetTextHeightPix(NumGadget))
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , marge+GetLongerTextInListWidthPix(NumGadget),min*(CountGadgetItems(NumGadget)+1))  
      Else
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , marge+GetLongerTextInListWidthPix(NumGadget),#PB_Ignore) 
      EndIf
      
  EndSelect
  ProcedureReturn #True
EndProcedure 



Un exemple:

Code : Tout sélectionner

XIncludeFile "FitSizeGadget.pbi"
Enumeration
  #gadget0
  #gadget1
  #gadget2
  #gadget3
  #gadget4
  #gadget5
  #gadget6
  #gadget7
  #gadget8
  #gadget9
  #gadget10
  #gadget11
  #gadget12
  #gadget13
  #gadget14
  #gadget15
  #gadget16
  #gadget17
  EndEnumeration

; GetTextWidthPix(NumGadget, espace=1)
; GetTextHeightPix(NumGadget, espace=8)
; FitGadget(NumGadget, En_Longueur.b=#True, En_Hauteur.b=#True)

UsePNGImageDecoder()
UseJPEGImageDecoder()

LoadImage(#gadget0, #PB_Compiler_Home + "examples/sources/Data/Geebee2.bmp")

If OpenWindow(100, 0, 0, 800, 600, "ButtonGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) 
  ;font1=LoadFont(0,"Arial",18)
  ;SetWindowColor(100, $ffffff) 
  ScrollAreaGadget(#gadget17, 0, 0, 800,600, 800, 3000, 30)
  SetGadgetColor(#Gadget17, #PB_Gadget_BackColor, $ffffff)

  ButtonGadget(#gadget1, 10, 0, 0 , 0, "Bouton standard"):FitGadget(#gadget1)
  ButtonImageGadget(#gadget2, 10, 0, 0, 0, ImageID(#gadget0)):FitGadget(#gadget2,#True,#True,#gadget0)
  OptionGadget(#gadget3, 10, 0, 0, 0, "Option 1"):FitGadget(#gadget3)
  CalendarGadget(#gadget4, 10, 0, 0, 0):FitGadget(#gadget4)
  CheckBoxGadget(#gadget5, 10,  0, 0, 0, "Case à cocher standard"):FitGadget(#gadget5)
  ComboBoxGadget(#gadget6, 10, 0, 0, 0)
      For i = 1 To 15
        AddGadgetItem(#gadget6, -1,"Elément de liste déroulante " + Str(i))
      Next i
      AddGadgetItem (#gadget6,-1,"ok")
      FitGadget(#gadget6)
   ComboBoxGadget(#gadget7, 10, 0, 0, 0, #PB_ComboBox_Image)
   AddGadgetItem(#gadget7, -1, "Liste déroulante avec une image", ImageID(#gadget0))
   FitGadget(#gadget7)
   StringGadget(#gadget8, 10,  0, 0, 0, "Gadget saisie de texte normal..."):FitGadget(#gadget8)
   TextGadget(#gadget9, 10, 0, 0, 0,"Gadget texte standard (texte aligné à gauche)"):FitGadget(#gadget9)
   DateGadget(#gadget10, 10, 0, 0, 0, "Date : %dd/%mm/%yyyy Heure : %hh:%ii"):FitGadget(#gadget10)
   EditorGadget(#gadget11, 10, 0, 0, 0) 
    For i = 0 To 5 
      AddGadgetItem(#gadget11, -1, "Ligne "+Str(i)) 
    Next i
    AddGadgetItem (#gadget11,-1,"ok")
    FitGadget(#gadget11)
    HyperLinkGadget(#gadget12, 10, 0, 0, 0,"Lien rouge", RGB(255,0,0)):FitGadget(#gadget12)
    HyperLinkGadget(#gadget13, 10, 0, 0, 0,"Lien vert souligné (Police Arial)", RGB(0,255,0), #PB_Font_Underline)
    SetGadgetFont(#gadget13, LoadFont(0, "Arial", 12))      
    FitGadget(#gadget13,#True,#True,#PB_Font_Underline)
    SpinGadget(#gadget14, 10, 0, 0, 0, 0, 1000)
    SetGadgetState (#gadget14, 5) : SetGadgetText(#gadget14, "5")   
    FitGadget(#gadget14)
  
  ListViewGadget(#gadget15,10,10,0,0)
  For a=1 To 12
    AddGadgetItem (#gadget15,-1,"Elément "+Str(a)+" de la boîte de liste")   ; défini le contenu de la boîte de liste
  Next
  AddGadgetItem (#gadget15,-1,"azertyuiopqsdfghjklmwxcvbnazertyuiop")
  AddGadgetItem (#gadget15,-1,"a")
  FitGadget(#gadget15)
  
  ListViewGadget(#gadget16,10,10,0,50)
  For a=1 To 12
    AddGadgetItem (#gadget16,-1,"Elément "+Str(a)+" de la boîte de liste")   ; défini le contenu de la boîte de liste
  Next
  AddGadgetItem (#gadget16,-1,"azertyuiopqsdfghjklmwxcvbnazertyuiop")
  AddGadgetItem (#gadget16,-1,"a")
  FitGadget(#gadget16,#True,#True,0)
  CloseGadgetList() 
;   For i=#gadget1 To #gadget17
;     FitGadget(i)
;   Next i
;   
  dy=10
  y=GadgetY(#gadget1)
  y=y+GadgetHeight(#gadget1)
  y=y+dy
  
  For i=#gadget2 To #gadget16
    ResizeGadget(i, #PB_Ignore, y, #PB_Ignore, #PB_Ignore)
    y=GadgetY(i)
  y=y+GadgetHeight(i)
  y=y+dy
  Next i
   
  
  ;ResizeGadget(0,#PB_Ignore,#PB_Ignore,133,#PB_Ignore)
  
  
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
;   ok #PB_GadgetType_Button        : ButtonGadget() 
;   ok #PB_GadgetType_ButtonImage   : ButtonImageGadget()
;   ok #PB_GadgetType_Option        : OptionGadget() 
;   ok #PB_GadgetType_Calendar      : CalendarGadget() 
;   ok #PB_GadgetType_CheckBox      : CheckBoxGadget() 
;   ok #PB_GadgetType_ComboBox      : ComboBoxGadget() 
;   ok #PB_GadgetType_String        : StringGadget() 
;   ok #PB_GadgetType_Text          : TextGadget() 
;   ok #PB_GadgetType_Date          : DateGadget() 
;   ok*#PB_GadgetType_Editor        : EditorGadget() 
;   ok #PB_GadgetType_HyperLink     : HyperLinkGadget()
;   ok #PB_GadgetType_Spin          : SpinGadget() 
;   bug #PB_GadgetType_IPAddress    : IPAddressGadget() 
;   ok #PB_GadgetType_ListView      : ListViewGadget() 
;
;=========================================================
;   #PB_GadgetType_Container     : ContainerGadget()
;   #PB_GadgetType_ExplorerCombo : ExplorerComboGadget() 
;   #PB_GadgetType_ExplorerList  : ExplorerListGadget() 
;   #PB_GadgetType_ExplorerTree  : ExplorerTreeGadget() 
;   #PB_GadgetType_Frame3D       : Frame3DGadget()
;   #PB_GadgetType_Image         : ImageGadget()
;   #PB_GadgetType_ListIcon      : ListIconGadget() 
;   #PB_GadgetType_MDI           : MDIGadget() 
;   #PB_GadgetType_Panel         : PanelGadget() 
;   #PB_GadgetType_ProgressBar   : ProgressBarGadget() 
;   #PB_GadgetType_Scintilla     : ScintillaGadget()
;   #PB_GadgetType_ScrollArea    : ScrollAreaGadget() 
;   #PB_GadgetType_ScrollBar     : ScrollBarGadget() 
;   #PB_GadgetType_Splitter      : SplitterGadget() 
;   #PB_GadgetType_TrackBar      : TrackBarGadget() 
;   #PB_GadgetType_Tree          : TreeGadget() 
;   #PB_GadgetType_Web           : WebGadget() 
;   #PB_GadgetType_Unknown       : Type inconnu, problablement pas un gadget PureBasic.
Avatar de l’utilisateur
djes
Messages : 4252
Inscription : ven. 11/févr./2005 17:34
Localisation : Arras, France

Re: [Windows]Êtes-vous DPI-aware ?

Message par djes »

Avatar de l’utilisateur
GallyHC
Messages : 1708
Inscription : lun. 17/déc./2007 12:44

Re: [Windows]Êtes-vous DPI-aware ?

Message par GallyHC »

PT1 MUI, la première fois que le l'avais installe et vu, je me suis pose plein de question, mais après quelque jour d'utilisation c'été une merveille.

Cordialement,
GallyHC
Configuration : Tower: Windows 10 (Processeur: i7 "x64") (Mémoire: 16Go) (GeForce GTX 760 - 2Go) - PureBasic 5.72 (x86 et x64)
Avatar de l’utilisateur
case
Messages : 1545
Inscription : lun. 10/sept./2007 11:13

Re: [Windows]Êtes-vous DPI-aware ?

Message par case »

t'abuses djes ... j'vais avoir envie de ressortir les amigas de leurs cartons :)
ImageImage
Le Soldat Inconnu
Messages : 4312
Inscription : mer. 28/janv./2004 20:58
Localisation : Clermont ferrand OU Olsztyn
Contact :

Re: [Windows]Êtes-vous DPI-aware ?

Message par Le Soldat Inconnu »

Win 7 ne se pose pas la question, il zoom carrément les fenêtres, du moins avec l'essai que j'ai fait, et du coup c'est tout moche. autant réduire la résolution de l'écran, ça revient au même 8O
Pour XP, je figeais la police avec un SetGadgetFont pour ne pas utiliser la police par défaut qui dépendait du DPI choisi dans les fonts.

(Personnellement je trouve que ça ne sert plus trop à grand chose puisque les nouveaux écrans ont des résolutions adaptées à leur taille, et plus comme il fut un temps du 1900*1200 sur du 15" ce qui était totalement débile.)
Je ne suis pas à moitié Polonais mais ma moitié est polonaise ... Vous avez suivi ?

[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
Avatar de l’utilisateur
Kwai chang caine
Messages : 6989
Inscription : sam. 23/sept./2006 18:32
Localisation : Isere

Re: [Windows]Êtes-vous DPI-aware ?

Message par Kwai chang caine »

Merci MESA pour ce travail et aussi pour le lien de RESCATOR car j'avais pas compris l'utilité de son code :oops:
En français c'est beaucoup plus simple a comprendre :wink:
ImageLe bonheur est une route...
Pas une destination

PureBasic Forum Officiel - Site PureBasic
Répondre