Operating System Manager
This Windows Operating System Manager was created as part of a personal project to enhance my knowledge of the Windows API using C++.
Overview
A C++ Windows operating system manager library that takes care of all of the Windows specific code. The library allows the user to create a window, query the mouse and keyboard, and create dialog boxes that controls can be added to. All of the operating system manager library classes/structures/functions etc… are all contained within the namespace OS, and all error information is sent to std::cerr.
Features
Application
The user must specify their main as :
int EntryPoint(OS_App *os)
The os pointer given to the user is used to access the operating system manager class, the user should not change this pointer or delete it as this is taken care of by the library when the users main function exits.
The application class allows :
- Querying of the current desktop resolution.
- Querying the supported resolutions of the monitor that the application is running on.
- Updating the os class – This must be done every game update as this allows the processing of windows messages.
- Querying the elapsed time in milliseconds since the application was started.
- Closing the application – Must be called before exiting the users main.
- Setting whether the cursor is visible over the window or not.
- Setting the cursor position.
- Retrieving the cursor position.
- Creating a folder on the users computer.
Window
To create a new window the user must use the function :
bool CreateNewDisplay(OS_Window **window)
If this function returns true the window parameter will be a valid pointer to a window. The user should not change or delete the window poiter, instead they should call :
window->Release();
The window class allows :
- The creation of a window.
- Querying if the user has requested to close the window.
- Querying of the window name – This is the name used to register the window with Windows, and also the title that will be shown in the window title bar if one is to be shown.
- Querying the window rectangle.
- Setting the window rectangle.
- Setting the window style.
- Destroying the window.
- Querying the keyboard state.
- Querying the mouse state.
- Releasing the window – This function should be called so that the window can delete itself instead of being deleted by the user.
Dialog
To create a new dialog the user must use the function :
bool CreateNewDialog(OS_Dialog **dialog)
If this function returns true the dialog parameter will be a valid pointer to a dialog. The user should not change or delete the dialog pointer, instead they should call :
dialog->Release();
The dialog class allows :
- The creation of a folder selection dialog.
- The creation of a file open/save dialog.
- The creation of a dialog box.
- Querying if the user has requested to close the dialog box.
- Closing the dialog box.
- Releasing the dialog box – This function should be called so that the dialog can delete itself instead of being deleted by the user.
- Buttons
- Adding a push button to the dialog box.
- Querying if the push button has been clicked.
- Adding a radio button to the dialog box.
- Querying if the radio button is selected.
- Selecting the radio button – Used to make a default selection.
- Edit Controls
- Adding a text edit control to the dialog box.
- Setting the text in an edit control.
- Getting the text from an edit control.
- Adding a numerical edit control – This edit box will only allow numbers to be typed into it.
- Setting the value of a numerical edit control.
- Getting the value from a numerical edit control.
- Static Text
- Adding static text to the dialog box.
- Getting the static text from the dialog box.
- Group Box
- Adding a group box to the dialog box – This is purely visual, this function does no actual grouping. For grouping see the dialog functions startGroup() and EndGroup().
- Slider Bars
- Adding a slider to the dialog box.
- Getting the value from the slider bar.
- Combo Boxes
- Adding a combo box to the dialgo box.
- Adding an item to the combo box.
- Getting the current selection from a combo box.
- Setting the current selection in a combo box.
- Grouping
- Starting a group – Best used with radio buttons to allow only one selection allowed instead of them all being individual radio buttons.
- Ending a group – Best used with radio buttons to allow only one selection allowed instead of them all being individual radio buttons.
- The ability to add a tool tip control to any control – A tool tip is a little balloon box that pops up with information when the control is hovered over with the mouse.
Documentation
The doxygen documentation for this library can be sound at the operating system manager documentation page
Notes
In applications using a renderer like DirectX or OpenGL a handle to the window is required. Though the library does not contain a function to retrieve the handle to the window it can be obtained using :
HWND hWnd = FindWindow(window->GetWindowName().c_str());
Where window is a valid OS_Window pointer returned from :
CreateNewDisplay(OS_Window **window);
FindWindow(…) is a windows function found in windows.h.