Windows header files

General FreeBASIC programming questions.
stephanbrunker
Posts: 62
Joined: Nov 02, 2013 14:57

Windows header files

Postby stephanbrunker » Mar 01, 2014 12:12

Hello,

as far as i found out, the *.bi Header files for freebasic are quite incomplete. I needed only a fraction of the missing ones, but here they are:

Code: Select all

'ListView Constants
#Define LVM_SETVIEW (&h1000 + 142)
#Define LVM_SORTITEMSEX (&h1000 + 81)
#Define LV_VIEW_ICON 0
#Define LV_VIEW_DETAILS 1
#Define LV_VIEW_SMALLICON 2
#Define LV_VIEW_LIST 3
#Define LV_VIEW_MAX 4
#Define LV_VIEW_TILE 4

'ComboBox Constants
#Define CB_SETCUEBANNER 5891
#Define CB_GETCUEBANNER 5892

'ListBox Macros
#Define ListBox_DeleteString(hLST,index) SendMessage(hLST,LB_DELETESTRING,index,NULL)
#Define ListBox_AddString(hLST,htext) SendMessage(hLST,LB_ADDSTRING,NULL,Cast(LPARAM,htext))
#Define ListBox_GetCurSel(hLST) SendMessage(hLST,LB_GETCURSEL,NULL,NULL)
#Define ListBox_GetSelCount(hLST) SendMessage(hLST,LB_GETSELCOUNT,NULL,NULL)
#Define ListBox_GetSelItems(hLST,nStrings,psel) SendMessage(hLST,LB_GETSELITEMS, _
   nStrings, Cast(LPARAM,psel))

'Button Macros
#Define Button_GetCheck(hBTN) SendMessage(hBTN,BM_GETCHECK,NULL,NULL)
#Define Button_SetCheck(hBTN) SendMessage(hBTN,BM_SETCHECK,NULL,NULL)

'Combo Box Macros
#Define ComboBox_AddString(hCBO,htext) SendMessage(hCBO,CB_ADDSTRING,NULL,Cast(LPARAM,htext))
#Define ComboBox_GetCurSel(hCBO) SendMessage(hCBO,CB_GETCURSEL,NULL,NULL)
#Define ComboBox_SetCurSel(hCBO,index) SendMessage(hCBO,CB_SETCURSEL,index,NULL)

'ListView Macros
#Define ListView_SetView(hLSV,flag) SendMessage(hLSV,LVM_SETVIEW,flag,NULL)
#Define ListView_SortItemsEx(hLSV,pfnCompare,lparamSort) SendMessage(hLSV,LVM_SORTITEMSEX, _
  lparamSort,Cast(LPARAM,pfnCompare))

Function ListView_SetItemText( ByVal hListview As HWND, ByVal i As Integer, _
   ByVal iSubItem As Integer, ByVal pszText As LPCTSTR) As BOOL                              
   Dim lvitem1 As LVITEM
   With lvitem1
      .mask      = LVIF_TEXT
      .iSubItem  = iSubItem
      .pszText  = pszText
      .iitem    = i
   End With
   If SendMessage(hListview,LVM_SETITEMTEXT,i,Cast(lParam,@lvitem1)) = TRUE Then
      Return TRUE
   Else
      Return FALSE
   End IF   
End Function

Function ListView_GetItemText( ByVal hListview As HWND, ByVal i As Integer, _
   ByVal iSubItem As Integer, ByRef pszText As LPCTSTR, ByVal cchTextMax As Integer) As BOOL                           
   Dim lvitem1 As LVITEM
   Dim text As ZString * MAX_PATH+1
   With lvitem1
      .mask      = LVIF_TEXT
      .iSubItem  = iSubItem
      .pszText  = psztext
      .iitem    = i
      .cchTextMax = cchTextMax
   End With
   SendMessage(hListview,LVM_GETITEMTEXT,i,Cast(lParam,@lvitem1))
   Return TRUE
End Function

'Subclassing declarations
Type SUBCLASSPROC As Function( ByVal As HWND, ByVal As UINT, ByVal As WPARAM, _
   ByVal As LPARAM, ByVal As UINT_PTR, ByVal As DWORD_PTR) As LRESULT

Declare Function SetWindowSubclass Alias "SetWindowSubclass" ( ByVal As HWND, _
   ByVal As SUBCLASSPROC, ByVal As UINT_PTR, ByVal As DWORD_PTR ) As BOOL

Declare Function RemoveWindowSubclass Alias "RemoveWindowSubclass" ( ByVal As HWND, _
   ByVal As SUBCLASSPROC, ByVal As UINT_PTR ) As BOOL

Declare Function DefSubclassProc Alias "DefSubclassProc" ( ByVal As HWND, ByVal As UINT, _
   ByVal As WPARAM, ByVal As LPARAM ) As LRESULT

Declare Function GetWindowSubclass Alias "GetWindowSubclass" ( ByVal As HWND, _
   ByVal As SUBCLASSPROC, ByVal As UINT_PTR, ByVal As DWORD_PTR Ptr ) As BOOL



And also the HtmlHelpA function which has to be loaded from a dll:

Code: Select all

#Define HH_DISPLAY_TOPIC 0000
#define HH_HELP_CONTEXT  0015
Dim As Any Ptr library = DylibLoad( "hhctrl.ocx" )
Dim Shared HtmlHelpA As Function (hwndCaller As HWND,pszFile As LPCSTR, _
   uCommand As UINT,dwData As DWORD_PTR) As HWND
HtmlHelpA = DyLibSymbol( library, "HtmlHelpA" )


Is anybody going to fix the files in the package?
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Re: Windows header files

Postby MichaelW » Mar 02, 2014 6:30

I suspect that the developers will be unwilling to add anything that was directly derived from Microsoft sources or documentation. My quick search of a ~1 year old MinGW installation found every declaration from your list that I searched for.

And for HtmlHelp my 2003 PSDK includes what appears to be an import library hhctrl.ocx, so creating one should be doable.

Duh, already been through this in this thread.
stephanbrunker
Posts: 62
Joined: Nov 02, 2013 14:57

Re: Windows header files

Postby stephanbrunker » Mar 02, 2014 15:21

The question is: where are the now existing header files from? As far as I can see, the files are pre-Windows XP, so every function added in later versions of windows is missing (Common Controls 6.0 for example).

At the top of every file is the following: "header translated with help of SWIG FB wrapper" - perhaps they simply should make a new translation of the actual version from whatevery files they have translated ...
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Re: Windows header files

Postby MichaelW » Mar 03, 2014 2:39

IIRC it was V1ctor who did the SWIG wrapper and the original translation, starting with MinGW, or similar.

viewtopic.php?f=14&t=10520&hilit=swig

And to put your “quite incomplete” into perspective, for release 0.90.1 the inc\win directory contains 213 files, with the 8 largest collectively containing 28000+ lines.
marcov
Posts: 2970
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: Windows header files

Postby marcov » Mar 03, 2014 6:07

MichaelW wrote:
And to put your “quite incomplete” into perspective, for release 0.90.1 the inc\win directory contains 213 files, with the 8 largest collectively containing 28000+ lines.


What's the long term plan for header maintenance, minimum editing and repeated full regeneration, or manual maintenance for now on?
stephanbrunker
Posts: 62
Joined: Nov 02, 2013 14:57

Re: Windows header files

Postby stephanbrunker » Mar 03, 2014 10:43

Okay, "quite incomplete" doesn't meant an absolute value. But relatively, it's seems frozen since 2008 and while I'm writing a tutorial about Windows GUI programming in reference to the MSDN, every lecture contains some missing definitions. The next tutorial is about the Drag&Drop Interface and the IDataObject Interface and that is also not up to date. By now, Freebasic does support virtual methods and inheritance - what IS nice, by the way - and so I'm writing sample code for the IUnknown, IDropTarget, IDropSource and IDataObject Interfaces. But for that i have to undef the existing definitions, because the types in the headers aren't compatible to that.

And for a side remark: The Package also contains two bigint libraries which are both not at all commented and it's very hard to use them. Based on Richards work, i evoluted a very simple to use bigint type integration with completely overloaded operators. If the developers are interested, I would be glad to support the windows GUI samples and the bigint libary for the package.
dkl
Site Admin
Posts: 3212
Joined: Jul 28, 2005 14:45
Location: Germany

Re: Windows header files

Postby dkl » Mar 03, 2014 13:38

I'm hoping that we can create/update bindings automatically in the future, and going through the FB Win32 headers (FreeBASIC/inc/win/*.bi, currently 91k lines containing 80k statements) manually, to add 64bit support or check for missing declarations, isn't fun.

We now have much better tools than SWIG (h_2_bi, fbfrog).

Return to “General”

Who is online

Users browsing this forum: No registered users and 2 guests