/* SampWin.cpp is the implementation file for class SampleWindow.

   Joel Adams, Spring 1995.
-----------------------------------------------------------------*/

// --- take these actions when the left mouse button is pressed
#include <stdio.h>                  // sprintf()
#include <string.h>                 // strlen()
#include "SampWin.h"

void SampleWindow::WMLButtonDown(RTMessage Msg)
{
   char Text[12];                   // what is to be displayed

   sprintf(Text,                    // fill Text acording to
            "[%d,%d]",              //  this format-pattern, with
            Msg.LP.Lo,              //   mouse's X in 1st %d
            Msg.LP.Hi);             //   mouse's Y in 2cd %d

   HDC DisplayCon = GetDC(HWindow); // set up a display context
                                    //  for graphics output
   TextOut(DisplayCon,              // in the display context,
         Msg.LP.Lo, Msg.LP.Hi,      //  at mouse click (x,y)
         Text,                      //  display this text
         strlen(Text));             //  with this length

   ReleaseDC(HWindow,DisplayCon);   // release display context
}

// --- take these actions when the right mouse button is released
void SampleWindow::WMRButtonUp(RTMessage)
{
        int Answer = MessageBox(           // show message box with
                     HWindow,            //  parent HWindow,
                    "Clear the screen?", //  this message,
                    "Decision:",         //  this title, and
                    MB_YESNO);           //  2 buttons: YES NO

    if (Answer == IDYES)                 // if YES was clicked
       InvalidateRect(HWindow,           //   redraw HWindow
                       NULL,             //   (all of it)
                       TRUE);            //   by erasing it
}


