Recent posts

#31
OxygenBasic Examples / Re: Gettext editbox qt
Last post by Frank Brübach - March 21, 2024, 02:40:58 PM
Thanks Charles Works fine Here now
Regards
#32
General Discussion / The Golden Ratio: Is It Myth o...
Last post by Charles Pegge - March 21, 2024, 02:35:02 PM
The Golden Ratio: Is It Myth or Math?

Be Smart
10 mar 2021


#33
OxygenBasic Examples / Re: Gettext editbox qt
Last post by Charles Pegge - March 21, 2024, 01:28:47 PM
Hi Frank,

Some info on using WM_GETTEXT and WM_SETTEXT. Also WM_GETTEXTLENGTH:

/*
LRESULT SendMessage(
  [in] HWND  hWnd,
  [in] UINT  Msg,
  [in] WPARAM wParam,
  [in] LPARAM lParam
);

  int a
  string s
  a=SendMessage( chwnd[1], WM_GETTEXTLENGTH,0,0)
  s=nuls a
  e=SendMessage( chwnd[1], WM_GETTEXT,a+1 , strptr(s) )
  SendMessage( chwnd[2], WM_SETTEXT, 0 , strptr(s) )
*/
'

https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendmessage
https://learn.microsoft.com/en-us/windows/win32/winmsg/wm-settext
https://learn.microsoft.com/en-us/windows/win32/winmsg/wm-gettext
#34
OxygenBasic Examples / Gettext editbox qt
Last post by Frank Brübach - March 21, 2024, 07:23:53 AM
Good morning,

I have a simple question how to get a Text of one edit box1 and send it to another one edit box2 ?

% IDC_EDIT 1002
sys myEdit

% IDC_EDIT2 1003
sys myEdit2

' wndpro()
'
' I would like to send a simple text of one edit box to another one
'
'char txtbuffer[1024]
string txtbuffer[1024]

        case WM_COMMAND
            select case loword(wParam)
               
          case IDB_BUTTON
            select case hiword(wParam)
                case BN_CLICKED
                    MessageBox(NULL, "Selected Standard Button", "InputText Control", MB_OK or MB_ICONINFORMATION)
                    ' Retrieve text from the first edit box
 
                    'GetWindowText(GetDlgItem(hwnd, IDC_EDIT), txtBuffer, sizeof(txtBuffer))

                     GetWindowText(myEdit, txtBuffer, sizeof(txtBuffer)) 'ok

                          SetWindowText(myEdit2, txtBuffer) ' not ok

                      'print "myEdit: " + txtBuffer
                      'print "myEdit2: " + txtBuffer
 
                   
                    'SendMessage hwnd,myEdit2,txtBuffer ?
            end select

Thought I must use Sendmessage() at the end?

If I am getting a Text of editbox1 (ok) and Sending to editbox2 the edit box2 is empty
SetWindowText(myEdit2, @txtBuffer)

PS my Idea is to build a simple translate program for a Song

My mistake I think I must do IT with WM_Gettext WM_Settext sorry


SendMessage(myEdit, WM_SETTEXT, 0, StrPtr("Initial Text"))
                      SendMessage(GetDlgItem(myedit, 1), WM_GETTEXT, IDC_EDIT, strPtr(txtbuffer))
                      print "Textbox content: " + @txtbuffer ''trim(txtbuffer)
                     
#35
General Discussion / DON'T Comment Your Code / 'Du...
Last post by Charles Pegge - March 21, 2024, 05:34:17 AM
Maybe a little...

Continuous Delivery
20 mar 2024

#36
reproducability crisis
publication bias
p-hacking

Neuro Transmissions
24 aug 2022

#37
General Discussion / Comparing Raspberry Pi with mi...
Last post by Charles Pegge - March 20, 2024, 06:43:09 PM
When Did Raspberry Pi become the villain?

Jeff Geerling
23 jan 2024

#38
OxygenBasic Examples / Re: Listview question
Last post by Charles Pegge - March 20, 2024, 03:02:56 PM
Hi Frank,

I don't know much about ListView. You will have to ask Bill:

https://learn.microsoft.com/en-us/windows/win32/controls/create-a-list-view-control

On the subject of loading and storing data, one of the simplest methods is to use a fixed-size text file, and map the row and column data into one text string. This technique is a good starting point, and is easy to extend to gain more flexibility.

'data table demo
'
'
===================
class FixedTable10k
===================
'
% TableSize  10000 'bytes
% RecordSize 100   'bytes
% FieldSize  10    'bytes
% offset    -109   '1-record-field
'
bstring ft 'FixedTable storage
'
method constructor()
====================
  ft=space(TableSize)
end method
'
method destructor()
===================
  ft=""
end method
'
method load(string f="t.dat")
=============================
  ft=getfile(f)
end method
'
method save(string f="t.dat")
=============================
  putfile(f,ft)
end method
'
method pad(string s) as string
==============================
  int le=len(s)
  if le=10
    return s
  else
    return left(s+space(FieldSize),FieldSize)
  endif
end method
'
method get(int y,x) as string
=============================
  return mid(ft, y*RecordSize+x*FieldSize+offset,FieldSize)
end method
'
method put(int y,x, string s)
=============================
  mid(ft, y*RecordSize+x*fieldSize+offset)=pad(s)
end method
'
method show(int y=0,x=0)
========================
  if y=0
    print ""
    exit method
  endif
  if x=0
    'whole record
    print mid(ft,y*RecordSize+FieldSize+offset,RecordSize)
  else
    'field
    print get(y,x)
  endif
end method
'
end class 'FixedTable10k
'
'TESTS
'=====
new FixedTable10k t()
t.put(2,3,"Hello")
t.put(2,4,"world")
'print t.get(2,3)
't.show(2)
't.show(2,4)
't.show(2,3)
t.save()
del t
new FixedTable10k u
u.load()
u.show(2)
u.put(2,3, ucase(u.get(2,3)) )
u.show(2)
del u
#39
OxygenBasic / Tools for 4 Dimensional Geomet...
Last post by Charles Pegge - March 19, 2024, 07:41:08 PM
Time is commonly considered to be the fourth dimension, but a very limited one. For instance, rotating in time by 45 degrees is not usually considered possible :) Does a spatial fourth dimension really exist?

This will go into the inc\MathUtil.inc library, for working in OpenGl, and projecting 4d geometry into 3d.

uses console

=================
class Transform4D
=================
'5x5 matrix
indexbase 0
float f[500] '5x5x20
int idx
method constructor()
  idx=0
end method
method destructor()
end method
method clear()
  int i=idx
  for i=idx to idx+24
    f[i]=0.0
  next
end method
method identity()
  clear()
  float g at @f+(idx*4)
  g[ 0]=1.0
  g[ 6]=1.0
  g[12]=1.0
  g[18]=1.0
  g[24]=1.0
end method
method pushmatrix()
  if idx<=475
    idx+=25
    copy @f+(idx*4),@f+(idx*4)-100,100 '25 floats
  endif
end method
'
method popmatrix()
  if idx>=25
    idx-=25
  endif
end method
'
method mulmatrix()
  'assembler version
  sys p=@f+(idx*4)-200 '4x25x2
  mov rcx,p
  mov rsi,rcx
  mov rdi,rcx 'matrix R
  add rsi,100 'matrix A
  add rdi,200 'matrix B
  jmp fwd begin
  ----
  row:
  ----
  fld  dword [esi   ] 'A col0
  fmul dword [edi   ] 'B row0
  '
  fld  dword [esi+20] 'A col1
  fmul dword [edi+ 4] 'B row1
  faddp
  fld  dword [esi+40] 'A col2
  fmul dword [edi+ 8] 'B row2
  faddp
  fld  dword [esi+60] 'A col3
  fmul dword [edi+12] 'B row3
  faddp
  fld  dword [esi+80] 'A col4
  fmul dword [edi+16] 'B row4
  faddp
  fstp dword [ecx]
  add ecx,4 'R next row
  add esi,4 'A next row
  ret
  ------
  block:
  ------
  call row
  call row
  call row
  call row
  call row
  sub esi,20 'A prev col
  add edi,20 'B next col
  ret
  ------
  begin:
  ------
  call block
  call block
  call block
  call block
  call block
  idx-=50 '-25x2 'drop matrix A & B
  end method
  '
  method translate(float x,y,z,w)
  pushmatrix()
  idx+=25
  identity()
  float g at @f+(idx*4)
  g[20]=x
  g[21]=y
  g[22]=z
  g[23]=w
  mulmatrix()
end method
'
method scale(float x,y,z,w)
  pushmatrix()
  idx+=25
  clear()
  float g at @f+(idx*4)
  g[0]=x
  g[6]=y
  g[12]=z
  g[18]=w
  g[24]=1.0
  mulmatrix()
end method
'
method rotate(float a,int m)
  'm rotation planes
  pushmatrix()
  idx+=25
  identity()
  a=rad(a)
  float sa,ca
  fld dword  a
  fsincos
  fstp dword ca
  fstp dword sa
  '
  float g at @f+(idx*4)
  '
  select m
  case 1 'xy
    g[0]=ca   ' cz00
    g[6]=ca   ' sc00
    g[1]=sa   ' 0010
    g[5]=-sa  ' 0001
  case 2 'xz
    g[0]=ca   ' c0z0
    g[12]=ca  ' 0100
    g[2]=sa   ' s0c0
    g[10]=-sa ' 0001
  case 3 'yz
    g[6]=ca   ' 1000
    g[12]=ca  ' 0cz0
    g[7]=sa   ' 0sc0
    g[11]=-sa ' 0001
  case 4 'xw
    g[0]=ca   ' c00z
    g[18]=ca  ' 0100
    g[3]=sa   ' 0010
    g[15]=-sa ' s00c
  case 5 'yw
    g[6]=ca   ' 1000
    g[18]=ca  ' 0c0z
    g[8]=sa   ' 0010
    g[16]=-sa ' 0s0c
  case 6 'zw
    g[12]=ca  ' 1000
    g[18]=ca  ' 0100
    g[13]=sa  ' 00cz
    g[17]=-sa ' 00sc
  end select
  mulmatrix()
end method
'
method TransformVec3(float *r,*v, int n=1,st=12,oo=0)
  '
  float m at @f+(idx*100)
  int i,j
  @v+=oo 'OFFSET BYTES
  for i=0 to n-1
    for j=0 to 2
      r = m[0]*v[0] + m[5]*v[1] +
          m[10]*v[2] +
          m[20]
      @r+=4
      @m+=4
    next
    @v+=st-12 'st stride bytes
    @r+=st-12
    @m-=12
  next
end method
'
method TransformVec4(float *r,*v, int n=1,st=16,oo=0)
  '
  float m at @f+(idx*100)
  int i,j
  @v+=oo 'OFFSET BYTES
  for i=0 to n-1
    for j=0 to 3
      r = m[0]*v[0] + m[5]*v[1] +
          m[10]*v[2] + m[15]*v[3] +
          m[20]
      @r+=4
      @m+=4
    next
    @v+=st-16 'st stride bytes
    @r+=st-16
    @m-=16
  next
end method
'
method show(string he)
  print he cr
  int x,y,i
  float g at @f+idx*4
  for y=0 to 4
    for x=0 to 4
      i=y+x*5
      print tab str(g[i],4)
    next
    print cr
  next
  print cr
end method
'
method ShowVec3(float *v, string he="", int n=1,st=12,oo=0)
  if he
    print he cr
  endif
  int i
  @v+=oo 'OFFSET BYTES
  for i=0 to n-1
    int x
    float g at @v
    for x=0 to 2
      print tab str(g[x],4)
    next
    print cr
    @v+=st-12 'st stride bytes
  next
end method
'
method ShowVec4(float *v, string he="", int n=1,st=16,oo=0)
  if he
    print he cr
  endif
  int i
  @v+=oo 'OFFSET BYTES
  for i=0 to n-1
    int x
    float g at @v
    for x=0 to 3
      print tab str(g[x],4)
    next
    print cr
    @v+=st-16 'st stride bytes
  next
end method
'
end class 'transform4d
=================
class Transform4D
=================
'5x5 matrix
indexbase 0
float f[500] '5x5x20
int idx
method constructor()
  idx=0
end method
method destructor()
end method
method clear()
  int i=idx
  for i=idx to idx+24
    f[i]=0.0
  next
end method
method identity()
  clear()
  float g at @f+(idx*4)
  g[ 0]=1.0
  g[ 6]=1.0
  g[12]=1.0
  g[18]=1.0
  g[24]=1.0
end method
method pushmatrix()
  if idx<=475
    idx+=25
    copy @f+(idx*4),@f+(idx*4)-100,100 '25 floats
  endif
end method
'
method popmatrix()
  if idx>=25
    idx-=25
  endif
end method
'
method mulmatrix()
  'assembler version
  sys p=@f+(idx*4)-200 '4x25x2
  mov rcx,p
  mov rsi,rcx
  mov rdi,rcx 'matrix R
  add rsi,100 'matrix A
  add rdi,200 'matrix B
  jmp fwd begin
  ----
  row:
  ----
  fld  dword [esi   ] 'A col0
  fmul dword [edi   ] 'B row0
  '
  fld  dword [esi+20] 'A col1
  fmul dword [edi+ 4] 'B row1
  faddp
  fld  dword [esi+40] 'A col2
  fmul dword [edi+ 8] 'B row2
  faddp
  fld  dword [esi+60] 'A col3
  fmul dword [edi+12] 'B row3
  faddp
  fld  dword [esi+80] 'A col4
  fmul dword [edi+16] 'B row4
  faddp
  fstp dword [ecx]
  add ecx,4 'R next row
  add esi,4 'A next row
  ret
  ------
  block:
  ------
  call row
  call row
  call row
  call row
  call row
  sub esi,20 'A prev col
  add edi,20 'B next col
  ret
  ------
  begin:
  ------
  call block
  call block
  call block
  call block
  call block
  idx-=50 '-25x2 'drop matrix A & B
  end method
  '
  method translate(float x,y,z,w)
  pushmatrix()
  idx+=25
  identity()
  float g at @f+(idx*4)
  g[20]=x
  g[21]=y
  g[22]=z
  g[23]=w
  mulmatrix()
end method
'
method scale(float x,y,z,w)
  pushmatrix()
  idx+=25
  clear()
  float g at @f+(idx*4)
  g[0]=x
  g[6]=y
  g[12]=z
  g[18]=w
  g[24]=1.0
  mulmatrix()
end method
'
method rotate(float a,int m)
  'm rotation planes
  pushmatrix()
  idx+=25
  identity()
  a=rad(a)
  float sa,ca
  fld dword  a
  fsincos
  fstp dword ca
  fstp dword sa
  '
  float g at @f+(idx*4)
  '
  select m
  case 1 'xy
    g[0]=ca   ' cz00
    g[6]=ca   ' sc00
    g[1]=sa   ' 0010
    g[5]=-sa  ' 0001
  case 2 'xz
    g[0]=ca   ' c0z0
    g[12]=ca  ' 0100
    g[2]=sa   ' s0c0
    g[10]=-sa ' 0001
  case 3 'yz
    g[6]=ca   ' 1000
    g[12]=ca  ' 0cz0
    g[7]=sa   ' 0sc0
    g[11]=-sa ' 0001
  case 4 'xw
    g[0]=ca   ' c00z
    g[18]=ca  ' 0100
    g[3]=sa   ' 0010
    g[15]=-sa ' s00c
  case 5 'yw
    g[6]=ca   ' 1000
    g[18]=ca  ' 0c0z
    g[8]=sa   ' 0010
    g[16]=-sa ' 0s0c
  case 6 'zw
    g[12]=ca  ' 1000
    g[18]=ca  ' 0100
    g[13]=sa  ' 00cz
    g[17]=-sa ' 00sc
  end select
  mulmatrix()
end method
'
method TransformVec3(float *r,*v, int n=1,st=12,oo=0)
  '
  float m at @f+(idx*100)
  int i,j
  @v+=oo 'OFFSET BYTES
  for i=0 to n-1
    for j=0 to 2
      r = m[0]*v[0] + m[5]*v[1] +
          m[10]*v[2] +
          m[20]
      @r+=4
      @m+=4
    next
    @v+=st-12 'st stride bytes
    @r+=st-12
    @m-=12
  next
end method
'
method TransformVec4(float *r,*v, int n=1,st=16,oo=0)
  '
  float m at @f+(idx*100)
  int i,j
  @v+=oo 'OFFSET BYTES
  for i=0 to n-1
    for j=0 to 3
      r = m[0]*v[0] + m[5]*v[1] +
          m[10]*v[2] + m[15]*v[3] +
          m[20]
      @r+=4
      @m+=4
    next
    @v+=st-16 'st stride bytes
    @r+=st-16
    @m-=16
  next
end method
'
method show(string he)
  print he cr
  int x,y,i
  float g at @f+idx*4
  for y=0 to 4
    for x=0 to 4
      i=y+x*5
      print tab str(g[i],4)
    next
    print cr
  next
  print cr
end method
'
method ShowVec3(float *v, string he="", int n=1,st=12,oo=0)
  if he
    print he cr
  endif
  int i
  @v+=oo 'OFFSET BYTES
  for i=0 to n-1
    int x
    float g at @v
    for x=0 to 2
      print tab str(g[x],4)
    next
    print cr
    @v+=st-12 'st stride bytes
  next
end method
'
method ShowVec4(float *v, string he="", int n=1,st=16,oo=0)
  if he
    print he cr
  endif
  int i
  @v+=oo 'OFFSET BYTES
  for i=0 to n-1
    int x
    float g at @v
    for x=0 to 3
      print tab str(g[x],4)
    next
    print cr
    @v+=st-16 'st stride bytes
  next
end method
'
end class 'transform4d
'
'TESTS
======
'
print "matrix 5x5 tests" cr cr
new transform4d m
m.clear                  : m.show "empty"
m.identity               : m.show "identity"
m.pushmatrix             : m.show "pushmatrix"
m.popmatrix              : m.show "popmatrix"
m.pushmatrix
m.pushmatrix
m.mulmatrix()            : m.show "mulmatrix"
m.scale(1,2,3,4)         : m.show "scale"
m.translate(10,20,30,40) : m.show "translate"
m.identity
m.rotate(30,1)           : m.show "rotate xy"
m.identity
m.rotate(30,2)           : m.show "rotate xz"
m.identity
m.rotate(30,3)           : m.show "rotate yz"
m.identity
m.rotate(30,4)           : m.show "rotate xw"
m.identity
m.rotate(30,5)           : m.show "rotate yw"
m.identity
m.rotate(30,6)           : m.show "rotate zw"
m.identity
m.rotate(-30,1)           : m.show "rotate xy"
'm.scale(1,2,3,4)         : m.show "scale"
'm.translate(10,20,30,40) : m.show "translate"
'
type vec4 float x,y,z,w
vec4 vi={1,0,0,0}
vec4 vo
m.transformVec4(vo,vi)    : m.showvec4(vi,"vector4 trans")
                          : m.showvec4(vo,"vector4 trans")
                          : m.showvec3(vo,"vector3 trans")
wait
#40
OxygenBasic Examples / Re: Listview question
Last post by Frank Brübach - March 19, 2024, 03:30:22 PM
PS and how and where to Change the Background color of the headers?


and how I can change the color of background of the headers?

 
    '===============================================
    function CustomDraw(NMLVCUSTOMDRAW* pcd) as sys
    '-----------------------------------------------
        %= st1 CDDS_ITEM | CDDS_PREPAINT
        %= st2 CDDS_ITEM | CDDS_SUBITEM | CDDS_PREPAINT
        select case pcd.nmcd.dwDrawStage
            case CDDS_PREPAINT:
               'item notification
                return CDRF_DODEFAULT | CDRF_NOTIFYITEMDRAW
     
            case st1:       
                'subitem notification
                return CDRF_DODEFAULT | CDRF_NOTIFYSUBITEMDRAW
     
            case st2:       
                select case pcd.iSubItem           
                    if (pcd.nmcd.dwItemSpec=CurrentRow-1) and (pcd.iSubItem=CurrentCol-1) then               
                       'highlight the selected row
                       pcd.clrTextBk = YELLOW 'GREEN
                    else
                       pcd.clrTextBk = WHITE
                    end if                     
           case st3:
               select case pcd.iSubItem
                     '----------------------------------------- //
                     ' // where and how to paint the background of the headers ?
                     int hBrush
                     hBrush = CreateSolidBrush(RGB(228,120,51))
                     InflateRect @pcd.nmcd.rc, -2, -2
                     FillRect @pcd.nmcd.hdc, @pcd.nmcd.rc, hBrush

                     SetBkMode @pcd.nmcd.hdc, %TRANSPARENT
                     ' // Change your text color here...
                     SetTextColor @pcd.nmcd.hdc, RGB(92,51,23)
                     '----------------------------------------- //

               end if

                 end select                               
        end select
        return CDRF_DODEFAULT
    end function
    ' ends
     

Thanks again