| version 1.2, 2003/11/21 06:51:15 | version 1.4, 2005/03/20 08:58:20 | 
| Line 7 | Line 7 | 
 | #include        "dialogs.h" | #include        "dialogs.h" | 
 |  |  | 
 |  |  | 
| static const char str_nc[] = "N/C"; | static const TCHAR str_nc[] = _T("N/C"); | 
 |  |  | 
| static  char    pathname[MAX_PATH]; | const TCHAR str_int0[] = _T("INT0"); | 
| static  char    filename[MAX_PATH]; | const TCHAR str_int1[] = _T("INT1"); | 
|  | const TCHAR str_int2[] = _T("INT2"); | 
| const char str_int0[] = "INT0"; | const TCHAR str_int4[] = _T("INT4"); | 
| const char str_int1[] = "INT1"; | const TCHAR str_int5[] = _T("INT5"); | 
| const char str_int2[] = "INT2"; | const TCHAR str_int6[] = _T("INT6"); | 
| const char str_int4[] = "INT4"; |  | 
| const char str_int5[] = "INT5"; |  | 
| const char str_int6[] = "INT6"; |  | 
 |  |  | 
 |  |  | 
 | // ---- file select | // ---- file select | 
 |  |  | 
| const char *dlgs_selectfile(HWND hWnd, const FILESEL *item, | BOOL dlgs_selectfile(HWND hWnd, const FILESEL *item, | 
| const char *defname, char *folder, UINT size, int *ro) { | TCHAR *path, UINT size, int *ro) { | 
 |  |  | 
 | OPENFILENAME    ofn; | OPENFILENAME    ofn; | 
 |  |  | 
| if ((defname) && (defname[0])) { | if ((item == NULL) || (path == NULL) || (size == 0)) { | 
| milstr_ncpy(pathname, defname, sizeof(pathname)); | return(FALSE); | 
| } |  | 
| else if (folder) { |  | 
| milstr_ncpy(pathname, folder, sizeof(pathname)); |  | 
| } |  | 
| else { |  | 
| pathname[0] = '\0'; |  | 
 | } | } | 
 | filename[0] = '\0'; |  | 
 |  |  | 
 | ZeroMemory(&ofn, sizeof(OPENFILENAME)); | ZeroMemory(&ofn, sizeof(OPENFILENAME)); | 
 | ofn.lStructSize = sizeof(OPENFILENAME); | ofn.lStructSize = sizeof(OPENFILENAME); | 
 | ofn.hwndOwner = hWnd; | ofn.hwndOwner = hWnd; | 
 | ofn.lpstrFilter = item->filter; | ofn.lpstrFilter = item->filter; | 
 | ofn.nFilterIndex = item->defindex; | ofn.nFilterIndex = item->defindex; | 
| ofn.lpstrFile = pathname; | ofn.lpstrFile = path; | 
| ofn.lpstrFileTitle = filename; | ofn.nMaxFile = size; | 
| ofn.nMaxFile = MAX_PATH; |  | 
 | ofn.Flags = OFN_FILEMUSTEXIST; | ofn.Flags = OFN_FILEMUSTEXIST; | 
 | ofn.lpstrDefExt = item->ext; | ofn.lpstrDefExt = item->ext; | 
 | ofn.lpstrTitle = item->title; | ofn.lpstrTitle = item->title; | 
 | if (!GetOpenFileName(&ofn)) { | if (!GetOpenFileName(&ofn)) { | 
| return(NULL); | return(FALSE); | 
| } |  | 
| if (folder) { |  | 
| milstr_ncpy(folder, pathname, size); |  | 
| sysmng_update(SYS_UPDATEOSCFG); |  | 
 | } | } | 
 | if (ro) { | if (ro) { | 
 | *ro = ofn.Flags & OFN_READONLY; | *ro = ofn.Flags & OFN_READONLY; | 
 | } | } | 
| return(pathname); | return(TRUE); | 
 | } | } | 
 |  |  | 
| const char *dlgs_selectwritefile(HWND hWnd, const FILESEL *item, | BOOL dlgs_selectwritefile(HWND hWnd, const FILESEL *item, | 
| const char *defname, char *folder, UINT size) { | TCHAR *path, UINT size) { | 
 |  |  | 
 | OPENFILENAME    ofn; | OPENFILENAME    ofn; | 
 |  |  | 
| if (defname) { | if ((item == NULL) || (path == NULL) || (size == 0)) { | 
| milstr_ncpy(pathname, defname, sizeof(pathname)); | return(FALSE); | 
| } |  | 
| else { |  | 
| pathname[0] = '\0'; |  | 
 | } | } | 
 | filename[0] = '\0'; |  | 
 |  |  | 
 | ZeroMemory(&ofn, sizeof(OPENFILENAME)); | ZeroMemory(&ofn, sizeof(OPENFILENAME)); | 
 | ofn.lStructSize = sizeof(OPENFILENAME); | ofn.lStructSize = sizeof(OPENFILENAME); | 
 | ofn.hwndOwner = hWnd; | ofn.hwndOwner = hWnd; | 
 | ofn.lpstrFilter = item->filter; | ofn.lpstrFilter = item->filter; | 
 | ofn.lpstrFile = pathname; |  | 
 | ofn.lpstrFileTitle = filename; |  | 
 | ofn.nFilterIndex = item->defindex; | ofn.nFilterIndex = item->defindex; | 
| ofn.nMaxFile = MAX_PATH; | ofn.lpstrFile = path; | 
| ofn.nMaxFileTitle = sizeof(filename); | ofn.nMaxFile = size; | 
 | ofn.Flags = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY; | ofn.Flags = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY; | 
 | ofn.lpstrDefExt = item->ext; | ofn.lpstrDefExt = item->ext; | 
 | ofn.lpstrTitle = item->title; | ofn.lpstrTitle = item->title; | 
 | if (!GetSaveFileName(&ofn)) { | if (!GetSaveFileName(&ofn)) { | 
| return(NULL); | return(FALSE); | 
| } |  | 
| if (folder) { |  | 
| milstr_ncpy(folder, pathname, size); |  | 
| sysmng_update(SYS_UPDATEOSCFG); |  | 
 | } | } | 
| return(pathname); | return(TRUE); | 
 | } | } | 
 |  |  | 
| const char *dlgs_selectwritenum(HWND hWnd, const FILESEL *item, | BOOL dlgs_selectwritenum(HWND hWnd, const FILESEL *item, | 
| const char *defname, char *folder, UINT size) { | TCHAR *path, UINT size) { | 
 |  |  | 
| char    numfile[MAX_PATH]; | TCHAR   *file; | 
| char    *p; | TCHAR   *p; | 
| int             i; | TCHAR   *q; | 
|  | UINT    i; | 
|  | BOOL    r; | 
 |  |  | 
| if (folder) { | if ((item == NULL) || (path == NULL) || (size == 0)) { | 
| milstr_ncpy(numfile, folder, sizeof(numfile)); | return(FALSE); | 
 | } | } | 
| else { | file = (TCHAR *)_MALLOC((size + 16) * sizeof(TCHAR), path); | 
| numfile[0] = '\0'; | if (file == NULL) { | 
| } | return(FALSE); | 
| file_cutname(numfile); | } | 
| p = numfile + strlen(numfile); | p = file_getname(path); | 
|  | milstr_ncpy(file, path, size); | 
|  | file_cutname(file); | 
|  | q = file + lstrlen(file); | 
|  |  | 
 | for (i=0; i<10000; i++) { | for (i=0; i<10000; i++) { | 
| wsprintf(p, defname, i); | wsprintf(q, p, i); | 
| if (file_attr(numfile) == -1) { | if (file_attr(file) == (short)-1) { | 
 | break; | break; | 
 | } | } | 
 | } | } | 
| return(dlgs_selectwritefile(hWnd, item, numfile, folder, size)); | r = dlgs_selectwritefile(hWnd, item, file, size); | 
|  | if (r) { | 
|  | milstr_ncpy(path, file, size); | 
|  | } | 
|  | _MFREE(file); | 
|  | return(r); | 
 | } | } | 
 |  |  | 
 |  |  | 
 | // ---- list | // ---- list | 
 |  |  | 
| void dlgs_setliststr(HWND hWnd, WORD res, const char **item, UINT items) { | void dlgs_setliststr(HWND hWnd, UINT res, const TCHAR **item, UINT items) { | 
 |  |  | 
 | HWND    wnd; | HWND    wnd; | 
 | UINT    i; | UINT    i; | 
| Line 135  void dlgs_setliststr(HWND hWnd, WORD res | Line 119  void dlgs_setliststr(HWND hWnd, WORD res | 
 | } | } | 
 | } | } | 
 |  |  | 
| void dlgs_setlistuint32(HWND hWnd, WORD res, const UINT32 *item, UINT items) { | void dlgs_setlistuint32(HWND hWnd, UINT res, const UINT32 *item, UINT items) { | 
 |  |  | 
 | HWND    wnd; | HWND    wnd; | 
 | UINT    i; | UINT    i; | 
| char    str[16]; | TCHAR   str[16]; | 
 |  |  | 
 | wnd = GetDlgItem(hWnd, res); | wnd = GetDlgItem(hWnd, res); | 
 | for (i=0; i<items; i++) { | for (i=0; i<items; i++) { | 
| Line 151  void dlgs_setlistuint32(HWND hWnd, WORD | Line 135  void dlgs_setlistuint32(HWND hWnd, WORD | 
 |  |  | 
 | // ---- draw | // ---- draw | 
 |  |  | 
| void dlgs_drawbmp(HDC hdc, BYTE *bmp) { | void dlgs_drawbmp(HDC hdc, UINT8 *bmp) { | 
 |  |  | 
 | BMPFILE         *bf; | BMPFILE         *bf; | 
 | BMPINFO         *bi; | BMPINFO         *bi; | 
 | BMPDATA         inf; | BMPDATA         inf; | 
 | HBITMAP         hbmp; | HBITMAP         hbmp; | 
| BYTE            *image; | UINT8           *image; | 
 | HDC                     hmdc; | HDC                     hmdc; | 
 |  |  | 
 | if (bmp == NULL) { | if (bmp == NULL) { |