Classes | Namespaces | Defines | Enumerations | Functions

winutil.h File Reference

This reference page is linked to from the following overview topics: Correctly Clearing XOR-ed Lines Drawn in the Viewport, Vista Aero Support.


#include "maxheap.h"
#include <limits>
#include <locale.h>
#include "coreexp.h"
#include <wtypes.h>
#include <CommCtrl.h>
#include "strclass.h"
#include "ipoint2.h"
#include "box2.h"
#include "plugapi.h"

Go to the source code of this file.

Classes

class   DialogItemSizeData
class   DialogResizer
class   MaxLocaleHandler
  MaxLocaleHandler handles Globalization. More...
class   ToolTipExtender
  Internal use only. Hidden internal implementation for ToolTipExtender. More...

Namespaces

namespace   MaxSDK

Defines

#define  MAKEPOINT(lparam, pt)   { pt.x = (short)LOWORD(lparam); pt.y = (short)HIWORD(lparam); }
#define  CUSTLIST_DISABLED   (1<<0)
#define  CUSTLIST_MED_DISABLED   (1<<1)
#define  CUSTLIST_SEPARATOR   (1<<2)
#define  CUSTLIST_DBL_SERPARATOR   (1<<3)
#define  CUSTLIST_RED   (1<<4)
#define  MAX_MB_HOLD   0x0001
  Add "Hold" button.
#define  MAX_MB_DONTSHOWAGAIN   0x0002
  Add "Don't show this dialog again" check box.

Enumerations

enum   LoadMAXIconErrors { LMI_Ok, LMI_ResourceNotFound, LMI_ResourceLoadFailed, LMI_ImageAndMaskNotCompatible }

Functions

CoreExport float  GetWindowFloat (HWND hwnd, BOOL *valid=NULL)
CoreExport int  GetWindowInt (HWND hwnd, BOOL *valid=NULL)
CoreExport BOOL  SetWindowTextInt (HWND hwnd, int i)
CoreExport BOOL  SetWindowTextFloat (HWND hwnd, float f, int precision=3)
CoreExport BOOL  SetDlgItemFloat (HWND hwnd, int idControl, float val)
CoreExport float  GetDlgItemFloat (HWND hwnd, int idControl, BOOL *valid=NULL)
CoreExport void  SetDlgFont (HWND hDlg, HFONT hFont)
CoreExport void  SlideWindow (HWND hwnd, int x, int y)
CoreExport void  StretchWindow (HWND hwnd, int w, int h)
CoreExport BOOL  CenterWindow (HWND hWndChild, HWND hWndParent)
CoreExport void  GetClientRectP (HWND hwnd, Rect *rect)
CoreExport void  DrawIconButton (HDC hdc, HBITMAP hBitmap, Rect &wrect, Rect &brect, BOOL in)
CoreExport int  GetListHieght (HWND hList)
CoreExport void  ShadedVertLine (HDC hdc, int x, int y0, int y1, BOOL in)
CoreExport void  ShadedHorizLine (HDC hdc, int y, int x0, int x1, BOOL in)
CoreExport void  ShadedRect (HDC hdc, RECT &rect)
CoreExport void  Rect3D (HDC hdc, RECT &rect, BOOL in)
CoreExport void  WhiteRect3D (HDC hdc, RECT rect, BOOL in)
CoreExport void  DrawButton (HDC hdc, RECT rect, BOOL in)
CoreExport void  SetPathWithEllipses (HWND hwnd, const MCHAR *path, HFONT hFont)
  Sets a pathname in an edit control, truncating with an ellipses if the pathname is too long.
CoreExport int  UpdateComboBoxDropDownWidth (HWND hComboBox, bool vScroll=true)
  Updates the width of a combo-box drop-down window to make all its items fit.
CoreExport void  XORDottedRect (HWND hwnd, IPoint2 p0, IPoint2 p1, int solidToRight=0, bool bErase=false, bool bDelayUpdate=false)
  XOR drawing method of rectangle.
CoreExport void  XORDottedCircle (HWND hwnd, IPoint2 p0, IPoint2 p1, int solidToRight=0, bool bErase=false, bool bDelayUpdate=false)
  XOR drawing method of circle.
CoreExport void  XORDottedPolyline (HWND hwnd, int count, IPoint2 *pts, int solid=0, bool bErase=false, bool bDelayUpdate=false)
  XOR drawing method of polylines.
CoreExport void  XORRect (HDC hdc, RECT &r, int border=1)
CoreExport BOOL  IsVistaAeroEnabled ()
  Vista Aero related method.
CoreExport BOOL  IsThemeSupported ()
  If theme is supported on current OS.
CoreExport BOOL  IsHovering (HWND hWnd)
  If the mouse cursor is currently hovering over a window.
CoreExport BOOL  IsHovering (HWND hWnd, int x, int y)
  If the cursor position specified is currently confined in a window's rectangle.
CoreExport void  MakeButton2State (HWND hCtrl)
CoreExport void  MakeButton3State (HWND hCtrl)
CoreExport int  GetCheckBox (HWND hw, int id)
CoreExport void  SetCheckBox (HWND hw, int id, BOOL b)
CoreExport BOOL  DoesFileExist (const MCHAR *file, bool allowDirectory=true)
  Detects whether the file specified by the full, absolute filename exists.
CoreExport bool  GetFileTime (const MCHAR *filePath, FILETIME *creationTime, FILETIME *lastAccessTime, FILETIME *lastWriteTime)
  Retrieves a file's or directory's creation, last access and last modification times.
CoreExport MSTR  FileTimeToString (const FILETIME &fileTime)
  Converts a FILETIME value to a string representation.
CoreExport int  GetBitsPerPixel ()
CoreExport void  StripTrailingZeros (MCHAR *buf)
template<class T >
void  LimitValue (T &value, T min, T max)
float  Dbl2Flt (double val, BOOL *valid=NULL)
  Safely casts double to float. Valid flag will indicate overflow.
int  Dbl2Int (double val, BOOL *valid=NULL)
  Safely casts double to int. Valid flag will indicate overflow.
CoreExport void  CustListMeasureItem (HWND hList, WPARAM wParam, LPARAM lParam)
CoreExport void  CustListDrawItem (HWND hList, WPARAM wParam, LPARAM lParam, DWORD flags)
CoreExport INT_PTR  MaxMsgBox (HWND hWnd, LPCMSTR lpText, LPCMSTR lpCaption, UINT type, UINT exType=0, DWORD *exRet=NULL)
CoreExport LoadMAXIconErrors  LoadMAXIcon (HINSTANCE hInstance, LPCMSTR resID, LPCMSTR resMaskID, COLORREF bkColor, HIMAGELIST imageList, int imageIndex, int preMultAlpha=TRUE)
CoreExport int  LoadMAXIconFromBMI (LPBITMAPINFOHEADER biImage, LPBITMAPINFOHEADER biMask, COLORREF bkColor, MCHAR *pFilePrefix, int preMultAlpha=TRUE, HIMAGELIST *pImageList=NULL)
CoreExport BITMAPINFOHEADER *  LoadBitmapFromFile (const MCHAR *filename)
CoreExport void  DrawMAXIcon (HDC hDC, Rect &r, HIMAGELIST hList32, HIMAGELIST hList16, int index)
CoreExport COLORREF  ComputeXORDrawColor (COLORREF bkgColor)
CoreExport COLORREF  ComputeViewportXORDrawColor ()
CoreExport bool  SearchComboBox (HWND hWnd, MCHAR key, const MCHAR *szTrim=NULL)
  Multiple character search for ComboBoxes.
CoreExport bool  SearchListBox (HWND hWnd, MCHAR key, const MCHAR *szTrim=NULL)
  Multiple character search for ListBoxes.
CoreExport int  GetDefaultToolTipMaxWidth ()

Define Documentation

#define MAKEPOINT (   lparam,
  pt 
)    { pt.x = (short)LOWORD(lparam); pt.y = (short)HIWORD(lparam); }

Definition at line 248 of file winutil.h.

#define CUSTLIST_DISABLED   (1<<0)

Definition at line 256 of file winutil.h.

#define CUSTLIST_MED_DISABLED   (1<<1)

Definition at line 257 of file winutil.h.

#define CUSTLIST_SEPARATOR   (1<<2)

Definition at line 258 of file winutil.h.

#define CUSTLIST_DBL_SERPARATOR   (1<<3)

Definition at line 259 of file winutil.h.

#define CUSTLIST_RED   (1<<4)

Definition at line 260 of file winutil.h.

#define MAX_MB_HOLD   0x0001

Add "Hold" button.

Definition at line 268 of file winutil.h.

#define MAX_MB_DONTSHOWAGAIN   0x0002

Add "Don't show this dialog again" check box.

Definition at line 270 of file winutil.h.


Enumeration Type Documentation


Function Documentation

CoreExport float GetWindowFloat ( HWND  hwnd,
BOOL *  valid = NULL 
)
CoreExport int GetWindowInt ( HWND  hwnd,
BOOL *  valid = NULL 
)
CoreExport BOOL SetWindowTextInt ( HWND  hwnd,
int  i 
)
CoreExport BOOL SetWindowTextFloat ( HWND  hwnd,
float  f,
int  precision = 3 
)
CoreExport BOOL SetDlgItemFloat ( HWND  hwnd,
int  idControl,
float  val 
)
CoreExport float GetDlgItemFloat ( HWND  hwnd,
int  idControl,
BOOL *  valid = NULL 
)
CoreExport void SetDlgFont ( HWND  hDlg,
HFONT  hFont 
)
CoreExport void SlideWindow ( HWND  hwnd,
int  x,
int  y 
)
CoreExport void StretchWindow ( HWND  hwnd,
int  w,
int  h 
)
CoreExport BOOL CenterWindow ( HWND  hWndChild,
HWND  hWndParent 
)
CoreExport void GetClientRectP ( HWND  hwnd,
Rect rect 
)
CoreExport void DrawIconButton ( HDC  hdc,
HBITMAP  hBitmap,
Rect wrect,
Rect brect,
BOOL  in 
)
CoreExport int GetListHieght ( HWND  hList )
CoreExport void ShadedVertLine ( HDC  hdc,
int  x,
int  y0,
int  y1,
BOOL  in 
)
CoreExport void ShadedHorizLine ( HDC  hdc,
int  y,
int  x0,
int  x1,
BOOL  in 
)
CoreExport void ShadedRect ( HDC  hdc,
RECT &  rect 
)
CoreExport void Rect3D ( HDC  hdc,
RECT &  rect,
BOOL  in 
)
CoreExport void WhiteRect3D ( HDC  hdc,
RECT  rect,
BOOL  in 
)
CoreExport void DrawButton ( HDC  hdc,
RECT  rect,
BOOL  in 
)
CoreExport void SetPathWithEllipses ( HWND  hwnd,
const MCHAR *  path,
HFONT  hFont 
)

Sets a pathname in an edit control, truncating with an ellipses if the pathname is too long.

CoreExport int UpdateComboBoxDropDownWidth ( HWND  hComboBox,
bool  vScroll = true 
)

Updates the width of a combo-box drop-down window to make all its items fit.

Call this function if some strings in your combo-box are longer than the actual combo-box control's width. This function will update the width of the combo-box to make the widest combo-box item fit.

Parameters:
hComboBox The handle of the combobox to update
vScroll true if the width of a vertical scroll bar should be taken into account
Returns:
-1 if the combo-box could not be updated successfully, the new width of the combo-box drop down otherwise.
CoreExport void XORDottedRect ( HWND  hwnd,
IPoint2  p0,
IPoint2  p1,
int  solidToRight = 0,
bool  bErase = false,
bool  bDelayUpdate = false 
)

XOR drawing method of rectangle.

This method will draw a dotted or solid rectangle onto the specified window. This method can provide better compatibility with Vista Aero than using GDI function directly.

Parameters:
[in] hWnd Window handle of the window on which the drawing will occur.
[in] p0 One corner of the rectangle.
[in] p1 p0's diagonal in the rectangle.
[in] solidToRight If zero, the rectangle will be dotted. If less than zero, and p0.x >= p1.x, the line will be solid, otherwize dotted. If greater than zero, and p0.x <= p1.x, the line will be solid, otherwize dotted.
[in] bErase Whether to erase the foreground and use the background to fill the affected pixels, this is only valid for the window handle associated with graphic window.
[in] bDelayUpdate if true, the result image will be stored on the back buffer and won't be presented to screen immediately. If next drawing function is invoked with bDelayUpdate being false, then the image will be presented combined with the result of previous drawing function. If the drawing result is not necessary to be seen immediately, passing true to this parameter will reduce the times of back buffer presenting, thus optimize the performance. This is only valid for window handle associated with graphic window.
CoreExport void XORDottedCircle ( HWND  hwnd,
IPoint2  p0,
IPoint2  p1,
int  solidToRight = 0,
bool  bErase = false,
bool  bDelayUpdate = false 
)

XOR drawing method of circle.

This method will draw a dotted or solid circle onto the specified window. This method can provide better compatibility with Vista Aero than using GDI function directly.

Parameters:
[in] hWnd Window handle of the window on which the drawing will occur.
[in] p0 One corner of the circle's bounding rectangle.
[in] p1 p0's diagonal in the rectangle.
[in] solidToRight If zero, the circle will be dotted. If less than zero, and p0.x >= p1.x, the line will be solid, otherwize dotted. If greater than zero, and p0.x <= p1.x, the line will be solid, otherwize dotted.
[in] bErase Whether to erase the foreground and use the background to fill the affected pixels, this is only valid for the window handle associated with graphic window.
[in] bDelayUpdate if true,the result image will be stored on the back buffer and won't be presented to screen immediately. If next drawing function is invoked with bDelayUpdate being false, then the image will be presented combined with the result of previous drawing function. If the drawing result is not necessary to be seen immediately, passing true to this parameter will reduce the times of back buffer presenting, thus optimize the performance. This is only valid for window handle associated with graphic window.
CoreExport void XORDottedPolyline ( HWND  hwnd,
int  count,
IPoint2 pts,
int  solid = 0,
bool  bErase = false,
bool  bDelayUpdate = false 
)

XOR drawing method of polylines.

This method will draw dotted or solid polylines onto the specified window. This method can provide better compatibility with Vista Aero than using GDI function directly.

Parameters:
[in] hWnd Window handle of the window on which the drawing will occur.
[in] count The count of corners of the polylines.
[in] pts Pointer to the corners.
[in] solid If nonzero, the polylines will be solid, otherwize dotted.
[in] bErase Whether to erase the foreground and use the background to fill the affected pixels, this is only valid for the window handle associated with graphic window.
[in] bDelayUpdate if true, the result image will be stored on the back buffer and won't be presented to screen immediately. If next drawing function is invoked with bDelayUpdate being false, then the image will be presented combined with the result of previous drawing function. If the drawing result is not necessary to be seen immediately, passing true to this parameter will reduce the times of back buffer presenting, thus optimize the performance. This is only valid for window handle associated with graphic window.
CoreExport void XORRect ( HDC  hdc,
RECT &  r,
int  border = 1 
)
CoreExport BOOL IsVistaAeroEnabled ( )

Vista Aero related method.

This method will tell whether the Vista Aero is turned on or not.

Returns:
TRUE if Vista Aero is turned on, otherwize FALSE. On Window XP or previous Windows, it will always return FALSE.
CoreExport BOOL IsThemeSupported ( )

If theme is supported on current OS.

Specifically, any Windows versions above Windows XP (Windows 5.1)should be able to support OS theme.

Returns:
TRUE if the OS supports theme(Windows XP or later), otherwise FALSE.
CoreExport BOOL IsHovering ( HWND  hWnd )

If the mouse cursor is currently hovering over a window.

This method will not differentiate whether the cursor is actually hovering over a window, or it's blocked by some other window. /*! It only does a point-rectangle containment test.

Parameters:
[in] hWnd The handle of the window.
Returns:
TRUE if the mouse cursor is currently hovering the window, otherwise FALSE.
CoreExport BOOL IsHovering ( HWND  hWnd,
int  x,
int  y 
)

If the cursor position specified is currently confined in a window's rectangle.

This method will not differentiate whether the cursor is actually hovering over a window, or it's blocked by some other window. /*! It only does a point-rectangle containment test.

Parameters:
[in] hWnd The handle of the window.
[in] x The x-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
[in] y The y-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
Returns:
TRUE if the mouse cursor is currently hovering the window, otherwise FALSE.
CoreExport void MakeButton2State ( HWND  hCtrl )
CoreExport void MakeButton3State ( HWND  hCtrl )
CoreExport int GetCheckBox ( HWND  hw,
int  id 
)
CoreExport void SetCheckBox ( HWND  hw,
int  id,
BOOL  b 
)
CoreExport BOOL DoesFileExist ( const MCHAR *  file,
bool  allowDirectory = true 
)

Detects whether the file specified by the full, absolute filename exists.

Detects whether specified file exists, optionally excluding files that are directories. Note that if the filename is a guid string, the guid string is converted to a AssetUser, and then the AssetUser's filename is tested to see if it exists.

Parameters:
file The null-terminated filename or guid string
allowDirectory If true, returns TRUE if the filename is found and is either a file or a directory. If false, returns TRUE if the filename is found and is a file but not a directory.
Returns:
TRUE if the file exists.
CoreExport bool GetFileTime ( const MCHAR *  filePath,
FILETIME *  creationTime,
FILETIME *  lastAccessTime,
FILETIME *  lastWriteTime 
)

Retrieves a file's or directory's creation, last access and last modification times.

Parameters:
[in] filePath - absolute path to the file
[out] creationTime - pointer to a FILETIME structure to receive the date and time the file or directory was created. This parameter can be NULL.
[out] lastAccessTime - pointer to a FILETIME structure to receive the date and time the file or directory was last accessed. This parameter can be NULL.
[out] lastWriteTime- pointer to a FILETIME structure to receive the date and time the file or directory was last modified. This parameter can be NULL.
Returns:
True if the operation was successful, false otherwise.
CoreExport MSTR FileTimeToString ( const FILETIME &  fileTime )

Converts a FILETIME value to a string representation.

The FILETIME is converted into local time and date, and then to a string. The format of the time and date string is given by the default user locale.

Parameters:
fileTime - the file time to convert to string
Returns:
A string representation of the file time, or empty string if an error occurred.
CoreExport int GetBitsPerPixel ( )
CoreExport void StripTrailingZeros ( MCHAR *  buf )
void LimitValue ( T &  value,
min,
max 
)

Definition at line 190 of file winutil.h.

{
    if ( value < min ) 
        value = min;
    if ( value > max )
        value = max;
}
float Dbl2Flt ( double  val,
BOOL *  valid = NULL 
) [inline]

Safely casts double to float. Valid flag will indicate overflow.

Definition at line 199 of file winutil.h.

{
    if ( val < 0.0f )
    {
        if ( val < -FLT_MAX )
        {
            if (valid) *valid = FALSE;
            return -FLT_MAX;
        }
        if ( val > -FLT_MIN )
        {
            if (valid) *valid = FALSE;
            return -FLT_MIN;
        }
        if (valid) *valid = TRUE;
        return (float)val;
    }

    if ( val > FLT_MAX )
    {
        if (valid) *valid = FALSE;
        return FLT_MAX;
    }
    if ( val < FLT_MIN && val != 0.0 )
    {
        if (valid) *valid = FALSE;
        return FLT_MIN;
    }
    if (valid) *valid = TRUE;
    return (float)val;
}
int Dbl2Int ( double  val,
BOOL *  valid = NULL 
) [inline]

Safely casts double to int. Valid flag will indicate overflow.

Definition at line 232 of file winutil.h.

{
    if ( val > INT_MAX )
    {
        if (valid) *valid = FALSE;
        return INT_MAX;
    }
    if ( val < INT_MIN )
    {
        if (valid) *valid = FALSE;
        return INT_MIN;
    }
    if (valid) *valid = TRUE;
    return (int)val;
}
CoreExport void CustListMeasureItem ( HWND  hList,
WPARAM  wParam,
LPARAM  lParam 
)
CoreExport void CustListDrawItem ( HWND  hList,
WPARAM  wParam,
LPARAM  lParam,
DWORD  flags 
)
CoreExport INT_PTR MaxMsgBox ( HWND  hWnd,
LPCMSTR  lpText,
LPCMSTR  lpCaption,
UINT  type,
UINT  exType = 0,
DWORD *  exRet = NULL 
)
CoreExport LoadMAXIconErrors LoadMAXIcon ( HINSTANCE  hInstance,
LPCMSTR  resID,
LPCMSTR  resMaskID,
COLORREF  bkColor,
HIMAGELIST  imageList,
int  imageIndex,
int  preMultAlpha = TRUE 
)
CoreExport int LoadMAXIconFromBMI ( LPBITMAPINFOHEADER  biImage,
LPBITMAPINFOHEADER  biMask,
COLORREF  bkColor,
MCHAR *  pFilePrefix,
int  preMultAlpha = TRUE,
HIMAGELIST *  pImageList = NULL 
)
CoreExport BITMAPINFOHEADER* LoadBitmapFromFile ( const MCHAR *  filename )
CoreExport void DrawMAXIcon ( HDC  hDC,
Rect r,
HIMAGELIST  hList32,
HIMAGELIST  hList16,
int  index 
)
CoreExport COLORREF ComputeXORDrawColor ( COLORREF  bkgColor )
CoreExport COLORREF ComputeViewportXORDrawColor ( )