| version 1.9, 2005/03/20 23:48:03 | version 1.11, 2007/10/26 14:38:34 | 
| Line 9 | Line 9 | 
 | #include        "mt32snd.h" | #include        "mt32snd.h" | 
 | #endif | #endif | 
 |  |  | 
 |  | extern HINSTANCE hInst; | 
 |  |  | 
 |  |  | 
 | const TCHAR str_nc[] = _T("N/C"); | const TCHAR str_nc[] = _T("N/C"); | 
 |  |  | 
| Line 20  const TCHAR str_int5[] = _T("INT5"); | Line 22  const TCHAR str_int5[] = _T("INT5"); | 
 | const TCHAR str_int6[] = _T("INT6"); | const TCHAR str_int6[] = _T("INT6"); | 
 |  |  | 
 |  |  | 
 |  | // ---- enable | 
 |  |  | 
 |  | void dlgs_enablebyautocheck(HWND hWnd, UINT uID, UINT uCheckID) | 
 |  | { | 
 |  | EnableWindow(GetDlgItem(hWnd, uID), | 
 |  | (SendDlgItemMessage(hWnd, uCheckID, BM_GETCHECK, 0, 0) != 0)); | 
 |  | } | 
 |  |  | 
 |  | void dlgs_disablebyautocheck(HWND hWnd, UINT uID, UINT uCheckID) | 
 |  | { | 
 |  | EnableWindow(GetDlgItem(hWnd, uID), | 
 |  | (SendDlgItemMessage(hWnd, uCheckID, BM_GETCHECK, 0, 0) == 0)); | 
 |  |  | 
 |  | } | 
 |  |  | 
 |  |  | 
 | // ---- file select | // ---- file select | 
 |  |  | 
 | BOOL dlgs_selectfile(HWND hWnd, const FILESEL *item, | BOOL dlgs_selectfile(HWND hWnd, const FILESEL *item, | 
 | OEMCHAR *path, UINT size, int *ro) { | OEMCHAR *path, UINT size, int *ro) { | 
 |  |  | 
 |  | TCHAR                   *pszTitle; | 
 | OPENFILENAME    ofn; | OPENFILENAME    ofn; | 
 | #if defined(OSLANG_UTF8) | #if defined(OSLANG_UTF8) | 
 | TCHAR                   _path[MAX_PATH]; | TCHAR                   _path[MAX_PATH]; | 
 | #endif | #endif | 
 |  | BOOL                    bResult; | 
 |  |  | 
 | if ((item == NULL) || (path == NULL) || (size == 0)) { | if ((item == NULL) || (path == NULL) || (size == 0)) { | 
 | return(FALSE); | return(FALSE); | 
 | } | } | 
 |  | pszTitle = lockstringresource(hInst, item->title); | 
 |  |  | 
 | ZeroMemory(&ofn, sizeof(OPENFILENAME)); | ZeroMemory(&ofn, sizeof(OPENFILENAME)); | 
 | ofn.lStructSize = sizeof(OPENFILENAME); | ofn.lStructSize = sizeof(OPENFILENAME); | 
 | ofn.hwndOwner = hWnd; | ofn.hwndOwner = hWnd; | 
| Line 48  BOOL dlgs_selectfile(HWND hWnd, const FI | Line 70  BOOL dlgs_selectfile(HWND hWnd, const FI | 
 | #endif | #endif | 
 | ofn.Flags = OFN_FILEMUSTEXIST; | ofn.Flags = OFN_FILEMUSTEXIST; | 
 | ofn.lpstrDefExt = item->ext; | ofn.lpstrDefExt = item->ext; | 
| ofn.lpstrTitle = item->title; | ofn.lpstrTitle = pszTitle; | 
| if (!GetOpenFileName(&ofn)) { |  | 
| return(FALSE); | bResult = GetOpenFileName(&ofn); | 
| } | unlockstringresource(pszTitle); | 
|  |  | 
|  | if (bResult) { | 
 | #if defined(OSLANG_UTF8) | #if defined(OSLANG_UTF8) | 
| tchartooem(path, NELEMENTS(path), _path, -1); | tchartooem(path, NELEMENTS(path), _path, -1); | 
 | #endif | #endif | 
| if (ro) { | if (ro) { | 
| *ro = ofn.Flags & OFN_READONLY; | *ro = ofn.Flags & OFN_READONLY; | 
|  | } | 
 | } | } | 
| return(TRUE); | return(bResult); | 
 | } | } | 
 |  |  | 
 | BOOL dlgs_selectwritefile(HWND hWnd, const FILESEL *item, | BOOL dlgs_selectwritefile(HWND hWnd, const FILESEL *item, | 
 | OEMCHAR *path, UINT size) { | OEMCHAR *path, UINT size) { | 
 |  |  | 
 | OPENFILENAME    ofn; | OPENFILENAME    ofn; | 
 |  | TCHAR                   *pszTitle; | 
 | #if defined(OSLANG_UTF8) | #if defined(OSLANG_UTF8) | 
 | TCHAR                   _path[MAX_PATH]; | TCHAR                   _path[MAX_PATH]; | 
 | #endif | #endif | 
 |  | BOOL                    bResult; | 
 |  |  | 
 | if ((item == NULL) || (path == NULL) || (size == 0)) { | if ((item == NULL) || (path == NULL) || (size == 0)) { | 
 | return(FALSE); | return(FALSE); | 
 | } | } | 
 |  |  | 
 |  | pszTitle = lockstringresource(hInst, item->title); | 
 |  |  | 
 | ZeroMemory(&ofn, sizeof(OPENFILENAME)); | ZeroMemory(&ofn, sizeof(OPENFILENAME)); | 
 | ofn.lStructSize = sizeof(OPENFILENAME); | ofn.lStructSize = sizeof(OPENFILENAME); | 
 | ofn.hwndOwner = hWnd; | ofn.hwndOwner = hWnd; | 
| Line 87  BOOL dlgs_selectwritefile(HWND hWnd, con | Line 117  BOOL dlgs_selectwritefile(HWND hWnd, con | 
 | #endif | #endif | 
 | 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 = pszTitle; | 
| if (!GetSaveFileName(&ofn)) { |  | 
| return(FALSE); | bResult = GetSaveFileName(&ofn); | 
| } |  | 
|  | unlockstringresource(pszTitle); | 
|  |  | 
 | #if defined(OSLANG_UTF8) | #if defined(OSLANG_UTF8) | 
| tchartooem(path, NELEMENTS(path), _path, -1); | if (bResult) { | 
|  | tchartooem(path, NELEMENTS(path), _path, -1); | 
|  | } | 
 | #endif | #endif | 
| return(TRUE); | return(bResult); | 
 | } | } | 
 |  |  | 
 | BOOL dlgs_selectwritenum(HWND hWnd, const FILESEL *item, | BOOL dlgs_selectwritenum(HWND hWnd, const FILESEL *item, | 
| Line 172  void dlgs_setliststr(HWND hWnd, UINT16 r | Line 206  void dlgs_setliststr(HWND hWnd, UINT16 r | 
 | } | } | 
 |  |  | 
 | void dlgs_setlistuint32(HWND hWnd, UINT16 res, const UINT32 *item, UINT items) { | void dlgs_setlistuint32(HWND hWnd, UINT16 res, const UINT32 *item, UINT items) { | 
 |  |  | 
 | HWND    wnd; | HWND    wnd; | 
 | UINT    i; | UINT    i; | 
 | OEMCHAR str[16]; | OEMCHAR str[16]; | 
| Line 185  void dlgs_setlistuint32(HWND hWnd, UINT1 | Line 218  void dlgs_setlistuint32(HWND hWnd, UINT1 | 
 | } | } | 
 |  |  | 
 |  |  | 
 |  | void dlgs_setdroplistitem(HWND hWnd, UINT uID, | 
 |  | const TCHAR **ppszItem, UINT uItems) | 
 |  | { | 
 |  | HWND    hItem; | 
 |  | UINT    uPos; | 
 |  | UINT    i; | 
 |  | TCHAR   szString[128]; | 
 |  |  | 
 |  | hItem = GetDlgItem(hWnd, uID); | 
 |  | uPos = 0; | 
 |  | for (i=0; i<uItems; i++) { | 
 |  | LPCTSTR lpcszStr = ppszItem[i]; | 
 |  | if (!HIWORD(lpcszStr)) | 
 |  | { | 
 |  | if (!loadstringresource(hInst, LOWORD(lpcszStr), | 
 |  | szString, NELEMENTS(szString))) | 
 |  | { | 
 |  | continue; | 
 |  | } | 
 |  | lpcszStr = szString; | 
 |  | } | 
 |  | SendMessage(hItem, CB_INSERTSTRING, (WPARAM)uPos, (LPARAM)lpcszStr); | 
 |  | SendMessage(hItem, CB_SETITEMDATA, (WPARAM)uPos, (LPARAM)i); | 
 |  | uPos++; | 
 |  | } | 
 |  | } | 
 |  |  | 
 |  | void dlgs_setdroplistnumber(HWND hWnd, UINT uID, int nNumber) | 
 |  | { | 
 |  | HWND    hItem; | 
 |  | int             nItems; | 
 |  | int             i; | 
 |  |  | 
 |  | hItem = GetDlgItem(hWnd, uID); | 
 |  | nItems = SendMessage(hItem, CB_GETCOUNT, 0, 0); | 
 |  | for (i=0; i<nItems; i++) | 
 |  | { | 
 |  | if (SendMessage(hItem, CB_GETITEMDATA, (WPARAM)i, 0) == nNumber) | 
 |  | { | 
 |  | SendMessage(hItem, CB_SETCURSEL, (WPARAM)i, 0); | 
 |  | break; | 
 |  | } | 
 |  | } | 
 |  | } | 
 |  |  | 
 |  | int dlgs_getdroplistnumber(HWND hWnd, UINT uID) | 
 |  | { | 
 |  | HWND    hItem; | 
 |  | int             nPos; | 
 |  |  | 
 |  | hItem = GetDlgItem(hWnd, uID); | 
 |  | nPos = SendMessage(hItem, CB_GETCURSEL, 0, 0); | 
 |  | if (nPos >= 0) | 
 |  | { | 
 |  | return SendMessage(hItem, CB_GETITEMDATA, (WPARAM)nPos, 0); | 
 |  | } | 
 |  | return -1; | 
 |  | } | 
 |  |  | 
 |  |  | 
 | // ---- MIDIデバイスのリスト | // ---- MIDIデバイスのリスト | 
 |  |  | 
 | void dlgs_setlistmidiout(HWND hWnd, UINT16 res, const OEMCHAR *defname) { | void dlgs_setlistmidiout(HWND hWnd, UINT16 res, const OEMCHAR *defname) { | 
| Line 260  void dlgs_setlistmidiin(HWND hWnd, UINT1 | Line 353  void dlgs_setlistmidiin(HWND hWnd, UINT1 | 
 | } | } | 
 |  |  | 
 |  |  | 
 |  |  | 
 | // ---- draw | // ---- draw | 
 |  |  | 
 | void dlgs_drawbmp(HDC hdc, UINT8 *bmp) { | void dlgs_drawbmp(HDC hdc, UINT8 *bmp) { | 
| Line 299  dsdb_err1: | Line 393  dsdb_err1: | 
 | _MFREE(bmp); | _MFREE(bmp); | 
 | } | } | 
 |  |  | 
 |  |  | 
 |  | // ---- | 
 |  |  | 
 |  | BOOL dlgs_getitemrect(HWND hWnd, UINT uID, RECT *pRect) | 
 |  | { | 
 |  | HWND    hItem; | 
 |  | POINT   pt; | 
 |  |  | 
 |  | if (pRect == NULL) | 
 |  | { | 
 |  | return FALSE; | 
 |  | } | 
 |  | hItem = GetDlgItem(hWnd, uID); | 
 |  | if (!GetWindowRect(hItem, pRect)) | 
 |  | { | 
 |  | return FALSE; | 
 |  | } | 
 |  | ZeroMemory(&pt, sizeof(pt)); | 
 |  | if (!ClientToScreen(hWnd, &pt)) | 
 |  | { | 
 |  | return FALSE; | 
 |  | } | 
 |  | pRect->left -= pt.x; | 
 |  | pRect->top -= pt.y; | 
 |  | pRect->right -= pt.x; | 
 |  | pRect->bottom -= pt.y; | 
 |  | return TRUE; | 
 |  | } | 
 |  |  |