www.digitalmars.com         C & C++   DMDScript  

c++.windows.32-bits - file extension when saving

reply "Steve & Denise De Chellis" <dbouton snet.net> writes:
How do I set up the common save dialog to deal with multiple filters? I want
it to append the proper extension to the file when saving.

I'm using this:

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
 if(nUID>=2000)
 {
 ofn.lpstrFilter = ("HackMaster Files (*.hmf)\0*.hmf\0HTM Files
(*.htm)\0*.htm\0HTML Files (*.html)\0*.html\0"); //Filters
 }
 if(nUID<2000)
 {
 ofn.lpstrFilter = ("HTM 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.Flags = OFN_HIDEREADONLY|OFN_PATHMUSTEXIST;   //Any flags here

 return GetSaveFileName(&ofn);      //Display dialog box
}


Steve De Chellis
Jul 31 2002
parent reply Jan Knepper <jan smartsoft.cc> writes:
See if you can used the attached files.
Good luck!
Jan



Steve & Denise De Chellis wrote:

 How do I set up the common save dialog to deal with multiple filters? I want
 it to append the proper extension to the file when saving.

 I'm using this:

 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
  if(nUID>=2000)
  {
  ofn.lpstrFilter = ("HackMaster Files (*.hmf)\0*.hmf\0HTM Files
 (*.htm)\0*.htm\0HTML Files (*.html)\0*.html\0"); //Filters
  }
  if(nUID<2000)
  {
  ofn.lpstrFilter = ("HTM 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.Flags = OFN_HIDEREADONLY|OFN_PATHMUSTEXIST;   //Any flags here

  return GetSaveFileName(&ofn);      //Display dialog box
 }

 Steve De Chellis
Jul 31 2002
parent reply "Steve & Denise De Chellis" <dbouton snet.net> writes:
Unfortunately for me I do not use classess much  in this program. I was
hoping their was something simple that I would use in OPENFILENAME that
would automaticaly use the appropriate extension based on the current filter
selection.

Steve De Chellis


"Jan Knepper" <jan smartsoft.cc> wrote in message
news:3D486A5B.B791F5CA smartsoft.cc...
 See if you can used the attached files.
 Good luck!
 Jan



 Steve & Denise De Chellis wrote:

 How do I set up the common save dialog to deal with multiple filters? I
want
 it to append the proper extension to the file when saving.

 I'm using this:

 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
  if(nUID>=2000)
  {
  ofn.lpstrFilter = ("HackMaster Files (*.hmf)\0*.hmf\0HTM Files
 (*.htm)\0*.htm\0HTML Files (*.html)\0*.html\0"); //Filters
  }
  if(nUID<2000)
  {
  ofn.lpstrFilter = ("HTM 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.Flags = OFN_HIDEREADONLY|OFN_PATHMUSTEXIST;   //Any flags here

  return GetSaveFileName(&ofn);      //Display dialog box
 }

 Steve De Chellis
Jul 31 2002
parent Jan Knepper <jan smartsoft.cc> writes:
Well, the class isn't that difficult to use...
Jan



Steve & Denise De Chellis wrote:

 Unfortunately for me I do not use classess much  in this program. I was
 hoping their was something simple that I would use in OPENFILENAME that
 would automaticaly use the appropriate extension based on the current filter
 selection.

 Steve De Chellis

 "Jan Knepper" <jan smartsoft.cc> wrote in message
 news:3D486A5B.B791F5CA smartsoft.cc...
 See if you can used the attached files.
 Good luck!
 Jan



 Steve & Denise De Chellis wrote:

 How do I set up the common save dialog to deal with multiple filters? I
want
 it to append the proper extension to the file when saving.

 I'm using this:

 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
  if(nUID>=2000)
  {
  ofn.lpstrFilter = ("HackMaster Files (*.hmf)\0*.hmf\0HTM Files
 (*.htm)\0*.htm\0HTML Files (*.html)\0*.html\0"); //Filters
  }
  if(nUID<2000)
  {
  ofn.lpstrFilter = ("HTM 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.Flags = OFN_HIDEREADONLY|OFN_PATHMUSTEXIST;   //Any flags here

  return GetSaveFileName(&ofn);      //Display dialog box
 }

 Steve De Chellis
Jul 31 2002