Esempio n. 1
0
BOOL CALLBACK info_dialog_proc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    faadAACInfo format;
    char *tmp_string;
    char info[1024];
    LV_COLUMN lvc;
    BOOL bResult;

    switch (message) {
    case WM_INITDIALOG:
        /* Set up the list control for the ID3 tag */
        
        /* Initialize the LV_COLUMN structure. */
        lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
        lvc.fmt = LVCFMT_LEFT;

        /* Add the columns. */
        lvc.iSubItem = 0;
        lvc.cx = 100;
        lvc.pszText = "Frame";
        ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_ID3LIST), 0, &lvc);
        lvc.iSubItem = 1;
        lvc.cx = 250;
        lvc.pszText = "Data";
        ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_ID3LIST), 1, &lvc);

        /* get AAC info */
        get_AAC_format(info_fn, &format, NULL, NULL, 1);

        switch(format.headertype)
        {
        case 0: /* Headerless */
            tmp_string = "RAW"; break;
        case 1: /* ADIF */
            tmp_string = "ADIF"; break;
        case 2: /* ADTS */
            tmp_string = "ADTS"; break;
        }
        SetDlgItemText(hwndDlg, IDC_HEADER, tmp_string);

        if (format.object_type == 0 /* Main */)
            tmp_string = "Main";
        else if (format.object_type == 1 /* Low Complexity */)
            tmp_string = "Low Complexity";
        else if (format.object_type == 2 /* SSR */)
            tmp_string = "SSR (unsupported)";
        else if (format.object_type == 3 /* LTP */)
            tmp_string = "Main LTP";
        SetDlgItemText(hwndDlg, IDC_PROFILE, tmp_string);

        if (format.version == 2) tmp_string = "MPEG2";
        else tmp_string = "MPEG4";
        SetDlgItemText(hwndDlg, IDC_VERSION, tmp_string);

        wsprintf(info, "%d bps", format.bitrate);
        SetDlgItemText(hwndDlg, IDC_BITRATE, info);

        wsprintf(info, "%d Hz", format.sampling_rate);
        SetDlgItemText(hwndDlg, IDC_SAMPLERATE, info);

        wsprintf(info, "%d ch", format.channels);
        SetDlgItemText(hwndDlg, IDC_CHANNELS, info);

        FillID3List(hwndDlg, GetDlgItem(hwndDlg, IDC_ID3LIST), info_fn);
        if (ListView_GetItemCount(GetDlgItem(hwndDlg, IDC_ID3LIST)) == 0)
            EnableWindow(GetDlgItem(hwndDlg, IDC_ID3V2TAG), FALSE);
        else
            EnableCheckbox(GetDlgItem(hwndDlg, IDC_ID3V2TAG), TRUE, TRUE);
        bFileChanged = FALSE;

        return TRUE;

    case WM_NOTIFY:
        
        /* Branch depending on the specific notification message. */
        switch (((LPNMHDR) lParam)->code) { 
            
        /* Process LVN_GETDISPINFO to supply information about */
        /* callback items. */
        case LVN_GETDISPINFO:
            List_OnGetDispInfo((LV_DISPINFO *)lParam);
            break;
        case NM_DBLCLK:
            bResult = List_EditData(hwndDlg, GetDlgItem(hwndDlg, IDC_ID3LIST));
            if (bResult)
                EnableCheckbox(GetDlgItem(hwndDlg, IDC_ID3V2TAG), TRUE, TRUE);
            bFileChanged = bFileChanged ? bFileChanged : bResult;
            break;
        }
        return TRUE;

    case WM_COMMAND:
        switch (LOWORD(wParam)) {
        case IDC_ADDSTFRAMES:
            bResult = List_AddStandardFrames(hwndDlg, GetDlgItem(hwndDlg, IDC_ID3LIST));
            if (bResult)
                EnableCheckbox(GetDlgItem(hwndDlg, IDC_ID3V2TAG), TRUE, TRUE);
            bFileChanged = bFileChanged ? bFileChanged : bResult;
            return TRUE;
        case IDC_ADDFRAME:
            bResult = List_AddFrame(hwndDlg, GetDlgItem(hwndDlg, IDC_ID3LIST));
            if (bResult)
                EnableCheckbox(GetDlgItem(hwndDlg, IDC_ID3V2TAG), TRUE, TRUE);
            bFileChanged = bFileChanged ? bFileChanged : bResult;
            return TRUE;
        case IDC_DELFRAME:
            bResult = List_DeleteSelected(hwndDlg, GetDlgItem(hwndDlg, IDC_ID3LIST));
            if (ListView_GetItemCount(GetDlgItem(hwndDlg, IDC_ID3LIST)) == 0)
                EnableCheckbox(GetDlgItem(hwndDlg, IDC_ID3V2TAG), FALSE, FALSE);
            bFileChanged = bFileChanged ? bFileChanged : bResult;
            return TRUE;
        case IDC_EDITFRAME:
            bResult = List_EditData(hwndDlg, GetDlgItem(hwndDlg, IDC_ID3LIST));
            if (bResult)
                EnableCheckbox(GetDlgItem(hwndDlg, IDC_ID3V2TAG), TRUE, TRUE);
            bFileChanged = bFileChanged ? bFileChanged : bResult;
            return TRUE;
        case IDC_ID3V2TAG:
            bFileChanged = TRUE;
            return TRUE;

        case IDC_CLOSE:
        case IDCANCEL:
            if (bFileChanged == TRUE) {
                if (MessageBox(hwndDlg, "Save changes?", "Save changes", MB_YESNO) == IDYES)
                    List_SaveID3(hwndDlg, GetDlgItem(hwndDlg, IDC_ID3LIST), info_fn);
            }
            EndDialog(hwndDlg, wParam);
            return TRUE;
        }
    }
    return FALSE;
}
Esempio n. 2
0
BOOL CALLBACK DlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    DWORD fdwMenu;
    LV_COLUMN lvc;
    BOOL bResult;
    int iFiles, i;
    char fileName[_MAX_PATH];
    struct FileDlgData *files;

    switch (message) {
    case WM_INITDIALOG:
        SendMessage(hwndDlg,WM_SETICON,(WPARAM)ICON_SMALL,(LPARAM)LoadIcon(hInstance_for_id3editor,MAKEINTRESOURCE(IDI_ICON)));
        SendMessage(GetDlgItem(hwndDlg, IDC_SETGENERAL), BM_SETCHECK, BST_CHECKED, 0);

        EnableWindow(GetDlgItem(hwndDlg, IDC_ID3V2TAG), FALSE);
        EnableWindow(GetDlgItem(hwndDlg, IDC_BACKFILE), FALSE);
        EnableWindow(GetDlgItem(hwndDlg, IDC_NEXTFILE), FALSE);

        /* Set up the list control for the ID3 tag */        
        /* Initialize the LV_COLUMN structure. */
        lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
        lvc.fmt = LVCFMT_LEFT;

        /* Add the columns. */
        lvc.iSubItem = 0;
        lvc.cx = 85;
        lvc.pszText = "Frame";
        ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_ID3LIST), 0, &lvc);
        lvc.iSubItem = 1;
        lvc.cx = 325;
        lvc.pszText = "Data";
        ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_ID3LIST), 1, &lvc);

        lvc.iSubItem = 0;
        lvc.cx = 75;
        lvc.pszText = "Frame";
        ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_GENFRAMES), 0, &lvc);
        lvc.iSubItem = 1;
        lvc.cx = 160;
        lvc.pszText = "Data";
        ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_GENFRAMES), 1, &lvc);
        return TRUE;

    case WM_DROPFILES:
        CloseID3File(hwndDlg, fileIndex);

        iFiles = DragQueryFile((HDROP)wParam, 0xFFFFFFFF, (LPSTR)fileName, _MAX_PATH - 1);
        if (iFiles > 0)
            fileSet = TRUE;

        files = &dat;
        FreeFilesMatrix(&files->files);
        fileIndex = 0;
        dat.files=(char**)malloc((iFiles+1)*sizeof(char*));
        dat.fileCount = iFiles;

        for (i = 0; i < iFiles; i++)
        {
            int len;
            if (len = DragQueryFile((HDROP)wParam, i, (LPSTR)fileName, _MAX_PATH - 1))
            {
                dat.files[i]=malloc(len+1);
                CopyMemory(dat.files[i],fileName,len+1);
            }
        }

        DragFinish((HDROP)wParam);
        SetWindowText(GetDlgItem(hwndDlg, IDC_FILENAME), dat.files[fileIndex]);
        CopyList(hwndDlg, GetDlgItem(hwndDlg, IDC_GENFRAMES), GetDlgItem(hwndDlg, IDC_ID3LIST));
        FillID3List(hwndDlg, GetDlgItem(hwndDlg, IDC_ID3LIST), dat.files[fileIndex]);
        EnableWindow(GetDlgItem(hwndDlg, IDC_BACKFILE), FALSE);
        if (dat.fileCount > 1)
            EnableWindow(GetDlgItem(hwndDlg, IDC_NEXTFILE), TRUE);
        else
            EnableWindow(GetDlgItem(hwndDlg, IDC_NEXTFILE), FALSE);
        return FALSE;

    case WM_NOTIFY:
        
        /* Branch depending on the specific notification message. */
        switch (((LPNMHDR) lParam)->code) { 
            
        /* Process LVN_GETDISPINFO to supply information about */
        /* callback items. */
        case LVN_GETDISPINFO:
            List_OnGetDispInfo((LV_DISPINFO *)lParam);
            break;
        case NM_DBLCLK:
            /* Fix so that it works for the general list tooo */
            bResult = List_EditData(hwndDlg, GetDlgItem(hwndDlg, IDC_ID3LIST));
            if (bResult)
                EnableCheckbox(GetDlgItem(hwndDlg, IDC_ID3V2TAG), TRUE, TRUE);
            bFileChanged = bFileChanged ? bFileChanged : bResult;
            break;
        }
        return TRUE;

    case WM_COMMAND:
        switch (LOWORD(wParam)) {
        case IDC_ADDSTFRAMES:
            if (SendMessage(GetDlgItem(hwndDlg, IDC_SETGENERAL), BM_GETCHECK, 0, 0) == BST_CHECKED) {
                List_AddStandardFrames(hwndDlg, GetDlgItem(hwndDlg, IDC_GENFRAMES));
                return TRUE;
            }
            bResult = List_AddStandardFrames(hwndDlg, GetDlgItem(hwndDlg, IDC_ID3LIST));
            if (bResult)
                EnableCheckbox(GetDlgItem(hwndDlg, IDC_ID3V2TAG), TRUE, TRUE);
            bFileChanged = bFileChanged ? bFileChanged : bResult;
            return TRUE;
        case IDC_ADDFRAME:
            if (SendMessage(GetDlgItem(hwndDlg, IDC_SETGENERAL), BM_GETCHECK, 0, 0) == BST_CHECKED) {
                List_AddFrame(hwndDlg, GetDlgItem(hwndDlg, IDC_GENFRAMES));
                return TRUE;
            }
            bResult = List_AddFrame(hwndDlg, GetDlgItem(hwndDlg, IDC_ID3LIST));
            if (bResult)
                EnableCheckbox(GetDlgItem(hwndDlg, IDC_ID3V2TAG), TRUE, TRUE);
            bFileChanged = bFileChanged ? bFileChanged : bResult;
            return TRUE;
        case IDC_DELFRAME:
            if (SendMessage(GetDlgItem(hwndDlg, IDC_SETGENERAL), BM_GETCHECK, 0, 0) == BST_CHECKED) {
                List_DeleteSelected(hwndDlg, GetDlgItem(hwndDlg, IDC_GENFRAMES));
                return TRUE;
            }
            bResult = List_DeleteSelected(hwndDlg, GetDlgItem(hwndDlg, IDC_ID3LIST));
            if (ListView_GetItemCount(GetDlgItem(hwndDlg, IDC_ID3LIST)) == 0)
                EnableCheckbox(GetDlgItem(hwndDlg, IDC_ID3V2TAG), FALSE, FALSE);
            bFileChanged = bFileChanged ? bFileChanged : bResult;
            return TRUE;
        case IDC_EDITFRAME:
            if (SendMessage(GetDlgItem(hwndDlg, IDC_SETGENERAL), BM_GETCHECK, 0, 0) == BST_CHECKED) {
                List_EditData(hwndDlg, GetDlgItem(hwndDlg, IDC_GENFRAMES));
                return TRUE;
            }
            bResult = List_EditData(hwndDlg, GetDlgItem(hwndDlg, IDC_ID3LIST));
            if (bResult)
                EnableCheckbox(GetDlgItem(hwndDlg, IDC_ID3V2TAG), TRUE, TRUE);
            bFileChanged = bFileChanged ? bFileChanged : bResult;
            return TRUE;
        case IDC_ID3V2TAG:
            bFileChanged = TRUE;
            return TRUE;

        case IDC_OPEN_FILE:
            OpenID3FileDlg(hwndDlg, fileIndex);
            return TRUE;

        case IDC_CLOSE_FILE:
            CloseID3File(hwndDlg, fileIndex);
            EnableWindow(GetDlgItem(hwndDlg, IDC_BACKFILE), FALSE);
            EnableWindow(GetDlgItem(hwndDlg, IDC_NEXTFILE), FALSE);
            EnableCheckbox(GetDlgItem(hwndDlg, IDC_ID3V2TAG), FALSE, FALSE);
            fileSet = FALSE;
            return TRUE;

        case IDC_SAVE_FILE:
            SaveID3File(hwndDlg, fileIndex);
            bFileChanged = FALSE;
            return TRUE;

        case IDC_NEXTFILE:
            CloseID3File(hwndDlg, fileIndex);
            EnableCheckbox(GetDlgItem(hwndDlg, IDC_ID3V2TAG), FALSE, FALSE);
            fileIndex++;
            OpenID3File(hwndDlg, fileIndex);
            SetNextBackButtons(hwndDlg, fileIndex, dat.fileCount);
            return TRUE;
        case IDC_BACKFILE:
            CloseID3File(hwndDlg, fileIndex);
            EnableCheckbox(GetDlgItem(hwndDlg, IDC_ID3V2TAG), FALSE, FALSE);
            fileIndex--;
            OpenID3File(hwndDlg, fileIndex);
            SetNextBackButtons(hwndDlg, fileIndex, dat.fileCount);
            return TRUE;

        case IDC_CLOSE:
        case IDCANCEL:
        case IDC_EXIT:
            if (bFileChanged == TRUE) {
                fdwMenu = GetMenuState(GetMenu(hwndDlg), IDC_AUTOSAVE, MF_BYCOMMAND);
                if (!(fdwMenu & MF_CHECKED))
                {
                    if (MessageBox(hwndDlg, "Save changes?", "Save changes", MB_YESNO) == IDYES)
                        List_SaveID3(hwndDlg, GetDlgItem(hwndDlg, IDC_ID3LIST), dat.files[fileIndex]);
                } else {
                    List_SaveID3(hwndDlg, GetDlgItem(hwndDlg, IDC_ID3LIST), dat.files[fileIndex]);
                }
            }
            EndDialog(hwndDlg, wParam);
            return TRUE;

        case IDC_ABOUT:
            DialogBox(hInstance_for_id3editor, MAKEINTRESOURCE(IDD_ABOUT), hwndDlg, DlgProcAbout);
            return TRUE;

        case IDC_SETGENERAL:
            if (fileSet == FALSE)
                SendMessage(GetDlgItem(hwndDlg, IDC_SETGENERAL), BM_SETCHECK, BST_CHECKED, 0);
            return TRUE;

        case IDC_AUTOSAVE:
            fdwMenu = GetMenuState(GetMenu(hwndDlg), IDC_AUTOSAVE, MF_BYCOMMAND);
            if (!(fdwMenu & MF_CHECKED))
                CheckMenuItem(GetMenu(hwndDlg), IDC_AUTOSAVE, MF_BYCOMMAND | MF_CHECKED);
            else
                CheckMenuItem(GetMenu(hwndDlg), IDC_AUTOSAVE, MF_BYCOMMAND | MF_UNCHECKED);
            return TRUE;
        }
    }
    return FALSE;
}