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. Open Filename dialog won't show.

Open Filename dialog won't show.

Scheduled Pinned Locked Moved C / C++ / MFC
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.
  • R Offline
    R Offline
    redeemer
    wrote on last edited by
    #1

    I'm trying to show an Open File dialog but it won't show and i can't figure out what i'm doing wrong, here's the code:

    {
    OPENFILENAME ofn;
    char szFileNames[(MAX_PATH+1)*1000+2];
    const char szFilter[] = "MP3 Files (*.mp3)\0" "*.mp3\0";

    szFileNames\[0\] = 0;
    ofn.lStructSize = sizeof(OPENFILENAME);
    
    ofn.hwndOwner = ghWnd;
    ofn.lpstrFilter = szFilter;
    ofn.lpstrCustomFilter = (LPSTR)NULL;
    ofn.nFilterIndex = 1;
    ofn.lpstrFile = szFileNames;
    ofn.nMaxFile = sizeof(szFileNames);
    ofn.lpstrFileTitle = NULL;
    ofn.lpstrTitle = (LPSTR)NULL;
    ofn.Flags = OFN\_ENABLESIZING | OFN\_FILEMUSTEXIST | OFN\_HIDEREADONLY | OFN\_PATHMUSTEXIST | OFN\_ALLOWMULTISELECT | OFN\_EXPLORER;
    ofn.nFileOffset = 0;
    ofn.nFileExtension = 0;
    ofn.lpstrDefExt = "mp3";
    
    GetOpenFileName(&ofn);
    

    Thanks in advance -Rune Svendsen

    P 1 Reply Last reply
    0
    • R redeemer

      I'm trying to show an Open File dialog but it won't show and i can't figure out what i'm doing wrong, here's the code:

      {
      OPENFILENAME ofn;
      char szFileNames[(MAX_PATH+1)*1000+2];
      const char szFilter[] = "MP3 Files (*.mp3)\0" "*.mp3\0";

      szFileNames\[0\] = 0;
      ofn.lStructSize = sizeof(OPENFILENAME);
      
      ofn.hwndOwner = ghWnd;
      ofn.lpstrFilter = szFilter;
      ofn.lpstrCustomFilter = (LPSTR)NULL;
      ofn.nFilterIndex = 1;
      ofn.lpstrFile = szFileNames;
      ofn.nMaxFile = sizeof(szFileNames);
      ofn.lpstrFileTitle = NULL;
      ofn.lpstrTitle = (LPSTR)NULL;
      ofn.Flags = OFN\_ENABLESIZING | OFN\_FILEMUSTEXIST | OFN\_HIDEREADONLY | OFN\_PATHMUSTEXIST | OFN\_ALLOWMULTISELECT | OFN\_EXPLORER;
      ofn.nFileOffset = 0;
      ofn.nFileExtension = 0;
      ofn.lpstrDefExt = "mp3";
      
      GetOpenFileName(&ofn);
      

      Thanks in advance -Rune Svendsen

      P Offline
      P Offline
      Pavel Klocek
      wrote on last edited by
      #2

      The dialog shows O.K. for me. The only diference was I tested it with hwndOwner set to NULL. Is the owner window (ghWnd) valid and displayed window? Sonork 100.15206;PavelK

      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