#include "WindowsDialogService.h"
#include <Vfw.h>
#pragma comment(lib,
"Vfw32.lib"
)
namespace
{
namespace
{
namespace
{
using
namespace
collections
;
::
(
)
:handleRetriver(
)
{
}
::
::
(
*
,
const
&
,
const
&
,
,
,
,
)
{
=
;
if
(
L""
&&
!=
0
)
{
realTitle
->
();
}
=
(
);
=
.
();
=
realTitle
.
();
=
0
;
#define MAP(A, B) case A: uType|=(B); break
switch
(
)
{
MAP(DisplayOK, MB_OK);
case
:
uType
|=(
0x00000000L
);
break
;
MAP(DisplayOKCancel, MB_OKCANCEL);
case
:
uType
|=(
0x00000001L
);
break
;
MAP(DisplayYesNo, MB_YESNO);
case
:
uType
|=(
0x00000004L
);
break
;
MAP(DisplayYesNoCancel, MB_YESNOCANCEL);
case
:
uType
|=(
0x00000003L
);
break
;
MAP(DisplayRetryCancel, MB_RETRYCANCEL);
case
:
uType
|=(
0x00000005L
);
break
;
MAP(DisplayAbortRetryIgnore, MB_ABORTRETRYIGNORE);
case
:
uType
|=(
0x00000002L
);
break
;
MAP(DisplayCancelTryAgainContinue, MB_CANCELTRYCONTINUE);
case
DisplayCancelTryAgainContinue
:
uType
|=(
0x00000006L
);
break
;
}
switch
(
)
{
MAP(DefaultFirst, MB_DEFBUTTON1);
case
:
uType
|=(
0x00000000L
);
break
;
MAP(DefaultSecond, MB_DEFBUTTON2);
case
:
uType
|=(
0x00000100L
);
break
;
MAP(DefaultThird, MB_DEFBUTTON3);
case
:
uType
|=(
0x00000200L
);
break
;
}
switch
(
)
{
MAP(IconError, MB_ICONERROR);
case
:
uType
|=(
0x00000010L
);
break
;
MAP(IconQuestion, MB_ICONQUESTION);
case
:
uType
|=(
0x00000020L
);
break
;
MAP(IconWarning, MB_ICONWARNING);
case
:
uType
|=(
0x00000030L
);
break
;
MAP(IconInformation, MB_ICONINFORMATION);
case
:
uType
|=(
0x00000040L
);
break
;
}
switch
(
)
{
MAP(ModalWindow, MB_APPLMODAL);
case
:
uType
|=(
0x00000000L
);
break
;
MAP(ModalSystem, MB_SYSTEMMODAL);
case
:
uType
|=(
0x00001000L
);
break
;
MAP(ModalTask, MB_TASKMODAL);
case
:
uType
|=(
0x00002000L
);
break
;
}
#undef MAP
vint result=MessageBox(hWnd, lpText, lpCaption, uType);
=
(
hWnd
,
lpText
,
lpCaption
,
uType
);
switch
(
result
)
{
case IDABORT: return SelectAbort;
case IDCANCEL: return SelectCancel;
case IDCONTINUE: return SelectContinue;
case IDIGNORE: return SelectIgnore;
case IDNO: return SelectNo;
case IDOK: return SelectOK;
case IDRETRY: return SelectRetry;
case IDTRYAGAIN: return SelectTryAgain;
case IDYES: return SelectYes;
default
:
return
;
}
}
bool
::
(
*
,
&
,
bool
,
ColorDialogCustomColorOptions
,
*
)
{
;
ZeroMemory(&chooseColor, sizeof(chooseColor));
((&
chooseColor
),
0
,(
sizeof
(
chooseColor
)));
[
16
]={
0
};
if
(
)
{
for
(
=
0
;
i
<
sizeof
(
customColorsBuffer
)/
sizeof
(*
customColorsBuffer
);
i
++)
{
customColorsBuffer[i]=RGB(customColors[i].r, customColors[i].g, customColors[i].b);
customColorsBuffer
[
i
]=((
)(((
)(
[
i
].
)|((
)((
)(
[
i
].
))<<
8
))|(((
)(
)(
[
i
].
))<<
16
)));
}
}
chooseColor
.
=
sizeof
(
chooseColor
);
chooseColor
.
=
(
);
chooseColor.rgbResult=RGB(selection.r, selection.g, selection.b);
chooseColor
.
=((
)(((
)(
.
)|((
)((
)(
.
))<<
8
))|(((
)(
)(
.
))<<
16
)));
chooseColor
.
=
customColorsBuffer
;
chooseColor.Flags=CC_ANYCOLOR;
#define MAP(A, B) case A: chooseColor.Flags|=(B); break
switch
(
)
{
MAP(CustomColorDisabled, CC_PREVENTFULLOPEN);
case
:
chooseColor
.
|=(
0x00000004
);
break
;
MAP(CustomColorOpened, CC_FULLOPEN);
case
:
chooseColor
.
|=(
0x00000002
);
break
;
}
#undef MAP
if
(
)
{
chooseColor.Flags|=CC_RGBINIT;
chooseColor
.
|=
0x00000001
;
}
BOOL result=ChooseColor(&chooseColor);
if
(
result
)
{
selection=Color(GetRValue(chooseColor.rgbResult), GetGValue(chooseColor.rgbResult), GetBValue(chooseColor.rgbResult));
((((
)(((
)(
chooseColor
.
)) &
0xff
))), (((
)(((
)(((
)(
chooseColor
.
)) >>
8
)) &
0xff
))), (((
)(((
)((
chooseColor
.
)>>
16
)) &
0xff
))));
if
(
)
{
for
(
=
0
;
i
<
sizeof
(
customColorsBuffer
)/
sizeof
(*
customColorsBuffer
);
i
++)
{
=
customColorsBuffer
[
i
];
customColors[i]=Color(GetRValue(color), GetGValue(color), GetBValue(color));
[
i
]
((((
)(((
)(
color
)) &
0xff
))), (((
)(((
)(((
)(
color
)) >>
8
)) &
0xff
))), (((
)(((
)((
color
)>>
16
)) &
0xff
))));
}
}
}
}
bool
::
(
*
,
&
,
&
,
bool
,
bool
,
bool
)
{
;
ZeroMemory(&logFont, sizeof(logFont));
((&
logFont
),
0
,(
sizeof
(
logFont
)));
logFont
.
=-(
int
)
.
;
logFont.lfWeight=selectionFont.bold?FW_BOLD:FW_REGULAR;
logFont.lfItalic=selectionFont.italic?TRUE:FALSE;
logFont.lfUnderline=selectionFont.underline?TRUE:FALSE;
logFont.lfStrikeOut=selectionFont.strikeline?TRUE:FALSE;
(
logFont
.
,
.
.
());
;
ZeroMemory(&chooseFont, sizeof(chooseFont));
((&
chooseFont
),
0
,(
sizeof
(
chooseFont
)));
chooseFont
.
=
sizeof
(
chooseFont
);
chooseFont
.
=
(
);
chooseFont
.
=&
logFont
;
chooseFont
.
=
0
;
chooseFont.Flags=(showEffect?CF_EFFECTS:0) | (forceFontExist?CF_FORCEFONTEXIST:0) | (selected?CF_INITTOLOGFONTSTRUCT:0);
chooseFont
.
=(
?
0x00000100L
:
0
) | (
?
0x00010000L
:
0
) | (
?
0x00000040L
:
0
);
chooseFont.rgbColors=RGB(selectionColor.r, selectionColor.g, selectionColor.b);
chooseFont
.
=((
)(((
)(
.
)|((
)((
)(
.
))<<
8
))|(((
)(
)(
.
))<<
16
)));
BOOL result=ChooseFont(&chooseFont);
if
(
result
)
{
.
=
logFont
.
;
selectionFont.bold=logFont.lfWeight>FW_REGULAR;
selectionFont.italic=logFont.lfItalic!=FALSE;
selectionFont.underline=logFont.lfUnderline!=FALSE;
selectionFont.strikeline=logFont.lfStrikeOut!=FALSE;
.
=-
logFont
.
;
selectionColor=Color(GetRValue(chooseFont.rgbColors), GetGValue(chooseFont.rgbColors), GetBValue(chooseFont.rgbColors));
((((
)(((
)(
chooseFont
.
)) &
0xff
))), (((
)(((
)(((
)(
chooseFont
.
)) >>
8
)) &
0xff
))), (((
)(((
)((
chooseFont
.
)>>
16
)) &
0xff
))));
}
}
bool
::
(
*
,
collections
::
<
>&
,
&
,
,
const
&
,
const
&
,
const
&
,
const
&
,
const
&
,
)
{
<
wchar_t
>
(
65536
>
.
()+
1
?
65536
:
.
()+
1
);
(&
fileNamesBuffer
0
],
fileNamesBuffer
.
(),
.
());
;
ZeroMemory(&ofn, sizeof(ofn));
((&
ofn
),
0
,(
sizeof
(
ofn
)));
ofn
.
=
sizeof
(
ofn
);
ofn
.
=
(
);
ofn.lpstrCustomFilter=NULL;
ofn
.
=
0
;
ofn
.
=(
int
)
+
1
;
ofn
.
=&
fileNamesBuffer
0
];
ofn
.
=(
int
)
fileNamesBuffer
.
();
ofn
.
=
0
;
ofn.lpstrInitialDir=initialDirectory==L""?NULL:initialDirectory.Buffer();
ofn.lpstrTitle=title==L""?NULL:title.Buffer();
ofn.lpstrDefExt=defaultExtension==L""?NULL:defaultExtension.Buffer();
<
>
;
for
(
=
0
;
i
<
.
();
i
++)
{
if
(
i
]==
L'|'
)
{
filterSeparators
.
(
i
);
}
}
if
(
filterSeparators
.
()%
2
==
1
)
{
filterSeparators
.
(
.
());
}
<
wchar_t
>
(
.
()+
2
);
=
0
;
for
(
=
0
;
i
<
filterSeparators
.
();
i
++)
{
=
filterSeparators
i
];
(&
filterBuffer
index
],
filterBuffer
.
()-
index
,
.
()+
index
,
end
-
index
);
filterBuffer
end
]=
0
;
index
=
end
+
1
;
}
filterBuffer
index
]=
0
;
ofn
.
=&
filterBuffer
0
];
ofn.Flags=OFN_ENABLESIZING | OFN_EXPLORER | OFN_LONGNAMES;
ofn
.
=
0x00800000
|
0x00080000
|
0x00200000
;
if(options&FileDialogAllowMultipleSelection) ofn.Flags|=OFN_ALLOWMULTISELECT;
if
(
FileDialogAllowMultipleSelection
)
ofn
.
|=
0x00000200
;
if(options&FileDialogFileMustExist) ofn.Flags|=OFN_FILEMUSTEXIST;
if(!(options&FileDialogShowReadOnlyCheckBox)) ofn.Flags|=OFN_HIDEREADONLY;
if
(!(
FileDialogShowReadOnlyCheckBox
))
ofn
.
|=
0x00000004
;
if(!(options&FileDialogDereferenceLinks)) ofn.Flags|=OFN_NODEREFERENCELINKS;
if
(!(
FileDialogDereferenceLinks
))
ofn
.
|=
0x00100000
;
if(!(options&FileDialogShowNetworkButton)) ofn.Flags|=OFN_NONETWORKBUTTON;
if
(!(
FileDialogShowNetworkButton
))
ofn
.
|=
0x00020000
;
if(options&FileDialogPromptCreateFile) ofn.Flags|=OFN_CREATEPROMPT;
if
(
FileDialogPromptCreateFile
)
ofn
.
|=
0x00002000
;
if(options&FileDialogPromptOverwriteFile) ofn.Flags|=OFN_OVERWRITEPROMPT;
if
(
FileDialogPromptOverwriteFile
)
ofn
.
|=
0x00000002
;
if(options&FileDialogDirectoryMustExist) ofn.Flags|=OFN_PATHMUSTEXIST;
if
(
FileDialogDirectoryMustExist
)
ofn
.
|=
0x00000800
;
if(!(options&FileDialogAddToRecent)) ofn.Flags|=OFN_DONTADDTORECENT;
if
(!(
))
ofn
.
|=
0x02000000
;
switch
(
)
{
case
:
result=GetOpenFileName(&ofn);
break
;
case
:
result=GetOpenFileNamePreview(&ofn);
break
;
case
:
result=GetSaveFileName(&ofn);
break
;
case
:
result=GetSaveFileNamePreview(&ofn);
break
;
}
if
(
result
)
{
=
ofn
.
-
1
;
.
();
if
(
FileDialogAllowMultipleSelection
)
{
const
wchar_t
*
=&
fileNamesBuffer
0
];
=
reading
;
reading
+=
directory
.
()+
1
;
while
(*
reading
)
{
=
reading
;
reading
+=
fileName
.
()+
1
;
.
(
directory
+
L"\\"
+
fileName
);
}
if
(
.
()==
0
)
{
.
(
directory
);
}
}
else
{
.
(&
fileNamesBuffer
0
]);
}
}
}
}
}
}