Category : C++ Source Code
Archive   : WINCPP.ZIP
Filename : SCRIBBLE.CPP

 
Output of file : SCRIBBLE.CPP contained in archive : WINCPP.ZIP
/*---------------------------------------------------------
Drawing with the mouse
---------------------------------------------------------*/
#include
#include "winclass.h"
#include "initinst.h"

class SCRIBBLE : public MAINWINDOW
{
protected:
HDC hDC;

LPSTR GetClassName() {return "Scribble";};
void MouseMove ();
void LButtonDown ();
void LButtonUp ();

public:
SCRIBBLE () { hDC = NULL; };
};

/*---------------------------------------------------------
When the user pushes down the left mouse button,
get a device context and set the current position
---------------------------------------------------------*/
void SCRIBBLE::LButtonDown ()
{
hDC = GetDC (hWnd);
if (hDC)
{
MoveTo (hDC, getx(), gety());
ShowCursor (FALSE); // Turn off the mouse arrow.
SetCapture (hWnd); // Capture the mouse.
}
}

/*---------------------------------------------------------
When the mouse moves from one pixel position to another,
draw a line if the device context is set
---------------------------------------------------------*/
void SCRIBBLE::MouseMove ()
{
if (hDC)
LineTo (hDC, getx(), gety());
}

/*---------------------------------------------------------
When the user lifts up on the left mouse button,
release the device context
---------------------------------------------------------*/
void SCRIBBLE::LButtonUp ()
{
if (hDC)
{
ReleaseDC (hWnd, hDC);
hDC = NULL;
ShowCursor (TRUE); // Turn the mouse arrow back on.
ReleaseCapture(); // Release the mouse.
}
}

/*---------------------------------------------------------
Create a Scribble window
---------------------------------------------------------*/
BOOL InitInstance()
{
static SCRIBBLE scribble;
return scribble.Make();
}


  3 Responses to “Category : C++ Source Code
Archive   : WINCPP.ZIP
Filename : SCRIBBLE.CPP

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/