PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Wilko Verweij on June 08, 2012, 10:08:44 AM

Title: From DDT to FireFly: 3D progressbar
Post by: Wilko Verweij on June 08, 2012, 10:08:44 AM
Hi,
Somewhere at the internet (I think the PowerBasic forums) I found an old but still nice example from Borje Hagsten to display 3D progress bars. I modified it to fit my needs and it works fine with the PBWIN-editor with DDT-commands.
Now when I try to set this up in FireFly, I fail. Probably something very stupid, but I have very little experience with DDT.
The code is :
FUNCTION PBMAIN () AS LONG
  LOCAL hDlg AS LONG

  DIALOG NEW 0, "ProgressBar3D test", ,, 250, 138, %WS_CAPTION OR %WS_SYSMENU TO hDlg

  IF InitPGBAR3D THEN  '<- if initialization succeeded, set up and build custom control Progressbar
    'TOP BAR, HORIZONTAL
    CONTROL ADD "PGBAR3D", hDlg, %ID_BARTOP, "", 5, 4, 203, 14, %WS_CHILD OR %WS_VISIBLE OR %DS_CONTROL, %WS_EX_CLIENTEDGE
    CONTROL SEND hDlg, %ID_BARTOP, %PGB_BUILDBARS, 0, 0  'finally, build the bars - IMPORTANT!
  ELSE
     MSGBOX "Progressbar could not be created!"              'failed, so no point in continuing
     DIALOG END hDlg : EXIT FUNCTION
  END IF

  DIALOG SHOW MODAL hDlg, CALL DlgMainProc

END FUNCTION


The initialization succeeds, but the line
CONTROL ADD "PGBAR3D", hDlg, %ID_BARTOP, "", 5, 4, 203, 14, %WS_CHILD OR %WS_VISIBLE OR %DS_CONTROL, %WS_EX_CLIENTEDGE
does not do anything (I changed the variable hDlg into the handle of the form where the bar is supposed to come).

Any suggestions how to get this work? I could make the entire form in DDT but I do not prefer that...

And yes, I know that it's better not to mix SDK and DDT, so if you have suggestions to convert this to SDK, they're welcome.

Wilko
Title: Re: From DDT to FireFly: 3D progressbar
Post by: Paul Squires on June 08, 2012, 10:48:20 AM
I checked my archive of files from Borje and I have a version of that control. It doesn't have the "init" function that you are calling. Here is the header from that file:

'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
' Progressbar include file, PGBAR3D.INC, version 2, for PB/DLL
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
' 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..
' NOTE: save this file as PGBAR3D.INC in your PBWIN70\WINAPI folder. (or PBDLL6..)
'       See sample program, PGBAR3D.BAS, for tips on how to use it.
'
' LOG:
' Jan 14, 2003: Changed to DWORD for handles in some places and
'               now use GetWindowLong(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.
' If you have been using an older version of this control, I'm sorry if new
' the barcol message and way to create breaks old code. Should be quite easy
' to make changes according to the news in this version though.
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

I have attached it to this post. Maybe it is newer than the one you are using and will work better?
Title: Re: From DDT to FireFly: 3D progressbar
Post by: Pete Totushek on June 08, 2012, 10:50:43 AM
Hi Wilko,

Here's the way that I converted that demo.

1. Make sure to Include PGBAR3d.INC
2. Create a test button called Command1
3. Code like this


%ID_BAR1        = 202

'--------------------------------------------------------------------------------
Function FORM1_WM_CREATE ( _
                         hWndForm As Dword, _      ' handle of Form
                         ByVal UserData As Long _  ' optional user defined Long value
                         ) As Long


   Local nTop, nLeft, nWidth, nHeight As Long
   Global ghProgressBar As Dword
   
   ghProgressBar = CreatePGBar3D (HWND_FORM1, %ID_BAR1, "", 67, 43, 189, 37, %WS_CHILD Or %WS_VISIBLE, 0, 0 ) 'BAR1
   SendMessage ghProgressbar, %PGB_SETMAX, 100, 0 'max number of steps
   SendMessage ghProgressbar, %PGB_SETBARCOL, %PGB_RED, 0 'bar color scheme
   SendMessage ghProgressbar, %PGB_BUILDBARS, 0, 0 'finally, build the bars - IMPORTANT!
   SendMessage ghProgressbar, %PGB_SETTXTON, 0, 2 'show own text
   SendMessage ghProgressbar, %PGB_SETTXTCOLBKG, Rgb(255,255,0), 0 'backgound text color
   SendMessage ghProgressbar, %PGB_SETTXTCOLBAR, Rgb(0,0,0), 0 'bar text color
           

End Function



'--------------------------------------------------------------------------------
Function FORM1_COMMAND1_BN_CLICKED ( _
                                   ControlIndex     As Long,  _  ' index in Control Array
                                   hWndForm         As Dword, _  ' handle of Form
                                   hWndControl      As Dword, _  ' handle of Control
                                   idButtonControl  As Long   _  ' identifier of button
                                   ) As Long

   Local i As Long
   Local txt As String
   
                 SendMessage ghProgressbar, %PGB_SETVALUE,0,1
                 For I = 1 To 100
                    SendMessage ghProgressbar, %PGB_SETVALUE,i,1
                    txt = Format$(I) + "%"
                    SendMessage ghProgressbar, %PGB_SETTXTBKG, StrPtr(txt), 1
                    SendMessage ghProgressbar, %PGB_SETTXTBAR, StrPtr(txt), 1
                    If I Mod 2 = 0 Then FF_DoEvents
                    Sleep 10                '<- if "slow" has been selected
                  Next i
End Function


Title: Re: From DDT to FireFly: 3D progressbar
Post by: Wilko Verweij on June 08, 2012, 11:03:14 AM
Thanks both of you. With this "newer" version of the ZIP plus the example I got it working. Thanks, Wilko