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

extern WCHAR wServerName[] ;

BOOL CALLBACK ServerNameDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg)
	{
		case WM_INITDIALOG:
		{
			char out [256] ;
			WideCharToMultiByte(CP_ACP, 0, wServerName, -1, out, sizeof(out), NULL, NULL) ;

			SetDlgItemText (hDlg, IDC_EDIT1, out) ;
			SetFocus (GetDlgItem (hDlg, IDC_EDIT1)) ;
			return FALSE ;
		}
		case WM_COMMAND:
		{
			if (LOWORD(wParam) == IDCANCEL)
			{
				EndDialog (hDlg, 0) ;
			}
			else if (LOWORD(wParam) == IDOK)
			{
				char in [256] ;
				GetDlgItemText (hDlg, IDC_EDIT1, in, sizeof(in)) ;
				MultiByteToWideChar (CP_ACP, 0, in, -1, wServerName, 256) ;
				EndDialog (hDlg, 0) ;
			}

			return TRUE ;
		}

	}

	return FALSE ;
}
