PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: STATIC/LABEL control text alignment  (Read 138 times)

Paul Squires

  • Administrator
  • Master Member
  • *****
  • Posts: 8544
  • Windows 10
    • PlanetSquires Software
STATIC/LABEL control text alignment
« on: July 03, 2018, 08:04:36 PM »

I am pretty sure that with a standard Static control that you can *NOT* set the text alignment to be bottom/left, bottom/center, or bottom/right?

Here is the code I just wrote for the Label control in the new visual designer:
Code: [Select]
   case "TEXTALIGN"
      AfxRemoveWindowStyle(pCtrl->hWindow, SS_CENTER)
      AfxRemoveWindowStyle(pCtrl->hWindow, SS_LEFT)
      AfxRemoveWindowStyle(pCtrl->hWindow, SS_RIGHT)
      AfxRemoveWindowStyle(pCtrl->hWindow, SS_CENTERIMAGE)
      dim as long wsStyle
      select case **wszPropValue
         CASE "LabelAlignment.MiddleCenter": wsStyle = SS_CENTER OR SS_CENTERIMAGE
         CASE "LabelAlignment.MiddleLeft":   wsStyle = SS_LEFT   OR SS_CENTERIMAGE
         CASE "LabelAlignment.MiddleRight":  wsStyle = SS_RIGHT  OR SS_CENTERIMAGE
         CASE "LabelAlignment.TopCenter":    wsStyle = SS_CENTER
         CASE "LabelAlignment.TopLeft":      wsStyle = SS_LEFT   
         CASE "LabelAlignment.TopRight":     wsStyle = SS_RIGHT 
      END SELECT
      AfxAddWindowStyle(pCtrl->hWindow, wsStyle)
      SetWindowPos( pCtrl->hWindow, 0, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_DRAWFRAME)

Would the only solution be to apply the SS_OWNERDRAW style and then handle the text alignment in WM_DRAWITEM? Then I could use the DrawText api with all of the flexibility of those drawing flags.
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor