// Common, group WinSystem
// Copyright Alexander Liss

#ifndef __MODALDIALOG_H__
#define __MODALDIALOG_H__

#include "win0.h"


		// MODAL DIALOG

// can be only one per thread, needs global data for data exchange;
// three functions work in concert to enable a modal dialog:
//	BOOL CALLBACK DialogFunc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
//	start_modal_dialog() and 
//	end_modal_dialog()
// hDlg created internaly by modal_dialog_box and
//	is passed to DialogFunc and 
//	from it to end_modal_dialog(...)
// nResult set in DialogFunc and
//	is passed through end_modal_dialog and 
//	throug start_modal_dialog(...)
// DialogFunc can create inside other modal dialogs, 
//	which is convenient for self-guided information display


// dwInitParam specifies the value to pass to the DialogFunc 
// in the lParam parameter of the WM_INITDIALOG message
INT_PTR start_modal_dialog(
	LPCTSTR lpTemplateName,  // dialog template
	DLGPROC lpDialogFunc,    // dialog procedure
	const WindowId& parent,
	LPARAM dwInitParam=0       // initialization value
					 )
{return ::DialogBoxParam(parent.app_instance,lpTemplateName,parent.window,lpDialogFunc,dwInitParam);}

BOOL end_modal_dialog(
  HWND hDlg,        // handle received in callback
  INT_PTR return_value = 0   
)
{return ::EndDialog(hDlg,return_value);}

#endif