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. Other Discussions
  3. IT & Infrastructure
  4. Windows API GetOpenFilename

Windows API GetOpenFilename

Scheduled Pinned Locked Moved IT & Infrastructure
c++jsonhelpquestion
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
    MacFromOK
    wrote on last edited by
    #1

    Hello, I'm having trouble getting a "file open" common dialog box. I keep getting a CDERR_STRUCTSIZE error, and I can't figure out why. Here's two methods I've tried: -------- OPENFILENAME ofn; memset(&ofn, 0, sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hwnd0; GetOpenFileName(&ofn); -------- OPENFILENAME ofn; ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hwnd0; GetOpenFileName(&ofn); -------- I've tried adding other members, but no success. "ofn.lStructSize" always shows to be 88 (is this normal?). "hwnd0" is a global HWND for the main window (I've also tried NULL for ofn.hwndOwner). The main window is NOT dialog based. I've tried the routine in several different locations, including winmain(), callback, and a procedure by itself. I'm using C++Builder command line compiler, Win95B, and it compiles fine. I'm using CommDlgExtendedError() in a switch/case function to find the error. My other API functions seem to work fine. Any ideas? Thanks, Mac

    L 1 Reply Last reply
    0
    • M MacFromOK

      Hello, I'm having trouble getting a "file open" common dialog box. I keep getting a CDERR_STRUCTSIZE error, and I can't figure out why. Here's two methods I've tried: -------- OPENFILENAME ofn; memset(&ofn, 0, sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hwnd0; GetOpenFileName(&ofn); -------- OPENFILENAME ofn; ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hwnd0; GetOpenFileName(&ofn); -------- I've tried adding other members, but no success. "ofn.lStructSize" always shows to be 88 (is this normal?). "hwnd0" is a global HWND for the main window (I've also tried NULL for ofn.hwndOwner). The main window is NOT dialog based. I've tried the routine in several different locations, including winmain(), callback, and a procedure by itself. I'm using C++Builder command line compiler, Win95B, and it compiles fine. I'm using CommDlgExtendedError() in a switch/case function to find the error. My other API functions seem to work fine. Any ideas? Thanks, Mac

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      OK, I found the problem... I used an int to set the structsize in a loop, started at zero and incremented it until it worked. For some reason it needs to be "76" instead of "88" as sizeof(ofn) returns. Cheers, Mac

      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