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

Pages: [1]
1
QB64 Discussion / Re: Errors running all examples in win-lib.
« on: October 13, 2019, 09:21:47 am »
I’d bet a dollar against a dime that you’ve download and using the 64-bit version of QB64.  ;)

A lot of those examples were written when we only offered a 32-bit version of QB64.  Change those DECLARE LIBRARY routines to be _INTEGER64, instead of LONG, and the issue will go away.
Yes, I'm running x64, why?
I changed all LONG to _INTEGER64
I'm trying to build a video-player for a drone project.
The code that plays the video, works fine for me, although I still haven't figured out the options to pass, for controls, etc. or getting information, like POINT (x,y) from a frame, etc - so it's a work i progress.
I added the Open File Dialog, from the examples (and in the built-in help) - but it just produces errors,


Code: [Select]
'=============
'QB64VIDEO.BAS
'=============
'Plays a video file in QB64 via MCI commands (WINDOWS ONLY)
'Coded by Dav, forgot what year...

'NOTE: This demo plays a sample video name davpiano.wmv.

DECLARE DYNAMIC LIBRARY "WINMM"
    FUNCTION mciSendStringA% (lpstrCommand AS STRING, lpstrReturnString AS STRING, BYVAL uReturnLength AS INTEGER, BYVAL hwndCallback AS INTEGER)
    ' mciSendStringA function plays media files and returns the following:
    ' 0 = command sucessful
    ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ' lpstrCommand is the MCI command string (and optional flags) to send.
    ' lpstrReturnString is a string that holds any return information.
    ' uReturnLength is the length of the lpstrReturnString string passed.
    ' NOTE: If lpstrCommand given doesn't retun a value then lpstrReturnString
    '       can be empty and uReturnLength can be set to 0.
    ' hwndCallback contains a callback window handle (only if the Notify flag used in lpstrCommand)
    '====================================================================
    FUNCTION mciGetErrorStringA% (BYVAL dwError AS INTEGER, lpstrBuffer AS STRING, BYVAL uLength AS INTEGER)
    ' mciGetErrorStringA returns error info if the mciSendStringA failed.
    ' dwError is the return value from the mciSendString function.
    ' lpstrBuffer string holds the error information returned by the function.
    ' uLength is the length of the lpstrBuffer string buffer.
    '====================================================================
END DECLARE

DECLARE CUSTOMTYPE LIBRARY
    FUNCTION FindWindow& (BYVAL ClassName AS _OFFSET, WindowName$)
END DECLARE

' Dialog flag constants (use + or OR to use more than 1 flag value)
CONST OFN_ALLOWMULTISELECT = &H200& '  Allows the user to select more than one file, not recommended!
CONST OFN_CREATEPROMPT = &H2000& '     Prompts if a file not found should be created(GetOpenFileName only).
CONST OFN_EXTENSIONDIFFERENT = &H400& 'Allows user to specify file extension other than default extension.
CONST OFN_FILEMUSTEXIST = &H1000& '    Chechs File name exists(GetOpenFileName only).
CONST OFN_HIDEREADONLY = &H4& '        Hides read-only checkbox(GetOpenFileName only)
CONST OFN_NOCHANGEDIR = &H8& '         Restores the current directory to original value if user changed
CONST OFN_NODEREFERENCELINKS = &H100000& 'Returns path and file name of selected shortcut(.LNK) file instead of file referenced.
CONST OFN_NONETWORKBUTTON = &H20000& ' Hides and disables the Network button.
CONST OFN_NOREADONLYRETURN = &H8000& ' Prevents selection of read-only files, or files in read-only subdirectory.
CONST OFN_NOVALIDATE = &H100& '        Allows invalid file name characters.
CONST OFN_OVERWRITEPROMPT = &H2& '     Prompts if file already exists(GetSaveFileName only)
CONST OFN_PATHMUSTEXIST = &H800& '     Checks Path name exists (set with OFN_FILEMUSTEXIST).
CONST OFN_READONLY = &H1& '            Checks read-only checkbox. Returns if checkbox is checked
CONST OFN_SHAREAWARE = &H4000& '       Ignores sharing violations in networking
CONST OFN_SHOWHELP = &H10& '           Shows the help button (useless!)
'--------------------------------------------------------------------------------------------

DEFINT A-Z
TYPE FILEDIALOGTYPE
    lStructSize AS _INTEGER64 '        For the DLL call
    hwndOwner AS _INTEGER64 '          Dialog will hide behind window when not set correctly
    hInstance AS _INTEGER64 '          Handle to a module that contains a dialog box template.
    lpstrFilter AS _OFFSET '     Pointer of the string of file filters
    lpstrCustFilter AS _OFFSET
    nMaxCustFilter AS _INTEGER64
    nFilterIndex AS _INTEGER64 '       One based starting filter index to use when dialog is called
    lpstrFile AS _OFFSET '       String full of 0's for the selected file name
    nMaxFile AS _INTEGER64 '           Maximum length of the string stuffed with 0's minus 1
    lpstrFileTitle AS _OFFSET '  Same as lpstrFile
    nMaxFileTitle AS _INTEGER64 '      Same as nMaxFile
    lpstrInitialDir AS _OFFSET ' Starting directory
    lpstrTitle AS _OFFSET '      Dialog title
    flags AS _INTEGER64 '              Dialog flags
    nFileOffset AS INTEGER '     Zero-based offset from path beginning to file name string pointed to by lpstrFile
    nFileExtension AS INTEGER '  Zero-based offset from path beginning to file extension string pointed to by lpstrFile.
    lpstrDefExt AS _OFFSET '     Default/selected file extension
    lCustData AS _INTEGER64
    lpfnHook AS _INTEGER64
    lpTemplateName AS _OFFSET
END TYPE

DECLARE DYNAMIC LIBRARY "comdlg32" ' Library declarations using _OFFSET types
    FUNCTION GetOpenFileNameA& (DIALOGPARAMS AS FILEDIALOGTYPE) ' The Open file dialog
    FUNCTION GetSaveFileNameA& (DIALOGPARAMS AS FILEDIALOGTYPE) ' The Save file dialog
END DECLARE


' Do the Open File dialog call!
Filter$ = "*.*"
Flags& = OFN_FILEMUSTEXIST + OFN_NOCHANGEDIR + OFN_READONLY '    add flag constants here
OFile$ = GetOpenFileName$(" ", ".\", Filter$, 1, Flags&, hWnd&)

IF OFile$ = "" THEN   ' Display Open dialog results
  PRINT "You must pick a file."
ELSE
END IF
filename$= OFile$


IF NOT _FILEEXISTS(filename$) THEN
    PRINT filename$ + " " + "not found."
    END
END IF

handle& = _NEWIMAGE(1024, 768, 32) '<===== The x/y size of my video
SCREEN handle&

DO UNTIL _SCREENEXISTS: _LIMIT 30: LOOP 'be sure screen exists before using in this way

title$ = "QB64 Video Player - " + filename$
_TITLE title$

hwnd& = FindWindow(0, title$ + CHR$(0))

ReturnString$ = SPACE$(255): ErrorString$ = SPACE$(255)
a% = mciSendStringA%("open " + filename$ + " style popup", ReturnString$, LEN(ReturnString$), 0)

IF a% THEN
    x% = mciGetErrorStringA%(a%, ErrorString$, LEN(ErrorString$))
    PRINT ErrorString$
    END
ELSE
    a2% = mciSendStringA%("window " + filename$ + " handle " + STR$(hwnd&), ReturnString$, LEN(ReturnString$), 0)
    b% = mciSendStringA%("play " + filename$, "", 0, 0)

    '=== Play video...
    DO
        _LIMIT 30

        'you can add pause/resume routine here if you want...

    LOOP UNTIL INKEY$ <> ""

    x% = mciSendStringA%("stop " + filename$, "", 0, 0)
    x% = mciSendStringA%("close " + filename$, "", 0, 0)
END IF


The original code:

Code: [Select]
'=============
'QB64VIDEO.BAS
'=============
'Plays a video file in QB64 via MCI commands (WINDOWS ONLY)
'Coded by Dav, forgot what year...

'NOTE: This demo plays a sample video name davpiano.wmv.

DECLARE DYNAMIC LIBRARY "WINMM"
    FUNCTION mciSendStringA% (lpstrCommand AS STRING, lpstrReturnString AS STRING, BYVAL uReturnLength AS INTEGER, BYVAL hwndCallback AS INTEGER)
    ' mciSendStringA function plays media files and returns the following:
    ' 0 = command sucessful
    ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ' lpstrCommand is the MCI command string (and optional flags) to send.
    ' lpstrReturnString is a string that holds any return information.
    ' uReturnLength is the length of the lpstrReturnString string passed.
    ' NOTE: If lpstrCommand given doesn't retun a value then lpstrReturnString
    '       can be empty and uReturnLength can be set to 0.
    ' hwndCallback contains a callback window handle (only if the Notify flag used in lpstrCommand)
    '====================================================================
    FUNCTION mciGetErrorStringA% (BYVAL dwError AS INTEGER, lpstrBuffer AS STRING, BYVAL uLength AS INTEGER)
    ' mciGetErrorStringA returns error info if the mciSendStringA failed.
    ' dwError is the return value from the mciSendString function.
    ' lpstrBuffer string holds the error information returned by the function.
    ' uLength is the length of the lpstrBuffer string buffer.
    '====================================================================
END DECLARE

DECLARE CUSTOMTYPE LIBRARY
    FUNCTION FindWindow& (BYVAL ClassName AS _OFFSET, WindowName$)
END DECLARE



' Dialog flag constants (use + or OR to use more than 1 flag value)
CONST OFN_ALLOWMULTISELECT = &H200& '  Allows the user to select more than one file, not recommended!
CONST OFN_CREATEPROMPT = &H2000& '     Prompts if a file not found should be created(GetOpenFileName only).
CONST OFN_EXTENSIONDIFFERENT = &H400& 'Allows user to specify file extension other than default extension.
CONST OFN_FILEMUSTEXIST = &H1000& '    Chechs File name exists(GetOpenFileName only).
CONST OFN_HIDEREADONLY = &H4& '        Hides read-only checkbox(GetOpenFileName only)
CONST OFN_NOCHANGEDIR = &H8& '         Restores the current directory to original value if user changed
CONST OFN_NODEREFERENCELINKS = &H100000& 'Returns path and file name of selected shortcut(.LNK) file instead of file referenced.
CONST OFN_NONETWORKBUTTON = &H20000& ' Hides and disables the Network button.
CONST OFN_NOREADONLYRETURN = &H8000& ' Prevents selection of read-only files, or files in read-only subdirectory.
CONST OFN_NOVALIDATE = &H100& '        Allows invalid file name characters.
CONST OFN_OVERWRITEPROMPT = &H2& '     Prompts if file already exists(GetSaveFileName only)
CONST OFN_PATHMUSTEXIST = &H800& '     Checks Path name exists (set with OFN_FILEMUSTEXIST).
CONST OFN_READONLY = &H1& '            Checks read-only checkbox. Returns if checkbox is checked
CONST OFN_SHAREAWARE = &H4000& '       Ignores sharing violations in networking
CONST OFN_SHOWHELP = &H10& '           Shows the help button (useless!)
'--------------------------------------------------------------------------------------------

DEFINT A-Z
TYPE FILEDIALOGTYPE
    lStructSize AS LONG '        For the DLL call
    hwndOwner AS LONG '          Dialog will hide behind window when not set correctly
    hInstance AS LONG '          Handle to a module that contains a dialog box template.
    lpstrFilter AS _OFFSET '     Pointer of the string of file filters
    lpstrCustFilter AS _OFFSET
    nMaxCustFilter AS LONG
    nFilterIndex AS LONG '       One based starting filter index to use when dialog is called
    lpstrFile AS _OFFSET '       String full of 0's for the selected file name
    nMaxFile AS LONG '           Maximum length of the string stuffed with 0's minus 1
    lpstrFileTitle AS _OFFSET '  Same as lpstrFile
    nMaxFileTitle AS LONG '      Same as nMaxFile
    lpstrInitialDir AS _OFFSET ' Starting directory
    lpstrTitle AS _OFFSET '      Dialog title
    flags AS LONG '              Dialog flags
    nFileOffset AS INTEGER '     Zero-based offset from path beginning to file name string pointed to by lpstrFile
    nFileExtension AS INTEGER '  Zero-based offset from path beginning to file extension string pointed to by lpstrFile.
    lpstrDefExt AS _OFFSET '     Default/selected file extension
    lCustData AS LONG
    lpfnHook AS LONG
    lpTemplateName AS _OFFSET
END TYPE

DECLARE DYNAMIC LIBRARY "comdlg32" ' Library declarations using _OFFSET types
    FUNCTION GetOpenFileNameA& (DIALOGPARAMS AS FILEDIALOGTYPE) ' The Open file dialog
    FUNCTION GetSaveFileNameA& (DIALOGPARAMS AS FILEDIALOGTYPE) ' The Save file dialog
END DECLARE


' Do the Open File dialog call!
Filter$ = "*.*"
Flags& = OFN_FILEMUSTEXIST + OFN_NOCHANGEDIR + OFN_READONLY '    add flag constants here
OFile$ = GetOpenFileName$(" ", ".\", Filter$, 1, Flags&, hWnd&)

IF OFile$ = "" THEN   ' Display Open dialog results
  PRINT "You must pick a file."
ELSE
END IF
filename$= OFile$




IF NOT _FILEEXISTS(filename$) THEN
    PRINT filename$ + " " + "not found."
    END
END IF

handle& = _NEWIMAGE(1024, 768, 32) '<===== The x/y size of my video
SCREEN handle&

DO UNTIL _SCREENEXISTS: _LIMIT 30: LOOP 'be sure screen exists before using in this way

title$ = "QB64 Video Player - " + filename$
_TITLE title$

hwnd& = FindWindow(0, title$ + CHR$(0))

ReturnString$ = SPACE$(255): ErrorString$ = SPACE$(255)
a% = mciSendStringA%("open " + filename$ + " style popup", ReturnString$, LEN(ReturnString$), 0)

IF a% THEN
    x% = mciGetErrorStringA%(a%, ErrorString$, LEN(ErrorString$))
    PRINT ErrorString$
    END
ELSE
    a2% = mciSendStringA%("window " + filename$ + " handle " + STR$(hwnd&), ReturnString$, LEN(ReturnString$), 0)
    b% = mciSendStringA%("play " + filename$, "", 0, 0)

    '=== Play video...
    DO
        _LIMIT 30

        'you can add pause/resume routine here if you want...

    LOOP UNTIL INKEY$ <> ""

    x% = mciSendStringA%("stop " + filename$, "", 0, 0)
    x% = mciSendStringA%("close " + filename$, "", 0, 0)
END IF


2
QB64 Discussion / Re: Errors running all examples in win-lib.
« on: October 12, 2019, 06:26:43 pm »
Same thing with the built-in help examples.
None of them run.

3
QB64 Discussion / Errors running all examples in win-lib.
« on: October 12, 2019, 06:17:55 pm »
Hi!

I was trying out different examples, looking for a solution to a problem, and I wanted to try some of the Windows-libraries.
Turns out that every example creates an error - sometimes not running or anything. (I tried even on a "clean" install, download, extract, run, paste, compile…)
The error output is:
"C++ Compilation failed  (Check .\internal\temp\compilefile.txt"

When I click on it, Notepad opens with this text:

In file included from qbx.cpp:2171:
..\\temp\\main.txt: In function 'void QBMAIN(void*)':
..\\temp\\main.txt:16:124: error: cast from 'HWND' {aka 'HWND__*'} to 'int' loses precision [-fpermissive]
 *__LONG_HWND=(  int32  )FindWindow(NULL,(char*)(qbs_add(qbs_new_txt_len("Color Common Dialog demo",24),func_chr( 0 )))->chr);
                                                                                                                            ^
compilation terminated due to -Wfatal-errors.

For the Color Dialog Box.
It's pretty much the same for rest.
I hope someone can fix that, because that how one learns to code in QB64.

Also - the IDE shows wrong characters for the last 3 Swedish letters åäö.

Thank you for your time and I hope it gets fixed.
I'd like to use the Open File Dialog, instead of writing my own - it would make it easier.

Cheers.

Cheers. ;)

4
QB64 Discussion / Re: Playing a video-file
« on: October 12, 2019, 04:17:47 pm »
I hope so?
Why would we have a forum otherwise?

Anyway - thing is, this code works fine for me IF:

I can get the parameters for different variables, like:
a% = mciSendStringA%("open " + filename$ + " style popup", ReturnString$, LEN(ReturnString$), 0)
Instead of a "style popup", what other options are there?
How do I use them?
And one important thing - how do I analyze a frame in QB64, like say in c%= POINT (x,y)

Thankful for any answer. ;)

5
QB64 Discussion / Re: Strange bug with FPS counter, popping up in QB64
« on: October 09, 2019, 10:58:34 pm »
This "built-in debug-function" that "also showed CPU and cores temperature among other things" simply doesn't exist in QB64. Your version sure got infected locally.

Glad you've sorted it out.

I think so too, as the file sizes were different.
That's why I'm suggesting some kind of CRC-check when qb64.exe starts, to make sure it's not compromised.

6
QB64 Discussion / Re: Playing a video-file
« on: October 09, 2019, 10:39:07 pm »
Perhaps looking this ?   https://www.qb64.org/forum/index.php?topic=608.0

Awesome!!!
Exactly what I'm looking for.
Thanks a lot my friend!
It plays all the supported video and audio files.
I'm going to play around a bit and see if it's usable for the task.

However, I'm trying to figure out how to enable controls, like rewind, fast forward, etc.
I found this page: https://social.msdn.microsoft.com/Forums/vstudio/en-US/81ceb34f-529e-4ce1-8af9-c66d2f553386/playing-video-with-winmmdll?forum=vbgeneral
Turns out that winmm.dll only supports a limited formats of videos and audios. (MOV is not among them.)

The DLL-file is full of functions - but I don't understand how to use them?
See: https://www.win7dll.info/winmm_dll.html

Thankful for any kind of help.

7
QB64 Discussion / Playing a video-file
« on: October 07, 2019, 11:21:30 pm »
Hey guys!

I was wondering - is there any way to play any kind of video-files in QB64?
I've tried searching, but can't find anything.
I was thinking, like a function that allows you to play a video-file inside a program, and place/re-size it somewhere on the screen?
If QB64 can access windows DLL-files, then it should be possible to use the built-in functions - I don't know, I never messed with DLL/SO-files, but as instructed in the help and tutorial section.
What I really need, is to show a stream of video from a drone... But that's an another story...

I'd be really thankful for any kind of help.

8
QB64 Discussion / Re: Strange bug with FPS counter, popping up in QB64
« on: October 07, 2019, 10:41:46 pm »
Hey guys!

I really tried everything, re-installed the GPU drivers several times, reset all configs (I've got many screens… See pic…) - even checked/unchecked stuff in the boot systematically (really time-consuming task) - but nope.
However, I downloaded QB64 again, and extracted it in a temp directory, and then copied and replaced the qb64.exe file only, in the real installation folder, and - tada!
It is gone!

Both versions were the latest build, to answer TempodiBasic's question.
The OS is Windows 10, and well - a lot of software out there can do this, but I noticed that the file-size of the two qb64.exe files were different by a couple of hundreds of kb's.
I think the old version was infected by some malware or spyware, and I or something in the QB64-code accidentally activated its built-in debug-function - because it also showed CPU and cores temperature among other things.
I've used SpyBot Search and Destroy (recommended) to scan my C: drive and it found a handful of crap, which it deleted.
The other two drives are 8 TB each, and it would take days to scan - so I skipped them.

However, it might be a good idea to add some simple CRC-check to qb64.exe, just to be on the safe side.
I'm gonna do that from now on with my own programs...

9
QB64 Discussion / Re: Strange bug with FPS counter, popping up in QB64
« on: September 27, 2019, 08:27:16 pm »
Ok?!! Thanks for the answer.
So.. For real? Because I haven't touched my computer between yesterday and today!!
Hmmm… Let's do as you propose and see if I find anything in boot or so. (I've tried re-booting, several times actually - it didn't help.)

It's just got even more stranger.

10
QB64 Discussion / Strange bug with FPS counter, popping up in QB64
« on: September 27, 2019, 07:50:46 pm »
Hi!
Sorry, I couldn't find a way to post this in "Bugs"-section, but here we go...

I'm a mostly daily user of QB64 as it was chosen as the standard programming language where I work (https://www.spacechain.org/download/download.html ) , and I was coding yesterday, just as today - nothing have changed. I haven't installed any new programs or done any reconfiguration, or anything at all.
I was coding yesterday - I shutdown my computer, and then I woke up, made my tea while the computer was booting, and then I started QB64 to start writing - but suddenly, this overlay OSD FPS-counter shows up after just a few seconds.
I thought at first that I had activated some kind of debug function and I've tried every key-combination I can think of, looked through the menus (as much as that can be seen, as it's below the FPS-counter.) but couldn't disable it.
I've tried to restart several times, even the computer too, but it keeps coming back.
The last thing I need right now, is to re-install QB64, because of lot reasons, like post-modifications of the compiler that I've no idea of, but the guy who instructed me on how-to, and I can't find that e-mail.
I can't just e-mail him and wait a couple of days before he answers, as I've got tons of work to do and I can't sit around doing nothing for days in the office.
So please! Help! I'm really stuck here.

Thanks in advance.
With regards.

Pages: [1]