PDA

View Full Version : Visual designer generated code - ProgressBar



DirectuX
02-11-2018, 11:27
Hi,


VD generates this code for a simple window with a progressbar,
line 96 leads to an error,

CONTROL SEND hDlg, lID, %PBM_SETRANGE,0,MAKDWR(0,100) would be the correct line.

File attached :9902


'------------------------------------------------------------------------------
'thinAir Visual Designer
'------------------------------------------------------------------------------
' Project: Visual Designer generated code
' File: Your file name
' Created: On 11-02-2018 at 10:07:36
'------------------------------------------------------------------------------

'---Needed thinBasic modules
USES "UI"

'---Controls IDs---
Begin ControlID
%IDC_PROGRESSBAR_1
End ControlID



'------------------------------------------------------------------------------
' Main thinBasic function
'------------------------------------------------------------------------------
Function TBMain() As Long

MainWindow_Create(%HWND_DESKTOP)

End Function

'------------------------------------------------------------------------------
' Create main Window
'------------------------------------------------------------------------------
Function MainWindow_Create(ByVal hParent As Long) As Long

Local hDlg As Long
Local hFont As Long
Local lStyle As Long
Local lStyleEx As Long
lStyle = _
%WS_DLGFRAME | _
%WS_CAPTION | _
%WS_SYSMENU | _
%WS_OVERLAPPEDWINDOW | _
%WS_CLIPCHILDREN | _
%WS_CLIPSIBLINGS | _
%DS_CENTER
lStyleEx = 0

Dialog New Pixels, hParent, "Form1", -1, -1, 468, 225, lStyle, lStyleEx, TO hDlg

hFont = Font_Create("MS Sans Serif", 8)
Dialog Send hDlg, %WM_SETFONT, hFont, 0



CONTROL ADD "MSCTLS_PROGRESS32", hDlg, %IDC_PROGRESSBAR_1, "ProgressBar1", 56, 40, 368, 24, %WS_CHILD OR %WS_CLIPSIBLINGS OR %WS_VISIBLE, 0

SampleProgress(hDlg, %IDC_PROGRESSBAR_1)

Dialog Show Modal hDlg, CALL MainWindow_Proc

Win_DeleteObject hFont

End Function

'------------------------------------------------------------------------------
' Main WIndow CallBack handler
'------------------------------------------------------------------------------
CallBack Function MainWindow_Proc() As Long

LOCAL pNMHDR AS NMHDR PTR

LOCAL PageNo AS LONG

LOCAL hFontTab AS LONG

SELECT CASE (CBMSG)

CASE %WM_INITDIALOG
CASE %WM_COMMAND
SELECT CASE LOWRD(CBWPARAM)
CASE %IDOK
CASE %IDCANCEL
END SELECT

CASE %WM_NOTIFY
CASE %WM_DESTROY
End Select
End Function

'--------------------------------------------------------------------------------
' ** Sample code **
'--------------------------------------------------------------------------------
FUNCTION SampleProgress(BYVAL hDlg AS LONG, BYVAL lID AS LONG) AS LONG

CONTROL SEND hDlg, lID, %PBM_SETBARCOLOR,0,RGB(89,89,171)
CONTROL SEND hDlg, lID, %PBM_SETBKCOLOR,0,RGB(205,205,205)
CONTROL SEND hDlg, lID, %PBM_SETRANGE,0,MAKDWD(0,100)
CONTROL SEND hDlg, lID, %PBM_SETSTEP,30,0
CONTROL SEND hDlg, lID, %PBM_STEPIT,0,0

END FUNCTION

ErosOlmi
02-11-2018, 15:28
Thanks, great catch.
Fixed, I will release soon a new version.