Click here to Skip to main content
15,896,348 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 19.1K   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 AppWindowH
#define AppWindowH

#include "DwlMdiBaseWin.h"
#include "DwlGrinPtr.h"
class Application;
#include "DwlBlankChild.h"  //SHOULD NOT NEED!
class DwlScrollbar;
class AppWinKeeper;
//class AppWindow;


const int SLW = 700; //Screen Length Width


class AppWindow : public DwlMdiBaseWin {
   //General stuff
      private:
         dwl::grin_ptr<Application>    appC;

         dwl::grin_ptr<DwlScrollbar>   horScrollC;
         dwl::grin_ptr<DwlScrollbar>   verScrollC;

      public:
         AppWindow(DwlControl * parent, int x, int y, int width, int height, bool openingFile=false);
         ~AppWindow();

         LRESULT wClose();
         virtual LRESULT wEraseBackground(HWND win, HDC dc) { return 0; }
         virtual LRESULT wPaint(DwlDC & wdc);
         virtual LRESULT wPosChanged(WINDOWPOS * windowPos);
         virtual LRESULT wPosChanging(WINDOWPOS * wp);
         Application & app() { return *appC; }
         
         void update() { }
         void updateDataAndViews();
         
   //For dealing with the name:
      public:
         virtual wString shortName();
         virtual wString fullName();
         //virtual LRESULT wMdiActivate(HWND activatingWindow, HWND deactivatingWindow);
         
   //For dealing with closing.  Overridden from DwlMdiBaseWin.
      public:
         virtual bool canClose();

   //For the scrollbars:
      public:
         void updateScrolls();
         virtual LRESULT wScrollHor(WORD scrollCode, int pos, HWND scrollHwnd);
         virtual LRESULT wScrollVer(WORD scrollCode, int pos, HWND scrollHwnd);
         virtual void scrollPosChanged(DwlScrollbar * bar, int pos);

   //Additional stuff for StupidSquares:
      private:
         void blitSelectedSquare(DwlDC & dc);
         int verScrollAmtC;
         int horScrollAmtC;
         StupidSquare * mouseSquareC;
         POINT pointInSquareC;
         POINT mousePointC;
         bool needToBlitCornerC;  //Need to blit the lower right hand corner because the
                                  //scrollbars are both visible.  (A purist would note that
                                  //it is possible for a user to 'move' a square under this
                                  //'blit', but as this is simply an example, we shall live
                                  //with this 'feature'.)
         int scrollbarWidthC;
         
         void constrainSquare(LONG & x, LONG & y);

   
   //For dealing with the mouse:
      public:
         virtual LRESULT wMouseDown(Button button, WPARAM flags, SHORT x, SHORT y);
         virtual LRESULT wMouseMove(WPARAM keys, SHORT x, SHORT y);
         virtual LRESULT wMouseUp(Button button, WPARAM flags, SHORT x, SHORT y);

   };

#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