• Welcome to PlanetSquires Forums.
 

From PowerBASIC to FreeBASIC ...

Started by Jean-pierre Leroy, April 01, 2015, 01:10:47 PM

Previous topic - Next topic

José Roca

#30
Not at all. An ole string descriptor has a field for the length, followed by a pointer to the string data, whereas the FB string descriptor uses a pointer for the string data, followed by the length and the size of the allocated memory block. Besides, memory is allocated using malloc.

Paul Squires

I assume they chose that method because there is no such thing as ole strings on Linux, Mac, etc. (basically, non-Windows systems)?
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Richard Kelly

It's interesting to see FB as perhaps my "logical" move from PB. I'm not sure now is the right time. I'm heavily invested in Jose's includes, I use all the FF functions, I have my own custom objects, and, I'm all over the PB Powercollection group of objects. The port over now would be painful and perhaps less so in the future.

Rick Kelly

Klaas Holland

I'am not a Pro, therefore I need examples how things are done.

Who can help me with the conversion of my Sample Listview to the FB Sample Listview?

The picture is Oke and compiles fine, but now I'am stuck.

Klaas


Paul Squires

Hi Klaas,

I took a very quick look at the generated source code and it looks like you have the "ResizeRules" set for the ListView in the FreeBASIC version. The code is generating "FL,FT,FR,FB" resize rules whereas the PB version is outputting nothing.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Klaas Holland

Hi Paul,

This line is failing in the AppStart, therefore the Format did not work.

#Include Once "string.bi"        ' so we can have access to the Format function


Next question is how to point to the Listview Item and Listview Sub_Item and show the Editbox or ComboBox

'--------------------------------------------------------------------------------
Function FORMT1_CUSTOM ( _
                       hWndForm      As HWnd, _      ' handle of Form
                       wMsg          As Integer,  _  ' type of message
                       wParam        As WPARAM, _    ' first message parameter
                       lParam        As LPARAM   _   ' second message parameter
                       ) As Integer

    Dim pNmLvw        As NM_LISTVIEW Ptr
    Dim RectSub       As Rect
    Dim sText         As String

    Select Case wMsg

        Case WM_NOTIFY         ', WM_VSCROLL, WM_MOUSEWHEEL
            Select Case wParam
                Case IDC_FORMT1_LISTVIEW1
                    pNmLvw = lParam

                    If (@pNmLvw.hdr.Code = NM_CLICK) And (@pNmLvw.iItem > -1) Then 'Click in listview
                        gLvRow  = @pNmLvw.iItem
                        gLvCol  = @pNmLvw.iSubItem
                        If gLvCol = 1 Or gLvCol = 3 Then EditCell
                        If gLvCol = 2 Then ComboCell

'                    ElseIf (@pNmLvw.hdr.Code = NM_DBLCLK) And (@pNmLvw.iItem > -1) Then 'DoubleClick in listview
'                        gLvRow  = @pNmLvw.iItem
'                        gLvCol  = 2   '@pNmLvw.iSubItem
'                        ComboCell

                    End If
                End Select

    End Select

   Function = 0   ' change according to your needs
End Function


'--------------------------------------------------------------------------------
Sub EditCell
'--------------------------------------------------------------------------------
    Dim RectSub      As Rect
    Dim sText        As String

    FF_ListView_SetSelectedItem HWND_FORMT1_LISTVIEW1, gLvRow
    ListView_EnsureVisible (HWND_FORMT1_LISTVIEW1, gLvRow, 0)

    'get Rect of the Cell
    ListView_GetSubItemRect (HWND_FORMT1_LISTVIEW1, gLvRow, gLvCol, LVIR_LABEL, RectSub)   
    FF_Control_SetLoc HWND_FORMT1_TEXT1, RectSub.nLeft , RectSub.nTop
    FF_Control_SetSize HWND_FORMT1_TEXT1, RectSub.nRight - RectSub.nLeft , RectSub.nBottom + 3 - RectSub.nTop

   
    'get Text from Listview to TextBox
    FF_ListView_GetItemText HWND_FORMT1_LISTVIEW1, gLvRow, gLvCol To sText
    FF_TextBox_SetText HWND_FORMT1_TEXT1, sText
    FF_Control_ShowState HWND_FORMT1_TEXT1, SW_SHOW
    FF_Control_SetFocus HWND_FORMT1_TEXT1

End Sub



'--------------------------------------------------------------------------------
Sub ComboCell
'--------------------------------------------------------------------------------
    Dim RectSub       As Rect
    Dim Txt           As String
    Dim Ws            As Long


    FF_ListView_SetSelectedItem HWND_FORMT1_LISTVIEW1, gLvRow
    ListView_EnsureVisible (HWND_FORMT1_LISTVIEW1, gLvRow, 0)
         
    'ermitteln der Label des Subitem
    ListView_GetSubItemRect HWND_FORMT1_LISTVIEW1, gLvRow, gLvCol, LVIR_LABEL, RectSub
    FF_Control_SetLoc HWND_FORMT1_COMBO2, RectSub.nLeft, RectSub.nTop
    FF_Control_SetSize HWND_FORMT1_COMBO2, RectSub.nRight - RectSub.nLeft , RectSub.nBottom - RectSub.nTop

    'get Text from Listview to ComboBox
    FF_ListView_GetItemText HWND_FORMT1_LISTVIEW1, gLvRow, gLvCol To Txt
    FF_ComboBox_FindString HWND_FORMT1_COMBO2, 1, Txt To Ws
    FF_ComboBox_SetCurSel HWND_FORMT1_COMBO2, Ws
 
    FF_Control_ShowState HWND_FORMT1_COMBO2, SW_SHOW
    FF_Control_SetFocus HWND_FORMT1_COMBO2
       
End Sub



Klaas

Michael Meeks

Paul,  I don't know how you can handle it all for free - but great job on the FF3FB.  If you put more into in the upcoming months - don't hesitate to charge me.  I'm totally funded.  I'm one of those willing to pay for great software.

I'm currently staying with PBWin10, (both versions of FF) for the moment.  With that said;

However, for those of you who really want to move on, Visual Studio Express 2013 for VB, C# and C++ is free also - up to 5 Users for commercial software.  I recommend getting your IIS working correct before installing.

1)  Visual Studio Desktop (install this 1st)
2)  Visual Studio Web (install this 2nd)

https://www.visualstudio.com/en-us/products/visual-studio-express-vs.aspx
(note:  it's a confusing website - but make sure you download the ISO's - not the online install)
These are huge files - 6.5GB ISO. 

Net isn't going away - so I'm just stating that fact here.  I'll keep praying - hoping - wondering if PowerBasic can pull off a big one and come out with PBWin64.

We can always hope and dream. 

Thanks
Mike





Klaas Holland

Hi Paul, Jose

Do we need a way to use Jose-Includes in FreeBasic to use i.e. ListView_GetSubItemRect
or is there a workaround.

Klaas

José Roca

The main problem is that the official FB declares aren't well suited for BASIC type programming. Someone has decided that despite being a BASIC compiler you must use it as if it was a C compiler.

Klaas Holland

So what do you suggest Jose.
Isn't there another suitable compiler? 

Paul Squires

The FB includes are okay to work with. It takes a little more effort because you need to remember to use the right data types otherwise you will get compiler warnings. So, instead of always using a LONG or DWORD as in PowerBASIC, you would use types like HANDLE, BITMAP, HWND, LPARAM, WPARAM, etc. It does lead to your code being a little more self-documenting but it also means that you need to know what type to use for each situation.

I am getting used to it now. It is like everything with programming, the more you do it - the easier it gets.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

Klaas,

The ListView_GetSubItemRect function is already defined in the FB include files. Look at "commctrl.bi" (line 3024):

private function ListView_GetSubItemRect(byval hwnd as HWND, byval iItem as long, byval iSubItem as long, byval code as long, byval prc as RECT ptr) as WINBOOL
if prc then
prc->top = iSubItem
prc->left = code
end if
function = SNDMSG(hwnd, LVM_GETSUBITEMRECT, cast(WPARAM, iItem), cast(LPARAM, prc))
end function

Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer