my code is as follows.
OPENFILENAMEA open;
ZeroMemory(&open, sizeof(open));
open.lStructSize = sizeof(LPOPENFILENAMEA);
open.lpstrFilter = "Képek\0*.jpg;*.jpeg;*.gif;*.png;*.bmp\0\0";
open.nFileOffset = 1;
open.lpstrFile[0] = '\0';
open.nMaxFile = 2048;
open.lpstrTitle = "Képek kiválasztása..";
open.Flags = OFN_ALLOWMULTISELECT | OFN_FILEMUSTEXIST;
OPENFILENAME selected = GetOpenFileName(open);
My problem is, that I get the following error when trying to build:
error: cannot convert 'OPENFILENAME {aka tagOFNA}' to 'LPOPENFILENAMEA {aka tagOFNA*}' for argument '1' to 'BOOL GetOpenFileNameA(LPOPENFILENAMEA)'
when I call GetOpenFileName
If I call it with the open parameter as a ptr GetOpenFileName(&open)
I get the following error: conversion from 'BOOL {aka int}' to non-scalar type 'OPENFILENAME {aka tagOFNA}' requested
Question: what do?
GetOpenFileName
returns a BOOL
, not an OPENFILENAME
.
It will return a non-zero value if it returned by the user selecting a file and clicking "Ok". If they clicked "Cancel", it'll return 0.
If it returns true, it will have modified the contents of your open
to reflect what the user selected.
So, you usually use it something like:
if (GetOpenFileName(&open)) {
// use open.whatever to get data about the selected file
}
else
// The user clicked cancel -- typically do nothing.