void w32g_setcur_playlist(void) { HWND hListBox; if(!(hListBox = playlist_box())) return; ListBox_SetCurSel(hListBox, playlist.selected); SetNumListWnd(playlist.selected,playlist.nfiles); }
int w32g_refine_playlist(int *is_selected_removed) { int nremoved; int i, j1, j2, cursel; HWND hListBox; hListBox = playlist_box(); if(hListBox) cursel = ListBox_GetCurSel(hListBox); else cursel = -1; if(is_selected_removed != NULL) *is_selected_removed = 0; nremoved = 0; j1 = j2 = 0; while(j2 < playlist.nfiles) /* j1 <= j2 */ { if(playlist.list[j2].info->format < 0) { nremoved++; free(playlist.list[j2].filename); if(j2 == playlist.selected && is_selected_removed != NULL && !*is_selected_removed) { *is_selected_removed = 1; playlist.selected = j1; } if(j2 < playlist.selected) playlist.selected--; if(j2 < cursel) cursel--; } else { playlist.list[j1] = playlist.list[j2]; j1++; } j2++; } if(nremoved) { for(i = 0; i < nremoved; i++) ListBox_DeleteString(hListBox, --playlist.nfiles); if(cursel >= playlist.nfiles) cursel = playlist.nfiles - 1; if(cursel >= 0){ ListBox_SetCurSel(hListBox, cursel); SetNumListWnd(cursel,playlist.nfiles); } w32g_update_playlist(); } return nremoved; }
int w32g_delete_playlist(int pos) { int i; HWND hListBox; if(!(hListBox = playlist_box())) return 0; if(pos >= playlist.nfiles) return 0; #ifdef W32G_RANDOM_IS_SHUFFLE w32g_shuffle_playlist_delete(pos); #endif ListBox_DeleteString(hListBox, pos); free(playlist.list[pos].filename); playlist.nfiles--; for(i = pos; i < playlist.nfiles; i++) playlist.list[i] = playlist.list[i + 1]; if(pos < playlist.selected || pos == playlist.nfiles) { playlist.selected--; if(playlist.selected < 0){ playlist.selected = 0; SetNumListWnd(playlist.selected,playlist.nfiles); } else w32g_update_playlist_pos(playlist.selected); } if(playlist.nfiles > 0) { if(pos == playlist.nfiles) pos--; ListBox_SetCurSel(hListBox, pos); SetNumListWnd(pos,playlist.nfiles); } return 1; }
void w32g_clear_playlist(void) { HWND hListBox; hListBox = playlist_box(); while(playlist.nfiles > 0) { playlist.nfiles--; free(playlist.list[playlist.nfiles].filename); #if 0 if(hListBox) ListBox_DeleteString(hListBox, playlist.nfiles); #endif } // LB_RESETCONTENT if(hListBox) ListBox_ResetContent(hListBox); playlist.selected = 0; SetNumListWnd(0,0); }
int w32g_uniq_playlist(int *is_selected_removed) { int nremoved; int i, n, j1, j2, cursel; HWND hListBox; hListBox = playlist_box(); if(hListBox) cursel = ListBox_GetCurSel(hListBox); else cursel = -1; if(is_selected_removed != NULL) *is_selected_removed = 0; nremoved = 0; n = playlist.nfiles; for(i = 0; i < n - 1; i++) { int save_n; /* remove list[i] from list[i+1 .. n-1] */ j1 = j2 = i + 1; save_n = n; while(j2 < save_n) /* j1 <= j2 */ { if(pathcmp(playlist.list[i].filename, playlist.list[j2].filename, 0) == 0) { nremoved++; n--; free(playlist.list[j2].filename); if(j2 == playlist.selected && is_selected_removed != NULL && !*is_selected_removed) { *is_selected_removed = 1; playlist.selected = j1; } if(j2 < playlist.selected) playlist.selected--; if(j2 < cursel) cursel--; } else { playlist.list[j1] = playlist.list[j2]; j1++; } j2++; } } if(nremoved) { for(i = 0; i < nremoved; i++) ListBox_DeleteString(hListBox, --playlist.nfiles); if(cursel >= 0){ ListBox_SetCurSel(hListBox, cursel); SetNumListWnd(cursel,playlist.nfiles); } w32g_update_playlist(); } return nremoved; }
void w32g_update_playlist(void) { #if 0 int i, cur, modified; HWND hListBox; if(!(hListBox = playlist_box())) return; cur = ListBox_GetCurSel(hListBox); modified = 0; for(i = 0; i < playlist.nfiles; i++) { char *filename, *title, *item1, *item2; int maxlen, item2_len; filename = playlist.list[i].filename; title = playlist.list[i].title; if(title == NULL || title[0] == '\0') { if(playlist.list[i].info->file_type == IS_ERROR_FILE) title = " --SKIP-- "; else title = " -------- "; } maxlen = strlen(filename) + strlen(title) + 32; item1 = (char *)new_segment(&tmpbuffer, maxlen); if(i == playlist.selected) snprintf(item1, maxlen, "==>%04d %s (%s)", i + 1, title, filename); else snprintf(item1, maxlen, " %04d %s (%s)", i + 1, title, filename); item2_len = ListBox_GetTextLen(hListBox, i); item2 = (char *)new_segment(&tmpbuffer, item2_len + 1); ListBox_GetText(hListBox, i, item2); if(strcmp(item1, item2) != 0) { ListBox_DeleteString(hListBox, i); ListBox_InsertString(hListBox, i, item1); modified = 1; } reuse_mblock(&tmpbuffer); } if(modified) { if(cur < 0) cur = playlist.selected; else if(cur >= playlist.nfiles - 1) cur = playlist.nfiles - 1; ListBox_SetCurSel(hListBox, cur); SetNumListWnd(cur,playlist.nfiles); } #else int i, cur, modified; HWND hListBox; if(!(hListBox = playlist_box())) return; cur = ListBox_GetCurSel(hListBox); modified = 0; for(i = 0; i < playlist.nfiles; i++) { w32g_update_playlist_pos(i); } if(modified) { if(cur < 0) cur = playlist.selected; else if(cur >= playlist.nfiles - 1) cur = playlist.nfiles - 1; ListBox_SetCurSel(hListBox, cur); SetNumListWnd(cur,playlist.nfiles); } #endif }
static BOOL CALLBACK ListWndProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam) { static BOOL ListSearchWndShow; switch (uMess){ case WM_INITDIALOG: ListSearchWndShow = 0; InitListSearchWnd(hwnd); SendDlgItemMessage(hwnd,IDC_LISTBOX_PLAYLIST, LB_SETHORIZONTALEXTENT,(WPARAM)LISTWND_HORIZONTALEXTENT,0); w32g_send_rc(RC_EXT_UPDATE_PLAYLIST, 0); SetWindowPosSize(GetDesktopWindow(),hwnd,ListWndInfo.PosX, ListWndInfo.PosY ); return FALSE; case WM_DESTROY: { RECT rc; GetWindowRect(hwnd,&rc); ListWndInfo.Width = rc.right - rc.left; ListWndInfo.Height = rc.bottom - rc.top; } DestroyMenu(ListWndInfo.hPopupMenu); ListWndInfo.hPopupMenu = NULL; INISaveListWnd(); break; /* マウス入力がキャプチャされていないための処理 */ case WM_SETCURSOR: switch(HIWORD(lParam)){ case WM_RBUTTONDOWN: if(LOWORD(lParam)!=HTCAPTION){ // タイトルバーにないとき POINT point; int res; GetCursorPos(&point); SetForegroundWindow ( hwnd ); res = TrackPopupMenu(ListWndInfo.hPopupMenu,TPM_TOPALIGN|TPM_LEFTALIGN, point.x,point.y,0,hwnd,NULL); PostMessage ( hwnd, WM_NULL, 0, 0 ); return TRUE; } break; default: break; } break; case WM_CHOOSEFONT_DIAG: { char fontName[64]; int fontHeight; int fontWidth; strcpy(fontName,ListWndInfo.fontName); fontHeight = ListWndInfo.fontHeight; fontWidth = ListWndInfo.fontWidth; if(DlgChooseFont(hwnd,fontName,&fontHeight,&fontWidth)==0){ ListWndSetFontListBox(fontName,fontWidth,fontHeight); } } break; case WM_LIST_SEARCH_DIAG: ShowListSearch(); break; case WM_COMMAND: switch (HIWORD(wParam)) { case IDCLOSE: ShowWindow(hwnd, SW_HIDE); MainWndUpdateListButton(); break; case LBN_DBLCLK: SendMessage(hwnd,WM_COMMAND,(WPARAM)IDM_LISTWND_PLAY,0); return FALSE; case LBN_SELCHANGE: { int idListBox = (int) LOWORD(wParam); HWND hwndListBox = (HWND) lParam; int selected, nfiles, cursel; w32g_get_playlist_index(&selected,&nfiles,&cursel); SetNumListWnd(cursel,nfiles); return FALSE; } default: break; } switch (LOWORD(wParam)) { case IDC_BUTTON_CLEAR: if(MessageBox(hListWnd,"Clear playlist?","Playlist", MB_YESNO)==IDYES) w32g_send_rc(RC_EXT_CLEAR_PLAYLIST, 0); return FALSE; case IDC_BUTTON_REFINE: if(MessageBox(hListWnd, "Remove unsupported file types from the playlist?", "Playlist",MB_YESNO) == IDYES) w32g_send_rc(RC_EXT_REFINE_PLAYLIST, 0); return FALSE; case IDC_BUTTON_UNIQ: if(MessageBox(hListWnd, "Remove the same files from the playlist and make files of the playlist unique?", "Playlist",MB_YESNO)==IDYES) w32g_send_rc(RC_EXT_UNIQ_PLAYLIST, 0); return FALSE; case IDM_LISTWND_REMOVE: w32g_send_rc(RC_EXT_DELETE_PLAYLIST, 0); break; case IDC_BUTTON_DOC: { int cursel; w32g_get_playlist_index(NULL, NULL, &cursel); w32g_send_rc(RC_EXT_OPEN_DOC, cursel); } break; case IDM_LISTWND_PLAY: { int new_cursel = SendDlgItemMessage(hwnd,IDC_LISTBOX_PLAYLIST,LB_GETCURSEL,0,0); int selected, nfiles, cursel; w32g_get_playlist_index(&selected, &nfiles, &cursel); if ( nfiles <= new_cursel ) new_cursel = nfiles - 1; if ( new_cursel >= 0 ) w32g_send_rc(RC_EXT_JUMP_FILE, new_cursel ); } return FALSE; case IDM_LISTWND_CHOOSEFONT: { SendMessage(hwnd,WM_CHOOSEFONT_DIAG,0,0); } return FALSE; case IDM_LISTWND_CURRENT: { int selected, nfiles, cursel; w32g_get_playlist_index(&selected, &nfiles, &cursel); SendDlgItemMessage(hwnd,IDC_LISTBOX_PLAYLIST, LB_SETCURSEL,(WPARAM)selected,0); SetNumListWnd(selected,nfiles); } return FALSE; case IDM_LISTWND_SEARCH: { SendMessage(hwnd,WM_LIST_SEARCH_DIAG,0,0); } return FALSE; default: break; } break; case WM_VKEYTOITEM: { UINT vkey = (UINT)LOWORD(wParam); int nCaretPos = (int)HIWORD(wParam); switch(vkey){ case VK_SPACE: case VK_RETURN: w32g_send_rc(RC_EXT_JUMP_FILE, nCaretPos); return -2; case 0x50: // VK_P SendMessage(hMainWnd,WM_COMMAND,MAKEWPARAM(IDM_PREV,0),0); return -2; case 0x4e: // VK_N SendMessage(hMainWnd,WM_COMMAND,MAKEWPARAM(IDM_NEXT,0),0); return -2; case 0x45: // VK_E SendMessage(hMainWnd,WM_COMMAND,MAKEWPARAM(IDM_STOP,0),0); return -2; case 0x53: // VK_S SendMessage(hMainWnd,WM_COMMAND,MAKEWPARAM(IDM_PAUSE,0),0); return -2; case VK_ESCAPE: SendMessage(hListWnd,WM_COMMAND,MAKEWPARAM(0,IDCLOSE),0); return -2; case 0x51: // VK_Q if(MessageBox(hListWnd,"Quit TiMidity?","TiMidity",MB_ICONQUESTION|MB_YESNO)==IDYES) SendMessage(hMainWnd,WM_CLOSE,0,0); return -2; case VK_BACK: w32g_send_rc(RC_EXT_DELETE_PLAYLIST, -1); return -2; case 0x44: // VK_D w32g_send_rc(RC_EXT_DELETE_PLAYLIST, 0); return -2; case VK_DELETE: w32g_send_rc(RC_EXT_ROTATE_PLAYLIST, -1); return -2; case VK_INSERT: w32g_send_rc(RC_EXT_ROTATE_PLAYLIST, 1); return -2; case 0x46: // VK_F return -2; case 0x42: // VK_B return -2; case 0x4D: // VK_M SendMessage(hListWnd,WM_COMMAND,MAKEWPARAM(IDC_BUTTON_REFINE,0),0); return -2; case 0x43: // VK_C SendMessage(hListWnd,WM_COMMAND,MAKEWPARAM(IDC_BUTTON_CLEAR,0),0); return -2; case 0x55: // VK_U SendMessage(hListWnd,WM_COMMAND,MAKEWPARAM(IDC_BUTTON_UNIQ,0),0); return -2; case 0x56: // VK_V SendMessage(hListWnd,WM_COMMAND,MAKEWPARAM(IDC_BUTTON_DOC,0),0); return -2; case 0x57: // VK_W SendMessage(hMainWnd,WM_COMMAND,MAKEWPARAM(IDM_WRD,0),0); return -2; case VK_F1: case 0x48: // VK_H if ( PlayerLanguage == LANGUAGE_JAPANESE ){ MessageBox(hListWnd, "キーコマンド\n" "リストウインドウコマンド\n" " ESC: ヘルプを閉じる H: ヘルプを出す\n" " V: ドキュメントを見る W: WRD ウインドウを開く\n" "プレイヤーコマンド\n" " SPACE/ENTER: 演奏開始 E: 停止 S: 一時停止\n" " P: 前の曲 N: 次の曲\n" "プレイリスト操作コマンド\n" " M: MIDIファイル以外を削除 U: 重複ファイルを削除\n" " C: プレイリストのクリア\n" " D: カーソルの曲を削除 BS: カーソルの前の曲を削除\n" " INS: カーソルの曲をリストの最後に移す (Push)\n" " DEL: リストの最後の曲をカーソルの前に挿入 (Pop)\n" "TiMidity コマンド\n" " Q: 終了\n" ,"ヘルプ", MB_OK); } else { MessageBox(hListWnd, "Usage of key.\n" "List window command.\n" " ESC: Close Help H: Help\n" " V: View Document W: Open WRD window\n" "Player command.\n" " SPACE/ENTER: PLAY E: Stop S: Pause\n" " P: Prev N: Next\n" "Playlist command.\n" " M: Refine playlist U: Uniq playlist\n" " C: Clear playlist\n" " D: Remove playlist BS: Remove previous playlist\n" " INS: Push Playlist DEL: Pop Playlist\n" "TiMidity command.\n" " Q: Quit\n" ,"Help", MB_OK); } return -2; default: break; } return -1; } case WM_SIZE: switch(wParam){ case SIZE_MAXIMIZED: case SIZE_RESTORED: { // なんか意味なく面倒(^^;; int x,y,cx,cy; int maxHeight = 0; int center, idControl; HWND hwndChild; RECT rcParent, rcChild, rcRest; int nWidth = LOWORD(lParam); int nHeight = HIWORD(lParam); GetWindowRect(hwnd,&rcParent); cx = rcParent.right-rcParent.left; cy = rcParent.bottom-rcParent.top; if(cx < 380) MoveWindow(hwnd,rcParent.left,rcParent.top,380,cy,TRUE); if(cy < 200) MoveWindow(hwnd,rcParent.left,rcParent.top,cx,200,TRUE); GetClientRect(hwnd,&rcParent); rcRest.left = rcParent.left; rcRest.right = rcParent.right; // IDC_EDIT_NUM idControl = IDC_EDIT_NUM; hwndChild = GetDlgItem(hwnd,idControl); GetWindowRect(hwndChild,&rcChild); cx = rcChild.right-rcChild.left; cy = rcChild.bottom-rcChild.top; x = rcParent.left; y = rcParent.bottom - cy; MoveWindow(hwndChild,x,y,cx,cy,TRUE); if(cy>maxHeight) maxHeight = cy; rcRest.left += cx; // IDC_BUTTON_DOC idControl = IDC_BUTTON_DOC; hwndChild = GetDlgItem(hwnd,idControl); GetWindowRect(hwndChild,&rcChild); cx = rcChild.right-rcChild.left; cy = rcChild.bottom-rcChild.top; x = rcRest.left + 10; y = rcParent.bottom - cy; MoveWindow(hwndChild,x,y,cx,cy,TRUE); if(cy>maxHeight) maxHeight = cy; rcRest.left += cx; // IDC_BUTTON_CLEAR idControl = IDC_BUTTON_CLEAR; hwndChild = GetDlgItem(hwnd,idControl); GetWindowRect(hwndChild,&rcChild); cx = rcChild.right-rcChild.left; cy = rcChild.bottom-rcChild.top; x = rcParent.right - cx - 5; y = rcParent.bottom - cy ; MoveWindow(hwndChild,x,y,cx,cy,TRUE); if(cy>maxHeight) maxHeight = cy; rcRest.right -= cx + 5; // IDC_BUTTON_UNIQ center = rcRest.left + (int)((rcRest.right - rcRest.left)*0.52); idControl = IDC_BUTTON_UNIQ; hwndChild = GetDlgItem(hwnd,idControl); GetWindowRect(hwndChild,&rcChild); cx = rcChild.right-rcChild.left; cy = rcChild.bottom-rcChild.top; x = center - cx; y = rcParent.bottom - cy; MoveWindow(hwndChild,x,y,cx,cy,TRUE); if(cy>maxHeight) maxHeight = cy; // IDC_BUTTON_REFINE idControl = IDC_BUTTON_REFINE; hwndChild = GetDlgItem(hwnd,idControl); GetWindowRect(hwndChild,&rcChild); cx = rcChild.right-rcChild.left; cy = rcChild.bottom-rcChild.top; x = center + 3; y = rcParent.bottom - cy; MoveWindow(hwndChild,x,y,cx,cy,TRUE); if(cy>maxHeight) maxHeight = cy; // IDC_LISTBOX_PLAYLIST idControl = IDC_LISTBOX_PLAYLIST; hwndChild = GetDlgItem(hwnd,idControl); cx = rcParent.right - rcParent.left; cy = rcParent.bottom - rcParent.top - maxHeight - 3; x = rcParent.left; y = rcParent.top; MoveWindow(hwndChild,x,y,cx,cy,TRUE); InvalidateRect(hwnd,&rcParent,FALSE); UpdateWindow(hwnd); GetWindowRect(hwnd,&rcParent); ListWndInfo.Width = rcParent.right - rcParent.left; ListWndInfo.Height = rcParent.bottom - rcParent.top; break; } case SIZE_MINIMIZED: case SIZE_MAXHIDE: case SIZE_MAXSHOW: default: break; } break; case WM_MOVE: // ListWndInfo.PosX = (int) LOWORD(lParam); // ListWndInfo.PosY = (int) HIWORD(lParam); { RECT rc; GetWindowRect(hwnd,&rc); ListWndInfo.PosX = rc.left; ListWndInfo.PosY = rc.top; } break; // See PreDispatchMessage() in w32g2_main.c case WM_SYSKEYDOWN: case WM_KEYDOWN: { int nVirtKey = (int)wParam; switch(nVirtKey){ case VK_ESCAPE: SendMessage(hwnd,WM_CLOSE,0,0); break; } } break; case WM_CLOSE: ShowSubWindow(hListWnd,0); // ShowWindow(hListWnd, SW_HIDE); MainWndUpdateListButton(); break; case WM_SHOWWINDOW: { BOOL fShow = (BOOL)wParam; if ( fShow ) { if ( ListSearchWndShow ) { ShowListSearch(); } else { HideListSearch(); } } else { if ( IsWindowVisible ( hListSearchWnd ) ) ListSearchWndShow = TRUE; else ListSearchWndShow = FALSE; HideListSearch(); } } break; case WM_DROPFILES: SendMessage(hMainWnd,WM_DROPFILES,wParam,lParam); return 0; default: return FALSE; } return FALSE; }
BOOL CALLBACK ListSearchWndProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam) { switch (uMess){ case WM_INITDIALOG: switch(PlayerLanguage){ case LANGUAGE_JAPANESE: SendMessage(hwnd,WM_SETTEXT,0,(LPARAM)"プレイリストの検索"); SendMessage(GetDlgItem(hwnd,IDC_STATIC_HEAD),WM_SETTEXT,0,(LPARAM)"検索キーワードを入れてください。"); SendMessage(GetDlgItem(hwnd,IDC_STATIC_TAIL),WM_SETTEXT,0,(LPARAM)""); SendMessage(GetDlgItem(hwnd,IDC_BUTTON_1),WM_SETTEXT,0,(LPARAM)"検索"); SendMessage(GetDlgItem(hwnd,IDC_BUTTON_2),WM_SETTEXT,0,(LPARAM)"次を検索"); SendMessage(GetDlgItem(hwnd,IDC_BUTTON_3),WM_SETTEXT,0,(LPARAM)"閉じる"); break; default: case LANGUAGE_ENGLISH: SendMessage(hwnd,WM_SETTEXT,0,(LPARAM)"Playlist Search"); SendMessage(GetDlgItem(hwnd,IDC_STATIC_HEAD),WM_SETTEXT,0,(LPARAM)"Enter search keyword."); SendMessage(GetDlgItem(hwnd,IDC_STATIC_TAIL),WM_SETTEXT,0,(LPARAM)""); SendMessage(GetDlgItem(hwnd,IDC_BUTTON_1),WM_SETTEXT,0,(LPARAM)"SEACH"); SendMessage(GetDlgItem(hwnd,IDC_BUTTON_2),WM_SETTEXT,0,(LPARAM)"NEXT SEARCH"); SendMessage(GetDlgItem(hwnd,IDC_BUTTON_3),WM_SETTEXT,0,(LPARAM)"CLOSE"); break; } return FALSE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDCLOSE: ShowWindow(hwnd, SW_HIDE); break; case IDC_BUTTON_1: case IDC_BUTTON_2: { int selected, nfiles, cursel; SendDlgItemMessage(hwnd,IDC_EDIT_ONE_LINE, WM_GETTEXT,(WPARAM)250,(LPARAM)ListSearchString); w32g_get_playlist_index(&selected, &nfiles, &cursel); if ( LOWORD(wParam) == IDC_BUTTON_2 ) cursel++; if ( strlen ( ListSearchString ) > 0 ) { char buff[ListSearchStringBuffSize]; for ( ; cursel < nfiles; cursel ++ ) { int result = SendDlgItemMessage(hListWnd,IDC_LISTBOX_PLAYLIST, LB_GETTEXTLEN,(WPARAM)cursel, 0 ); if ( result < ListSearchStringBuffSize ) { result = SendDlgItemMessage(hListWnd,IDC_LISTBOX_PLAYLIST, LB_GETTEXT,(WPARAM)cursel,(LPARAM)buff); if ( result == LB_ERR ) { cursel = LB_ERR; break; } if ( strstr ( buff, ListSearchString ) != NULL ) { break; } } else if ( result == LB_ERR ) { cursel = LB_ERR; break; } } if ( cursel >= nfiles ) { cursel = LB_ERR; } } else { cursel = LB_ERR; } if ( cursel != LB_ERR ) { SendDlgItemMessage(hListWnd,IDC_LISTBOX_PLAYLIST, LB_SETCURSEL,(WPARAM)cursel,0); SetNumListWnd(cursel,nfiles); if ( LOWORD(wParam) == IDC_BUTTON_1 ) HideListSearch(); } } break; case IDC_BUTTON_3: HideListSearch(); break; default: return FALSE; } break; case WM_CLOSE: ShowWindow(hListSearchWnd, SW_HIDE); break; default: return FALSE; } return FALSE; }
static BOOL CALLBACK ListWndProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam) { switch (uMess){ case WM_INITDIALOG: SendDlgItemMessage(hwnd,IDC_LISTBOX_PLAYLIST, LB_SETHORIZONTALEXTENT,(WPARAM)1600,0); w32g_send_rc(RC_EXT_UPDATE_PLAYLIST, 0); return FALSE; case WM_DESTROY: INISaveListWnd(); break; /* マウス入力がキャプチャされていないための処理 */ case WM_SETCURSOR: switch(HIWORD(lParam)){ case WM_RBUTTONDOWN: { POINT point; GetCursorPos(&point); TrackPopupMenu(ListWndInfo.hPopupMenu,TPM_TOPALIGN|TPM_LEFTALIGN, point.x,point.y,0,hwnd,NULL); } break; default: break; } break; case WM_COMMAND: switch (HIWORD(wParam)) { case IDCLOSE: ShowWindow(hwnd, SW_HIDE); MainWndUpdateListButton(); break; case LBN_DBLCLK: SendMessage(hwnd,WM_COMMAND,(WPARAM)IDM_LISTWND_PLAY,0); return FALSE; case LBN_SELCHANGE: { int idListBox = (int) LOWORD(wParam); HWND hwndListBox = (HWND) lParam; int selected, nfiles, cursel; w32g_get_playlist_index(&selected,&nfiles,&cursel); SetNumListWnd(cursel,nfiles); return FALSE; } default: break; } switch (LOWORD(wParam)) { case IDC_BUTTON_CLEAR: if(MessageBox(hListWnd,"Clear playlist?","Playlist", MB_YESNO)==IDYES) w32g_send_rc(RC_EXT_CLEAR_PLAYLIST, 0); return FALSE; case IDC_BUTTON_REFINE: if(MessageBox(hListWnd, "Remove unsupported file types from the playlist?", "Playlist",MB_YESNO) == IDYES) w32g_send_rc(RC_EXT_REFINE_PLAYLIST, 0); return FALSE; case IDC_BUTTON_UNIQ: if(MessageBox(hListWnd, "Remove the same files from the playlist and make files of the playlist unique?", "Playlist",MB_YESNO)==IDYES) w32g_send_rc(RC_EXT_UNIQ_PLAYLIST, 0); return FALSE; case IDM_LISTWND_REMOVE: w32g_send_rc(RC_EXT_DELETE_PLAYLIST, 0); break; case IDC_BUTTON_DOC: { int cursel; w32g_get_playlist_index(NULL, NULL, &cursel); w32g_send_rc(RC_EXT_OPEN_DOC, cursel); } break; case IDM_LISTWND_PLAY: { HWND hListBox = GetDlgItem(hListWnd, IDC_LISTBOX_PLAYLIST); if(hListBox) w32g_send_rc(RC_EXT_JUMP_FILE, ListBox_GetCurSel(hListBox)); } return FALSE; case IDM_LISTWND_CHOOSEFONT: { char fontName[64]; int fontHeight; int fontWidth; strcpy(fontName,ListWndInfo.fontName); fontHeight = ListWndInfo.fontHeight; fontWidth = ListWndInfo.fontWidth; if(DlgChooseFont(hwnd,fontName,&fontHeight,&fontWidth)==0){ ListWndSetFontListBox(fontName,fontWidth,fontHeight); } } return FALSE; default: break; } break; case WM_VKEYTOITEM: { UINT vkey = (UINT)LOWORD(wParam); int nCaretPos = (int)HIWORD(wParam); switch(vkey){ case VK_SPACE: case VK_RETURN: w32g_send_rc(RC_EXT_JUMP_FILE, nCaretPos); return -2; case 0x50: // VK_P SendMessage(hMainWnd,WM_COMMAND,MAKEWPARAM(IDM_PREV,0),0); return -2; case 0x4e: // VK_N SendMessage(hMainWnd,WM_COMMAND,MAKEWPARAM(IDM_NEXT,0),0); return -2; case 0x45: // VK_E SendMessage(hMainWnd,WM_COMMAND,MAKEWPARAM(IDM_STOP,0),0); return -2; case 0x53: // VK_S SendMessage(hMainWnd,WM_COMMAND,MAKEWPARAM(IDM_PAUSE,0),0); return -2; case VK_ESCAPE: SendMessage(hListWnd,WM_COMMAND,MAKEWPARAM(0,IDCLOSE),0); return -2; case 0x51: // VK_Q if(MessageBox(hListWnd,"Quit TiMidity?","TiMidity",MB_ICONQUESTION|MB_YESNO)==IDYES) SendMessage(hMainWnd,WM_CLOSE,0,0); return -2; case VK_BACK: w32g_send_rc(RC_EXT_DELETE_PLAYLIST, -1); return -2; case 0x44: // VK_D w32g_send_rc(RC_EXT_DELETE_PLAYLIST, 0); return -2; case VK_DELETE: w32g_send_rc(RC_EXT_ROTATE_PLAYLIST, -1); return -2; case VK_INSERT: w32g_send_rc(RC_EXT_ROTATE_PLAYLIST, 1); return -2; case 0x46: // VK_F return -2; case 0x42: // VK_B return -2; case 0x4D: // VK_M SendMessage(hListWnd,WM_COMMAND,MAKEWPARAM(IDC_BUTTON_REFINE,0),0); return -2; case 0x43: // VK_C SendMessage(hListWnd,WM_COMMAND,MAKEWPARAM(IDC_BUTTON_CLEAR,0),0); return -2; case 0x55: // VK_U SendMessage(hListWnd,WM_COMMAND,MAKEWPARAM(IDC_BUTTON_UNIQ,0),0); return -2; case 0x56: // VK_V SendMessage(hListWnd,WM_COMMAND,MAKEWPARAM(IDC_BUTTON_DOC,0),0); return -2; case VK_F1: case 0x48: // VK_H MessageBox(hListWnd, "Usage of key.\n" "List window command.\n" " ESC: Close Help H: Help\n" " V: View Document\n" "Player command.\n" " SPACE/ENTER: PLAY E: Stop S: Pause\n" " P: Prev N: Next\n" "Playlist command.\n" " M: Refine playlist U: Uniq playlist\n" " C: Clear playlist\n" " D: Remove playlist BS: Remove previous playlist\n" " INS: Push Playlist DEL: Pop Playlist\n" "TiMidity command.\n" " Q: Quit\n" ,"Help", MB_OK); return -2; default: break; } return -1; } case WM_SIZE: switch(wParam){ case SIZE_MAXIMIZED: case SIZE_RESTORED: { // なんか意味なく面倒(^^;; int x,y,cx,cy; int maxHeight = 0; int center, idControl; HWND hwndChild; RECT rcParent, rcChild, rcRest; int nWidth = LOWORD(lParam); int nHeight = HIWORD(lParam); GetWindowRect(hwnd,&rcParent); cx = rcParent.right-rcParent.left; cy = rcParent.bottom-rcParent.top; if(cx < 380) MoveWindow(hwnd,rcParent.left,rcParent.top,380,cy,TRUE); if(cy < 200) MoveWindow(hwnd,rcParent.left,rcParent.top,cx,200,TRUE); GetClientRect(hwnd,&rcParent); rcRest.left = rcParent.left; rcRest.right = rcParent.right; // IDC_EDIT_NUM idControl = IDC_EDIT_NUM; hwndChild = GetDlgItem(hwnd,idControl); GetWindowRect(hwndChild,&rcChild); cx = rcChild.right-rcChild.left; cy = rcChild.bottom-rcChild.top; x = rcParent.left; y = rcParent.bottom - cy; MoveWindow(hwndChild,x,y,cx,cy,TRUE); if(cy>maxHeight) maxHeight = cy; rcRest.left += cx; // IDC_BUTTON_DOC idControl = IDC_BUTTON_DOC; hwndChild = GetDlgItem(hwnd,idControl); GetWindowRect(hwndChild,&rcChild); cx = rcChild.right-rcChild.left; cy = rcChild.bottom-rcChild.top; x = rcRest.left + 10; y = rcParent.bottom - cy; MoveWindow(hwndChild,x,y,cx,cy,TRUE); if(cy>maxHeight) maxHeight = cy; rcRest.left += cx; // IDC_BUTTON_CLEAR idControl = IDC_BUTTON_CLEAR; hwndChild = GetDlgItem(hwnd,idControl); GetWindowRect(hwndChild,&rcChild); cx = rcChild.right-rcChild.left; cy = rcChild.bottom-rcChild.top; x = rcParent.right - cx - 5; y = rcParent.bottom - cy ; MoveWindow(hwndChild,x,y,cx,cy,TRUE); if(cy>maxHeight) maxHeight = cy; rcRest.right -= cx + 5; // IDC_BUTTON_UNIQ center = rcRest.left + (int)((rcRest.right - rcRest.left)*0.52); idControl = IDC_BUTTON_UNIQ; hwndChild = GetDlgItem(hwnd,idControl); GetWindowRect(hwndChild,&rcChild); cx = rcChild.right-rcChild.left; cy = rcChild.bottom-rcChild.top; x = center - cx; y = rcParent.bottom - cy; MoveWindow(hwndChild,x,y,cx,cy,TRUE); if(cy>maxHeight) maxHeight = cy; // IDC_BUTTON_REFINE idControl = IDC_BUTTON_REFINE; hwndChild = GetDlgItem(hwnd,idControl); GetWindowRect(hwndChild,&rcChild); cx = rcChild.right-rcChild.left; cy = rcChild.bottom-rcChild.top; x = center + 3; y = rcParent.bottom - cy; MoveWindow(hwndChild,x,y,cx,cy,TRUE); if(cy>maxHeight) maxHeight = cy; // IDC_LISTBOX_PLAYLIST idControl = IDC_LISTBOX_PLAYLIST; hwndChild = GetDlgItem(hwnd,idControl); cx = rcParent.right - rcParent.left; cy = rcParent.bottom - rcParent.top - maxHeight - 3; x = rcParent.left; y = rcParent.top; MoveWindow(hwndChild,x,y,cx,cy,TRUE); InvalidateRect(hwnd,&rcParent,FALSE); UpdateWindow(hwnd); GetWindowRect(hwnd,&rcParent); ListWndInfo.Width = rcParent.right - rcParent.left; ListWndInfo.Height = rcParent.bottom - rcParent.top; break; } case SIZE_MINIMIZED: case SIZE_MAXHIDE: case SIZE_MAXSHOW: default: break; } break; // See PreDispatchMessage() in w32g2_main.c case WM_SYSKEYDOWN: case WM_KEYDOWN: { int nVirtKey = (int)wParam; switch(nVirtKey){ case VK_ESCAPE: SendMessage(hwnd,WM_CLOSE,0,0); break; } } break; case WM_CLOSE: ShowSubWindow(hListWnd,0); // ShowWindow(hListWnd, SW_HIDE); MainWndUpdateListButton(); break; case WM_DROPFILES: SendMessage(hMainWnd,WM_DROPFILES,wParam,lParam); return 0; default: return FALSE; } return FALSE; }