www.digitalmars.com         C & C++   DMDScript  

c++.windows.32-bits - file i/o dialog problem

reply "Steve & Denise De Chellis" <dbouton snet.net> writes:
I have a very strange problem.

One of my program testers cannot use the file save dialog in my program.
Every other tester has no problem and he has no problem with other programs
that use the generic microsoft file dialogs.

What happens is he presses the save button.

The common dialog for saving a file shows up on screen but in the edit
control where the filename goes he gets a single random character.

When he tries to save a file he gets no response from the system.

The program is designed to look at the file extension and then save in the
appropriate format.

          case BN_CLICKED:
                // Save Character
   if(GetFileNameSave(fname,50,hwnd))
   {
    SaveFile(fname, hwnd); //Call function to save file
   }
               break ;

BOOL GetFileNameSave(char *filename, int len, HWND hWnd)
{
 OPENFILENAME ofn;

 ZeroMemory(&ofn, sizeof(OPENFILENAME));    //Zero out the memory for the
filename info
 ofn.lStructSize = sizeof(OPENFILENAME);    //Size of the structure
 ofn.hwndOwner = hWnd;       //Window that is calling this
 ofn.lpstrFilter = ("HackMaster Files (*.hmf)\0*.hmf\0HTM Files
(*.htm)\0*.htm\0HTML Files (*.html)\0*.html\0"); //Filters
 ofn.lpstrFile = filename;      //Where to store it
 ofn.nMaxFile = len;       //Tell it how big the char array is
 ofn.lpstrTitle = ("Save a File");     //Title
 ofn.lpstrDefExt = ("htm");
 ofn.Flags = OFN_HIDEREADONLY|OFN_PATHMUSTEXIST;   //Any flags here
     //^These flags together mean the file name/path typed must exist
     //And it won't ask for the user if they want to create it.
 return GetSaveFileName(&ofn);      //Display dialog box
}

It seems to me that somwhere along the way the filename string is getting
overwritten by something, but I can not figure out why it only happens to
him!

All other users see the filename last used showing up in the save dialoag
edit control...

Thanks
Steve De Chellis
Aug 09 2002
parent reply Jan Knepper <jan smartsoft.cc> writes:
You might want to check into the version of comdlg32.dll this user has on his
system.
If it worked fine with other users, his comdlg32.dll might be an older version
and causing problems.

Jan



Steve & Denise De Chellis wrote:

 I have a very strange problem.

 One of my program testers cannot use the file save dialog in my program.
 Every other tester has no problem and he has no problem with other programs
 that use the generic microsoft file dialogs.

 What happens is he presses the save button.

 The common dialog for saving a file shows up on screen but in the edit
 control where the filename goes he gets a single random character.

 When he tries to save a file he gets no response from the system.

 The program is designed to look at the file extension and then save in the
 appropriate format.

           case BN_CLICKED:
                 // Save Character
    if(GetFileNameSave(fname,50,hwnd))
    {
     SaveFile(fname, hwnd); //Call function to save file
    }
                break ;

 BOOL GetFileNameSave(char *filename, int len, HWND hWnd)
 {
  OPENFILENAME ofn;

  ZeroMemory(&ofn, sizeof(OPENFILENAME));    //Zero out the memory for the
 filename info
  ofn.lStructSize = sizeof(OPENFILENAME);    //Size of the structure
  ofn.hwndOwner = hWnd;       //Window that is calling this
  ofn.lpstrFilter = ("HackMaster Files (*.hmf)\0*.hmf\0HTM Files
 (*.htm)\0*.htm\0HTML Files (*.html)\0*.html\0"); //Filters
  ofn.lpstrFile = filename;      //Where to store it
  ofn.nMaxFile = len;       //Tell it how big the char array is
  ofn.lpstrTitle = ("Save a File");     //Title
  ofn.lpstrDefExt = ("htm");
  ofn.Flags = OFN_HIDEREADONLY|OFN_PATHMUSTEXIST;   //Any flags here
      //^These flags together mean the file name/path typed must exist
      //And it won't ask for the user if they want to create it.
  return GetSaveFileName(&ofn);      //Display dialog box
 }

 It seems to me that somwhere along the way the filename string is getting
 overwritten by something, but I can not figure out why it only happens to
 him!

 All other users see the filename last used showing up in the save dialoag
 edit control...

 Thanks
 Steve De Chellis
Aug 09 2002
parent reply "Steve & Denise De Chellis" <dbouton snet.net> writes:
Is there any other possibility? I now have two users with this problem.

I have built in a temporary file save / load systems using an edit control
to enter the filename but it is very limited.

"Jan Knepper" <jan smartsoft.cc> wrote in message
news:3D54AE3A.D67EAF8E smartsoft.cc...
 You might want to check into the version of comdlg32.dll this user has on
his
 system.
 If it worked fine with other users, his comdlg32.dll might be an older
version
 and causing problems.

 Jan



 Steve & Denise De Chellis wrote:

 I have a very strange problem.

 One of my program testers cannot use the file save dialog in my program.
 Every other tester has no problem and he has no problem with other
programs
 that use the generic microsoft file dialogs.

 What happens is he presses the save button.

 The common dialog for saving a file shows up on screen but in the edit
 control where the filename goes he gets a single random character.

 When he tries to save a file he gets no response from the system.

 The program is designed to look at the file extension and then save in
the
 appropriate format.

           case BN_CLICKED:
                 // Save Character
    if(GetFileNameSave(fname,50,hwnd))
    {
     SaveFile(fname, hwnd); //Call function to save file
    }
                break ;

 BOOL GetFileNameSave(char *filename, int len, HWND hWnd)
 {
  OPENFILENAME ofn;

  ZeroMemory(&ofn, sizeof(OPENFILENAME));    //Zero out the memory for
the
 filename info
  ofn.lStructSize = sizeof(OPENFILENAME);    //Size of the structure
  ofn.hwndOwner = hWnd;       //Window that is calling this
  ofn.lpstrFilter = ("HackMaster Files (*.hmf)\0*.hmf\0HTM Files
 (*.htm)\0*.htm\0HTML Files (*.html)\0*.html\0"); //Filters
  ofn.lpstrFile = filename;      //Where to store it
  ofn.nMaxFile = len;       //Tell it how big the char array is
  ofn.lpstrTitle = ("Save a File");     //Title
  ofn.lpstrDefExt = ("htm");
  ofn.Flags = OFN_HIDEREADONLY|OFN_PATHMUSTEXIST;   //Any flags here
      //^These flags together mean the file name/path typed must exist
      //And it won't ask for the user if they want to create it.
  return GetSaveFileName(&ofn);      //Display dialog box
 }

 It seems to me that somwhere along the way the filename string is
getting
 overwritten by something, but I can not figure out why it only happens
to
 him!

 All other users see the filename last used showing up in the save
dialoag
 edit control...

 Thanks
 Steve De Chellis
Aug 19 2002
parent Chris <chris widdows.demon.nl> writes:
On Mon, 19 Aug 2002 11:01:21 -0400, "Steve & Denise De Chellis"
<dbouton snet.net> wrote:

Is there any other possibility? I now have two users with this problem.

I have built in a temporary file save / load systems using an edit control
to enter the filename but it is very limited.
I agree with Jan, the comdlg32.dll seems a prime suspect. A couple of things to check. 1. What are the versions of the dll (you need the numbers found on the second tab of the dialog you get when requesting the file properties)? 2. Do this for one or two machines not having any problems (but be sure to include the one this is built on) 3. Check to see if there is only one copy of the file (I've seen this happen a lot) that can be found using the standard win search (i.e. current dir, windows system dir, windows dir and all directories in the path environment variable). If you find more than one, copy the latest version to the windows system directory and get rid of the rest. Be carefull not to get rid of versions that you could be sending out as redistributables, but they should be the same version and should not be in the search path. In principle you should be ok if the version you built with is met or surpassed on the target machine. But it is also possible that a particular version doesn't work, so try installing the same version as you built with (I forget if the comdlg32.dll is different for NT/98, check that). But now you should save the version you're replacing. If that solves the problem, test all other software to see if they have been broken by the install. File open and Save As dialogs are prime candidates. I have also seen broken installations of these common components, particulary on W95/98/Me systems, so it might be an option to get the latest set from Microsoft for that platform. A quick glance at the code isn't that revealing. It does seem to be fixing the filename length at 50, which perhaps isn't a good idea. If you have to fix the size, go for MAX_FILE_LEN (or similar, but there's a constant for the maximum filename length). There should be a logical explanation for that failing only some machines, but based on the provided info I can't think of anything. HTH Chris
"Jan Knepper" <jan smartsoft.cc> wrote in message
news:3D54AE3A.D67EAF8E smartsoft.cc...
 You might want to check into the version of comdlg32.dll this user has on
his
 system.
 If it worked fine with other users, his comdlg32.dll might be an older
version
 and causing problems.

 Jan



 Steve & Denise De Chellis wrote:

 I have a very strange problem.

 One of my program testers cannot use the file save dialog in my program.
 Every other tester has no problem and he has no problem with other
programs
 that use the generic microsoft file dialogs.

 What happens is he presses the save button.

 The common dialog for saving a file shows up on screen but in the edit
 control where the filename goes he gets a single random character.

 When he tries to save a file he gets no response from the system.

 The program is designed to look at the file extension and then save in
the
 appropriate format.

           case BN_CLICKED:
                 // Save Character
    if(GetFileNameSave(fname,50,hwnd))
    {
     SaveFile(fname, hwnd); //Call function to save file
    }
                break ;

 BOOL GetFileNameSave(char *filename, int len, HWND hWnd)
 {
  OPENFILENAME ofn;

  ZeroMemory(&ofn, sizeof(OPENFILENAME));    //Zero out the memory for
the
 filename info
  ofn.lStructSize = sizeof(OPENFILENAME);    //Size of the structure
  ofn.hwndOwner = hWnd;       //Window that is calling this
  ofn.lpstrFilter = ("HackMaster Files (*.hmf)\0*.hmf\0HTM Files
 (*.htm)\0*.htm\0HTML Files (*.html)\0*.html\0"); //Filters
  ofn.lpstrFile = filename;      //Where to store it
  ofn.nMaxFile = len;       //Tell it how big the char array is
  ofn.lpstrTitle = ("Save a File");     //Title
  ofn.lpstrDefExt = ("htm");
  ofn.Flags = OFN_HIDEREADONLY|OFN_PATHMUSTEXIST;   //Any flags here
      //^These flags together mean the file name/path typed must exist
      //And it won't ask for the user if they want to create it.
  return GetSaveFileName(&ofn);      //Display dialog box
 }

 It seems to me that somwhere along the way the filename string is
getting
 overwritten by something, but I can not figure out why it only happens
to
 him!

 All other users see the filename last used showing up in the save
dialoag
 edit control...

 Thanks
 Steve De Chellis
Aug 22 2002