Click here to Skip to main content
15,885,546 members
Articles / Desktop Programming / Win32

DWinLib - The Guts

Rate me:
Please Sign up or sign in to vote.
4.96/5 (8 votes)
17 Jan 2021CPOL28 min read 19K   374   15  
A little about how things work behind the scenes in DWinLib!
In this article, you will get an overview of the internal workings of DWinLib, a semi-simple wrapper for the Windows API.
#ifndef WinMainOH
#define WinMainOH

#include "DwlMainWin.h"
#include "DwlMdiClient.h"
#include "DwlGrinPtr.h"
#include "DwlTimer.h"

class ToolbarWin;
class ObjViewWin;
class ToolbarSettings;
class FlexiCharWrap;


class WinMainO : public DwlMainWin {
   //Basic stuff
      public:
         WinMainO(LPSTR cmdStr, FlexiCharWrap * titleStr);
         ~WinMainO();

   //DwlBaseWin overrides
      public:
         virtual LRESULT winProc(HWND window, UINT msg, WPARAM wParam, LPARAM lParam);
         virtual LRESULT wClose();
         virtual LRESULT wEraseBackground(HWND win, HDC dc) { return 0; }
         virtual LRESULT wPosChanging(WINDOWPOS * windowPos);
         virtual LRESULT wDestroyNonClientArea();
         virtual LRESULT wNcActivate(BOOL activating, HWND deactivatedWin);
         virtual LRESULT wEnable(BOOL enabled, HWND disabledWindow);
         virtual LRESULT wPosChanged(WINDOWPOS * pos);
   
   //For dealing with the application names:
      private:
         std::set<wString> appNamesC;

   //Some other framework items used in this window
      public:
         void showStatusMessage(const wString & str);
         MenuMain & mainMenu() { return * mainMenuC.get(); }

   //A callback for the callback items:
      private:
         dwl::grin_ptr<DwlCallbackItem> deleteCallbackC;
         dwl::grin_ptr<DwlCallbackItem> undoCallbackC;
         dwl::grin_ptr<DwlCallbackItem> redoCallbackC;
         dwl::grin_ptr<DwlCallbackItem> ctrlXcallbackC;
         dwl::grin_ptr<DwlCallbackItem> newCompositionC;
         dwl::grin_ptr<DwlCallbackItem> openCompositionC;
         dwl::grin_ptr<DwlCallbackItem> saveCompositionC;

   //For dealing with the toolbar and object view bar:
      private:
         dwl::grin_ptr<ToolbarSettings> toolbarSettingsC; //Deals w both toolbar & objViewBar
         dwl::grin_ptr<ToolbarWin> toolbarC;
         ToolbarWin * createToolbar();
         dwl::grin_ptr<ObjViewWin> objViewWinC;
         ObjViewWin * createObjView();
      public:
         ToolbarSettings * toolbarSettings() { return toolbarSettingsC.get(); }
         //The following (releaseToolbar) is only called by the ToolbarWin wClose function.
         void releaseToolbar();
         ToolbarWin * toolbar() { return toolbarC.get(); }
         void showToolbar(DwlWinObject *);
         
         void releaseObjViewWin();
         ObjViewWin * objViewWin() { return objViewWinC.get(); }
         void showObjView(DwlWinObject *);

   //Event handlers:
      public:
         void newWindow(DwlWinObject *);
         void closeWindow(DwlWinObject *);
         void closeAll(DwlWinObject *);
         void open(DwlWinObject *);
         void exit(DwlWinObject *);
         void save(DwlWinObject *);
         void saveAs(DwlWinObject *);
         void undo(DwlWinObject *);
         void redo(DwlWinObject *);

         void play(DwlWinObject *);
         void stop(DwlWinObject *);
         void record(DwlWinObject *);

         void deleteKeyPress(DwlWinObject *);
         void ctrlXselection(DwlWinObject *);

   //boolean for determining whether a file is currently being opened:
   //(MEdit does not need this, but you may find it handy in your own app.)
      private:
         bool openingFileC;
      public:
         bool openingFile() { return openingFileC; }

   //Other stuff
         dwl::grin_ptr<DwlWinDialogs> dialogsC; //SHOULD THIS BE PRIVATE?????
      public:
         wString iniFileName();
         void updateUI();
         void updateDataAndViews();
         Application * topApp();

         void caption(wString str);

      public:
         void addAppName(const wString & perfName);
         void removeAppName(const wString & appName);
         void openMultiFiles(const wString & str);
         void openFile(const wString & str);

   //And for help:
      public:
         virtual LRESULT wHelp(HELPINFO * );
         LRESULT help(int helpTopic = 1); //Default for any projects
         //The following 'helpTopic' is used so that some modal windows can get appropriate
         //help.  See Port::portPatchFile for an example.  It is important that those
         //routines set it back to '1'
         void helpTopic(int topic) { wHelpTopicC = topic; }

   };

#endif

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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer www.randommonkeyworks.com
United States United States
I am the author of Laughing at the Devil: One Man’s Religious Discoveries. If you want to understand the astronomic investigations of our priests 3,000 years ago, LATD is the book to turn to. It opens up the thoughts that pushed them away from their earlier polytheism and towards our current definition of God.

Trained as a mechanical engineer, I have been involved with design, supervision, and project management. I taught myself C++ programming in order to play around with binaural beats more easily. I've also created various databases to help with project management and personal tasks.

Databases are cool and extremely useful! Happy coding, everybody!

Comments and Discussions