W32DLib
W32DLib::Common Class Reference

The Common class. More...

#include <w32dlib/common.h>

Static Public Member Functions

static bool Initialise (int size=sizeof(TCHAR))
 Initialises any Windows APIs required by W32DLib.
 
static void MessageTitle (const TCHAR *title)
 Sets the default titles for message boxes.
 
static void Message (HWND parent, const TCHAR *title, const TCHAR *msg)
 Displays a message box.
 
static void Message (HWND parent, const TCHAR *title, const W32String &msg)
 Displays a message box.
 
static void Error (HWND parent, const TCHAR *title, const TCHAR *msg)
 Displays an error message box.
 
static void Error (HWND parent, const TCHAR *title, const W32String &msg)
 Displays an error message box.
 
static bool Query (HWND parent, const TCHAR *title, const TCHAR *msg)
 Displays a Yes/No message box.
 
static bool Query (HWND parent, const TCHAR *title, const W32String &msg)
 Displays a Yes/No message box.
 
static bool OpenFile (HWND parent, const TCHAR *title, W32String &path, const TCHAR *filter)
 Requests a file to open.
 
static bool SaveFile (HWND parent, const TCHAR *title, W32String &path, const TCHAR *filter)
 Requests a file to save.
 
static bool SelectDir (HWND parent, const TCHAR *title, W32String &path)
 Selects a directory.
 
static W32String GetOSError ()
 Returns the last error as a readable string.
 
static HINSTANCE GetInstance ()
 Get an HINSTANCE.
 
static HWND GetAppWindow ()
 Get an application's top-level window.
 

Detailed Description

The Common class.

This class provides common dialogs and useful routines.

Member Function Documentation

static void W32DLib::Common::Error ( HWND  parent,
const TCHAR *  title,
const TCHAR *  msg 
)
static

Displays an error message box.

Parameters
parentParent window (NULL for none)
titleThe title to display. NULL for default ("Error") or to use the default supplied to MessageTitle().
msgThe error message to display.
static void W32DLib::Common::Error ( HWND  parent,
const TCHAR *  title,
const W32String msg 
)
static

Displays an error message box.

Parameters
parentParent window (NULL for none)
titleThe title to display. NULL for default ("Error") or to use the default supplied to MessageTitle().
msgThe error message to display.
static HWND W32DLib::Common::GetAppWindow ( )
static

Get an application's top-level window.

This finds the top-level window for the application. This is mainly a helper for when you're in a DLL, cannot access the applications window handle any other way and wish to display a modal Dialog.

Returns
The window handle, or zero for error or the window couldn't be found.
static HINSTANCE W32DLib::Common::GetInstance ( )
static

Get an HINSTANCE.

This should (though it hasn't been proved in all cases) get the apropriate HINSTANCE for the application or DLL the library has be linked into.

Returns
The HINSTANCE
static W32String W32DLib::Common::GetOSError ( )
static

Returns the last error as a readable string.

Returns
The error message
static bool W32DLib::Common::Initialise ( int  size = sizeof(TCHAR))
static

Initialises any Windows APIs required by W32DLib.

Initialise and performs startup checks (mainly that TCHAR is the same as the library was created with.

Parameters
sizePass sizeof(TCHAR).
Returns
True if the library can initialise.
static void W32DLib::Common::Message ( HWND  parent,
const TCHAR *  title,
const TCHAR *  msg 
)
static

Displays a message box.

Parameters
parentParent window (NULL for none)
titleThe title to display. NULL for default ("Message") or to use the default supplied to MessageTitle().
msgThe message to display.
static void W32DLib::Common::Message ( HWND  parent,
const TCHAR *  title,
const W32String msg 
)
static

Displays a message box.

Parameters
parentParent window (NULL for none)
titleThe title to display. NULL for default ("Message") or to use the default supplied to MessageTitle().
msgThe message to display.
static void W32DLib::Common::MessageTitle ( const TCHAR *  title)
static

Sets the default titles for message boxes.

All MessageBox type calls provide a default title if non is provided. Using this you can set the default title to an application specific one.

Parameters
titleThe default title. This pointer must remain valid throughout the life of the application.
static bool W32DLib::Common::OpenFile ( HWND  parent,
const TCHAR *  title,
W32String path,
const TCHAR *  filter 
)
static

Requests a file to open.

Parameters
parentThe parent window.
titleTitle for the selector.
pathThe current filename. This will hold the selected name on return if a file is selected.
filterThe file selector filter.
Returns
True if a file was selected and path updated.
static bool W32DLib::Common::Query ( HWND  parent,
const TCHAR *  title,
const TCHAR *  msg 
)
static

Displays a Yes/No message box.

Parameters
parentParent window (NULL for none)
titleThe title to display. NULL for default ("Question") or to use the default supplied to MessageTitle().
msgThe message to display.
Returns
True if the user selects Yes.
static bool W32DLib::Common::Query ( HWND  parent,
const TCHAR *  title,
const W32String msg 
)
static

Displays a Yes/No message box.

Parameters
parentParent window (NULL for none)
titleThe title to display. NULL for default ("Question") or to use the default supplied to MessageTitle().
msgThe message to display.
Returns
True if the user selects Yes.
static bool W32DLib::Common::SaveFile ( HWND  parent,
const TCHAR *  title,
W32String path,
const TCHAR *  filter 
)
static

Requests a file to save.

Parameters
parentThe parent window.
titleTitle for the selector.
pathThe current filename. This will hold the selected name on return if a file is selected.
filterThe file selector filter.
Returns
True if a file was selected and path updated.
static bool W32DLib::Common::SelectDir ( HWND  parent,
const TCHAR *  title,
W32String path 
)
static

Selects a directory.

Parameters
parentThe parent window.
titleTitle for the selector.
pathThe current path. This will hold the selected path on return if a directory is selected.
Returns
True if a directory was selected and path updated.

The documentation for this class was generated from the following file: