Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem with directories and file selector (VC++ 2008)
    primarykey
    data
    text
    <p>I have implemented a file selector with a combobox. I want to write the selected filename to a log. The problem is that when I select a file from the original directory it goes well but when I choose a file from another directory it won't work. Can anybody help with this? Here is the code for the file selector, it is inside a dialog.</p> <pre><code>BOOL CALLBACK BateriaFaxDlg(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam){ char descripcion[100]=""; char archivo[100]=""; char cad[100]; int i,l; switch (msg) { case WM_INITDIALOG: InitCombo(hDlg, "*.*"); return TRUE; break; case WM_COMMAND: switch(LOWORD(wParam)) { case IDOK: i = SendDlgItemMessage(hDlg, IDC_ARCH2, CB_GETCURSEL, 0, 0); if(i &gt;= 0) { SendDlgItemMessage(hDlg, IDC_ARCH2, CB_GETLBTEXT, (WPARAM)i, (LPARAM)archivo); } if (!GetDlgItemText(hDlg, IDC_DESCBATER, descripcion , 100)) { MessageBox(hDlg, "Ambos campos son obligatorios", "ERROR", MB_ICONEXCLAMATION | MB_OK); break; } actualizarBaterias(GetParent(hDlg), "FAX", archivo, descripcion); EndDialog(hDlg, FALSE); break; case IDCANCEL: EndDialog(hDlg, FALSE); break; case IDC_ARCH2: switch(HIWORD(wParam)) { case CBN_CLOSEUP: case CBN_KILLFOCUS: if(DlgDirSelectComboBoxEx(hDlg, cad, 100, IDC_ARCH2)) { strcat(cad, "*.*"); InitCombo(hDlg, cad); } break; } break; default: break; return TRUE; } } return FALSE; } </code></pre> <p>This is InitCombo:</p> <pre><code>void IniciarCombo(HWND hwnd, char* p) { char path[100]; strcpy(path, p); DlgDirListComboBox( hwnd, path, IDC_ARCH2, ID_TITULO, DDL_DIRECTORY | DDL_DRIVES ); SendDlgItemMessage(hwnd, IDC_ARCH2, CB_SETCURSEL, 0, 1); } </code></pre> <p>and finally this is where i write the filename to a file.</p> <pre><code>void actualizarBaterias(HWND hWnd, char *tipo, char *archivo, char *descripcion) { FILE *fp; HWND hctrl; int i; HFONT hfont; fp = fopen("conf\\Baterias.conf", "a" ); if (fp) { MessageBox(hWnd, "Actuali","error", MB_ICONEXCLAMATION | MB_OK); fprintf(fp, "\n%s %s %s", tipo, archivo, descripcion); fclose(fp); } } </code></pre> <p>Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload