Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 328857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:32:02+00:00 2026-05-12T09:32:02+00:00

I have implemented a file selector with a combobox. I want to write the

  • 0

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.

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 >= 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;
}

This is InitCombo:

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);
}

and finally this is where i write the filename to a file.

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);
    }
}

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T09:32:03+00:00Added an answer on May 12, 2026 at 9:32 am

    From the documentation for DlgDirListComboBox:

    If lpPathSpec specifies a directory,
    DlgDirListComboBox changes the current
    directory to the specified directory
    before filling the combo box. The text
    of the static control identified by
    the nIDStaticPath parameter is set to
    the name of the new current directory.

    You probably want to cache the current directory (GetCurrentDirectory) before calling DlgDirSelectComboBoxEx, then set it back after it returns. Or, don’t call fopen with a relative directory.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just implemented an Ajax File Upload control that uses a progress bar.
I have implemented a csv file builder that takes in an xml document applies
I have implemented a VirtualPathProvider. The VirtualPathProvider reads the view from File system. However
I have implemented a file transfer rate calculator to display kB/sec for an upload
How can I enforce the JFileChooser filetype (when saving). I have implemented a file
So I have a UIWebView implemented in one .m file and a UITableView implemented
I have one desktop application which was implemented in C#. This app uploads file
I have a WSDL file defining a service that I have to implement in
I have implemented below function in a separate .js script file which I load
Hello I'm doing file upload with Yii. I have implemented this way and it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.