-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathJPL.Win.Dialogs.pas
76 lines (52 loc) · 2.07 KB
/
JPL.Win.Dialogs.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
unit JPL.Win.Dialogs;
interface
{$IFDEF MSWINDOWS}
{$I .\..\jp.inc}
{$IFDEF FPC}{$mode delphi}{$H+}{$ENDIF}
uses
Windows;
{
Information = Asterisks
Warning = Exclamation
Error = Hand = Stop
}
function WinMsg(const Text, Caption: string; Handle: HWND = 0; MBType: DWORD = MB_OK or MB_ICONINFORMATION): integer;
procedure MB(const Text: string; Caption: string = 'Information'; Handle: HWND = 0);
procedure WinMsgInfo(Text: string; Caption: string = 'Information'; Handle: HWND = 0);
procedure WinMsgWarning(Text: string; Caption: string = 'Warning'; Handle: HWND = 0);
procedure WinMsgError(Text: string; Caption: string = 'Error'; Handle: HWND = 0);
function WinMsgQuery(const Text, Caption: string; Handle: HWND = 0; MBType: DWORD = MB_YESNO): integer;
{$ENDIF} // MSWINDOWS
implementation
{$IFDEF MSWINDOWS}
function WinMsg(const Text, Caption: string; Handle: HWND = 0; MBType: DWORD = MB_OK or MB_ICONINFORMATION): integer;
begin
{$IFDEF FPC}
// NOTE: Dlaczego w FPC bez takich kombinacji (PWideChar + UnicodeString) pojawiają się tutaj "krzaki"?
Result := MessageBoxW(Handle, PWideChar(UnicodeString(Text)), PWideChar(UnicodeString(Caption)), MBType);
{$ELSE}
Result := MessageBox(Handle, PChar(Text), PChar(Caption), MBType);
{$ENDIF}
end;
procedure MB(const Text: string; Caption: string = 'Information'; Handle: HWND = 0);
begin
WinMsgInfo(Text, Caption, Handle);
end;
procedure WinMsgInfo(Text: string; Caption: string = 'Information'; Handle: HWND = 0);
begin
WinMsg(Text, Caption, Handle, MB_OK or MB_ICONINFORMATION);
end;
procedure WinMsgWarning(Text: string; Caption: string = 'Warning'; Handle: HWND = 0);
begin
WinMsg(Text, Caption, Handle, MB_OK or MB_ICONWARNING);
end;
procedure WinMsgError(Text: string; Caption: string = 'Error'; Handle: HWND = 0);
begin
WinMsg(Text, Caption, Handle, MB_OK or MB_ICONERROR);
end;
function WinMsgQuery(const Text, Caption: string; Handle: HWND = 0; MBType: DWORD = MB_YESNO): integer;
begin
Result := MessageBox(Handle, PChar(Text), PChar(Caption), MBType or MB_ICONQUESTION);
end;
{$ENDIF} // MSWINDOWS
end.