In this article, you will get an overview of the internal workings of DWinLib, a semi-simple wrapper for the Windows API.
|
// --------------------------------------------------------------------------------------- //
// The following is the window that holds the toolbar for the BareApp example. //
// --------------------------------------------------------------------------------------- //
#include "PrecompiledHeaders.h"
#pragma hdrstop
#include "ToolbarWin.h"
#include "DwlDockChild.h"
#include "Toolbar.h"
#include "ToolbarSettings.h"
#include "HelpFileConstants.h"
#include "UIManager.h"
#include "Application.h"
#include "WinMainO.h"
extern WinMainO * gWinMain;
#include "DwlApp.h"
extern DwlBaseApp * gWinApp;
#include "Globals.h"
extern Globals gGlobals;
#ifdef DEBUG
#include "WinDebugWin.h"
extern WinDebugWin * gDebugWin;
#endif
ToolbarWin::ToolbarWin(DwlDockManager * parent, bool docked, DwlDockPosition dockPos,
int floatX, int floatY, int floatWidth, int floatHeight, int dockDim,
bool allowDockedResize) :
DwlDockChild(parent, docked, dockPos, floatX, floatY, floatWidth, floatHeight,
dockDim, allowDockedResize) {
caption(_T("Toolbar"));
toolbarC = new Toolbar(this);
//Each window that derives from DwlDockChild needs to include these lines at the end of
//its ctor. See DwlDockChild ctor for reason.
if (dockedC) {
dockedC = false;
wHeightC = floatHeight; //Otherwise floatHeight and floatWidth are not set correctly
wWidthC = floatWidth;
toggleDockingMode();
}
showWindow(true);
gWinMain->toolbarSettings()->tbVisible(true);
wHelpTopicC = HFC::ToolbarWin;
}
ToolbarWin::~ToolbarWin() {
saveSettings();
gWinMain->releaseToolbar();
delete toolbarC;
}
void ToolbarWin::saveSettings() {
ToolbarSettings * settings = gWinMain->toolbarSettings();
settings->tbDocked(dockedC);
settings->tbDockPos(dockPosC);
settings->tbDockedSize(dockedDimC);
settings->tbx(floatXC);
settings->tby(floatYC);
settings->tbFloatWidth(floatWidthC);
settings->tbFloatHeight(floatHeightC);
}
LRESULT ToolbarWin::wClose() {
//This has to be placed in the 'wClose' function. In dtor, would ALWAYS cause
//WinMainO->toolbarVisibleC == false upon closing.
DwlDockChild::wClose();
gWinMain->toolbarSettings()->tbVisible(false);
return DefWindowProc(hwndC, WM_CLOSE, 0, 0);
}
void ToolbarWin::makeVertical(bool vertical) {
toolbarC->makeVertical(vertical);
toolbarC->moveWindow(10, 10, toolbarC->neededWidth(), toolbarC->neededHeight());
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.