Recent posts

#71
OxygenBasic Examples / Re: Create a Line consoleG
Last post by Charles Pegge - November 13, 2023, 06:04:58 AM
Hi Frank,

This code demonstrates how lines can be connected to the moveable sphere points:

  #compact
  %filename "t.exe"
 'uses RTL64
 '% Title "Create Points and Lines Demo"
  % Title "ConsoleG Demo:  Move text with mouse and arrow keys etc"

 '% WindowStyle WS_OVERLAPPEDWINDOW
 '% Animated
 '% ScaleUp
  % PlaceCentral
  % AnchorCentral

  % shaders

  uses consoleG
 
  'Keys: Esc, arrow-keys, n,m, F4

  BeginScript

  procedure main
  ==============

  'WaitForEvent '0 off 1 on (default on)
  static quad t1,t2

  if opening then 'FIRST CALL ONLY
    'picked=100
    'mbox "helo"
  end if
  '
  if closing then 'FINAL CALL BEFORE SHUTDOWN
    'mbox "Bye!"
    exit sub
  end if
  cls 0,.4,0
  shading
  'CREATE POINTS
  if opening
    %n 100
    static MoveableObject mu[n]
    '#recordof a
    scope
      int i=n
      int k=100
      for i=1 to n
        mu[i].mode=0x101
        k+=100
        mu[i].id=k
      next
    end scope
  endif
  scale 1
  int i, j
  thickness 3
  for i=1 to 20
    pushstate
    mu[i].act 'FIXES LOCATION
    if mu[i].x + mu[i].y = 0
      color .9,.9,.9,1
    else
      color .9,.5,0,1
    endif
    go sphere
    popstate
  next
  '
  flat
  for i=1 to 20
    j=i+1
    if mu[i].x + mu[i].y <> 0
      if mu[j].x + mu[j].y <> 0
        'DRAW LINE BETWEEN POINTS
        'INCLUDE D.X D.Y MOUSE DRAG
        glbegin GL_LINES
        glVertex3f mu[i].x+mu[i].d.x, mu[i].y+mu[i].d.y, 0
        glVertex3f mu[j].x+mu[j].d.x, mu[j].y+mu[j].d.y, 0
        glend
      endif
    endif
  next
  shading
  picklabel 0

  move 5,0

  'if not pick then
    if key[49] then picked=100 'keypress '1'
    if key[50] then picked=200 'kypress  '2'
    pushstate
    move -20,12
    static sys tally
    timemark t2
    scale 1.0
    '
    macro pr(a,b) 'PRINTING LIST
    ----------------------------
      pushstate : color .5,1,1 : print a : popstate
      pushstate : color 1,1,.5 : move 8 : print b : popstate
      printl ""
    end macro
    picklabel 10
   'pr "Action Code:   ", str(act)
   'pr "indexbase      ", str(indexbase)
    pr "Picked ID:     ", str(picked)
    pr "Keyboard Code: ", str(keyd)
    picklabel 0
    popstate
  'end if

  end procedure 'main

  EndScript
#72
OxygenBasic / Re: FileDialog Multiselect
Last post by Nicola - November 12, 2023, 10:58:49 PM
Of course not...
It's better not to end up like a rabbit. ???

That's why my idea of making a string easily workable with a split return, using a separator character that can't be used for a filename.
The string contains the number of selected files in the first place, then the Directory and then the names of the files.
#73
OxygenBasic Examples / Re: Create a Line consoleG
Last post by Frank Brübach - November 12, 2023, 08:19:56 PM
Hey Charles some Help would be great Something I did wrong but what?

My Intention was to create a simple Line between x and y and Transform IT to your Data overview. I tried a new Procedure for Mousehandling (freebasic stuff) ... Must be more simpler to Code

Thanks Frank


 '#compact
 '%filename "t.exe"
 'uses RTL64
  % Title "Triangle Data:  Move points with mouse and arrow keys etc"

 '% WindowStyle WS_OVERLAPPEDWINDOW
 '% Animated
 '% ScaleUp
  % PlaceCentral
  % AnchorCentral

 '% shaders

  uses consoleG
 'uses glo2/geoplanar
 
  'Keys: Esc, arrow-keys, n,m, F4

  BeginScript

  procedure sqbutton(float x,y)
  =============================
  glbegin GL_QUADS
  glvertex2f 0,0
  glvertex2f x,0
  glvertex2f x,y
  glvertex2f 0,y
  glend
  end procedure

  '--------------- mouse click for line creation2 ------ //

  procedure handleMouseClick(float x, y)
  =========================================
    static float xa, ya, xb, yb
    static integer clickCount

    if clickCount = 0 then
      xa = x
      ya = y
      clickCount = 1
    elseif clickCount = 1 then
      xb = x
      yb = y
      clickCount = 0

      glBegin GL_LINES
        glVertex2f xa, ya
        glVertex2f xb, yb
      glEnd
    end if
  end procedure
 
  '--------------- mouse click for line creation2 ------ //


  procedure main()
  ================

  'WaitForEvent '0 off 1 on (default on)
  static quad t1,t2

  static float rc,gc,bc 'colors

  if opening 'FIRST CALL ONLY
    timemark t1
    'picked=100
    'mbox "helo"
    'Triangle interior color
    rc=0.8
    gc=0.0
    bc=0.8
  end if
  '
  if closing 'FINAL CALL BEFORE SHUTDOWN
    'mbox "Bye!"
    exit sub
  end if
  cls
  shading
  UserMovement mu,1100,3 'symbol identity, count
  if opening
    mu[1].x= 0
    mu[1].y= 5
    mu[2].x=-5
    mu[2].y=-5
    mu[3].x= 5
    mu[3].y=-5
  endif
  scale 1
  picklabel 0
  int i
  for i=1 to 3
    pushstate
    color 1,.9,0,1
    mu[i].act
    scale 0.5
    go sphere
    popstate
  next
  picklabel 0
  float xa,xb,xc,ya,yb,yc
  xa=mu[1].x : ya=mu[1].y
  xb=mu[2].x : yb=mu[2].y
  xc=mu[3].x : yc=mu[3].y
  '
  select picked
    'COLOR BUTTON SELECTION
    case 10 : rc=0.9 : gc=0.2 : bc=0.0
    case 20 : rc=0.2 : gc=0.9 : bc=0.0
    case 30 : rc=0.0 : gc=0.6 : bc=0.9
    case 40 : rc=0.6 : gc=0.0 : bc=0.9
    case 50 : rc=0.2 : gc=0.1 : bc=0.9

    'MOUSE DRAG ADJUSTMENT
    case 1100 : xa+=mu[1].d.x : ya+=mu[1].d.y
    case 1200 : xb+=mu[2].d.x : yb+=mu[2].d.y
    case 1300 : xc+=mu[3].d.x : yc+=mu[3].d.y
  end select
  flat
  thickness 2
  '
  if pick
    picklabel 2000
   
  else
    color 1,1,0,1
    pushstate
    move xa-.5,ya-1
    gprint "A"
    popstate
    pushstate
    move xb+1,yb+1
    gprint "B"
    popstate
    pushstate
    move xc-1,yc+1
    gprint "C"
    popstate
  endif
  '
  '------------- create a line x to y by mouseclick -------- //
    pushstate
    'if key[65] then picked=3000
    'gprint "key a was pushed"
 
    'if not pick
    picklabel 3000
    move 5.0
    move mu[1].x-1.5,mu[1].y-2 'xa-.5,ya-1
    gprint "point X "
    handleMouseClick(mu[1].x, mu[1].y)
    'handleMouseClick(xa, ya)
    popstate
   
    pushstate
    move 5.0
    'move mu[2].x+2.5,mu[2].y+3.5 'xb+2,yb+2
    gprint "point Y "
    handleMouseClick(mu[2].x, mu[2].y)
    'handleMouseClick(xb, yb)

    'gprint "mouse on line A "
    'move xa-.15,ya-2
    'move xb+2,yb+2
    'gprint " mouse on line B"
    'end if
    popstate
'------------- create a line a to b by mouseclick -------- //

  if not pick
    color rc,gc,bc
    float zp=-1.001
    glBegin GL_TRIANGLES
    glVertex3f xa,ya,zp
    glVertex3f xb,yb,zp
    glVertex3f xc,yc,zp
    glEnd
    '
    color 0,.9,.9
    glBegin GL_LINES
    glVertex2f xa,ya
    glVertex2f xb,yb
    glVertex2f xb,yb
    glVertex2f xc,yc
    glVertex2f xc,yc
    glVertex2f xa,ya
    glEnd
  endif
'-------------------------------- //
'-------------------------------- //
  move 5

  'if not pick
    if key[49] then picked=100 'keypress '1'
    if key[50] then picked=200 'keypress  '2'
    pushstate
    move -20,12
    static sys tally
    timemark t2
    scale 1.0
    '
    int dp=3
    '
    macro pr1(a) 'PRINTING LIST
    -----------------------------
      pushstate : color .5,1,1 : print a : popstate
      printl ""
    end macro
    '
    macro pr2(a,b) 'PRINTING LIST
    -----------------------------
      pushstate : color .5,1,1 : print a : popstate
      pushstate : color 1,1,.5 : move 4 : print str(b,dp) : popstate
      printl ""
    end macro
    '
    macro pr3(a,b,c) 'PRINTING LIST
    ------------------------------
      pushstate : color .5,1,1 : print a : popstate
      pushstate : color 1,1,.5 : move 4 : print str(b,dp) : popstate
      pushstate : color 1,1,.5 : move 8 : print str(c,dp) : popstate
      printl ""
    end macro
    '
    'BUTTON CONTROLS
    ----------------
    '
    pushstate
    if pick
      picklabel 10
    else
      color .80,.2,0
    endif
    sqbutton 2,2
    move 3.0
    '
    if pick
      picklabel 20
    else
      color .2,.80,0
    endif
    sqbutton 2,2
    move 3.0
    '
    if pick
      picklabel 30
    else
      color 0,.60,.90
    endif
    sqbutton 2,2
    move 3.0
    '
    if pick
      picklabel 40
    else
      color .60,0,.90
    endif
    sqbutton 2,2
    move 3.0
    '
    if pick
      picklabel 50
    else
      color .20,0,.90
    endif
    sqbutton 2,2
    move 3.0
   
    popstate

    move 0,-3.0,0
    '
    'DISPLAY INFO
    -------------
    picklabel 0

    pushstate
    scale 2
    color 1,1,1
    print "Triangle Data"
    popstate


    move 0,-1.5

   'pr2 "Action Code:   ", act
   'pr2 "indexbase      ", indexbase
   'pr2 "Keyboard Code: ", keyd
    pr2 "Picked ID:     ", picked
    '
    move 0,-1.5
    '
    pr3 "Point A: ", str(xa,3), ya
    pr3 "Point B: ", str(xb,3), yb
    pr3 "Point C: ", str(xc,3), yc
    '
    float ab,ac,bc,ar,ht,hb
    '
    ab=hypot(xa-xb, ya-yb)
    ac=hypot(xa-xc, ya-yc)
    bc=hypot(xb-xc, yb-yc)
    '
    hb=0.5* ( ab*ab - ac*ac + bc*bc ) / bc
    ht=sqr(ab*ab-hb*hb)
    ar=0.5*bc*ht

    'ANGLES
    float na,nb,nc
    nb=deg(asin(ht/ab))
    nc=deg(asin(ht/ac))
    na=180-nb-nc

    pr1 ""
    pr2 "Angle A:",na
    pr2 "Angle B:",nb
    pr2 "Angle C:",nc
   
    pr1 ""
    pr2 "Line AB:",ab
    pr2 "Line AC:",ac
    pr2 "Line BC:",bc
    pr2 "Left base:",hb
    pr2 "Height:",ht
    pr2 "Area:", ar
    pr1 ""
    '
    picklabel 0
    popstate
  'end if
  end procedure 'main
  EndScript

#74
OxygenBasic / Re: FileDialog Multiselect
Last post by Charles Pegge - November 12, 2023, 03:53:32 PM
It is possible but there's trouble from the (string) garbage collector so you have to use bstrings and dispose of them yourself.

Also, when working in a multi-threaded application, it is not safe to pass string arrays naively.

Do you want to go down this technical rabbit hole?  :)
#75
OxygenBasic / Re: FileDialog Multiselect
Last post by Nicola - November 12, 2023, 01:33:09 PM
Thanks Charles.

I'm probably saying a lot of nonsense, but wouldn't it be possible to do the opposite? That is, return the pointer to an array worked in the procedure:

procedure foo()
dim s[100]
...
  return *s[]

end procedure

dim string f
*f = foo[]
#76
OxygenBasic / Re: FileDialog Multiselect
Last post by Charles Pegge - November 12, 2023, 08:37:12 AM
Hi Nicola,

Because it is customized, I would recommend exposing the full OPENFILENAME structure in your application, and process the result directly. Then you can set up a string array to capture the filenames instead of printing them.

But to return an array of strings, from any procedure, deploy the string array param like this:
procedure foo(string *s[])
...
end procedure

dim string f[100]
foo f[]
#77
OxygenBasic Examples / Create a Line consoleG
Last post by Frank Brübach - November 12, 2023, 01:23:43 AM
Good morning... Hi Charles how I can create a simple Line by mouseclick with a Label? I have build a Procedure for IT but how to place IT and how to Transform These Data?
Nice sunday Bye Frank

PS I have changed the Code a little.


 '#compact
 '%filename "t.exe"
 'uses RTL64
  % Title "Triangle Data:  Move points with mouse and arrow keys etc"

 '% WindowStyle WS_OVERLAPPEDWINDOW
 '% Animated
 '% ScaleUp
  % PlaceCentral
  % AnchorCentral

 '% shaders

  uses consoleG
 'uses glo2/geoplanar
 
  'Keys: Esc, arrow-keys, n,m, F4

  BeginScript

  procedure sqbutton(float x,y)
  =============================
  glbegin GL_QUADS
  glvertex2f 0,0
  glvertex2f x,0
  glvertex2f x,y
  glvertex2f 0,y
  glend
  end procedure

  '--------------- mouse click for line creation ------ //
  procedure handleMouseClick(float x,y) 'z
  =========================================
  float xa,ya,xb,yb,xc,yc
  glBegin GL_LINES
    glVertex2f xa+10, ya-10 '10,-10 '
    glVertex2f xb-10, yb+10 '-10, 10
    'glVertex2f xc, yc
  glEnd
  end procedure
    '--------------- mouse click for line creation ------ //


  procedure main()
  ================

  'WaitForEvent '0 off 1 on (default on)
  static quad t1,t2

  static float rc,gc,bc 'colors

  if opening 'FIRST CALL ONLY
    timemark t1
    'picked=100
    'mbox "helo"
    'Triangle interior color
    rc=0.8
    gc=0.0
    bc=0.8
  end if
  '
  if closing 'FINAL CALL BEFORE SHUTDOWN
    'mbox "Bye!"
    exit sub
  end if
  cls
  shading
  UserMovement mu,1100,3 'symbol identity, count
  if opening
    mu[1].x= 0
    mu[1].y= 5
    mu[2].x=-5
    mu[2].y=-5
    mu[3].x= 5
    mu[3].y=-5
  endif
  scale 1
  picklabel 0
  int i
  for i=1 to 3
    pushstate
    color 1,.9,0,1
    mu[i].act
    scale 0.5
    go sphere
    popstate
  next
  picklabel 0
  float xa,xb,xc,ya,yb,yc
  xa=mu[1].x : ya=mu[1].y
  xb=mu[2].x : yb=mu[2].y
  xc=mu[3].x : yc=mu[3].y
  '
  select picked
    'COLOR BUTTON SELECTION
    case 10 : rc=0.9 : gc=0.2 : bc=0.0
    case 20 : rc=0.2 : gc=0.9 : bc=0.0
    case 30 : rc=0.0 : gc=0.6 : bc=0.9
    case 40 : rc=0.6 : gc=0.0 : bc=0.9
    case 50 : rc=0.2 : gc=0.1 : bc=0.9

    'MOUSE DRAG ADJUSTMENT
    case 1100 : xa+=mu[1].d.x : ya+=mu[1].d.y
    case 1200 : xb+=mu[2].d.x : yb+=mu[2].d.y
    case 1300 : xc+=mu[3].d.x : yc+=mu[3].d.y
  end select
  flat
  thickness 2
  '
  if pick
    picklabel 2000
   
  else
    color 1,1,0,1
    pushstate
    move xa-.5,ya-1
    gprint "A"
    popstate
    pushstate
    move xb+1,yb+1
    gprint "B"
    popstate
    pushstate
    move xc-1,yc+1
    gprint "C"
    popstate
  endif
  '
  '------------- create a line a to b by mouseclick -------- //
    pushstate
    'if key[65] then picked=3000
    'gprint "key a was pushed"
 
    'if pick
    picklabel 3000
    move mu[1].x-1.5,mu[1].y-2 'xa-.5,ya-1
    gprint "point X "
    popstate
    pushstate
    move mu[2].x+2,mu[2].y+2 'xb+2,yb+2
    gprint "point Y "
   
    gprint "mouse on line A "
    'move xa-.15,ya-2
    handleMouseClick(mu[1].x, mu[1].y)
    'move xb+2,yb+2
    handleMouseClick(mu[2].x, mu[2].y)
    gprint " mouse on line B"
    'end if
    popstate
'------------- create a line a to b by mouseclick -------- //

  if not pick
    color rc,gc,bc
    float zp=-1.001
    glBegin GL_TRIANGLES
    glVertex3f xa,ya,zp
    glVertex3f xb,yb,zp
    glVertex3f xc,yc,zp
    glEnd
    '
    color 0,.9,.9
    glBegin GL_LINES
    glVertex2f xa,ya
    glVertex2f xb,yb
    glVertex2f xb,yb
    glVertex2f xc,yc
    glVertex2f xc,yc
    glVertex2f xa,ya
    glEnd
  endif
'-------------------------------- //
'-------------------------------- //
  move 5

  'if not pick
    if key[49] then picked=100 'keypress '1'
    if key[50] then picked=200 'keypress  '2'
    pushstate
    move -20,12
    static sys tally
    timemark t2
    scale 1.0
    '
    int dp=3
    '
    macro pr1(a) 'PRINTING LIST
    -----------------------------
      pushstate : color .5,1,1 : print a : popstate
      printl ""
    end macro
    '
    macro pr2(a,b) 'PRINTING LIST
    -----------------------------
      pushstate : color .5,1,1 : print a : popstate
      pushstate : color 1,1,.5 : move 4 : print str(b,dp) : popstate
      printl ""
    end macro
    '
    macro pr3(a,b,c) 'PRINTING LIST
    ------------------------------
      pushstate : color .5,1,1 : print a : popstate
      pushstate : color 1,1,.5 : move 4 : print str(b,dp) : popstate
      pushstate : color 1,1,.5 : move 8 : print str(c,dp) : popstate
      printl ""
    end macro
    '
    'BUTTON CONTROLS
    ----------------
    '
    pushstate
    if pick
      picklabel 10
    else
      color .80,.2,0
    endif
    sqbutton 2,2
    move 3.0
    '
    if pick
      picklabel 20
    else
      color .2,.80,0
    endif
    sqbutton 2,2
    move 3.0
    '
    if pick
      picklabel 30
    else
      color 0,.60,.90
    endif
    sqbutton 2,2
    move 3.0
    '
    if pick
      picklabel 40
    else
      color .60,0,.90
    endif
    sqbutton 2,2
    move 3.0
    '
    if pick
      picklabel 50
    else
      color .20,0,.90
    endif
    sqbutton 2,2
    move 3.0
   
    popstate

    move 0,-3.0,0
    '
    'DISPLAY INFO
    -------------
    picklabel 0

    pushstate
    scale 2
    color 1,1,1
    print "Triangle Data"
    popstate


    move 0,-1.5

   'pr2 "Action Code:   ", act
   'pr2 "indexbase      ", indexbase
   'pr2 "Keyboard Code: ", keyd
    pr2 "Picked ID:     ", picked
    '
    move 0,-1.5
    '
    pr3 "Point A: ", str(xa,3), ya
    pr3 "Point B: ", str(xb,3), yb
    pr3 "Point C: ", str(xc,3), yc
    '
    float ab,ac,bc,ar,ht,hb
    '
    ab=hypot(xa-xb, ya-yb)
    ac=hypot(xa-xc, ya-yc)
    bc=hypot(xb-xc, yb-yc)
    '
    hb=0.5* ( ab*ab - ac*ac + bc*bc ) / bc
    ht=sqr(ab*ab-hb*hb)
    ar=0.5*bc*ht

    'ANGLES
    float na,nb,nc
    nb=deg(asin(ht/ab))
    nc=deg(asin(ht/ac))
    na=180-nb-nc

    pr1 ""
    pr2 "Angle A:",na
    pr2 "Angle B:",nb
    pr2 "Angle C:",nc
   
    pr1 ""
    pr2 "Line AB:",ab
    pr2 "Line AC:",ac
    pr2 "Line BC:",bc
    pr2 "Left base:",hb
    pr2 "Height:",ht
    pr2 "Area:", ar
    pr1 ""
    '
    picklabel 0
    popstate
  'end if

  end procedure 'main

  EndScript

'picklabel 2000
'  pushstate
'   if pick
'    move 3.0
'    picklabel 3000
    'handleMouseClick(mu[1].x, mu[1].y) ' Handle mouse click for the first point
'  popstate
'  endif

#78
OxygenBasic / Re: FileDialog Multiselect
Last post by Nicola - November 12, 2023, 12:36:46 AM
Great Charles. :)

I tried putting this in the FileDialogs. I got this...
Unfortunately, I don't know how to get an array to return from a function.

'no case sensitivity

#ifndef HAS_COREWIN
  uses corewin
#endif

% OFN_READONLY                 0x00000001
% OFN_OVERWRITEPROMPT          0x00000002
% OFN_HIDEREADONLY             0x00000004
% OFN_NOCHANGEDIR              0x00000008
% OFN_SHOWHELP                 0x00000010
% OFN_ENABLEHOOK               0x00000020
% OFN_ENABLETEMPLATE           0x00000040
% OFN_ENABLETEMPLATEHANDLE     0x00000080
% OFN_NOVALIDATE               0x00000100
% OFN_ALLOWMULTISELECT         0x00000200
% OFN_EXTENSIONDIFFERENT       0x00000400
% OFN_PATHMUSTEXIST            0x00000800
% OFN_FILEMUSTEXIST            0x00001000
% OFN_CREATEPROMPT             0x00002000
% OFN_SHAREAWARE               0x00004000
% OFN_NOREADONLYRETURN         0x00008000
% OFN_NOTESTFILECREATE         0x00010000
% OFN_NONETWORKBUTTON          0x00020000
% OFN_NOLONGNAMES              0x00040000     '// force no long names for 4.x modules
% OFN_EXPLORER                 0x00080000     '// new look commdlg
% OFN_NODEREFERENCELINKS       0x00100000
% OFN_LONGNAMES                0x00200000     '// force long names for 3.x modules
% OFN_ENABLEINCLUDENOTIFY      0x00400000     '// send include message to callback
% OFN_ENABLESIZING             0x00800000
% OFN_DONTADDTORECENT          0x02000000
% OFN_FORCESHOWHIDDEN          0x10000000     '// Show All files including System and hidden files


type OPENFILENAMEA
  DWORD  lStructSize
  SYS    hwndOwner
  SYS    hInstance
  CHAR*  lpstrFilter
  CHAR*  lpstrCustomFilter
  DWORD  nMaxCustFilter
  DWORD  nFilterIndex
  CHAR*  lpstrFile
  DWORD  nMaxFile
  CHAR*  lpstrFileTitle
  DWORD  nMaxFileTitle
  CHAR*  lpstrInitialDir
  CHAR*  lpstrTitle
  DWORD  Flags
  WORD   nFileOffset
  WORD   nFileExtension
  CHAR*  lpstrDefExt
  LONG   lCustData
  SYS    lpfnHook
  CHAR*  lpTemplateName
end type

typedef OPENFILENAMEA OPENFILENAME

Declare GetModuleHandle      lib "kernel32.dll" alias "GetModuleHandleA" (optional char*n) as sys
Declare GetOpenFileName      Lib "comdlg32.dll" Alias "GetOpenFileNameA" (OPENFILENAME*opfn) As sys
Declare GetSaveFileName      Lib "comdlg32.dll" Alias "GetSaveFileNameA" (OPENFILENAME*opfn) As sys
Declare CommDlgExtendedError Lib "comdlg32.dll" () as dword

[font=Verdana, Arial, Helvetica, sans-serif][/font]
[font=Verdana, Arial, Helvetica, sans-serif]'FileDialog( $ iDir , $ filter ,$ title , % parent , flag )[/font]

Function FileDialog(string iDir,filter,Title,Name, sys Hwnd, Flags, a) As String
'===============================================================================
String Selex

OPENFILENAME ofn
int FileNameLen=2048
char         FileName[2048]
if Name then FileName=Name
int          retval

 ofn.lStructSize       = sizeof(OPENFILENAME)
 ofn.hwndOwner         = hWnd
 ofn.hInstance         = GetModuleHandle
 ofn.lpstrFilter       = filter
 ofn.lpstrCustomFilter = null
 ofn.nMaxCustFilter    = 0
 'ofn.nFilterIndex      = 1
 ofn.lpstrFile         = FileName 'coupling to char buffer
 ofn.nMaxFile          = FileNameLen
 ofn.lpstrFileTitle    = null
 ofn.nMaxFileTitle     = 0
 ofn.lpstrInitialDir   = idir
 ofn.lpstrTitle        = title
 ofn.Flags             = flags
 ofn.nFileOffset       = 0
 ofn.nFileExtension    = 0
 ofn.lpstrDefExt       = null
 ofn.lCustData         = 0
 ofn.lpfnHook          = 0
 ofn.lpTemplateName    = null


sys retval
'
if a then
 retval=GetSaveFileName(ofn)
else
 retval=GetOpenFileName(ofn)
end if
'
'http://msdn.microsoft.com/en-us/library/windows/desktop/ms646916(v=vs.85).aspx

if retval
  char*pt
  @pt=@Filename
  int j
  int fcount
  j=ofn.nFileOffset
  Selex = left(pt,j)+";"
  @pt+=j    
  while asc(pt)
    fCount++
    Selex=Selex+pt+";"
    @pt+=len(pt)+1
  wend
  return fCount+";"+Selex
else
  return ""
end if

End Function


Function GetFileName(string name, sys a, string filt="") as string
'=================================================================
'
'dir="OxygenBasic\demos\GUI"
'
sys    hwnd
string filter,dir,title
'
if filt then
  filter=filt
else
  string sep=chr(0)
  filter=
  "all files"+sep+"*.*"+sep+
  "text"+sep+"*.txt"+sep+
  "basic"+sep+"*.bas;*.o2bas"+sep+
  "include"+sep+"*.inc"+sep+
  "header"+sep+"*.h"+sep+
  sep
end if
'
if a then
  title="Save File as"
else
  title="Load File"
end if
'
sys flags = OFN_EXPLORER or OFN_OVERWRITEPROMPT or OFN_HIDEREADONLY
'
return FileDialog(dir,filter,title,name,hwnd,flags,a)
'
end function



'! SHBrowseForFolder Lib "shell32" (BrowseInfo *lpbi) as sys
'! SHGetPathFromIDList Lib "shell32" (sys pidList, sys lpBuffer) As sys



function BrowseCallbackProc(sys hwnd, int uMsg, sys wParam, lParam) as int, callback
====================================================================================
'Used with the BrowseForFolder function to select a default folder
  % BFFM_ENABLEOK       0x465
  % BFFM_SETSELECTION   0x466
  % BFFM_SETSTATUSTEXT  0x464
  % BFFM_INITIALIZED    1
  % BFFM_SELCHANGED     2
  % BFFM_VALIDATEFAILED 3
  '
  if uMsg = BFFM_INITIALIZED
    SendMessage(hwnd, BFFM_SETSELECTION, uMsg, lParam )
  endif
  return 0  ' the function should always return 0
end function


type BrowseInfo
  sys hWndOwner
  sys pIDLRoot
  sys pszDisplayName
  sys lpszTitle
  int ulFlags
  sys lpfnCallback
  sys lParam
  int iImage
end type
'
function BrowseForDir(sys hWnd,  string strTitle="", strInitDir="\" ) as string
===============================================================================
 '% BIF_RETURNONLYFSDIRS = 1
 '% BIF_EDITBOX = &H10
  % MAX_PATH = 260
  '
  BrowseInfo tbi
  tbi.hWndOwner = hwnd
  tbi.lpszTitle = strptr(strTitle)
 'tbi.ulFlags = BIF_RETURNONLYFSDIRS or BIF_EDITBOX
  tbi.lpfnCallback = @BrowseCallbackProc
  tbi.lParam = strptr(strInitDir)
  sys h = SHBrowseForFolder(@tbi)
  if h
    char s[MAX_PATH]
    SHGetPathFromIDList(h, s)
    return s
  endif
end function

'USAGE:
'sys hWnd=0
'print strDir = BrowseForDir(hWnd,"Select a Folder","c:\users")


The program to try I used this:
uses filedialogs_1

string sep=chr(0)
string filter="pdf"+sep+"*.pdf"
string tipOFN, f
sys tipo

int i

sub printout()
[font=Verdana, Arial, Helvetica, sans-serif]   f=FileDialog("C:\",filter,tipofn,"", 0,tipo,0)[/font]
  print f
 
end sub



tipOFN="OFN_EXPLORER or OFN_ALLOWMULTISELECT"
tipo=OFN_EXPLORER or OFN_ALLOWMULTISELECT
printout

tipOFN="OFN_EXPLORER"
tipo=OFN_EXPLORER
printout
ExitProcess(0)

tipOFN="OFN_EXPLORER or OFN_OVERWRITEPROMPT or OFN_HIDEREADONLY or OFN_ALLOWMULTISELECT"
tipo=OFN_EXPLORER or OFN_OVERWRITEPROMPT or OFN_HIDEREADONLY or OFN_ALLOWMULTISELECT
printout


tipOFN="OFN_OVERWRITEPROMPT or OFN_HIDEREADONLY or OFN_ALLOWMULTISELECT"
tipo=OFN_OVERWRITEPROMPT or OFN_HIDEREADONLY or OFN_ALLOWMULTISELECT
printout

tipOFN="OFN_OVERWRITEPROMPT or OFN_ALLOWMULTISELECT"
tipo=OFN_OVERWRITEPROMPT or OFN_ALLOWMULTISELECT
printout

tipOFN="OFN_EXPLORER or OFN_ALLOWMULTISELECT"
tipo=OFN_EXPLORER or OFN_ALLOWMULTISELECT
printout

tipOFN="OFN_ALLOWMULTISELECT or OFN_LONGNAMES"
tipo=OFN_ALLOWMULTISELECT or OFN_LONGNAMES
printout


#79
OxygenBasic Examples / Re: My Plan of a 3d modeller ...
Last post by Charles Pegge - November 11, 2023, 04:56:05 PM
I would focus on consoleG since it allows individual objects to be moved easily, and includes OpenglSceneFrame. I will also be adding shaders soon.
#80
OxygenBasic Examples / Re: My Plan of a 3d modeller ...
Last post by Frank Brübach - November 11, 2023, 01:25:43 PM
Hi Charles... I have a General question about consoleG using and OpenGL whats the better way of working If I want to model via mouseclick a rectangle or Other Polygon similar to Triangel vector Data example?
I have constructed a simple Demo with rectangle Data vector and two OpenGL objects in IT See Pic below...
I suppose I cant working with both Systems together in one OpenGL window frame

Thanks Frank