• Welcome to Jose's Read Only Forum 2023.
 

The new Oxygenbasicprogress.zip compile differently

Started by Chris Chancellor, January 17, 2019, 08:20:59 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Chris Chancellor

Hello Charles

When i use the Oxygenbasicprogress.zip  of Jan 14 2019,  to
compile my Listview with multiline header the resultant exe is broken.

These are

1.  Tooltips do not work -- it display special characters
2. No multiline header -- all in a single line
3.  Statusbar do not display anything

When i used the previous Oxygenbasicprogress.zip  of Jul 21 2018   
all these functions work

Can you please advise what i can do to make these programs work using the
new compiler? 

maybe say change some type sys to dword or what?

i have atteched the program for you to check

Thanxx

Chris Chancellor


Now i had made some changes in the O2Tooltips.inc by replacing all  string  types with bstring
and now was able to make the tooltips work.

There are still some issues with the Multiline header and Status bar
so anyone got any ideas that can help out here ?


here's the new listing of O2Tooltips.inc


    'O2ToolTips.inc
    'https://docs.microsoft.com/de-de/windows/desktop/Controls/tooltip-control-reference
     'https://www.oxygenbasic.org/forum/index.php?PHPSESSID=oeqf5lmiprivqr5uadgkijer94&topic=1751.msg19014;topicseen#msg19014
   '  Updated  Jan 17 2019
  '   Allowing differing color tooltips text
'   Changed char*  and string to bstring in the tooltips -- so that it works
'    with Oxygenbasicprogress.zip of  Jan 14 2019
     
   #lookahead


    ' tooltips constants
    % TTF_IDISHWND=1
    % TTF_CENTERTIP=2
    % TTF_SUBCLASS=16
    % TTI_NONE  0
    % TTI_INFO  1
    % TTI_WARNING  2
    % TTI_ERROR  3
    % TTI_INFO_LARGE  4
    % TTI_WARNING_LARGE  5
    % TTI_ERROR_LARGE  6
    % TTM_ADDTOOL=1028
    % TTM_DELTOOL=1029
    % TTM_SETTIPBKCOLOR=1043
    % TTM_SETTIPTEXTCOLOR=1044
    % TTM_SETMAXTIPWIDTH=1048
    % TTM_SETTITLE=1056
    % TTS_ALWAYSTIP=1
    % TTS_BALLOON=64
    % TTM_NEWTOOLRECTA    = %WM_USER + 6
    % TTM_NEWTOOLRECTW    = %WM_USER + 52
     %  TTM_ACTIVATE        = %WM_USER + 1
     %  TTM_SETDELAYTIME    = %WM_USER + 3


' GetSystemMetrics() codes
% SM_CXSCREEN            = 0
% SM_CYSCREEN            = 1
% SM_CXVSCROLL           = 2
% SM_CYHSCROLL           = 3
% SM_CYCAPTION           = 4
% SM_CXBORDER            = 5
% SM_CYBORDER            = 6
% SM_CXDLGFRAME          = 7
% SM_CYDLGFRAME          = 8
% SM_CYVTHUMB            = 9
% SM_CXHTHUMB            = 10
% SM_CXICON              = 11
% SM_CYICON              = 12
% SM_CXCURSOR            = 13
% SM_CYCURSOR            = 14
% SM_CYMENU              = 15
% SM_CXFULLSCREEN        = 16
% SM_CYFULLSCREEN        = 17
% SM_CYKANJIWINDOW       = 18
% SM_MOUSEPRESENT        = 19
% SM_CYVSCROLL           = 20
% SM_CXHSCROLL           = 21
% SM_DEBUG               = 22
% SM_SWAPBUTTON          = 23
% SM_RESERVED1           = 24
% SM_RESERVED2           = 25
% SM_RESERVED3           = 26
% SM_RESERVED4           = 27
% SM_CXMIN               = 28
% SM_CYMIN               = 29
% SM_CXSIZE              = 30
% SM_CYSIZE              = 31
% SM_CXFRAME             = 32
% SM_CYFRAME             = 33
% SM_CXMINTRACK          = 34
% SM_CYMINTRACK          = 35
% SM_CXDOUBLECLK         = 36
% SM_CYDOUBLECLK         = 37
% SM_CXICONSPACING       = 38
% SM_CYICONSPACING       = 39
% SM_MENUDROPALIGNMENT   = 40
% SM_PENWINDOWS          = 41
% SM_DBCSENABLED         = 42
% SM_CMOUSEBUTTONS       = 43

% SM_CXFIXEDFRAME        = % SM_CXDLGFRAME  ' win40 name change
% SM_CYFIXEDFRAME        = % SM_CYDLGFRAME  ' win40 name change
% SM_CXSIZEFRAME         = % SM_CXFRAME     ' win40 name change
% SM_CYSIZEFRAME         = % SM_CYFRAME     ' win40 name change

% SM_SECURE              = 44
% SM_CXEDGE              = 45
% SM_CYEDGE              = 46
% SM_CXMINSPACING        = 47
% SM_CYMINSPACING        = 48
% SM_CXSMICON            = 49
% SM_CYSMICON            = 50
% SM_CYSMCAPTION         = 51
% SM_CXSMSIZE            = 52
% SM_CYSMSIZE            = 53
% SM_CXMENUSIZE          = 54
% SM_CYMENUSIZE          = 55
% SM_ARRANGE             = 56
% SM_CXMINIMIZED         = 57
% SM_CYMINIMIZED         = 58
% SM_CXMAXTRACK          = 59
% SM_CYMAXTRACK          = 60
% SM_CXMAXIMIZED         = 61
% SM_CYMAXIMIZED         = 62
% SM_NETWORK             = 63
% SM_CLEANBOOT           = 67
% SM_CXDRAG              = 68
% SM_CYDRAG              = 69
% SM_SHOWSOUNDS          = 70
% SM_CXMENUCHECK         = 71   ' Use instead of GetMenuCheckMarkDimensions()
% SM_CYMENUCHECK         = 72
% SM_SLOWMACHINE         = 73
% SM_MIDEASTENABLED      = 74
% SM_MOUSEWHEELPRESENT   = 75
% SM_XVIRTUALSCREEN      = 76
% SM_YVIRTUALSCREEN      = 77
% SM_CXVIRTUALSCREEN     = 78
% SM_CYVIRTUALSCREEN     = 79
% SM_CMONITORS           = 80
% SM_SAMEDISPLAYFORMAT   = 81
% SM_IMMENABLED          = 82
% SM_CXFOCUSBORDER       = 83
% SM_CYFOCUSBORDER       = 84
% SM_TABLETPC            = 86
% SM_MEDIACENTER         = 87
% SM_STARTER             = 88
% SM_SERVERR2            = 89
% SM_MOUSEHORIZONTALWHEELPRESENT  = 91
% SM_CXPADDEDBORDER       = 92
% SM_DIGITIZER            = 94
% SM_MAXIMUMTOUCHES       = 95
% SM_CMETRICS             = 97   ' depends on Windows version
% SM_REMOTESESSION        = &H1000
% SM_SHUTTINGDOWN         = &H2000
% SM_REMOTECONTROL        = &H2001
% SM_CARETBLINKINGENABLED = &H2002



    type TOOLINFO
      UINT      cbSize
      UINT      uFlags
      sys       hwnd
      sys       uId    'UINT_PTR
      RECT      rect   'must be checked
      sys       hinst
      bstring     lpszText
      sys       lParam
      sys       *lpReserved
    end type
     

   sys hTooltip ,  hToolTipLVH , hToolTipLVH2


!  FUNCTION SetWindowTheme LIB "UxTheme.dll" ALIAS "SetWindowTheme" ( _
   BYVAL hwnd AS sys  _                                ' __in HWND hwnd
, BYREF pszSubAppName AS WSTRING _                    ' __in LPCWSTR pszSubAppName
, BYREF pszSubIdList AS WSTRING _                     ' __in LPCWSTR pszSubIdList
) AS LONG                                              ' HRESULT




'============================================
' Calling SetWindowTheme with an empty string for a control
'     do that it is NOT painted with the current window  Theme.
'   This is to ensure that color tooltips can be display for that control
'  https://forum.powerbasic.com/forum/user-to-user-discussions/source-code/776731-custom-tooltip-on-a-region
'
FUNCTION DisableThemeControl(BYVAL hControl AS Sys) AS LONG
    LOCAL hLib AS Sys, pProc AS Sys
   Local    lRes AS LONG
    hLib = LoadLibrary("UxTheme.dll")
    IF hLib THEN
        pProc = GetProcAddress(hLib, "SetWindowTheme")
        IF pProc THEN
            lRes =   SetWindowTheme(hControl, " ", " ") 
             FUNCTION = lRes
        END IF
        FreeLibrary hLib
    END IF
END FUNCTION



'===========================
' Place the  dialog at the topmost position
' most likely be called in the  CASE  WM_INITDIALOG section
SUB SetTopMost(BYVAL sys hwndDlg )
   SetWindowPos hwndDlg,  HWND_TOPMOST ,0,0,0,0, SWP_NOMOVE OR  SWP_NOSIZE
END SUB                                 




'=============================================
'Set tooltips for any given area in a dialog or control
' Mainly for the listview columns headers which is based
' on the rect area where the mouse hovers
'  It can also display color tooltips, however only one color
'  can be display for each program using this function

  FUNCTION SetToolTipsPArea(BYVAL hWnd AS sys, ttRect AS RECT , _
               BYVAL sTxt AS bString,   BYVAL ttFGcolor  as  sys ,  _
              OPTIONAL RecChangeId AS WORD) AS sys

  LOCAL  ToolInf  AS TOOLINFO
  STATIC hInst    AS sys
  STATIC IDtt       AS sys

  IF hToolTipLVH  = 0 THEN
    hInst    = GetModuleHandle("")
    hToolTipLVH = CreateWindowEx(0, "tooltips_class32", "",
                             TTS_ALWAYSTIP OR TTS_BALLOON, _
                              0, 0, 0, 0, 0, BYVAL NULL, hInst, BYVAL NULL)
'      Need to disable the theme for this control before
'       we can display its color tooltips
        DisableThemeControl(hToolTipLVH)
        SendMessage (hToolTipLVH, TTM_SETTIPTEXTCOLOR, ttFGColor, 0)
      SetTopMost(hToolTipLVH)
  END IF



  ToolInf.cbSize   = SIZEOF(TOOLINFO)
  ' OR  TTF_IDISHWND 'Indicates that the uId member
  ' is the window handle to the tool. If this flag is not set,
  ' uId is the tool's identifier.
  ToolInf.uFlags   = TTF_SUBCLASS
  ToolInf.hwnd     = hWnd
  ToolInf.hinst    = hInst
  ToolInf.rect     = ttRect

  IF VARPTR(RecChangeId) = 0 THEN 'New tooltip
      ToolInf.lpszText = STRPTR(sTxt)
       IDtt = IDtt + 1
      ToolInf.uId = IDtt
      'Returns TRUE if successful
       SendMessage(hToolTipLVH, TTM_ADDTOOL, 0, BYVAL VARPTR(ToolInf))
      '    Allocate for multiline tooltips
      SendMessage(hToolTipLVH, TTM_SETMAXTIPWIDTH, 0, 300)
  ELSE
         'Change rect for an existing tooltip
        ToolInf.uId = RecChangeId
          SendMessage(hToolTipLVH, TTM_NEWTOOLRECTW, 0, BYVAL VARPTR(ToolInf))
     '    Allocate for multiline tooltips
          SendMessage(hToolTipLVH, TTM_SETMAXTIPWIDTH, 0, 300)
   END IF
  FUNCTION = IDtt

END FUNCTION
             



'=============================================
'Set tooltips for any given area in a dialog or control
' Mainly for the listview columns headers which is based
' on the rect area where the mouse hovers
'  It can also display color tooltips, however only one color
'  can be display for each program using this same function

  FUNCTION SetToolTipsPArea2(BYVAL hWnd AS sys, ttRect AS RECT , _
               BYVAL sTxt AS bSTRING,   BYVAL ttFGcolor2  as  sys ,  _
              OPTIONAL RecChangeId AS WORD) AS sys

  LOCAL  ToolInf  AS TOOLINFO
  STATIC  hInst2     AS sys
  STATIC   IDtt2        AS sys

  IF hToolTipLVH2  = 0 THEN
    hInst2     = GetModuleHandle("")
    hToolTipLVH2 = CreateWindowEx(0, "tooltips_class32", "",
                             TTS_ALWAYSTIP OR TTS_BALLOON, _
                              0, 0, 0, 0, 0, BYVAL NULL, hInst2 , BYVAL NULL)
'      Need to disable the theme for this control before
'       we can display its color tooltips
        DisableThemeControl(hToolTipLVH2)
        SendMessage (hToolTipLVH2, TTM_SETTIPTEXTCOLOR, ttFGColor2 , 0)
      SetTopMost(hToolTipLVH2)
  END IF



  ToolInf.cbSize   = SIZEOF(TOOLINFO)
  ' OR  TTF_IDISHWND 'Indicates that the uId member
  ' is the window handle to the tool. If this flag is not set,
  ' uId is the tool's identifier.
  ToolInf.uFlags   = TTF_SUBCLASS
  ToolInf.hwnd     = hWnd
  ToolInf.hinst    = hInst2
  ToolInf.rect     = ttRect

  IF VARPTR(RecChangeId) = 0 THEN 'New tooltip
      ToolInf.lpszText = STRPTR(sTxt)
       IDtt2  = IDtt2  + 1
      ToolInf.uId = IDtt2
      'Returns TRUE if successful
       SendMessage(hToolTipLVH2, TTM_ADDTOOL, 0, BYVAL VARPTR(ToolInf))
      '    Allocate for multiline tooltips
      SendMessage(hToolTipLVH2, TTM_SETMAXTIPWIDTH, 0, 300)
  ELSE
         'Change rect for an existing tooltip
        ToolInf.uId = RecChangeId
          SendMessage(hToolTipLVH2, TTM_NEWTOOLRECTW, 0, BYVAL VARPTR(ToolInf))
     '    Allocate for multiline tooltips
          SendMessage(hToolTipLVH2, TTM_SETMAXTIPWIDTH, 0, 300)
   END IF
  FUNCTION = IDtt2

END FUNCTION
             




 
     '=========================================================
    Function SetToolTip(sys hwnd, bstring TipText, optional bool Balloon=false,
                bCentered=false) as sys
     
        TOOLINFO TI
        sys flags=TTS_ALWAYSTIP
        uint uFlags=TTF_SUBCLASS or TTF_IDISHWND
     
        if Balloon then
                flags=flags or TTS_BALLOON
         end if
        if bCentered then
              uflags=uflags or TTF_CENTERTIP
         end if
     
         hToolTip = CreateWindowEx(0, "tooltips_class32", "", flags,
                                      0, 0, 0, 0, hwnd, null, GetModuleHandle(null), null)
   

        TI.cbSize    = sizeof(TI)
        TI.uFlags    = uflags
        TI.hWnd      = GetParent(hToolTip)
        TI.uId       = hwnd
        TI.lpszText  = strptr TipText
       
        SendMessage (hToolTip, TTM_ADDTOOL, 0, &ti)
       
         return hToolTip
    End Function
     



 

Charles Pegge

#2
Hi Chris,

I commented out several #lookaheads, and corrected some dword/sys type members. Working with OXSC190115 now. The alignment rules affecting NMHDR members have changed in OXSC to be C-compliant.

Amended files attached:



Chris Chancellor

Thanxx a lot, Charles

We all salute you,  and that your OXSC190115  did the job!

So far we have checked our programs, only those programs with list views are affected
all related to the dreaded NMHDR  and NMCUSTOMDRAW types