Main forum > Bug Reports
FILEREQUEST$ in Windows 7 x64 doesn't work
Qedo:
Thanks
if it can help I use this code
--- Code: (glbasic) ---SETCURRENTDIR("Media") // go to media files
file$=Get_Open_File_Name$()
--- End code ---
--- Code: (glbasic) ---// --------------------------------- //
// Project: Qedo
// Start: Saturday, June 26, 2021
// IDE Version: 16.793
INLINE
}
#define HINSTANCE W32HINSTANCE
#define HINSTANCE__ W32HINSTANCE__
#define HMODULE W32HMODULE
#undef LPSTR
#undef DECLARE_HANDLE
#undef LPCTSTR
#undef DWORD
#undef LPWSTR
#undef LPCWSTR
#define HWND W32HWND
#define HWND__ W32HWND__
#define HANDLE W32HANDLE
#undef MAX_PATH
#undef TCHAR
#define WIN32_LEAN_AND_MEAN
#define WinMain WinMain2
#include <windows.h>
#include <commdlg.h>
namespace __GLBASIC__ {
ENDINLINE
FUNCTION Get_Open_File_Name$:
INLINE
char filename[ 200 ];
char filetitle[ 200 ];
tagOFNA ofn;
*filename = 0; *filetitle = 0;
for(int i=0; i<sizeof(tagOFNA); ++i) // ZeroMemory
{
((char*)&ofn)[i] = 0;
}
ofn.lStructSize = sizeof( ofn );
ofn.hwndOwner = GetFocus(); // If you have a window to center over, put its HANDLE here
ofn.lpstrFilter = "Jpg & Png File\0*.Jpg;*.png\0All Files(.)\0*.*\0";
ofn.lpstrFile = filename;
ofn.nMaxFile = 1000;
ofn.lpstrTitle = "Select a photo";
ofn.Flags = OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST;
ofn.lpstrInitialDir = "."; // Initial directory.
ofn.lpstrFileTitle = filetitle;
int ret=GetOpenFileNameA(&ofn);
return filename;
ENDINLINE
ENDFUNCTION
--- End code ---
Kitty Hello:
try this, maybe?
--- Code: (glbasic) ---
// --------------------------------- //
// Project: Qedo
// Start: Saturday, June 26, 2021
// IDE Version: 16.793
INLINE
}
#define HINSTANCE W32HINSTANCE
#define HINSTANCE__ W32HINSTANCE__
#define HMODULE W32HMODULE
#undef LPSTR
#undef DECLARE_HANDLE
#undef LPCTSTR
#undef DWORD
#undef LPWSTR
#undef LPCWSTR
#define HWND W32HWND
#define HWND__ W32HWND__
#define HANDLE W32HANDLE
#undef MAX_PATH
#undef TCHAR
#define WIN32_LEAN_AND_MEAN
#define WinMain WinMain2
#include <windows.h>
#include <commdlg.h>
namespace __GLBASIC__ {
ENDINLINE
FUNCTION Get_Open_File_Name$:
INLINE
char filename[ 1024] = "";
// char filetitle[ 1024 ] = "";
tagOFNA ofn;
char extra_memory_just_to_be_safe[1024];
for(int i=0; i<sizeof(tagOFNA); ++i) // ZeroMemory
{
((char*)&ofn)[i] = 0;
}
ofn.lStructSize = sizeof( ofn );
ofn.hwndOwner = HWND(GLBASIC_HWND()); // If you have a window to center over, put its HANDLE here
ofn.lpstrFilter = "Jpg & Png File\0*.Jpg;*.png\0All Files(.)\0*.*\0";
ofn.lpstrFile = filename;
ofn.nMaxFile = 1000;
char title[1024] = "Select a photo";
ofn.lpstrTitle = title;
ofn.Flags = OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST;
ofn.lpstrInitialDir = "."; // Initial directory.
ofn.lpstrFileTitle = NULL;
int ret=GetOpenFileNameA(&ofn);
return DGStr(filename);
ENDINLINE
ENDFUNCTION
--- End code ---
See
https://www.glbasic.com/forum/index.php?topic=2129.0
and
https://docs.microsoft.com/en-us/windows/win32/api/commdlg/nf-commdlg-getopenfilenamea
Hints:
LPCTSTR - the 'C' stands for 'const'. If it's ommited, do NOT provide a hard coded string like "test", but a pointer to an allocated stack buffer.
I had problems with a wrong size of the struct once, so I added some extra bytes. Might not be a problem....
lpstrFileTitle should be null.
Qedo:
Thank you Gernot.
Also this version work in normal mode but in Debug mode i get the following:
*** Unhandled exception ***
ExceptionCode = 0xc0020043
it's a stupid problem that complicates debugging of the program but when compiled it works fine
P.S:
thanks for the very useful clarifications
Kitty Hello:
Doens't crash for me in debug mode. I think your problem is somewere else.
--- Code: (glbasic) ---
SYSTEMPOINTER TRUE
AUTOPAUSE FALSE
LOCAL a$ = Get_Open_File_Name$()
PRINT a$,0,0
SHOWSCREEN
MOUSEWAIT
END
// --------------------------------- //
// Project: Qedo
// Start: Saturday, June 26, 2021
// IDE Version: 16.793
FUNCTION foo:
ENDFUNCTION
INLINE
}
#define HINSTANCE W32HINSTANCE
#define HINSTANCE__ W32HINSTANCE__
#define HMODULE W32HMODULE
#undef LPSTR
#undef DECLARE_HANDLE
#undef LPCTSTR
#undef DWORD
#undef LPWSTR
#undef LPCWSTR
#define HWND W32HWND
#define HWND__ W32HWND__
#define HANDLE W32HANDLE
#undef MAX_PATH
#undef TCHAR
#define WIN32_LEAN_AND_MEAN
#define WinMain WinMain2
#include <windows.h>
#include <commdlg.h>
namespace __GLBASIC__ {
ENDINLINE
FUNCTION Get_Open_File_Name$:
INLINE
char filename[ 1024] = "";
// char filetitle[ 1024 ] = "";
tagOFNA ofn;
char extra_memory_just_to_be_safe[1024];
for(int i=0; i<sizeof(tagOFNA); ++i) // ZeroMemory
{
((char*)&ofn)[i] = 0;
}
ofn.lStructSize = sizeof( ofn );
ofn.hwndOwner = HWND(GLBASIC_HWND()); // If you have a window to center over, put its HANDLE here
ofn.lpstrFilter = "Jpg & Png File\0*.Jpg;*.png\0All Files(.)\0*.*\0";
ofn.lpstrFile = filename;
ofn.nMaxFile = 1000;
char title[1024] = "Select a photo";
ofn.lpstrTitle = title;
ofn.Flags = OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST;
ofn.lpstrInitialDir = "."; // Initial directory.
ofn.lpstrFileTitle = NULL;
int ret=GetOpenFileNameA(&ofn);
return DGStr(filename);
ENDINLINE
ENDFUNCTION
--- End code ---
I fear, you're having a buffer overrun somewere else. These are hard to debug and find. Most likely in an INLINE block. Try to make a small as possible program, that crashes and zip it.
Qedo:
It doesn't work, it's definitely a problem with my computer. I loaded your code but except sometimes in debug mode the system crashes
ad maiora
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version