--- np2/win9x/dialog/dialogs.cpp 2005/03/20 23:48:03 1.9 +++ np2/win9x/dialog/dialogs.cpp 2007/10/26 14:38:34 1.11 @@ -9,6 +9,8 @@ #include "mt32snd.h" #endif +extern HINSTANCE hInst; + const TCHAR str_nc[] = _T("N/C"); @@ -20,19 +22,39 @@ const TCHAR str_int5[] = _T("INT5"); 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 BOOL dlgs_selectfile(HWND hWnd, const FILESEL *item, OEMCHAR *path, UINT size, int *ro) { + TCHAR *pszTitle; OPENFILENAME ofn; #if defined(OSLANG_UTF8) TCHAR _path[MAX_PATH]; #endif + BOOL bResult; if ((item == NULL) || (path == NULL) || (size == 0)) { return(FALSE); } + pszTitle = lockstringresource(hInst, item->title); + ZeroMemory(&ofn, sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hWnd; @@ -48,30 +70,38 @@ BOOL dlgs_selectfile(HWND hWnd, const FI #endif ofn.Flags = OFN_FILEMUSTEXIST; ofn.lpstrDefExt = item->ext; - ofn.lpstrTitle = item->title; - if (!GetOpenFileName(&ofn)) { - return(FALSE); - } + ofn.lpstrTitle = pszTitle; + + bResult = GetOpenFileName(&ofn); + unlockstringresource(pszTitle); + + if (bResult) { #if defined(OSLANG_UTF8) - tchartooem(path, NELEMENTS(path), _path, -1); + tchartooem(path, NELEMENTS(path), _path, -1); #endif - if (ro) { - *ro = ofn.Flags & OFN_READONLY; + if (ro) { + *ro = ofn.Flags & OFN_READONLY; + } } - return(TRUE); + return(bResult); } BOOL dlgs_selectwritefile(HWND hWnd, const FILESEL *item, OEMCHAR *path, UINT size) { OPENFILENAME ofn; + TCHAR *pszTitle; #if defined(OSLANG_UTF8) TCHAR _path[MAX_PATH]; #endif + BOOL bResult; if ((item == NULL) || (path == NULL) || (size == 0)) { return(FALSE); } + + pszTitle = lockstringresource(hInst, item->title); + ZeroMemory(&ofn, sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hWnd; @@ -87,14 +117,18 @@ BOOL dlgs_selectwritefile(HWND hWnd, con #endif ofn.Flags = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY; ofn.lpstrDefExt = item->ext; - ofn.lpstrTitle = item->title; - if (!GetSaveFileName(&ofn)) { - return(FALSE); - } + ofn.lpstrTitle = pszTitle; + + bResult = GetSaveFileName(&ofn); + + unlockstringresource(pszTitle); + #if defined(OSLANG_UTF8) - tchartooem(path, NELEMENTS(path), _path, -1); + if (bResult) { + tchartooem(path, NELEMENTS(path), _path, -1); + } #endif - return(TRUE); + return(bResult); } BOOL dlgs_selectwritenum(HWND hWnd, const FILESEL *item, @@ -172,7 +206,6 @@ void dlgs_setliststr(HWND hWnd, UINT16 r } void dlgs_setlistuint32(HWND hWnd, UINT16 res, const UINT32 *item, UINT items) { - HWND wnd; UINT i; OEMCHAR str[16]; @@ -185,6 +218,66 @@ 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= 0) + { + return SendMessage(hItem, CB_GETITEMDATA, (WPARAM)nPos, 0); + } + return -1; +} + + // ---- MIDIデバイスのリスト void dlgs_setlistmidiout(HWND hWnd, UINT16 res, const OEMCHAR *defname) { @@ -260,6 +353,7 @@ void dlgs_setlistmidiin(HWND hWnd, UINT1 } + // ---- draw void dlgs_drawbmp(HDC hdc, UINT8 *bmp) { @@ -299,3 +393,32 @@ dsdb_err1: _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; +} +