Recent posts

#71
OxygenBasic / Re: ver 0.9.0 issue
Last post by Roland Stowasser - April 06, 2025, 03:32:36 PM
Hi Charles,

I found the missbehaviour of Listview.o2bas in function AboutDlgProc in line 116, 117. If I modify this:

'      if loword(wParam) = IDCANCEL or
'        loword(wParam) = IDOK then
      if loword(wParam) = IDCANCEL or loword(wParam) = IDOK then

then the app will run. But I think line 116, 117 should also work?

Nevertheless there is a mistake in line 201 / 202 also. The line should read.

              Dialog( 0,0,144,77, "About Listview Sample", 


So this would be the interim code:

'====================================================================
' Listview example, nested modeless dialog.
'====================================================================


$ filename "ListView.exe"
'uses rtl32
'uses rtl64

'% review

uses dialogs


'Identifiers
#define IDD_DLG1 1000
#define IDC_LSV1 1001
#define IDM_EXIT        104
#define IDM_ABOUT       105
#define IDI_LOGO        106


macro ListView_InsertColumn(hwnd,iCol,pcol) (SendMessage(hwnd, LVM_INSERTCOLUMN, iCol, pcol))
macro ListView_SetColumnWidth(hwnd,iCol,cx) (SendMessage(hwnd, LVM_SETCOLUMNWIDTH, iCol, cx))
macro ListView_InsertItem(hwnd,pitem) (SendMessage(hwnd, LVM_INSERTITEM,0, pitem))
macro ListView_SetItem(hwnd,pitem) (SendMessage(hwnd, LVM_SETITEM,0, pitem))

% DS_CENTER=0x0800
% DS_MODALFRAME=0x80
% SS_CENTERIMAGE=0x200
% LVS_LIST  0x0003
% LVS_REPORT  0x0001
% LVS_EX_GRIDLINES 1
% LVS_EX_CHECKBOXES 4
% LVS_EX_FULLROWSELECT  0x0020
% LVSCW_AUTOSIZE  -1
% LVSCW_AUTOSIZE_USEHEADER  -2
% LVM_INSERTCOLUMN=4123
% LVM_SETCOLUMNWIDTH=4126
% LVM_INSERTITEM=4103
% LVM_SETITEM=4102
% LVCF_FMT 1
% LVCF_WIDTH 2
% LVCF_TEXT=4
% LVCF_SUBITEM 8
% LVIF_TEXT=1
% LVM_SETEXTENDEDLISTVIEWSTYLE 0x1036
% LVN_COLUMNCLICK = -108
% LVN_ITEMCHANGED = -101
% LR_LOADFROMFILE=0x0010
% IMAGE_ICON=1
% STM_SETIMAGE=0x172
% SWP_NOZORDER=4

type LVCOLUMN
  uint  mask
  int   fmt
  int   cx
  char* pszText
  int   cchTextMax
  int   iSubItem
  int   iImage
  int   iOrder
  int   cxMin
  int   cxDefault
  int   cxIdeal 
end type
typedef LVCOLUMN LV_COLUMN

type LVITEM 
  uint   mask
  int    iItem
  int    iSubItem
  uint   state
  uint   stateMask
  char*  pszText
  int    cchTextMax
  int    iImage       // index of the list view item's icon
  sys    lParam       // 32-bit value to associate with item
  int    iIndent
  int    iGroupId
  uint   cColumns
  uint   *puColumns
  int    *piColFmt
  int    iGroup
end type
typedef LVITEM LV_ITEM

% LVROWS = 200   ' Number of rows in the ListView
% LVCOLS = 3     ' Number of columns in the ListView

! GetDlgItem lib "user32.dll" (sys hDlg, int nIDDlgItem) as sys
! IsDialogMessage lib "user32.dll" alias"IsDialogMessageA" (sys hDlg, sys lpMsg) as bool
! IsWindow lib "user32.dll" (sys hWnd) as bool


sys AboutDlg
'string o2dir = "c:\oxygenbasic\"
string o2dir = "..\..\"
string fullname


init_common_controls()

function AboutDlgProc( sys hDlg, uint uMsg, sys wParam, lParam) as sys callback

  select case uMsg

    case WM_INITDIALOG
      fullname = o2dir + "tools\OxideIcon.ico"
      sys hIcon = LoadImage( 0, fullname, IMAGE_ICON,0,0, LR_LOADFROMFILE )
      if hIcon=null then mbox "Cannot load " + fullname +"!"
      SendMessage (GetDlgItem(hDlg,IDI_LOGO), STM_SETIMAGE, IMAGE_ICON, hIcon)

    case WM_COMMAND
'      if loword(wParam) = IDCANCEL or
'         loword(wParam) = IDOK then
      if loword(wParam) = IDCANCEL or loword(wParam) = IDOK then
        DestroyWindow( hDlg )
      end if

    case WM_CLOSE
      DestroyWindow( hDlg )

      'Reset so main can determine if nested dialog is open.
      AboutDlg = 0

  end select

  return 0
end function

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

function DlgProc( sys hDlg, uint uMsg, sys wParam, lParam ) as sys callback

  sys hMenu
  sys hListview = GetDlgItem(hDlg, IDC_LSV1) 
  int i,j
  LV_COLUMN lvc
  LV_ITEM lvi
  select case uMsg

     case WM_INITDIALOG
        MENU(hMenu)
       
        BEGIN
          POPUP "&File"
          BEGIN
            MENUITEM "E&xit",IDM_EXIT
          ENDMenu
          POPUP "&Help"
          BEGIN
            MENUITEM "&About...",IDM_ABOUT
          ENDMenu
        ENDMenu

        if SetMenu( hDlg, hMenu ) = 0 then
          mbox "SetMenu hMenu failed!"
        end if

        string text
        'Column Headers
        For i = 0 To LVCOLS
           lvc.mask = LVCF_FMT OR LVCF_WIDTH OR LVCF_TEXT OR LVCF_SUBITEM 'LVCF_TEXT
           text="Column #" & str(i+1)
           lvc.pszText = text               
           ListView_InsertColumn(hListview, i, &lvC)
        Next i

        'Rows
        For i=1 To LVROWS
           'First column
           lvi.mask      =  LVIF_TEXT
           text = "Row #" & str(200-i+1) ", Col # 1"
           lvi.pszText   = text
           lvi.iSubItem  =  0
           ListView_InsertItem(hListview, &lvi)
           'Remaining columns
           for j=2 to LVCOLS
              text = "Row #" & str(200-i+1) ", Col # " & str(j)
              lvi.pszText   = text
              lvi.iSubItem  =  j-1
              ListView_SetItem(hListview, &lvi)
           next j
        Next i

        for i = 0 to LVCOLS
           ListView_SetColumnWidth(hListview,i,LVSCW_AUTOSIZE_USEHEADER)
        next i
       
        SendMessage(hListview, LVM_SETEXTENDEDLISTVIEWSTYLE, 0,  LVS_EX_FULLROWSELECT|LVS_EX_CHECKBOXES)
'        SendMessage(hListview, LVM_SETEXTENDEDLISTVIEWSTYLE, 0,  LVS_EX_GRIDLINES)
'        SendMessage(hListview, LVM_SETEXTENDEDLISTVIEWSTYLE, 0,  LVS_EX_CHECKBOXES)
         
    case WM_COMMAND

       select case loword(wParam)
          case IDM_ABOUT
            'Open nested dialog only if not already open.
            if IsWindow( AboutDlg ) = 0 then           
              Dialog( 0,0,144,77, "About Listview Sample",
                      WS_POPUP|WS_VISIBLE|WS_CAPTION|DS_MODALFRAME or DS_SETFONT or DS_CENTER,
                      8,"MS Sans Serif" )
              CONTROL "OK",IDOK,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,54,51,40,14
              CONTROL "Creating a Listview Control",-1,"Static",WS_CHILDWINDOW|WS_VISIBLE|WS_GROUP, 50,17,92,8
              CONTROL "in OxygenBasic",-1,"Static",WS_CHILDWINDOW|WS_VISIBLE|WS_GROUP,65,27,70,8
              Control(  "",IDI_LOGO, "STATIC", SS_ICON|SS_CENTERIMAGE, 0, 0, 40, 40 )
              AboutDlg = CreateModelessDialog( hDlg, @AboutDlgProc, 0 )
            end if

        case IDCANCEL, IDM_EXIT
           DestroyWindow( hDlg )
        end select

    case WM_NOTIFY
       NMHDR pnm at lParam
       
       if pnm.hwndFrom = hListview then      'ListView         
            select case pnm.code
              case LVN_COLUMNCLICK
mbox "LVN_COLUMNCLICK"                           
              case LVN_ITEMCHANGED
#ifdef review
  printl "LVN_ITEMCHANGED"
  printl
#endif             
            end select
       end if
 

      case WM_SIZE     
         RECT rcClient
     
         // Calculate remaining height and size edit
         GetClientRect(hDlg, &rcClient)
         SetWindowPos(hListview, NULL, 0, rcClient.top, rcClient.right, rcClient.bottom, SWP_NOZORDER)

    case WM_CLOSE
      DestroyWindow( hDlg )

    case WM_DESTROY
      PostQuitMessage( null )

  end select

  return 0
end function

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

sys hDlg
MSG wMsg

Dialog( 10,10,280,150, "Listview example",
        WS_OVERLAPPEDWINDOW or DS_CENTER or WS_VISIBLE,
        8,"MS Sans Serif" )

CONTROL "",IDC_LSV1,"SysListView32", _
        WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|WS_BORDER|LVS_REPORT, _
        3,3,273,141,WS_EX_CLIENTEDGE

hDlg = CreateModelessDialog( 0, @DlgProc, 0 )

while GetMessage( @wMsg, null, 0, 0 ) <> 0
  if IsDialogMessage( hDlg,  @wMsg ) = 0 then
    if IsDialogMessage( AboutDlg,  @wMsg ) = 0 then
      TranslateMessage( @wMsg )
      DispatchMessage( @wMsg )
    end if
  end if
wend
#72
OxygenBasic / Re: version 0.9.0 2025-04-04 i...
Last post by Roland Stowasser - April 05, 2025, 06:11:39 PM
Thank you, James. I now understand the purpose of the -32 / -64 option.
#73
OxygenBasic / Re: version 0.9.0 2025-04-04 i...
Last post by James C. Fuller - April 05, 2025, 02:49:25 PM
I actually compile from within RadAsm3 ( I should clean my implementation and post here).
I ONLY work with 64bit

cO2m64 -m -64 pcre_test

James
#74
OxygenBasic / Re: ver 0.9.0 issue
Last post by Roland Stowasser - April 05, 2025, 11:53:29 AM
Hi Charles,

I downloaded Oxygenbasic.zip version 0.09.0 2025-04-04T15:04. AsciTerix works fine, also AsciTerix2 where you used different coding variations. But I suppose the Home - Shortcut is superfluous?

Checking the demos in the WinDynDialogs folder, most of the apps work fine. But I noticed that in Listview.o2bas there is an error message:
ERROR:    unclosed brackets at end of script (1)
COL:    1
LINE:    271
FILE:    "main source"

Moreover Pgbar3d.o2bas and Pgbar3d3.o2bas do not run at all. As all the demos work fine with version 0.8.0 I am not sure if there are changes like with the single liner types, which must be taken into account, or if there is something missing in oxygen.dll. Hopefully you do not think that I am lazy.

#75
OxygenBasic / Re: version 0.9.0 2025-04-04 i...
Last post by Charles Pegge - April 05, 2025, 11:09:13 AM
I think James was compiling from the command line.
#76
OxygenBasic / Re: version 0.9.0 2025-04-04 i...
Last post by Zlatko Vid - April 05, 2025, 11:01:52 AM
and what is NOW wrong with $ filename "name"  :o
do we must complicate things without reason.
#77
OxygenBasic / Re: version 0.9.0 2025-04-04 i...
Last post by Roland Stowasser - April 05, 2025, 09:56:15 AM
When studying the code of pcre_test.o2bas I found that I missed some innovations.
"uses pcre_test.res" is an interesting option.

It also seems to be possible to create an executable without using $filename "Name". I will keep this procedure. But what command can I use to create pcre_test.exe without using $filename?
#78
General Discussion / Re: José fallen into the recyc...
Last post by José Roca - April 04, 2025, 06:49:19 PM
For example, I have just finished a function to extract substrings.

' ========================================================================================
PRIVATE FUNCTION wstrExtract (BYREF wszSourceString AS CONST WSTRING, BYREF wszMatchString AS CONST WSTRING, BYVAL IgnoreCase AS BOOLEAN = TRUE) AS DWSTRING
   IF wszSourceString = "" OR wszMatchString ="" THEN RETURN wszSourceString
   DIM pRegExp AS CRegExp
   pRegExp.Global = FALSE
   pRegExp.IgnoreCase = IgnoreCase
   ' // This pattern matches the delimiter passed (can consist of a group of one or more characters)
   ' // Passing wszMatchString enclosed between "[]" will match any of the individual characters
   pRegExp.Pattern = "^(.*?)" & wszMatchString
   SetLastError(pRegExp.Execute(wszSourceString))
   iF pRegExp.SubMatchesCount THEN
      RETURN STRPTR(pRegExp.SubMatchValue(0, 0))
   END IF
   ' // If wszMatchString is not found return all of wszSourceString
   RETURN wszSourceString
END FUNCTION
' ========================================================================================

DIM dws AS DWSTRING = "abacadabra"
Print wstrExtract(dws, "cad")
' Output: aba - match on "cad"

DIM dws AS DWSTRING = "abacadabra"
Print wstrExtract(dws, "[dr]")
' Output: abaca - match on "d"

The difference is that to search for individual characters to match, you enclose them between "[]": "[dr]" will search for d or r; "cad" will search for "cad".

The same function can be used for different purposes and can be case-sensitive or insensitive.

Now I will write an overloaded function with two delimiters to extract text between them.
#79
General Discussion / Re: José fallen into the recyc...
Last post by José Roca - April 04, 2025, 06:28:48 PM
It is a work in progress, subject to numerous changes. It is better to look at my repository in GitHub. Otherwise, Google and company will return code that is outdated.

I'm finishing the include file that contain the string functions, now prefixed as "wstr" ("wcs" is already used by Microsoft). The ones that aren't complicated or that need speed, are hard coded; the ones that are complex or with many variations (case-sensitive, case-insensitive, single delimiters or ANY delimiters, local or global), are being coded using my wrapper class CRegExp and regular expressions patterns. This way, I can have only one function instead of 4 or 6.

Additionally, besides the ready to use string functions, you can use the CRegExp class to write your own code or procedures if what you need is not covered by these ready to use functions. You only need to find the appropriate pattern. This is where the AI can help. I'm unable to remember how to construct these darn patterns.

Thanks for your interest.
#80
General Discussion / José fallen into the recycle b...
Last post by Charles Pegge - April 04, 2025, 04:46:28 PM
I've been following José's postings and got a surprise!

https://forum.it-berater.org/index.php/topic,6892.0.html