-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcecommdlg.c
124 lines (100 loc) · 2.71 KB
/
cecommdlg.c
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// cecommdlg.c
//
// Time-stamp: <10/05/02 09:03:01 [email protected]>
#include "celib.h"
#include <commdlg.h>
BOOL XCEAPI
XCEChooseColor(LPVOID lp)
{
XCEShowMessageA("ChooseColor not supported");
return FALSE;
}
#define OPEN_FILE 1
#define SAVE_FILE 2
static BOOL
XCEFileNameNameDlg(LPOPENFILENAMEA lpofna, int type)
{
BOOL status;
LPOPENFILENAMEW lpofnw = malloc(sizeof(OPENFILENAMEW));
char *p;
int len;
memcpy(lpofnw, lpofna, sizeof(OPENFILENAMEW));
if(lpofna->lpstrFilter)
{
for(p = (char *) lpofna->lpstrFilter; ; p++)
{
if(p[0] == 0 && p[1] == 0)
break;
}
len = p + 1 - lpofna->lpstrFilter;
lpofnw->lpstrFilter = XCEMakeUnicode(lpofna->lpstrFilter, len);
}
lpofnw->lpstrCustomFilter = NULL;
if(lpofna->lpstrFile != NULL)
{
lpofnw->lpstrFile = malloc(lpofna->nMaxFile * sizeof(wchar_t));
MultiByteToWideChar(CP_ACP, 0,
lpofna->lpstrFile, -1,
lpofnw->lpstrFile, lpofna->nMaxFile);
}
if(lpofna->lpstrFileTitle != NULL)
{
lpofnw->lpstrFileTitle = malloc(lpofna->nMaxFileTitle * sizeof(wchar_t));
}
if(lpofna->lpstrInitialDir != NULL)
{
wchar_t *p;
lpofnw->lpstrInitialDir = XCEMakeUnicode(lpofna->lpstrInitialDir, -1);
for(p = lpofnw->lpstrInitialDir; *p; p++)
{
if(*p == '/')
*p = '\\';
}
}
if(lpofna->lpstrTitle != NULL)
{
lpofnw->lpstrTitle = XCEMakeUnicode(lpofna->lpstrTitle, -1);
}
if(lpofna->lpstrDefExt != NULL)
{
lpofnw->lpstrDefExt = XCEMakeUnicode(lpofna->lpstrDefExt, -1);
}
if(type == OPEN_FILE)
status = GetOpenFileNameW(lpofnw);
else
status = GetSaveFileNameW(lpofnw);
if(status == TRUE)
{
WideCharToMultiByte(CP_ACP, 0,
lpofnw->lpstrFile, -1,
lpofna->lpstrFile, lpofna->nMaxFile,
NULL, NULL);
if(lpofna->lpstrFileTitle)
{
WideCharToMultiByte(CP_ACP, 0,
lpofnw->lpstrFileTitle, -1,
lpofna->lpstrFileTitle, lpofna->nMaxFileTitle,
NULL, NULL);
}
lpofna->nFileOffset = lpofnw->nFileOffset;
lpofna->nFileExtension = lpofnw->nFileExtension;
}
free((void *) lpofnw->lpstrFilter);
free((void *) lpofnw->lpstrFile);
free((void *) lpofnw->lpstrFileTitle);
free((void *) lpofnw->lpstrInitialDir);
free((void *) lpofnw->lpstrTitle);
free((void *) lpofnw->lpstrDefExt);
free(lpofnw);
return status;
}
BOOL XCEAPI
XCEGetOpenFileNameA(LPOPENFILENAMEA lpofna)
{
return XCEFileNameNameDlg(lpofna, OPEN_FILE);
}
BOOL XCEAPI
XCEGetSaveFileNameA(LPOPENFILENAMEA lpofna)
{
return XCEFileNameNameDlg(lpofna, SAVE_FILE);
}