GUI design

General FreeBASIC programming questions.
BasicCoder2
Posts: 3954
Joined: Jan 01, 2009 7:03
Location: Australia

Re: GUI design

Post by BasicCoder2 »

All I did was download the FBIDE + FreeBASIC installer and run it. It is apparently an old version of FreeBASIC.
http://fbide.freebasic.net/download
Then I downloaded the latest version of FreeBASIC and installed it over the the old version that came with FBIDE.
I can't find any dll and I am not really up to speed with what a static library actually is.
I wouldn't know how to compile something directly from its C source code all I can say is the program I posted worked as is.
Rather sad it is all so hard to get working.

This file was also in the disphelper folder not sure what it does.

Code: Select all

''
''
'' convert -- header translated with help of SWIG FB wrapper
''
'' NOTICE: This file is part of the FreeBASIC Compiler package and can't
''         be included in other distributions without authorization.
''
''
#ifndef __disphelper_convert_bi__
#define __disphelper_convert_bi__

#include once "win/objbase.bi"

extern "c"
declare function ConvertFileTimeToVariantTime (byval pft as FILETIME ptr, byval pDate as DATE_ ptr) as HRESULT
declare function ConvertVariantTimeToFileTime (byval date as DATE_, byval pft as FILETIME ptr) as HRESULT
declare function ConvertVariantTimeToSystemTime (byval date as DATE_, byval pSystemTime as SYSTEMTIME ptr) as HRESULT
declare function ConvertSystemTimeToVariantTime (byval pSystemTime as SYSTEMTIME ptr, byval pDate as DATE_ ptr) as HRESULT
declare function ConvertTimeTToVariantTime (byval timeT as time_t, byval pDate as DATE_ ptr) as HRESULT
declare function ConvertVariantTimeToTimeT (byval date as DATE_, byval pTimeT as time_t ptr) as HRESULT
declare function ConvertAnsiStrToBStr (byval szAnsiIn as LPCSTR, byval lpBstrOut as BSTR ptr) as HRESULT
declare function ConvertBStrToAnsiStr (byval bstrIn as BSTR, byval lpszOut as LPSTR ptr) as HRESULT
end extern

#endif

BasicCoder2
Posts: 3954
Joined: Jan 01, 2009 7:03
Location: Australia

Re: GUI design

Post by BasicCoder2 »

Are you able to compile and run these two files posted by Imortis?
http://www.freebasic.net/forum/viewtopi ... 60#p227660

Here is the sapi.bi file required followed by the same program as before but with a different speech setup at the start.

save this as sapi.bi

Code: Select all

dim Shared IID_ISpVoice as GUID    => ( &H6c44df74, &H72b9, &H4992, {&Ha1, &Hec, &Hef, &H99, &H6e, &H04, &H22, &Hd4 })
dim Shared CLSID_SpVoice as GUID  => ( &H96749377, &H3391, &H11d2, {&H9e, &He3, &H00, &Hc0, &H4f, &H79, &H73, &H96 })

type ISpVoiceVtbl_ as ISpVoiceVtbl

type ISpVoice
   lpVtbl as ISpVoiceVtbl_ ptr
end type

#define SPF_DEFAULT 0

type ISpVoiceVtbl
   rem iunknown
   QueryInterface as function(byval as ISpVoice ptr, byval as IID ptr, byval as any ptr) as HRESULT
   AddRef as function(byval as ISpVoice ptr) as ULONG
   Release as function(byval as ISpVoice ptr) as ULONG

   rem stubs
   SetNotifySink as function() as HRESULT
   SetNotifyWindowMessage as function() as HRESULT
   SetNotifyCallbackFunction as function() as HRESULT
   SetNotifyCallbackInterface as function() as HRESULT
   SetNotifyWin32Event as function() as HRESULT
   WaitForNotifyEvent as function() as HRESULT
   GetNotifyEventHandle as function() as HRESULT
   SetInterest as function() as HRESULT
   GetEvents as function() as HRESULT    
   GetInfo as function() as HRESULT
   SetOutput as function() as HRESULT
   GetOutputObjectToken as function() as HRESULT
   GetOutputStream as function() as HRESULT

   rem done
   Pause as function(byval as ISpVoice ptr) as HRESULT
   Resume as function(byval as ISpVoice ptr) as HRESULT

   rem stubs
   SetVoice as function() as HRESULT
   GetVoice as function() as HRESULT

        rem done
   Speak as function(byval as ISpVoice ptr, byval pwcs as wstring ptr, byval dwFlags as DWORD, byval pulStreamNumber as ULONG ptr) as HRESULT

   rem stubs
   SpeakStream as function() as HRESULT
   GetStatus as function() as HRESULT
   Skip as function() as HRESULT
   SetPriority as function() as HRESULT
   GetPriority as function() as HRESULT
   SetAlertBoundary as function() as HRESULT
   GetAlertBoundary as function() as HRESULT

   rem done        
        SetRate as function(byval as ISpVoice ptr, byval RateAdjust as integer) as HRESULT
        GetRate as function(byval as ISpVoice ptr, byval RateAdjust as integer ptr) as HRESULT
        SetVolume as function(byval as ISpVoice ptr, byval usVolume as ushort) as HRESULT
        GetVolume as function(byval as ISpVoice ptr, byval pusVolume as ushort ptr) as HRESULT
   WaitUntilDone as function(byval as ISpVoice ptr, byval msTimeout as ULONG) as HRESULT        

   rem stubs
   SetSyncSpeakTimeout as function() as HRESULT
   GetSyncSpeakTimeout as function() as HRESULT
   SpeakCompleteEvent as function() as HRESULT
   IsUISupported as function() as HRESULT
   DisplayUI as function() as HRESULT
end type




save this as speech.bas

Code: Select all

'option explicit

#include once "windows.bi"
#include once "win/winnt.bi"
#include once "win/objbase.bi"
#include once "sapi.bi"
#inclib "ole32"

'dim text as wstring * 256 => "Hello, World"

Dim Shared voice as ISpVoice Ptr


Sub Speak(text As WString Ptr)
   CoInitialize(NULL)
   
   CoCreateInstance(@CLSID_SpVoice, NULL, CLSCTX_ALL, @IID_ISpVoice, cast (any ptr, @voice))
   
   voice->lpVtbl->Speak(voice, *text, SPF_DEFAULT, NULL)
   voice->lpVtbl->WaitUntilDone(voice, INFINITE)
   
   voice->lpVtbl->Release(voice)
   
   CoUninitialize()
End Sub

declare function sound alias"Beep"(frequency as integer,duration as integer) as integer

'======================================================================================

type BUTTON
    as integer x
    as integer y
    as integer w
    as integer h
    as string  t
end type


dim shared as integer totalRows,totalCols
totalRows = 10
totalCols = 10
dim shared as BUTTON  buttons(0 to totalRows,0 to totalCols)
for j as integer = 0 to 10
    for i as integer = 0 to 10
        buttons(i,j).x = i
        buttons(i,j).y = j
        buttons(i,j).w = 1
        buttons(i,j).h = 1
        buttons(i,j).t = "empty"
    next i
next j


dim shared as integer col,row

sub Help()
    speak "We have a 10 by 10 array of buttons."
    speak "Use the four arrow keys to move around the array of buttons."
    speak "A deep tone means you are at the array size limits."
    speak "Press the space bar to read out the current cell coordinates of the array."
    speak "Press the letter H to listen to these instructions at any time."
    speak "Press Escape key to end the program."
end sub

Dim strKey As String
dim ascKey as integer


help()

do
       strKey = inkey
       ascKey = asc(strKey)

        if strKey <> "" then
           ascKey = asc(strKey)
            if ascKey = 255 then
               ascKey = asc(right(strKey,1))
               
                If ascKey = 75 Then
                    if col>0 then
                        col = col - 1
                        sound (500,400)
                    else
                        sound (200,500)
                    end if
                end if
      
                If ascKey = 77 Then
                    if col < totalCols then
                        col = col + 1
                        sound (500,400)
                    else
                        sound (200,500)
                    end if
                end if
                
                if ascKey = 72 then 'up one line
                    if row > 0 then
                        row = row - 1
                        sound (600,400)
                    else
                        sound (200,500)
                    end if
                end if
                
                if ascKey = 80 then 'down one line
                    if row < totalRows then
                        row = row + 1
                        sound (600,400)
                    else
                        sound (200,500)
                    end if
                end if
                
                'update()
                print col,row
            
            else
                
                if strKey = " " then
                    speak "You are at column " & str(col) & "and row" & str(row) & "with contents " & buttons(col,row).t
                end if
                
                if ucase(strKey) = "H" then
                    help()
                end if
                
            end if
            
            
        end if
        sleep 2
    
loop until multikey(&H01)
.
OSchmidt
Posts: 49
Joined: Jan 01, 2016 12:27
Contact:

Re: GUI design

Post by OSchmidt »

Psyche_Demon wrote: I haven't lost interest - I am still following the thread ...
I know I'm a bit late... so hopefully that's still the case... ;)
Psyche_Demon wrote: Although my programming ventures aren't concentrated on GUI's at the moment until a good solution can be found, I am still researching the possibilities of porting LBC (Layout by Code), written by Jamal Mazrui, to FreeBASIC...
If anyone else has taken on this challenge I'd be very interested.
I've tried my best below, to offer something comparable (not really compatible to LBC, but doing a quite
similar thing using a "Vertical-Layout-Class" (which supports horizontal "Bands", containing 1 or more "Cells"
for automatic Widget-alignment).

Speech-support is also included (per MS-SAPI) - and the necessary coding-efforts on your end are relatively low.

It's currently done in a version for VBScript (because it's easier to address COM-libs from there) -
but if you find it useful - and would prefer a version for FreeBasic, I could "wrap it up" for FB-Win32 as well.

What's contained below, is a "FruitBasket-implementation" (FruitBasket.vbs) - which you
probably know as a simple GUI-Demo-scenario, existing for several languages:
https://github.com/jamalmazrui/FruitBasket

There is a ReadMe.txt in the Root of this Zip, which has a few more details how to run the thing, etc.
http://vbRichClient.com/Downloads/ScriptGUI5.zip

In short, if you are on Vista or higher, the Script will run "out of the Box" (after unzipping the RootFolder) -
if you are on XP, you will have to register the RC5-COM-Framework first (but all that is explained in the ReadMe).

Olaf
Post Reply