#include "pch.h"
#include "mzMessageBox.h"
#include "mzstdGlobals.h"

namespace mzstd {

LONG WINAPI MessageBox(CmzString caption, CmzString message) {
	LONG result = ::MessageBoxW(GetActiveWindow(), message.getBuffer(), caption.getBuffer(), MB_OK | MB_ICONINFORMATION);
    return result;
}

LONG WINAPI AlertBox(CmzString message) {
	LONG result = ::MessageBoxW(GetActiveWindow(), message.getBuffer(), L"Uwaga", MB_OK | MB_ICONWARNING);
    return result;
}

LONG WINAPI WarningBox(CmzString message) {
	LONG result = ::MessageBoxW(GetActiveWindow(), message.getBuffer(), L"Uwaga", MB_OK | MB_ICONWARNING);
    return result;
}

LONG WINAPI QuestionBox(CmzString message) {
	LONG result = ::MessageBoxW(GetActiveWindow(), message.getBuffer(), L"Pytanie", MB_YESNO | MB_ICONQUESTION);
    return result;
}

LONG WINAPI QuestionCancelBox(CmzString message) {
	LONG result = ::MessageBoxW(GetActiveWindow(), message.getBuffer(), L"Pytanie", MB_YESNOCANCEL | MB_ICONQUESTION);
    return result;
}

LONG WINAPI ErrorBox(CmzString message) {
	LONG result = ::MessageBoxW(GetActiveWindow(), message.getBuffer(), L"Błąd", MB_OK | MB_ICONERROR);
    return result;
}

LONG WINAPI InformationBox(CmzString message) {
	LONG result = ::MessageBoxW(GetActiveWindow(), message.getBuffer(), L"Informacja", MB_OK | MB_ICONINFORMATION);
    return result;
}

VOID WINAPI ShowLastSystemError(WCHAR* prependString) {
    ShowSystemError(GetLastError(), prependString);
}

VOID WINAPI ShowSystemError(DWORD errorCode, WCHAR* prependString) {
	ErrorBox(GetSystemErrorMessage(errorCode));
}

VOID WINAPI ShowDetailedLastSystemError(WCHAR* prependString) {
    ShowDetailedSystemError(GetLastError(), prependString);
}

VOID WINAPI ShowDetailedSystemError(DWORD errorCode, WCHAR* prependString) {
	ErrorBox(GetDetailedSystemErrorMessage(errorCode, prependString));
}

}
