Liberty BASIC Community Forum
« Search Results »

Welcome Guest. Please Login or Register.
Sep 18th, 2014, 10:39am


Rules|Home|Help|Search|Recent Posts|Notification

--Liberty BASIC Resources--
Yahoo Code Repository (source must be included)
Liberty BASIC Community WikiSpace
Liberty Labs
Bay Six Software Forum
Liberty BASIC Home Page

Official Liberty BASIC Support
Liberty BASIC Programmer's Encyclopedia
Liberty BASIC 5 Handbook
Liberty BASIC on Rosetta Code

Search Results

Total results: 10


 1   Novice / add small bitmap directly to your code  on: Today at 04:40am
Started by Rui Branco | Post by Rui Branco
Hello,
Once I found a code in lb forum that add small bitmap directly to your code and then we can show the image in a window, now I can not find the code. Anyone know about this?

Thank you,
Rui
 
  Reply Quote Notify of replies

 2   Novice / Re: Meet the identification of the hard disk  on: Today at 04:19am
Started by YACKARE | Post by Rod
Have a browse at this, Brents second set of code extracts a serial number, whether it stays unique? you will need to experiment. http://libertybasic.conforums.com/index.cgi?board=api&action=display&num=1174897227&start=
 
  Reply Quote Notify of replies

 3   Novice / Re: Drag and Drop?  on: Yesterday at 04:28am
Started by marklew1956 | Post by Rod
I assume here that its files not folders we are dropping. If so there is a cheat, its horrible and I hesitate to post it but it works.

Create this .bat file by copying the code to the liberty editor and saving it as a .bat file name.

Code:
cd\atest
dragdropfile %*
exit 
 


Create an .exe of this program

Code:
    open "CommandLine$ Test" for graphics as #win
    #win "trapclose [quit]"
    #win "down ; place 100 100 ;\";CommandLine$
    wait

 [quit]
    close #win
    end
 


Notice I called the program dragdropfile.exe and that I stored it in C:atest. Name and put yours where you like but edit the .bat file to use the correct name and directory.

What happens now is that if you drop files on the .bat it first changes the directory to the one where your .exe is stored, invokes the .exe and passes the complete argument which is the file list.

So in the .exe CommandLine$ receives the file list which you would need to parse.

If you can arrange for all of the files to be selected to be in the same directory as the .exe you can simply drop them on the .exe. The .bat trick is needed when you move between folders.

 
  Reply Quote Notify of replies

 4   Novice / Re: Drag and Drop?  on: Sep 16th, 2014, 11:30pm
Started by marklew1956 | Post by Chris Iverson
Implementing full drag and drop is nearly impossible in LB, due to needing to use COM. (It can be done, but would be very difficult without a helper library.)

While I happened to find a helper library that would likely be useful for someone wanting to implement full D&D in LB, I also found out that basic D&D that works only on files is available through the basic Win32 API, although it needs another window message that we need WMLiberty to handle.


Here's a basic example of a file drag and drop using the Win32 method. You'll need to put WMLiberty in the same folder as this source code.

Code:
'Form created with the help of Freeform 3 v07-15-08
'Generated on Jul 10, 2014 at 12:24:02

open "WMLiberty" for DLL as #wm
global hButton
global newDropFlag
global hDrop
hDrop = 0
newDropFlag = 0
[setup.main.Window]

    '-----Begin code for #main

    nomainwin
    WindowWidth = 550
    WindowHeight = 410
    UpperLeftX=int((DisplayWidth-WindowWidth)/2)
    UpperLeftY=int((DisplayHeight-WindowHeight)/2)


    Callback filterCB, WMHandler(ulong, ulong, ulong, ulong), ulong
    '-----Begin GUI objects code

    TexteditorColor$ = "white"
    texteditor #main.textedit1,   5,   5, 510, 260

    '-----End GUI objects code

    '-----Begin menu code

    menu #main, "Edit"  ' <-- Texteditor menu.


    '-----End menu code

    open "untitled" for window as #main
    print #main, "font ms_sans_serif 10"
    print #main, "trapclose Quit"

    hMain = hWnd(#main)

    'Set WMLiberty to listen for the DROPFILES message
    CallDLL #wm, "SetWMHandler",_
    hMain as ulong,_
    _WM_DROPFILES as ulong,_
    filterCB as ulong,_
    0 as long,_
    ret as long
    If ret <> 0 then call Quit "#main"

    'Tell Windows that our window can accept files
    'through drag and drop
    CallDLL #shell32, "DragAcceptFiles",_
    hMain as ulong,_
    1 as ulong,_
    ret as void

[main.inputLoop]   'wait here for input event
    scan
    callDLL #kernel32, "Sleep", 100 as long, ret as void

    'If we have new drop data to handle, then take care of it
    if newDropFlag then gosub [handleDrop]
    goto [main.inputLoop]


'The meat of the drag & drop stuff happens here.
'DragQueryFile has three uses, all useful.
[handleDrop]
    'Calling DQF() with 0xFFFFFFFF as the iFile parameter will have
    'it return the total number of files dropped
    '
    'Using this, we check if a file was actually dropped, and then move forward
    'to take care of it.  (A 0 return means an error happened, so we don't handle it.)
    numFiles = DragQueryFile(hDrop, hexdec("FFFFFFFF"), buf$, 0)
    If numFiles > 0 then
        #main.textedit1, numFiles ; " files dropped"
        For x = 1 to numFiles

            'DQF's second use is if you specify a valid file ID in iFile,
            'but give it a null buffer for the name,
            'it will return the size of the buffer needed to hold the name.
            '
            'Therefore, we grab that size, and make a new buffer at
            'exactly that size(+1 to handle the null terminator)
            bufSize = DragQueryFile(hDrop, x - 1, buf$, 0)

            'Again, 0 is an error, so don't continue on the code path
            If bufSize > 0 then
                buf$ = space$(bufSize+1)

                'Finally, we pass in the file ID, the real buffer, and the buffer size,
                'and get the data we need.
                a = DragQueryFile(hDrop, x - 1, buf$, bufSize+1)


                '(Assuming we didn't hit an error.)
                If a > 0 then
                    #main.textedit1, trim$(buf$)

                    'Anything you want to do with the names should be done here.
                End If
            End If
        next x

    End If

    'Each time we get a drag handle, we have to free it back to the OS
    'with DragFinish(hDrop);.
    Call DragFinish hDrop

    'Reset our flag and our drop handle
    '
    'The flag so we don't try to do the drag info twice,
    'and the drop handle so we don't try to use a freed handle
    hDrop = 0
    newDropFlag = 0
    return

Sub Quit hndl$
    hMain = hwnd(#hndl$)
    CallDLL #shell32, "DragAcceptFiles",_
    hMain as ulong,_
    0 as ulong,_
    ret as void

    close #hndl$
    close #wm
    end
End Sub

Function DragQueryFile(hDropHndl, iFile, byref buf$, bufSize)
    If bufSize = 0 then
        CallDLL #shell32, "DragQueryFileA",_
        hDropHndl as ulong,_
        iFile as ulong,_
        _NULL as ulong,_
        0 as ulong,_
        DragQueryFile as ulong
    Else
        CallDLL #shell32, "DragQueryFileA",_
        hDropHndl as ulong,_
        iFile as ulong,_
        buf$ as ptr,_
        bufSize as ulong,_
        DragQueryFile as ulong
    End If
End Function

Sub DragFinish hDropHndl
    CallDLL #shell32, "DragFinish",_
    hDropHndl as ulong,_
    ret as void
End Sub

Function WMHandler(hWnd, uMsg, wParam, lParam)
    'For our handler, instead of doing all the work here,
    'we set the hDrop, set a flag, and do the work later and let
    'WMLiberty return
    hDrop = wParam
    newDropFlag = 1
    WMHandler = 0
End Function 



I'll also point out that this does NOT filter out files versus folders, so that would have to be handled yourself. It also doesn't recursively fill the drop data with folder data, that you will also have to handle yourself. (The FILES command can help for both of these.)
 
  Reply Quote Notify of replies

 5   Novice / Re: Drag and Drop?  on: Sep 16th, 2014, 12:44pm
Started by marklew1956 | Post by Janet
Search in the API / DLL board for SHBrowseForFolder. Set your search back days to 9999.

 
  Reply Quote Notify of replies

 6   Novice / Drag and Drop?  on: Sep 16th, 2014, 07:25am
Started by marklew1956 | Post by marklew1956
Ok, I'm not even sure how to ask the question but here goes....
I've written a program that will process information that I feed it into usable data for a robot. The program uses file input to get file data. It works fine but is very slow since I have to navigate to each folder. What I want is to open a Windows Explorer window, select several folders, then drop them into my program and have it use the folder information for my existing program.
First question: What would you call this? Drag and Drop?
Second question: Where do I start looking.... API calls?
Third question: Any ideas or sample code anywhere?

Thanks in advance...
 
  Reply Quote Notify of replies

 7   Liberty BASIC Code / Re: what's happened to help files  on: Sep 16th, 2014, 02:15am
Started by jlpoynor | Post by Rod
You can simply download and reinstall 4.04. It will not delete your own files. 4.04 should install without problems on everything up to Win8.1 don't think you even need to reregister it should remember you.

Allow the installer to use its default settings.

Tell us if this fixes the problem.
 
  Reply Quote Notify of replies

 8   Liberty BASIC Code / what's happened to help files  on: Sep 15th, 2014, 5:40pm
Started by jlpoynor | Post by jlpoynor
I've got 4.04 and havn't used it for about a year. Now when I click on help it tries to find it on the internet but a message says it's not available. The help stuff that I had disappeared from my hard drive.
 
  Reply Quote Notify of replies

 9   Novice / Re: Meet the identification of the hard disk  on: Sep 15th, 2014, 4:35pm
Started by YACKARE | Post by yackare
First things first:
I have made ​​an application to language learning that would like to distribute on a pendrive, but avoiding that it can be copied. The only solution that occurred to me is to enter the id of the pendrive in an encrypted file and the program checks that matches that number with the id of the pendrive.

I mean, what I want is a code that will give me the ID of the disk or pendrive where the program executable is.
I followed your instructions on the DLL HardwareIDExtractorC.dll and after many tests, I got the following simplified code:

-----
disco$ = "N:"
Open "HardwareIDExtractorC.dll" for DLL as #HwIDex
calldll #HwIDex, "GetPartitionID", disco$ as ptr, pointer as ulong
'GetPartitionID$ = winstring(pointer)
GetPartitionID$ = str$(pointer)
calldll #HwIDex, "ReleaseMemory", pointer as ulong, result as void
print GetPartitionID$
close #HwIDex
end
----------------
The problem is that if you run it from the editor works properly, providing guidance 179834208 and 9E7F-0917 ID pendrive.
However, if I make an executable application, the address (and the ID pendrive) changes each time the run and gives unpredictable results (eg 151 326 048 and 0932-6989).

Give me I would appreciate your opinion on what may be happening.

Also wanted to ask if you could get that data by invoking a windows API (Api GetVolumeInformation) and if you can tell me the code for LibertyBasic.

Thanks for your great help.

 
  Reply Quote Notify of replies

 10   Game and Graphic Programming / Re: Raytracing  on: Sep 13th, 2014, 09:19am
Started by Rod | Post by bluatigro
update :
- now whitout error reports

error :
- i get only a line what shoot be a square

Code:
''ray caster : spheres and planes
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
global winx , winy
winx = WindowWidth
winy = WindowHeight
dim shape( 10 , 7 ) , dist( 10 )
global ttype , tx , ty , tz , td , tred , tgreen , tblue , ttel
global tsphere , tplane

ttype = 0
tx = 1
ty = 2
tz = 3
td = 4
tred = 5
tgreen = 6
tblue = 7

tsphere = 1
tplane = 2

red = rgb( 255 , 0 , 0 )
white = rgb( 255 , 255 , 255 )

call plane 0,1,0 , -100 , white
call sphere 0,0,50 , 50 , red

nomainwin

open "ray 1.1" for graphics as #m
  #m "trapclose [quit]"

  for x = -100 to 100
    for y = -100 to 100
      ox = x
      oy = y
      oz = 0
      dx = x / 100
      dy = y / 100
      dz = 1
      for i = 0 to ttel
        dist( i ) = hit( i , ox , oy , oz , dx , dy , dz )
      next i
      i = index()
      if i < 0 then
        #m "color black"
      else
        #m "color" ; kleur$( i )
      end if
      #m "goto " ; winx / 2 + x ; " " ; winy / 2 - y
      #m "down"
      #m "set " ; winx / 2 + x ; " " ; winy / 2 - y
      #m "up"
    next y
  next x

  notice "ready !!"
wait
[quit]
  close #m
end

function index()
  low = 1e10
  uit = -1
  for i = 0 to ttel
    if dist( i ) > 0 and dist( i ) < low then
      uit = i
      low = dist( i )
    end if
  next i
  index  = uit
end function

function kleur$( i )
  r = shape(i,tred)
  g = shape(i,tgreen)
  b = shape(i,tblue)
  kleur$ = " " ; r ; " " ; g ; " "; b
end function

function color$( no )
  kl = shape(no,tred)
  r = int( kl ) and 255
  g = int( kl / 256 ) and 255
  b = int( kl / 256^2 ) and 255
  color$ = " " ; r ; " " ; g ; " " ; b
end function

function rgb( r , g , b )
  r = r and 255
  g = g and 255
  b = b and 255
  rgb = r + g * 256 + b * 256 ^ 2
end function

function hit( no , ox , oy , oz , dx , dy , dz )

      sx = shape( no , tx )
      sy = shape( no , ty )
      sz = shape( no , tz )
      sr = shape( no , tr )

  select case shape( no , ttype )
    case tsphere
      a = 1
      b = ( 2 * ( ox - sx ) * dx ) _
        + ( 2 * ( oy - sy ) * dy ) _
        + ( 2 * ( oz - sz ) * dz )
      c = ( ox - sx ) ^ 2 _
        + ( oy - sy ) ^ 2 _
        + ( oz - sz ) ^ 2 _
        - ( sr )
      dis = b * b - 4 * a * c
      if dis < 0 then
        uit = -1
      else
        root = ( 0 - sqr( dis ) - b ) / 2 - 1e-10
        if root > 0 then
          uit = root
        else
          uit = ( sqr( dis ) - b ) / 2 + 1e-10
        end if
      end if
    case tplane
      a = dot( sx , sy , sz , dx , dy , dz )
      if a = 0 then
        uit = -1
      else
        call multy sx , sy , sz , 0 - sr
        call add ox , oy , oz , sx , sy , sz
        b = dot( sx , sy , sz , ox , oy , oz )
        uit = 0 - ( b / a )
      end if
    case else
      uit = -1
  end select
  hit = uit
end function

sub multy byref x , byref y , byref z , f
  x = x * f
  y = y * f
  z = z * f
end sub

function lenght( x , y , z )
  lenght = sqr( x ^ 2 + y ^ 2 + z ^ 2 )
end function

function dot( x1 , y1 , z1 , x2 , y2 , z2 )
  dot = x1 * x2 + y1 * y2 + z1 * z2
end function

sub sphere x , y , z , d , kl
  shape( ttel , tx ) = x
  shape( ttel , ty ) = y
  shape( ttel , tz ) = z
  shape( ttel , td ) = d * d
  shape( ttel , tred ) = int( kl ) and 255
  shape( ttel , tgreen ) = int( kl / 256 ) and 255
  shape( ttel , tblue ) = int( kl / 256 ^ 2 ) and 255
  shape( ttel , ttype ) = tsphere
  ttel = ttel + 1
end sub

sub plane x , y , z , d , kl
  call multy x , y , z , 1 / lenght( x , y , z )
  shape( ttel , tx ) = x
  shape( ttel , ty ) = y
  shape( ttel , tz ) = z
  shape( ttel , td ) = d
  shape( ttel , tred ) = int( kl ) and 255
  shape( ttel , tgreen ) = int( kl / 256 ) and 255
  shape( ttel , tblue ) = int( kl / 256 ^ 2 ) and 255
  shape( ttel , ttype ) = tplane
  ttel = ttel + 1
end sub

 

 
  Reply Quote Notify of replies


Rules|Home|Help|Search|Recent Posts|Notification



Donate $6.99 for 50,000 Ad-Free Pageviews!


This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls