Sorting Network Verify and Draw
Check Whether Comparator Networks Sort and Draw Them
Functions
WindowsHelpers.cpp File Reference

Code for some helpful Windows-specific functions. More...

#include <shobjidl_core.h>
#include <atlbase.h>
#include "WindowsHelpers.h"
#include "Includes.h"
#include "SortingNetwork.h"
#include "resource.h"

Go to the source code of this file.

Functions

std::wstring FileNameBase (const std::wstring &wstrPath)
 
void MinDragRect (HWND hwnd, WPARAM wParam, RECT *pRect, int w, int h)
 Enforce minimum drag rectangle. More...
 
void InitWindow (HINSTANCE hInst, INT nShow, WNDPROC WndProc)
 Initialize window. More...
 
ULONG_PTR InitGDIPlus ()
 Initialize GDI+. More...
 
HRESULT GetEncoderClsid (const WCHAR *format, CLSID *pClsid)
 Get encoder CLSID. More...
 
HRESULT ExportImage (const eExport t, HWND hwnd, CRenderableComparatorNet *pNet, std::wstring &wstrName)
 Export. More...
 
HRESULT Load (HWND hwnd, CComparatorNetwork *pNet, std::wstring &wstrName)
 Load comparator network. More...
 
void CreateFileMenu (HMENU hParent)
 Create File menu. More...
 
void CreateExportMenu (HMENU hParent)
 Create File menu. More...
 
void CreateGenerateMenu (HMENU hParent)
 Create Generate menu. More...
 
void CreateViewMenu (HMENU hParent)
 Create View menu. More...
 
void CreateHelpMenu (HMENU hParent)
 Create Help menu. More...
 

Detailed Description

These platform-dependent functions are hidden away so that the faint-of-heart don't have to see them if they're offended by them.

Definition in file WindowsHelpers.cpp.

Function Documentation

◆ CreateExportMenu()

void CreateExportMenu ( HMENU  hParent)

Create the Export menu.

Parameters
hParentHandle to the parent menu.

Definition at line 374 of file WindowsHelpers.cpp.

◆ CreateFileMenu()

void CreateFileMenu ( HMENU  hParent)

Create the File menu.

Parameters
hParentHandle to the parent menu.

Definition at line 354 of file WindowsHelpers.cpp.

◆ CreateGenerateMenu()

void CreateGenerateMenu ( HMENU  hParent)

Create the Generate menu.

Parameters
hParentHandle to the parent menu.

Definition at line 387 of file WindowsHelpers.cpp.

◆ CreateHelpMenu()

void CreateHelpMenu ( HMENU  hParent)

Create the Help menu.

Parameters
hParentHandle to the parent menu.

Definition at line 417 of file WindowsHelpers.cpp.

◆ CreateViewMenu()

void CreateViewMenu ( HMENU  hParent)

Create the View menu.

Parameters
hParentHandle to the parent menu.

Definition at line 405 of file WindowsHelpers.cpp.

◆ ExportImage()

HRESULT ExportImage ( const eExport  t,
HWND  hwnd,
CRenderableComparatorNet pNet,
std::wstring &  wstrName 
)

Display a Save dialog box save an image of a comparator network to the file that the user selects. Export an image to a file.

Parameters
tExport file type.
hwndWindow handle.
pNetPointer to a renderable comparator network.
wstrNameDefault file name.
Returns
S_OK for success, E_FAIL for failure.

Definition at line 225 of file WindowsHelpers.cpp.

◆ FileNameBase()

std::wstring FileNameBase ( const std::wstring &  wstrPath)

Remove the path and the extension from a file name.

Parameters
wstrPathFile path, possibly with extension.
Returns
File name with path and extension removed (if any).

Definition at line 41 of file WindowsHelpers.cpp.

◆ GetEncoderClsid()

HRESULT GetEncoderClsid ( const WCHAR *  format,
CLSID *  pClsid 
)

Get an encoder clsid for an image file format.

Parameters
formatFile format using wide characters.
pClsid[OUT] Pointer to clsid.
Returns
S_OK for success, E_FAIL for failure.

Definition at line 193 of file WindowsHelpers.cpp.

◆ InitGDIPlus()

ULONG_PTR InitGDIPlus ( )

Initialize GDI+ and get a GDI+ token.

Returns
A GDI+ token.

Definition at line 174 of file WindowsHelpers.cpp.

◆ InitWindow()

void InitWindow ( HINSTANCE  hInst,
INT  nShow,
WNDPROC  WndProc 
)

Create and initialize a window.

Parameters
hInstInstance handle.
nShow1 to show window, 0 to hide.
WndProcWindow procedure.

Definition at line 131 of file WindowsHelpers.cpp.

◆ Load()

HRESULT Load ( HWND  hwnd,
CComparatorNetwork pNet,
std::wstring &  wstrName 
)

Pop up a Windows Open dialog box for the user to pick a text file and read the comparator network from there into a comparator network.

Parameters
hwndWindow handle.
pNet[OUT] Pointer to a renderable comparator network.
wstrName[IN, OUT] File name without extension.
Returns
S_OK for success, E_FAIL for failure.

Definition at line 303 of file WindowsHelpers.cpp.

◆ MinDragRect()

void MinDragRect ( HWND  hwnd,
WPARAM  wParam,
RECT *  pRect,
int  w,
int  h 
)

Resize the drag rectangle provided by a WM_SIZING message to ensure a minimum client area width and height.

Parameters
hwndWindow handle.
wParamWMSZ message telling us which edge is being dragged on.
pRect[IN, OUT] Pointer to drag rectangle.
wMinimum width of client area.
hMinimum height of client area.

Definition at line 63 of file WindowsHelpers.cpp.