Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Kitty Hello

Pages: [1] 2 3 ... 703
1
Another try:
Code: (glbasic) [Select]
FUNCTION Get_Open_File_Name$:
INLINE
    char filename[ 2048 ] = "";
    // char filetitle[ 1024 ] = "";
    struct MYOFN : public tagOFNA{
    char extra_memory_just_to_be_safe[1024];
    };
    MYOFN ofn = {};

    ofn.lStructSize  = sizeof( tagOFNA );
    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\0\0\0\0\0\0\0\0\0";
    ofn.lpstrFile    = filename;
    ofn.nMaxFile     = 1000;
    char title[1024] = "Select a photo";
    ofn.lpstrTitle   = title;
    ofn.Flags        = OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST;
    DGStr current = GETCURRENTDIR_Str();
    ofn.lpstrInitialDir   = current.c_str(); // Initial directory.
    ofn.lpstrFileTitle    = NULL;
    int ret=GetOpenFileNameA(&ofn);
    return DGStr(filename);
 ENDINLINE
ENDFUNCTION


2
Get the beta branch: I fixed it, didn't I?

3
Before the dialog opens? Or when you click "OK"?

4
Yikes. Can you debug in GLB and see what line it crashes? (Add some DEBUG() commands to find it in INLINE).

5
Good find. It was a signed/unsigned error checking the first bytes of the file. I'll prepare an update.

6
Doens't crash for me in debug mode. I think your problem is somewere else.

Code: (glbasic) [Select]


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

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.

7
try this, maybe?

Code: (glbasic) [Select]

// --------------------------------- //
// 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



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.




8
can you zip me a tiny project?

9
Phew. I'll try to find it again.

10
GLBasic - en / Re: Windows - Universal App?
« on: 2021-Jun-29 »
Attached is a batch script, that tells you wat to do and how to wrap an exe file.
I wanted to make an easier to use program for this, but, hey, it's a start.

11
Announcements / New BETA
« on: 2021-Jun-15 »
Including long requested MEM2FONT and FONT2MEM commands.

12
GLBasic - en / Re: SPRITE TO FONT
« on: 2021-Jun-15 »
Get the new beta. It contains FONT2MEM and MEM2FONT commands.

13
I think when uploading the stuff to the new server, the newlines of the zip and png files were changed. But I don't have the original filey anymore. I'll try to find an old backup, but it doesn't look good :(

14
GLBasic - en / Re: SPRITE TO FONT
« on: 2021-Jun-09 »
Not possible so far. I'm sorry.

15
For a quick fix, please write (old style) self.m[] = matArray[] // <-- the final braces are the problem. Don't omit so far.

Pages: [1] 2 3 ... 703