Hello all
i have encountered some conversion errors from PB listview to FB
i have use the PB program from http://www.jose.it-berater.org/smfforum/index.php?topic=4567.0 (http://www.jose.it-berater.org/smfforum/index.php?topic=4567.0)
which is a SDK listview with tooltips
and this is so far my converted code
' SDK Listview Tooltip.bas
'http://www.jose.it-berater.org/smfforum/index.php?topic=4567.0
' reply#1
#define UNICODE
#INCLUDE ONCE "Afx/CWindow.inc"
USING Afx
#define Common_Controls = WM_USER + 1
' // Forward declaration
DECLARE FUNCTION WndProc (BYVAL hgWnd AS HWND, BYVAL wMsg AS UINT, BYVAL wParam AS WPARAM, BYVAL lParam AS LPARAM) AS Long
'--------------------------------------------------------------------------------------------------------------------------
' Windows Callback function
'--------------------------------------------------------------------------------------------------------------------------
FUNCTION WndProc(BYVAL hgWnd AS HWND, BYVAL wMsg AS UINT, _
BYVAL wParam AS WPARAM, BYVAL lParam AS LPARAM) AS LONG
dim wzText AS ZString*80 ' WSTRINGZ * 80
'--------------------------------------------------------------------------------------------------------------------------
SELECT CASE wMsg
'--------------------------------------------------------------------------------------------------------------------------
CASE WM_NOTIFY
' Listview Tooltips
dim LVTT_Info AS NMLVGetInfoTip PTR
' LVTT_Info = lParam
LVTT_Info = CAST(NMLVGetInfoTip PTR, lParam)
' SELECT CASE @LVTT_Info.hdr.code
SELECT CASE LVTT_Info->hdr.code
CASE LVN_GETINFOTIP
' SELECT CASE @LVTT_Info.hdr.idFrom
SELECT CASE LVTT_Info->hdr.idFrom
CASE Common_Controls
PREFIX "IF LVTT_Info->iItem = "
0 THEN wzText = "Add Buttons"
1 THEN wzText = "Add Checkbox Controls"
2 THEN wzText = "Add Combobox Controls"
3 THEN wzText = "Add Custom Controls"
4 THEN wzText = "Add Frame Controls"
5 THEN wzText = "Add Graphic Controls"
6 THEN wzText = "Add Label Controls"
7 THEN wzText = "Add Listbox Controls"
8 THEN wzText = "Add Listview Controls"
9 THEN wzText = "Add Radio Button Controls"
10 THEN wzText = "Add Textbox Controls"
END PREFIX
CASE ELSE
wzText = ""
END SELECT
IF ISNOTNULL(wzText) THEN @LVTT_Info.@pszText = wzText
END SELECT
'--------------------------------------------------------------------------------------------------------------------------
CASE WM_CLOSE
PostQuitMessage(0)
EXIT FUNCTION
'--------------------------------------------------------------------------------------------------------------------------
END SELECT
'--------------------------------------------------------------------------------------------------------------------------
FUNCTION = DefWindowProc(hgWnd, wMsg, wParam, lParam)
END FUNCTION
FUNCTION PBMAIN () AS LONG
dim LV_Style AS ulong
dim hListview as HWND
'--------------------------------------------------------------------------------------------------------------------------
' Loads the CWindow CLASS
'--------------------------------------------------------------------------------------------------------------------------
dim pWindow AS CWindow
' pWindow = CLASS "CWindow"
' IF ISNOTHING(pWindow) THEN EXIT FUNCTION
'--------------------------------------------------------------------------------------------------------------------------
'--------------------------------------------------------------------------------------------------------------------------
' Create Window
'--------------------------------------------------------------------------------------------------------------------------
' pWindow.ClassName = "Listview Test"
pWindow.Create(HWND_DESKTOP, "ListView Test", @WndProc)
' pWindow.CreateWindow(HWND_DESKTOP, "Listview Test", 0, 0, 0, 0, _
' WS_SYSMENU OR WS_CAPTION OR WS_MINIMIZEBOX, WS_EX_CONTROLPARENT, CODEPTR(WndProc))
pWindow.ClassStyle = CS_DBLCLKS
' // Set the client size
pWindow.SetClientSize 300, 350
' // Center the window
pWindow.Center
'--------------------------------------------------------------------------------------------------------------------------
' Create fonts needed for program
'--------------------------------------------------------------------------------------------------------------------------
pWindow.DefaultFontName = "Arial"
pWindow.DefaultFontSize = 12
pWindow.SetFont(pWindow.DefaultFontName, pWindow.DefaultFontSize, _
FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET)
dim hTooltipFont AS ulong
hTooltipFont = pWindow.CreateFont("Times New Roman", 10,_
FW_BOLD, FALSE, FALSE, FALSE, DEFAULT_CHARSET)
'--------------------------------------------------------------------------------------------------------------------------
' Add Common Control Listview
'--------------------------------------------------------------------------------------------------------------------------
hListView = pWindow.AddListview(pWindow.hWnd, Common_Controls, "", 10, 10, 210, 290, _
WS_VISIBLE OR WS_CLIPCHILDREN OR WS_TABSTOP OR LVS_REPORT _
OR LVS_SHOWSELALWAYS OR LVS_SHAREIMAGELISTS OR LVS_AUTOARRANGE OR LVS_ALIGNTOP)
Listview_AddColumn(hListview, 0, "Common Controls", 206, LVCFMT_LEFT)
Listview_AddItem(hListview, 0, 0, "Buttons")
Listview_AddItem(hListview, 1, 0, "Checkboxes")
Listview_AddItem(hListview, 2, 0, "Comboboxes")
Listview_AddItem(hListview, 3, 0, "Custom Controls")
Listview_AddItem(hListview, 4, 0, "Frames")
Listview_AddItem(hListview, 5, 0, "Graphics")
Listview_AddItem(hListview, 6, 0, "Labels")
Listview_AddItem(hListview, 7, 0, "Listboxes")
Listview_AddItem(hListview, 8, 0, "Listviews")
Listview_AddItem(hListview, 9, 0, "Radio Buttons")
Listview_AddItem(hListview, 10, 0, "Textboxes")
LV_Style = ListView_GetExtendedListViewStyle(hListView)
ListView_SetExtendedListViewStyle hListView, LV_Style XOR LVS_EX_CHECKBOXES OR LVS_EX_INFOTIP
'--------------------------------------------------------------------------------------------------------------------------
dim hTooltiphWnd AS ulong
IF hTooltipFont THEN
hTooltiphWnd = ListView_GetToolTips(hListview)
IF hTooltiphWnd THEN AfxSetWindowFont(hTooltiphWnd, hTooltipFont)
END IF
' // Default message pump (you can replace it with your own)
pWindow.DoEvents(SW_SHOW)
IF hTooltipFont THEN DeleteObject hTooltipFont
END FUNCTION
and the errors listed out by WinFBE are as below
FreeBASIC Compiler - Version 1.06.0 (07-03-2018), built for win32 (32bit)
Copyright (C) 2004-2016 The FreeBASIC development team.
standalone
target: win32, 486, 32bit
compiling: C:\FreeBasic\Programs\ListView programs\Listview with Tooltips\Listview Tooltip.bas -o C:\FreeBasic\Programs\ListView programs\Listview with Tooltips\Listview Tooltip.asm (main module)
C:\FreeBasic\Programs\ListView programs\Listview with Tooltips\Listview Tooltip.bas(35) error 9: Expected expression, found '=' in 'CASE Common_Controls'
C:\FreeBasic\Programs\ListView programs\Listview with Tooltips\Listview Tooltip.bas(35) error 3: Expected End-of-Line, found '=' in 'CASE Common_Controls'
C:\FreeBasic\Programs\ListView programs\Listview with Tooltips\Listview Tooltip.bas(36) error 42: Variable not declared, PREFIX in 'PREFIX "IF LVTT_Info->iItem = "'
C:\FreeBasic\Programs\ListView programs\Listview with Tooltips\Listview Tooltip.bas(37) error 146: Only valid in -lang deprecated or fblite or qb in '0 THEN wzText = "Add Buttons"'
C:\FreeBasic\Programs\ListView programs\Listview with Tooltips\Listview Tooltip.bas(38) error 146: Only valid in -lang deprecated or fblite or qb in '1 THEN wzText = "Add Checkbox Controls"'
C:\FreeBasic\Programs\ListView programs\Listview with Tooltips\Listview Tooltip.bas(39) error 146: Only valid in -lang deprecated or fblite or qb in '2 THEN wzText = "Add Combobox Controls"'
C:\FreeBasic\Programs\ListView programs\Listview with Tooltips\Listview Tooltip.bas(40) error 146: Only valid in -lang deprecated or fblite or qb in '3 THEN wzText = "Add Custom Controls"'
C:\FreeBasic\Programs\ListView programs\Listview with Tooltips\Listview Tooltip.bas(41) error 146: Only valid in -lang deprecated or fblite or qb in '4 THEN wzText = "Add Frame Controls"'
C:\FreeBasic\Programs\ListView programs\Listview with Tooltips\Listview Tooltip.bas(42) error 146: Only valid in -lang deprecated or fblite or qb in '5 THEN wzText = "Add Graphic Controls"'
C:\FreeBasic\Programs\ListView programs\Listview with Tooltips\Listview Tooltip.bas(43) error 146: Only valid in -lang deprecated or fblite or qb in '6 THEN wzText = "Add Label Controls"'
C:\FreeBasic\Programs\ListView programs\Listview with Tooltips\Listview Tooltip.bas(43) error 133: Too many errors, exiting
the error started at lines 36 , 37
CASE Common_Controls
PREFIX "IF LVTT_Info->iItem = "
not sure why error occurs as i have already defined Common_Controls constant at line 9
#define Common_Controls = WM_USER + 1
appreciate all help
PREFIX is a PB thingy. It does not exist in FreeBasic.
#define does not use = . It must be: #define Common_Controls WM_USER + 1
PBMAIN is another PowerBasic thingy.
Hope you learn from my translation, because I'm not going to translate all the PB code that you find.
' SDK Listview Tooltip.bas
'http://www.jose.it-berater.org/smfforum/index.php?topic=4567.0
' reply#1
#define UNICODE
#INCLUDE ONCE "Afx/CWindow.inc"
USING Afx
#define Common_Controls WM_USER + 1
DECLARE FUNCTION WinMain (BYVAL hInstance AS HINSTANCE, _
BYVAL hPrevInstance AS HINSTANCE, _
BYVAL szCmdLine AS ZSTRING PTR, _
BYVAL nCmdShow AS LONG) AS LONG
END WinMain(GetModuleHandleW(NULL), NULL, COMMAND(), SW_NORMAL)
' // Forward declaration
DECLARE FUNCTION WndProc (BYVAL hgWnd AS HWND, BYVAL wMsg AS UINT, BYVAL wParam AS WPARAM, BYVAL lParam AS LPARAM) AS LRESULT
'--------------------------------------------------------------------------------------------------------------------------
' Windows Callback function
'--------------------------------------------------------------------------------------------------------------------------
FUNCTION WndProc(BYVAL hgWnd AS HWND, BYVAL wMsg AS UINT, _
BYVAL wParam AS WPARAM, BYVAL lParam AS LPARAM) AS LRESULT
DIM wzText AS WSTRING * 80
'--------------------------------------------------------------------------------------------------------------------------
SELECT CASE wMsg
'--------------------------------------------------------------------------------------------------------------------------
CASE WM_NOTIFY
' Listview Tooltips
dim LVTT_Info AS NMLVGetInfoTip PTR
LVTT_Info = CAST(NMLVGetInfoTip PTR, lParam)
SELECT CASE LVTT_Info->hdr.code
CASE LVN_GETINFOTIP
SELECT CASE LVTT_Info->hdr.idFrom
CASE Common_Controls
SELECT CASE LVTT_Info->iItem
CASE 0 : wzText = "Add Buttons"
CASE 1 : wzText = "Add Checkbox Controls"
CASE 2 : wzText = "Add Combobox Controls"
CASE 3 : wzText = "Add Custom Controls"
CASE 4 : wzText = "Add Frame Controls"
CASE 5 : wzText = "Add Graphic Controls"
CASE 6 : wzText = "Add Label Controls"
CASE 7 : wzText = "Add Listbox Controls"
CASE 8 : wzText = "Add Listview Controls"
CASE 9 : wzText = "Add Radio Button Controls"
CASE 10 : wzText = "Add Textbox Controls"
END SELECT
CASE ELSE
wzText = ""
END SELECT
IF LEN(wzText) THEN *LVTT_Info->pszText = wzText
END SELECT
'--------------------------------------------------------------------------------------------------------------------------
CASE WM_CLOSE
PostQuitMessage(0)
EXIT FUNCTION
'--------------------------------------------------------------------------------------------------------------------------
END SELECT
'--------------------------------------------------------------------------------------------------------------------------
FUNCTION = DefWindowProc(hgWnd, wMsg, wParam, lParam)
END FUNCTION
FUNCTION WinMain (BYVAL hInstance AS HINSTANCE, _
BYVAL hPrevInstance AS HINSTANCE, _
BYVAL szCmdLine AS ZSTRING PTR, _
BYVAL nCmdShow AS LONG) AS LONG
' // Set process DPI aware
' // The recommended way is to use a manifest file
AfxSetProcessDPIAware
dim LV_Style AS ulong
dim hListview as HWND
DIM pWindow AS CWindow
pWindow.DefaultFontName = "Arial"
pWindow.DefaultFontSize = 12
pWindow.Create(NULL, "ListView Test", @WndProc)
pWindow.ClassStyle = CS_DBLCLKS
' // Set the client size
pWindow.SetClientSize 300, 350
' // Center the window
pWindow.Center
'--------------------------------------------------------------------------------------------------------------------------
' Create fonts needed for program
'--------------------------------------------------------------------------------------------------------------------------
dim hTooltipFont AS HFONT
hTooltipFont = pWindow.CreateFont("Times New Roman", 10,_
FW_BOLD, FALSE, FALSE, FALSE, DEFAULT_CHARSET)
'--------------------------------------------------------------------------------------------------------------------------
' Add Common Control Listview
'--------------------------------------------------------------------------------------------------------------------------
hListView = pWindow.AddControl("ListView", pWindow.hwindow, Common_Controls, "", 10, 10, 210, 290, _
WS_VISIBLE OR WS_CLIPCHILDREN OR WS_TABSTOP OR LVS_REPORT _
OR LVS_SHOWSELALWAYS OR LVS_SHAREIMAGELISTS OR LVS_AUTOARRANGE OR LVS_ALIGNTOP)
Listview_AddColumn(hListview, 0, "Common Controls", 206 * pWindow.rxRatio, LVCFMT_LEFT)
Listview_AddItem(hListview, 0, 0, "Buttons")
Listview_AddItem(hListview, 1, 0, "Checkboxes")
Listview_AddItem(hListview, 2, 0, "Comboboxes")
Listview_AddItem(hListview, 3, 0, "Custom Controls")
Listview_AddItem(hListview, 4, 0, "Frames")
Listview_AddItem(hListview, 5, 0, "Graphics")
Listview_AddItem(hListview, 6, 0, "Labels")
Listview_AddItem(hListview, 7, 0, "Listboxes")
Listview_AddItem(hListview, 8, 0, "Listviews")
Listview_AddItem(hListview, 9, 0, "Radio Buttons")
Listview_AddItem(hListview, 10, 0, "Textboxes")
LV_Style = ListView_GetExtendedListViewStyle(hListView)
ListView_SetExtendedListViewStyle(hListView, LV_Style XOR LVS_EX_CHECKBOXES OR LVS_EX_INFOTIP)
'--------------------------------------------------------------------------------------------------------------------------
dim hTooltiphWnd AS HWND
IF hTooltipFont THEN
hTooltiphWnd = ListView_GetToolTips(hListview)
IF hTooltiphWnd THEN AfxSetWindowFont(hTooltiphWnd, hTooltipFont)
END IF
' // Default message pump (you can replace it with your own)
FUNCTION = pWindow.DoEvents(nCmdShow)
IF hTooltipFont THEN DeleteObject hTooltipFont
END FUNCTION
Thanxx a lot, Sir Jose
i'm eternally grateful to you especially in these crucial times of converting our 32bits programs
to 64bits ones.
Your introduction of templates via WinFBE is a tremendous help and it was a very good progress
to be able to translate so many PB programs to FB in such a short time