chsvlib
chsv helper source code
chsvwinutil.h File Reference

Helper functionality for working with Win32 APIs. More...

#include "chsvbase.h"
#include "chsvsal.h"
#include "chsverr.h"

Namespaces

 Chusov
 Basic chsvlib namespace.
 
 Chusov::Win32
 Axillary chsvlib elements simplifying calls to Win32 API.
 
 Chusov::Win32::GDI
 Defines auxiliary functionality easing working with Windows GDI functions.
 
 Chusov::Win32::ExecutionControl
 Defines auxiliary functionality easing working with Windows multitasking routines.
 

Macros

#define GDI_BEGIN   namespace GDI {
 Defines the beginning of the Chusov::Win32::GDI namespace without defining the encapsulating namespaces. More...
 
#define GDI_END   }
 Defines the end of the Chusov::Win32::GDI namespace. More...
 
#define EXECUTION_CONTROL_BEGIN   namespace ExecutionControl {
 Defines the beginning of the Chusov::Win32::ExecutionControl namespace without defining the encapsulating namespaces. More...
 
#define EXECUTION_CONTROL_END   }
 Defines the end of the Chusov::Win32::ExecutionControl namespace. More...
 
#define WINDOWS_BEGIN   namespace Win32 {
 Defines the beginning of the Chusov::Win32 namespace without defining the encapsulating namespace. More...
 
#define WINDOWS_END   }
 Defines the end of the Chusov::Win32 namespace. More...
 
#define HRESULT_CUSTOMBIT(hr)   (((hr) & 0x20000000) != 0)
 Maps to boolean value, which is true, if the specified HRESULT value has the custom bit set, or to false otherwise.
 
Helper directives used during a construction of COM interfaces

The directives provide ability to reduce amount of code needed to define a COM interface and classes that implement it. An example below shows using these definitions in order to define a pair of structures, where the Class1 structure defines the QueryInterface method inplace, and the Class2 structure declares the method inside its body and defines it in a separate implementation file.

Example code:

//Interface header
struct Class1:IUnknown, Interface1, Interface2
{
DEFINE_COM_QUERY_INTERFACE_ADD_ENTRY(Interface1_IID, Interface1)
DEFINE_COM_QUERY_INTERFACE_ADD_ENTRY(Interface2_IID, Interface2)
};
struct Class2:IUnknown, Interface1, Interface2
{
};
//Implementation source
DEFINE_COM_QUERY_INTERFACE_ADD_ENTRY(Interface1_IID, Interface1)
DEFINE_COM_QUERY_INTERFACE_ADD_ENTRY(Interface2_IID, Interface2)
#define DECLARE_COM_QUERY_INTERFACE
Definition: chsvwinutil.h:223
#define DEFINE_COM_QUERY_INTERFACE_ADD_ENTRY(iid_value, iface_type)
Definition: chsvwinutil.h:265
#define DEFINE_COM_QUERY_INTERFACE_BEGIN(classname)
Definition: chsvwinutil.h:250
#define DEFINE_COM_QUERY_INTERFACE_END
Definition: chsvwinutil.h:275
#define DECLARE_AND_DEFINE_COM_QUERY_INTERFACE_BEGIN
Definition: chsvwinutil.h:234
#define DECLARE_COM_QUERY_INTERFACE   virtual HRESULT __stdcall QueryInterface(REFIID refiid, void** ppv);
 
#define DECLARE_AND_DEFINE_COM_QUERY_INTERFACE_BEGIN
 
#define DEFINE_COM_QUERY_INTERFACE_BEGIN(classname)
 
#define DEFINE_COM_QUERY_INTERFACE_ADD_ENTRY(iid_value, iface_type)   else if (refiid == iid_value) *ppv = static_cast<std::remove_pointer_t<iface_type>*> (this);
 
#define DEFINE_COM_QUERY_INTERFACE_END   else {*ppv = NULL; return E_NOINTERFACE;} return S_OK;}
 

Functions

INT MsgBoxV (HWND hParent, UINT nType, LPCWSTR lpszTitle, LPCWSTR lpszMessageFormat, va_list ap) noexcept
 A wrap over the Windows MessageBoxW function providing Chusov::String::PrintfW formatting capability. More...
 
INT MsgBox (HWND hParent, UINT nType, LPCWSTR lpszTitle, LPCWSTR lpszMessageFormat,...) noexcept
 A wrap over the Windows MessageBoxW function providing Chusov::String::PrintfW formatting capability. More...
 
HANDLE CreateCPPThread (LPSECURITY_ATTRIBUTES lpThreadAttributes, DWORD dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId) noexcept
 A wrap over the _beginthreadex function with prototype of the CreateThread function. More...
 
HRESULT Win32DlgErrorToWin32Error (DWORD dwCommDlgExtendedError) noexcept
 Translates a Windows dialogue error code to the corresponding Windows system error code. More...
 
chsverror_t Win32DlgErrorToChsvError (DWORD dwCommDlgExtendedError) noexcept
 Translates a Windows dialogue error code to the corresponding chsvlib error code. More...
 

Detailed Description

Helper functionality for working with Win32 APIs.