Last o2 Update 9-4-2025

Started by Frank Brübach, April 13, 2025, 05:57:09 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Frank Brübach


hello charles, I have found some new errors in last update of oxygen version dated 9-04-2025
I think there are some more problems, but I haven't checked all

1) openGL/UserInterface

polygons.o2bas
uses drawgui
line 162 drawgui.inc

function=left(buf,k)
  'del buf
  'del s
  end function

2) textIinp3_grid.o2bas

' new correction
  redim int ytot[5,1] 'static
  redim bstring dat[5,5] 'static
' new correction

'  dim string dat[5,5] 'error
'  dim int ytot[5,1] 'error

other grid examples are ok

3) openGL/creating/createLines1.o2bas
createLines2.o2bas
createLines3.o2bas
createLines4.o2bas

two shader problems..
line 95: createshaderprog / releaseshaderprog
file: /inc/glo2/shaderutil.inc

4) demos/Asm64

helloWorld64.o2bas

$ FileName "test64.exe"
#include "$\inc\RTL64.inc"

Declare Function MessageBox Lib "user32.dll" Alias "MessageBoxA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Sys

zstring tit[]="64Bit OxygenBasic"
zstring msg[]="Hello World!"
'#show sys a=@messagebox
'#show addr rax,messagebox
sub  rsp,32
mov  r9,  0       
lea  r8,  tit   
lea  rdx, msg   
mov  rcx, 0
call messagebox       
add  rsp, 32

' error: unterminated procedure rsp
' col 1 line 16

regards, frank

Frank Brübach

Demos/Translate/ctoOx.o2bas

Two end If are Missing about Line 126

fBtoOx.o2bas is OK

Charles Pegge

Thanks Frank,

I've fixed all the problems except for the 2 demos\WinDynDialogs\PgBar3D examples, which have eluded me so far.

Frank Brübach

#3
Hello Charles.. Look in my rar folder.. pgbar3d.o2bas Works with an old oxygen.dll File from february 2024... All other Files are Working too..  winutil.inc pgbar3d.inc

Roland Stowasser

#4
Hi Charles,

as the pgbar3d(3) apps work with oxygenbasic contribution with oxygen.dll version 0.8.0 2025-02-19T05;08:09 I compared with distribution of 0.9.0.

I modified Pgbar3d.inc:

...
uses corewin
uses console
'Oxygen
% DT_SINGLELINE = &H20
% DT_LEFT      = &H0
...

and in about 280:

...:
    case PGB_SETGRADIENTDIR
printl wparam
printl lparam   
        pgb.gradientDir = wParam                              'horizontal = 0, default
        if lParam then SendMessage hWnd, PGB_BUILDBARS, 0, 1  'rebuild and refresh if lParam says so

    case PGB_GETGRADIENTDIR
//      return pgb.gradientDir      'return gradient direction
...

the file Pgbar3d.inc would read now:
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
' Progressbar include file, PGBAR3D.inc, version 2, version 2, for PB/DLL
' Ported to Oxygenbasic
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
' Public Domain, by Borje Hagsten, September 2001
' (first released in March 2001 - this is version 2)
' Feel free to use and enhance, but as always - use at own risk..
'
' LOG:
' Jan 14, 2003: Changed to DWORD for handles in some places and
'               now use GetWindowLongPtr(hParent, GWL_HINSTANCE)
'               to get proper instance handle at creation.
'
' NEW IN VERSION 2
' Now control looks good in 256 color mode too, thanks to own palette.
' New message, PGB_SETBARCOL replaces previous PGB_SETBARCOLMID and
' PGB_SETBARCOLEDGE. Makes it easier to set bar colors via color table,
' see messages below. New way to create control. No need to initialize
' control, just use CreatePGBar3D message directly. See sample on how
' to use it. Otherwise, trimmed code and improved some DC handling.
'
' COMMENTS:
' PGBAR3D is pretty advanced. Can also be used as label, with possibility to
' set separate text on bar/background for nice "fade in/out" effects.
' Should be quite easy
' to make changes according to the news in this version though.
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤


uses corewin
uses console
'Oxygen
% DT_SINGLELINE = &H20
% DT_LEFT       = &H0
% DT_CENTER     = &H1
% DT_VCENTER    = &H4
% DT_NOCLIP     = &H100
% DT_NOPREFIX   = &H800
% NUMCOLORS     = 24          ' Number of colors the device supports
% RASTERCAPS    = 38          ' Bitblt capabilities
% RC_PALETTE    = &H00000100  ' supports a palette
% PS_SOLID      = 0
% SRCCOPY       = 0x00CC0020
% WM_GETFONT    = 49

type SIZE
   long cx
   long cy
end type

macro MakeLong(lo,hi) { ( (lo) or ( (hi)<<16 ) ) }

function RGB(int r, g, b) as int
    return (r + g*256 + b*65536)
end Function

function min(int a,b)
   if a<b then return a
   return b
end function

function max(int a,b)
   if a>b then return a
   return b
end function
'----------------------------------------------------------------------

'PGBAR3D
' wParam colors for %PGB_SETBARCOL message
%PGB_SILVER = 0
%PGB_RED    = 1
%PGB_GREEN  = 2
%PGB_BLUE   = 3
%PGB_CYAN   = 4 'blue-green
%PGB_VIOLET = 5 'red-blue
%PGB_GOLD   = 6 'yellow
%PGB_BRONZE = 7 'brown

'custom control messages
%PGB_SETMAX         = %WM_USER + 100 'wParam sets max number of steps
%PGB_STEPUP         = %WM_USER + 103 'increases step while < max - wParam and lParam shall be 0
%PGB_STEPDN         = %WM_USER + 104 'decreases step while > 0   - wParam and lParam shall be 0
%PGB_SETVALUE       = %WM_USER + 105 'wParam sets progessbar value, lParam controls redraw
%PGB_BUILDBARS      = %WM_USER + 109 'build/rebuild the scrollbars, lParam controls redraw
%PGB_REFRESH        = %WM_USER + 110 'redraw the control - wParam and lParam shall be 0

%PGB_GETMAX         = %WM_USER + 120 'returns max number of steps
%PGB_GETVALUE       = %WM_USER + 121 'returns step value
%PGB_GETTXTON       = %WM_USER + 122 'returns txtOnOff value
%PGB_GETTXTPOS      = %WM_USER + 123 'returns text position in control
%PGB_GETTXTCOLBAR   = %WM_USER + 124 'returns bar text color
%PGB_GETTXTCOLBKG   = %WM_USER + 125 'returns background text color
%PGB_GETCOLBKG      = %WM_USER + 126 'returns background color
%PGB_GETBARCOL      = %WM_USER + 127 'returns bar color scheme
%PGB_GETBARDIR      = %WM_USER + 128 'returns bar direction, 0:left/right 1:upside down 2:bottom/top 3:top/bottom
%PGB_GETGRADIENTDIR = %WM_USER + 129 'returns gradient direction - 0:horizontal, 1:vertical
%PGB_GETTXTANGLE    = %WM_USER + 130 'returns rotated font

%PGB_SETTXTON       = %WM_USER + 150 'lParam sets: 0 = no text, 1 = auto text (%), 2 = custom text
%PGB_SETTXTBAR      = %WM_USER + 151 'wParam points to text text for bar, lParam controls redraw
%PGB_SETTXTBKG      = %WM_USER + 152 'wParam points to text text for background, lParam controls redraw
%PGB_SETTXTPOS      = %WM_USER + 153 'wParam sets text position in control
%PGB_SETTXTCOLBAR   = %WM_USER + 154 'wParam sets bar text color

%PGB_SETTXTCOLBKG   = %WM_USER + 155 'wParam sets background text color
%PGB_SETCOLBKG      = %WM_USER + 156 'wParam sets background color, lParam controls rebuild of control
%PGB_SETBARCOL      = %WM_USER + 157 'wParam sets bar color scheme, lParam controls rebuild of control
%PGB_SETBARDIR      = %WM_USER + 159 'wParam sets bar direction, 0:left/right 1:upside down 2:bottom/top 3:top/bottom, lParam controls rebuild of control
%PGB_SETGRADIENTDIR = %WM_USER + 160 'wParam sets gradient direction - 0:horizontal, 1:vertical, lParam controls rebuild of control
%PGB_SETTXTANGLE    = %WM_USER + 161 'wParam sets set rotated font, lParam controls rebuild of control


TYPE PGB3DDATA             'for storing control specific data in memory block
  pStep       AS LONG         'for tracking what step we are on
  pMax        AS LONG         'for storing max number of steps, usually 100 (%)
  hbBack      AS DWORD        'handle for background brush
  barDC       AS DWORD        'memCD for Progressbar
  barBit      AS DWORD        'handle to Progressbar bitmap
  barDC2      AS DWORD        'memCD for Progressbar buffer
  barBit2     AS DWORD        'handle to Progressbar buffer bitmap
  memDc       AS DWORD        'memCD for main buffer
  hBit        AS DWORD        'handle to main buffer bitmap
  hRotateFont AS DWORD        'handle to rotated font style
  hImageBar   AS DWORD        'bar image handle
  hImageBkg   AS DWORD        'background image handle
  direction   AS LONG         'bar direction - left to right, or right to left?
  gradientDir AS LONG         'gradient direction - left to right, or right to left?
  txtAngle    AS LONG         'store given text angle
  bkgColor    AS LONG         'background color
  barCol      AS LONG         'bar color scheme
  txtColBar   AS LONG         'custom text color in bar
  txtColBkg   AS LONG         'custom text color on background
  txtOnOff    AS LONG         '0 = no text, 1 = auto text (%), 2 = custom text
  txtPos      AS LONG         'text position in control, see DrawText API..
  txtBkg(255) AS ASCIIZ       'text to be painted on background, increase/decrease size to suit your needs
  txtBar(255) AS ASCIIZ       'text to be painted on bar, increase/decrease size to suit your needs
  PalClr(192) AS LONG         'array for color sceme used by the control
end TYPE

declare function CreateGradientBars(sys hWnd) as sys
declare function CreatePGBar3D(sys hParent, id, string  txt, int vLeft,vTop,vWidth,vHeight, dword wStyle, optional dword wStyleEx=0, DlgUnits=0) as sys

'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
' Create PGBAR3D control
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
function CreatePGBar3D(sys hParent, id, string  txt, int vLeft,vTop,vWidth,vHeight, dword wStyle,  optional dword wStyleEx=0, DlgUnits=0) as sys
   sys hBar
   WNDCLASSEX wc
   string szClassName
 
   szClassName      = "PGBAR3D"
   if GetClassInfoEx(GetModuleHandle(null), szClassName, &wc) = 0 then
     wc.cbSize        = sizeof(wc)
     wc.lpfnWndProc   = @PgbWndProc
     wc.cbWndExtra    = sizeof(sys)  'for pointer to user defined TYPE with control-specific data
     wc.hInstance     = GetWindowLongPtr(hParent, GWL_HINSTANCE)
     wc.hCursor       = LoadCursor(null,  IDC_ARROW )
     wc.lpszClassName = strptr szClassName

     if RegisterClassEx(&wc) = null then mbox "Error: RegisterdClassEx PGBAR3D failed" 
   end if
 
  if DlgUnits then
      RECT rc = {0, 0, 4, 8}
      MapDialogRect (hParent, @rc)
      float PixelX = rc.right/4
      float pixelY = rc.bottom/8
      'create control using dialog units
      hBar = CreateWindowEx(wStyleEx, "PGBAR3D",  null, wStyle,
                           convert int vLeft*PixelX,
                           convert int vTop*PixelY,
                           convert int vWidth*PixelX,
                           convert int vHeight*PixelY,
                           hParent, id, GetWindowLongPtr(hParent, GWL_HINSTANCE),  null)
      if hBar = 0 then mbox "Error: CreateWindowEx PGBAR3D failed" 
   else
      'create control using pixels
      hBar = CreateWindowEx(wStyleEx, "PGBAR3D",  null, wStyle,
                           vLeft, vTop, vWidth, vHeight,
                           hParent, id, GetWindowLongPtr(hParent, GWL_HINSTANCE),  null)
      if hBar = 0 then mbox "Error: CreateWindowEx PGBAR3D failed"
   end if
   
   if hBar and len(txt) then SetWindowText(hBar, txt)
   function = hBar
end function

'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
' Progressbar procedure
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
function PgbWndProc ( sys hWnd, uint wMsg, sys wParam, lParam) as sys callback

   local pgb AS PGB3DDATA PTR
   'PGB3DDATA *pgb

   if wMsg <> WM_CREATE then &pgb = GetWindowLongPtr(hWnd, 0) 'Get control specific data

   select case wMsg
      case WM_CREATE:  'store control specific data, PGB3DDATA structure, in memory

        sys ppgb=Getmemory sizeof(PGB3DDATA)       
        if ppgb then
           SetWindowLongPtr(hWnd, 0, ppgb)     'Store the pointer for later use
        else
           return -1  'failed to allocate memory, so return -1 to break the action
        end if

        sys hDC, hFontOld
        int xPos, yPos
        RECT rc, rcTxt
        PAINTSTRUCT ps
        SIZE lpSize
        zstring *tp

        @pgb = ppgb       'get address of PGB3DDATA structure
       
        pgb.txtOnOff   = 0     'some initial values - can be changed via custom messages
        pgb.txtPos     = DT_SINGLELINE OR DT_CENTER OR DT_VCENTER OR DT_NOCLIP OR DT_NOPREFIX
        pgb.txtColBar  = RGB(0, 0, 0)
        pgb.txtColBkg  = RGB(255, 255, 0)
        pgb.bkgColor   = RGB(128, 128, 128)              'Background color
        pgb.barCol     = 0
        pgb.hbBack     = CreateSolidBrush(pgb.bkgColor)  'Background brush

'CUSTOM CONTROL MESSAGES
     case PGB_STEPUP
        if pgb.pStep < pgb.pMax then                     'step up while < max
           pgb.pStep+=1
           SendMessage hWnd, PGB_REFRESH, 0, 0           'repaint window (bar)
        end if

     case PGB_STEPDN
        if pgb.pStep > 0 then                            'step down while above 0
           pgb.pStep-=1
           SendMessage hWnd, PGB_REFRESH, 0, 0           'repaint window (bar)
        end if

     case PGB_SETVALUE
        pgb.pStep = min(pgb.pMax, wParam)
        if lParam then SendMessage hWnd, PGB_REFRESH, 0, 0 'refresh if lParam says so

     case PGB_BUILDBARS
        CreateGradientBars(hWnd)                           'build the scrollbars
        if lParam then SendMessage hWnd, PGB_REFRESH, 0, 0 'refresh if lParam says so

     case PGB_REFRESH                                      'redraw control
        InvalidateRect hWnd, null, 0 : UpdateWindow hWnd

'BAR SETTINGS
     case PGB_SETMAX
        pgb.pMax = wParam            'set max number of steps

     case PGB_GETMAX
        return pgb.pMax              'Get max number of steps

     case PGB_GETVALUE
        return pgb.pStep             'return current step value

     case PGB_SETCOLBKG
        pgb.bkgColor = wParam                                 'Set background color via wParam
        if pgb.hbBack then DeleteObject pgb.hbBack            'delete old brush, if any
        pgb.hbBack = CreateSolidBrush(pgb.bkgColor)           'create background color brush
        if lParam then SendMessage hWnd, PGB_BUILDBARS, 1, 0  'refresh if lParam says so

     case PGB_SETBARCOL
        pgb.barCol = wParam * 24 + 1                          'Set bar color
        if lParam then SendMessage hWnd, PGB_BUILDBARS, 0, 1  'rebuild and refresh if lParam says so

     case PGB_GETBARCOL
        return pgb.barCol / 24                                'return bar color scheme
       
     case PGB_SETBARDIR
        pgb.direction = wParam                                'left to right = 0, default
        if lParam then SendMessage hWnd, PGB_BUILDBARS, 0, 1  'rebuild and refresh if lParam says so

     case PGB_GETBARDIR
        return pgb.direction                                  'return bar direction

     case PGB_SETGRADIENTDIR
printl wparam
printl lparam     
        pgb.gradientDir = wParam                              'horizontal = 0, default
        if lParam then SendMessage hWnd, PGB_BUILDBARS, 0, 1  'rebuild and refresh if lParam says so

     case PGB_GETGRADIENTDIR
//        return pgb.gradientDir       'return gradient direction

'TEXT MESSAGES
     case PGB_SETTXTON
        pgb.txtOnOff = lParam        'set text on/off

     case PGB_GETTXTON
        return pgb.txtOnOff          'return txtOnOff setting

     case PGB_SETTXTPOS
        pgb.txtPos = wParam          'set text position in control

     case PGB_GETTXTPOS
        return pgb.txtPos            'return txtPos setting

     case PGB_GETTXTCOLBAR
        return pgb.txtColBar         'return bar text color

     case PGB_GETTXTCOLBKG
        return pgb.txtColBkg         'return background text color

     case PGB_GETCOLBKG
        return pgb.bkgColor          'return background color

     case PGB_SETTXTBAR
        tp = wParam     
        pgb.txtBar = tp       
        if lParam then SendMessage hWnd, PGB_REFRESH, 0, 0  'refresh if lParam says so

     case PGB_SETTXTBKG
        tp = wParam
        pgb.txtBkg = tp
        if lParam then SendMessage hWnd, PGB_REFRESH, 0, 0  'refresh if lParam says so

     case PGB_SETTXTCOLBAR
        pgb.txtColBar = wParam                              'set bar's text color

     case PGB_SETTXTCOLBKG
        pgb.txtColBkg = wParam                              'set background's text color

     case PGB_SETTXTANGLE
        LOGFONT logF
        dword tFont

        pgb.txtAngle = wParam
        tFont = SendMessage(hWnd, WM_GETFONT, 0, 0)
        if tFont = null then tFont = GetStockObject(ANSI_VAR_FONT)      'null if system font..
        GetObject(tFont, sizeof(logF), &logF)

        logF.lfEscapement  = wParam * 10                     'angle is given in tenths of degrees
        logF.lforientation = wParam * 10                     'both should be same
        logF.lfWeight = FW_BOLD                              'whatever, this one looks something like system font..
        logF.lfFaceName = "Arial"                            'must be True Type font for rotation purposes
        pgb.hRotateFont = CreateFontIndirect(&logF)          'create the font and store its handle

        if lParam then SendMessage hWnd, PGB_BUILDBARS, 0, 1 'rebuild and refresh if lParam says so

     case PGB_GETTXTANGLE
        return pgb.txtAngle                          'return eventual text angle

'STANDARD CONTROL MESSAGES
     case WM_ERASEBKGND: return 1                    'we handle background redraw ourselves

     case WM_PAINT                                   'time to paint bar
        GetClientRect hWnd, &rc                      'get size of control
        FillRect pgb.memDC, &rc, pgb.hbBack          'clear background
        xPos = pgb.pStep * rc.right / pgb.pMax       'pre-calculate, since often used
        yPos = pgb.pStep * rc.bottom / pgb.pMax      'pre-calculate, since often used

        if pgb.txtOnOff then                         'WITH TEXT
           if pgb.txtOnOff = 1 then
              pgb.txtBar = str(pgb.pStep) + ""       'auto text to paint on bar
              pgb.txtBkg = pgb.txtBar                'auto text to paint on background
           end if
           
           rcTxt.left=rc.left                        'copy rect for drawtext - the easy way
           rcTxt.top=rc.top
           rcTxt.right=rc.right
           rcTxt.bottom=rc.bottom
                                           
           if pgb.hRotateFont then
              hFontOld = SelectObject(pgb.memDC, pgb.hRotateFont)     'store original font for later use
              hFontOld = SelectObject(pgb.barDC2, pgb.hRotateFont)    'is same in both DC's

              if pgb.direction = 1 then     'upside down
                 pgb.txtPos = DT_SINGLELINE OR DT_CENTER OR DT_VCENTER OR DT_NOCLIP OR DT_NOPREFIX
                 GetTextExtentPoint32(pgb.memDC, pgb.txtBar, len(pgb.txtBar), &lpSize)
                 rcTxt.bottom = rcTxt.bottom + lpSize.cy * 2
                 rcTxt.right  = rcTxt.right + lpSize.cx * 2

              elseif pgb.direction = 2 then 'bottom to top
                 pgb.txtPos = DT_SINGLELINE OR DT_LEFT OR DT_VCENTER OR DT_NOCLIP OR DT_NOPREFIX
                 GetTextExtentPoint32(pgb.memDC, pgb.txtBar, len(pgb.txtBar), &lpSize)
                 rcTxt.left    = (rcTxt.right - lpSize.cy) / 2
                 rcTxt.bottom = rcTxt.bottom + lpSize.cx * 1.25

              elseif pgb.direction = 3 then 'top to bottom
                 pgb.txtPos = DT_SINGLELINE OR DT_LEFT OR DT_VCENTER OR DT_NOCLIP OR DT_NOPREFIX
                 GetTextExtentPoint32(pgb.memDC, pgb.txtBar, len(pgb.txtBar), &lpSize)
                 rcTxt.left = (rcTxt.right + lpSize.cy) / 2
                 rcTxt.top = rcTxt.top - lpSize.cx / 1.35
              end if

           end if

           BitBlt pgb.barDC2, 0, 0, rc.right, rc.bottom,
                  pgb.barDC, 0, 0, SRCCOPY                         'paint original bar to buffer

           SetTextColor pgb.barDC2, pgb.txtColBar                  'set color on bar
           DrawText pgb.barDC2, pgb.txtBar, -1, rcTxt, pgb.txtPos  'draw text on bar

           SetTextColor pgb.memDC, pgb.txtColBkg                   'set color on background
           DrawText pgb.memDC, pgb.txtBkg, -1, rcTxt, pgb.txtPos   'draw text on background

           if pgb.direction = 0 then 'LEFT to RIGHT - WITH TEXT
              BitBlt pgb.memDC, 0, 0, xPos, rc.bottom,
                     pgb.barDC2, 0, 0, SRCCOPY                     'paint proper part of gradiant bar

           elseif pgb.direction = 1 then  'RIGHT to LEFT - WITH TEXT
              BitBlt pgb.memDC, rc.right - xPos, 0, xPos, rc.bottom,
                     pgb.barDC2, rc.right - xPos, 0, SRCCOPY

           elseif pgb.direction = 2 then  'BOTTOM to TOP - WITH TEXT
              BitBlt pgb.memDC, 0, rc.bottom - yPos, rc.right, rc.bottom,
                     pgb.barDC2, 0, rc.bottom - yPos, SRCCOPY

           elseif pgb.direction = 3 then  'TOP to BOTTOM - WITH TEXT
              BitBlt pgb.memDC, 0, 0, rc.right, yPos,
                     pgb.barDC2, 0, 0, SRCCOPY

           end if

        else                                         'WITHOUT TEXT
           if pgb.direction = 0 then      'LEFT to RIGHT - NO TEXT
              BitBlt pgb.memDC, 0, 0, xPos, rc.bottom,
                     pgb.barDC, 0, 0, SRCCOPY                      'paint proper part of gradiant bar

           elseif pgb.direction = 1 then  'RIGHT to LEFT - NO TEXT
              BitBlt pgb.memDC, rc.right - xPos, 0, xPos, rc.bottom,
                     pgb.barDC, rc.right - xPos, 0, SRCCOPY

           elseif pgb.direction = 2 then  'BOTTOM to TOP - NO TEXT
              BitBlt pgb.memDC, 0, rc.bottom - yPos, rc.right, rc.bottom,
                     pgb.barDC, 0, rc.bottom - yPos, SRCCOPY

           elseif pgb.direction = 3 then  'TOP to BOTTOM - NO TEXT
              BitBlt pgb.memDC, 0, 0, rc.right, yPos,
                     pgb.barDC, 0, 0, SRCCOPY

           end if

        end if

        BeginPaint hWnd, &ps                             'begin screen painting
        if pgb.PalClr(0) then                            'if we have palette (256 color mode)
           SelectPalette ps.hDC, pgb.PalClr(0), 0        'then use it in DC..
           RealizePalette ps.hDC
        end if

        BitBlt ps.hDC, 0, 0, rc.right, rc.bottom,
               pgb.memDC, 0, 0, SRCCOPY                  'paint it all to screen

        if hFontOld then
            SelectObject(pgb.memDC, hFontOld)            'select the original font back
            SelectObject(pgb.barDC2, hFontOld)           'was the same in both DC's
        end if

        EndPaint hWnd, &ps                               'finish up
        return 0

     case WM_DESTROY :                                                         'clean up, to avoid nasty memory leaks
        if pgb.hRotateFont then DeleteObject pgb.hRotateFont                   'may be a stockobject, but doesn't matter
        if pgb.hbBack      then DeleteObject pgb.hbBack                        'delete brush
        if pgb.hbit        then DeleteObject SelectObject(pgb.memDC, pgb.hbit)
        if pgb.memDC       then DeleteDC pgb.memDC                             'and memory DC's + bitmaps
        if pgb.barBit      then DeleteObject SelectObject(pgb.barDC, pgb.barBit)
        if pgb.barDC       then DeleteDC pgb.barDC
        if pgb.barBit2     then DeleteObject SelectObject(pgb.barDC2, pgb.barBit2)
        if pgb.barDC2      then DeleteDC pgb.barDC2
        if pgb.PalClr(0)   then DeleteObject pgb.PalClr(0)
        freememory &pgb
        return 0

   end select

   return DefWindowProc(hWnd, wMsg, wParam, lParam)
end function

'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
' Create actual ProgressBar, based on previously made settings
' Note: one could also load a couple of bitmaps here instead,
' for some terrific effects.. :-)
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
function CreateGradientBars( sys hWnd) as sys
  sys hDC, hPen
  int ic, jj
  float kk, L
  RECT rc
  PGB3DDATA *pgb
 
  &pgb = GetWindowLongPtr(hWnd, 0)                                    'Get control specific data

  if pgb.hbit    then DeleteObject SelectObject(pgb.memDC, pgb.hbit)
  if pgb.memDC   then DeleteDC pgb.memDC                              'delete old memDC's and bitmaps, if any
  if pgb.barBit  then DeleteObject SelectObject(pgb.barDC, pgb.barBit)
  if pgb.barDC   then DeleteDC pgb.barDC
  if pgb.barBit2 then DeleteObject SelectObject(pgb.barDC2, pgb.barBit2)
  if pgb.barDC2  then DeleteDC pgb.barDC2

  GetClientRect hWnd, rc                                              'get control height and width

  hDC = GetDc(hWnd)
  if hDC then                                                         'create 3 compatible memory DC's based on
     pgb.memDC   = CreateCompatibleDC(hDC)                            'control's DC, for faster action in WM_PAINT
     pgb.hbit    = CreateCompatibleBitmap(hDC, rc.right, rc.bottom)
     pgb.hbit    = SelectObject(pgb.memDC, pgb.hbit)
     pgb.barDC   = CreateCompatibleDC(hDC)
     pgb.barBit  = CreateCompatibleBitmap(hDC, rc.right, rc.bottom)
     pgb.barBit  = SelectObject(pgb.barDC, pgb.barBit)
     pgb.barDC2  = CreateCompatibleDC(hDC)
     pgb.barBit2 = CreateCompatibleBitmap(hDC, rc.right, rc.bottom)
     pgb.barBit2 = SelectObject(pgb.barDC2, pgb.barBit2)
     SetBkMode pgb.memDC, TRANSPARENT                                 'set text background modes
     SetBkMode pgb.barDC2, TRANSPARENT

'------------------------------------------------------------------------------
' 'need own palette if in 256 color mode
'------------------------------------------------------------------------------
     jj = 1
     for ic = 117 to 255 STEP 6         '0, gray table 1-24
        pgb.PalClr(jj) = RGB(ic, ic, ic) : jj+=1
     next
     for ic = 117 to 255 STEP 6         '1, red table 25-48
        pgb.PalClr(jj) = RGB(ic, ic - 117, ic - 117) : jj+=1
     next
     for ic = 117 to 255 STEP 6         '2, green table 49-72
        pgb.PalClr(jj) = RGB(ic - 117, ic, ic - 117) : jj+=1
     next
     for ic = 117 to 255 STEP 6         '3, blue table 73-96
        pgb.PalClr(jj) = RGB(ic - 117, ic - 117, ic) : jj+=1
     next
     for ic = 117 to 255 STEP 6         '4, blue-green table 97-120
        pgb.PalClr(jj) = RGB(ic - 117, ic, ic) : jj+=1
     next
     for ic = 117 to 255 STEP 6         '5, violet table 121-144
        pgb.PalClr(jj) = RGB(ic, ic - 117, ic) : jj+=1
     next
     for ic = 117 to 255 STEP 6         '6, gold table 145-168
        pgb.PalClr(jj) = RGB(min(ic + 64, 255), ic, ic - 117) : jj+=1
     next
     for ic = 117 to 255 STEP 6         '7, brown table 169-192
        pgb.PalClr(jj) = RGB(min(ic + 16, 255), ic - 48, ic - 117) : jj+=1
     next
     jj-=1

     if GetDeviceCaps(hDC, NUMCOLORS) > -1 and                         'if needed, create own palette
     (GetDeviceCaps(hDC, RASTERCAPS) and RC_PALETTE) = RC_PALETTE then
        if pgb.PalClr(0) then DeleteObject pgb.PalClr(0)
        pgb.PalClr(0) = MakeLong(&H0300, jj)
        pgb.PalClr(0) = CreatePalette pgb.PalClr(0)
        for ic = 1 to jj
           pgb.PalClr(ic) = pgb.PalClr(ic) + &H02000000
        next
     end if
     ReleaseDc hWnd, hDC                                               'release the temporary DC

     if pgb.PalClr(0) then 'if we have palette (256 color mode), then use it in memDCs..
        SelectPalette pgb.barDC, pgb.PalClr(0), 0
        RealizePalette pgb.barDC
        SelectPalette pgb.barDC2, pgb.PalClr(0), 0
        RealizePalette pgb.barDC2
     end if

'------------------------------------------------------------------------------
     if pgb.gradientDir = 0 then   'HORIZONTAL BAR
        jj = rc.bottom - 1
     else                          'VERTICAL BAR
        jj = rc.right - 1
     end if
     kk = pgb.barCol
     L = 1 / ((jj / 2) / 24)       'calculate steps for color

     for ic = 0 to jj                                    'draw the whole gradient bar
        hPen = CreatePen(PS_SOLID, 1, pgb.PalClr(kk))    'create pen
        hPen = SelectObject(pgb.barDC, hPen)             'select pen into DC, store original pen
        if pgb.gradientDir = 0 then                      'HORIZONTAL BAR
           MoveToEx pgb.barDC, 0, ic, null               'move into position
           LineTo pgb.barDC, rc.right, ic                'and draw a line from left to right
        else                                             'VERTICAL BAR
           MoveToEx pgb.barDC, ic, 0, null               'move into position
           LineTo pgb.barDC, ic, rc.bottom               'and draw a line from top to bottom
        end if
        DeleteObject SelectObject(pgb.barDC, hPen)       'delete pen to avoid memory leaks

        if ic < jj / 2 -1 then
           kk = MIN(pgb.barCol + 23, int(kk + L))
        else
           kk = MAX(pgb.barCol, int(kk - L))
        end if
     next

     return true                                         'return true on success
  end if

end function

when I run Pgbar3d.o2bas version 0.8.0 shows the expected values 0 and 1. Version 0.9.0 show no values but if I move with the mouse in the control there are shown unexpected values.

If you get Pgbar.inc work with version 0.9.0 then I think, WinGui\BurningControl.o2bas (also a  custom control) will work also

Charles Pegge

Hi Roland,

The problem is that   function PgbWndProc is called but does not receive the WM_CREATE message, so the getmemory was not called, leading to a null structure and consequent GPF. I can avoid the GPF by ensuring that getmemory is called.

That still leaves the problem of garbled messages, and a failure to create the pgbar controls, returning a null hbar handle.

I have never seen this behavior before, so my concern is that the "PGBAR3D" control itself has become corrupted in some way.

Roland Stowasser

I wished I could be of some more help. My guess is that there is a side effect in one of the changes after 19/02/2025. In WinGui\BurningControl.o2bas WM_CREATE does also not work in function WndProc with version 0.9.0. But RegisterClassEx worked before.

Frank Brübach

#7
hello charles,

I have made this test for about three hours to find a solution... I have build a new oxygen.dll (today, 14-04-2025)
to make a lot of winutil and windynamic folder examples for running again.

I have noticed you have made since this time of begin/middle of february 2025 a lot of changes for oxygen.dll and
depending inc files and self folder *.inc files.

I have built (compiled 32-bit) with the current oxygen.dll of 13-04-2025, oxide.o2bas and all inc (self) files of 31.01-2025
this new oxygen.dll (14-04-25) , version 0.9.0 with the inc files of main.inc from 10-02-25.

all files are working again, all control buttons in WinUtil folder and pgbar files and WinDynDialog folder.
I add all files in my rar folder for testing.

regards, frank

Charles Pegge

#8
Thanks Frank and Roland,

BurningControl seems to work correctly, though the control itself (PanelProc) does not process the WM_CREATE message, but the WM_CREATE message is sent as expected. So that just leaves the problem with "PGBAR3D"

Has anyone tried to create a simple custom control demo?

Frank Brübach

#9
Simple Buttons

// Standard Buttons

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

$ EscapeKeyEnd
uses WinUtil

% EDGE_RAISED=5
% EDGE_SUNKEN=10
% BF_RECT=15
% WM_DRAWITEM=43
% ETO_OPAQUE=2
% ETO_CLIPPED=4
% ODS_SELECTED=1
% GWL_HINSTANCE -6

type SIZE
  long cx
  long cy
end type


% IDB_BUTTON  100
sys hWndStdButton

% IDC_BUTTON2  1000
sys hWndStdButton2

MainWindow 340, 220 , WS_OVERLAPPEDWINDOW

function WndProc(sys hwnd, uint MainMsg, sys wParam, lParam) as sys callback
    select case MainMsg

        case WM_CREATE
            SetWindowText(hwnd, "Buttons")

            sys hInstance = GetWindowLongPtr(hWnd, GWL_HINSTANCE)

            hWndStdButton = CreateWindowEx(
            0,
            "BUTTON",
            "Standard Button",
            WS_VISIBLE or WS_CHILD,
            10,  10,
            126, 24,
            hWnd,
            IDB_BUTTON,
            hInstance,
            NULL)

            hWndStdButton2 = CreateWindowEx(
            0,
            "BUTTON",
            "Standard Button2",
            WS_CHILD or WS_CHILD,
            10,  40,
            126, 24,
            hWnd,
            IDC_BUTTON2,
            GetWindowLongPtr(hWnd, GWL_HINSTANCE),
            NULL)

            if not hWndStdButton2 then
                MessageBox(NULL, "Button Creation Failed.", "Error", MB_OK or MB_ICONERROR)
                return 0
            end if

            ShowWindow(hWndStdButton2, SW_SHOW)

       

        case WM_COMMAND
            select case loword(wParam)
                case IDB_BUTTON
                    select case hiword(wParam)
                        case BN_CLICKED
                            MessageBox(NULL, "Selected Standard Button", "Standard Button", MB_OK or MB_ICONINFORMATION)
                    end select
                case IDC_BUTTON2
                    select case hiword(wParam)
                        case BN_CLICKED
                            MessageBox(NULL, "Selected Standard Button2", "Standard Button2", MB_OK or MB_ICONINFORMATION)
                    end select
               
            end select

        case WM_CLOSE
            DestroyWindow(hWnd)

        case WM_DESTROY
            PostQuitMessage(0)

        case else
            return DefWindowProc(hWnd, MainMsg, wParam, lParam)
    end select

    return 0
end function

May BE the Problem lies in quite other fields and dont belongs to Control s?  What about your Changes in Macros and redims?

Roland Stowasser

Hi Charles,

I downloaded the latest distribution of Oxygenbasic (13/04/2025) and BurningControl.o2bas works as expected, Pgbar3d(3).o2bas show an error message (CreateWindowEx)
Other apps with custom controls are \WinGui\DoubleBuff1(2).o2bas. The error message because of Register Custom Control has gone.
WinGui\UniversalButton.o2bas always worked ok. (The two wrong shapes of $ and @ buttons existed since the beginning because of an error in translating to Oxygen, but I forgot about it).

I noticed that you edited Pgbar3d.inc a little bit. This was a learning project for me as I do not know much about Powerbasic. As the app is declared as public domain I add the whole original zip file. Perhaps you  then recognize some weak points of my porting to Oxygenbasic.

Charles Pegge

Got it!

It was misreading equate expressions containing % or $ prefixes. for example %WM_USER

%PGB_SETMAX         = %WM_USER + 100 'wParam sets max number of steps

All working now.

Roland Stowasser

That is great! Small cause, big effect. Do you currently intend to make other important changes or should the remaining demo programs be tested beforehand? Perhaps this has already happened?

Charles Pegge

Apart from self-compiling, I have a wide range of key programs, large and small  for testing new code. I'll make sure that older GUI demos such as pgbar3d are included in future. I always test for COM, GDIplus, OpenGl and GLSL since they are technically demanding.