Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to set document file extension?

How to set document file extension?

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++helptutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    maxmaven
    wrote on last edited by
    #1

    Hi, I am using serialize to write out my MFC application document data. I want to have names in the file dialog post-fixed with a file extension, like "binky.dfg" (.dfg is the file extension). I understand I need to call CWinApp::RegisterShellFileTypes(...). However, this will only work if I set the appropriate string for the file extension in my CSingleDocTemplate. I browsed around and found CSingleDocTemplate.GetDocString(...). This will let me read what the file extension is for my document. But how do I set a file extension? There is no SetDocString(...). It looks like the CSingleDocTemplate members I am interested in are some/all of regFileTypeId, regFileTypeName, filterExt, or filterName. I'm not sure which one I should be working with. Also, these are member variables of the class. Shouldn't I be not touching these directly? Rather, shouldn't I be using some class member functions to do the work? Help? :doh: Max

    P 1 Reply Last reply
    0
    • M maxmaven

      Hi, I am using serialize to write out my MFC application document data. I want to have names in the file dialog post-fixed with a file extension, like "binky.dfg" (.dfg is the file extension). I understand I need to call CWinApp::RegisterShellFileTypes(...). However, this will only work if I set the appropriate string for the file extension in my CSingleDocTemplate. I browsed around and found CSingleDocTemplate.GetDocString(...). This will let me read what the file extension is for my document. But how do I set a file extension? There is no SetDocString(...). It looks like the CSingleDocTemplate members I am interested in are some/all of regFileTypeId, regFileTypeName, filterExt, or filterName. I'm not sure which one I should be working with. Also, these are member variables of the class. Shouldn't I be not touching these directly? Rather, shouldn't I be using some class member functions to do the work? Help? :doh: Max

      P Offline
      P Offline
      Paresh Chitte
      wrote on last edited by
      #2

      If you are using CFileDialog then look at the second parameter lpszDefExt of the constructor CFileDialog( BOOL bOpenFileDialog, LPCTSTR lpszDefExt = NULL, LPCTSTR lpszFileName = NULL, DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, LPCTSTR lpszFilter = NULL, CWnd* pParentWnd = NULL ); Regards, Paresh.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups