/*
*********************************************************************
*
*	The Essence of OLE
*
*	Source code sample
*
*	Copyright (c) 1996, Rolling Thunder Computing, Ipswich MA
*
*	e-mail: essence@rollthunder.com
*	CompuServe: 73540.3430
*	Web: http://www.rollthunder.com
*
*	File Name: EDITDLG.CPP
*
*	Purpose: Dialog box response function
*
*********************************************************************
*/

#include <windows.h>
#include "resource.h"
#include "main.h"

extern char DisplayText[ ] ;


BOOL WINAPI EditDlgProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{

		case WM_INITDIALOG:
		{
			SetDlgItemText (hDlg, IDC_EDIT1, DisplayText) ;
			SetFocus (GetDlgItem (hDlg, IDC_EDIT1)) ;
			SendDlgItemMessage (hDlg, IDC_EDIT1, EM_SETSEL, 0, -1) ;
			return FALSE ;
		}

		case WM_COMMAND:
		{
			if (LOWORD(wParam) == IDOK)
			{
				GetDlgItemText (hDlg, IDC_EDIT1, DisplayText, DISPLAY_TEXT_LENGTH) ;
				EndDialog (hDlg, IDOK) ;
				return TRUE ;
			}
			else  if (LOWORD (wParam) == IDCANCEL)
			{
				EndDialog (hDlg, IDCANCEL) ;
				return TRUE ;
			}

			return FALSE ;
		}
	}

	return FALSE ;
}
