Announcement

Collapse
No announcement yet.

QHTM mousewheel

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Paul Noble
    replied
    Keith,

    Ooops, sorry for that, I thought I'd put it in there . Anyway, here it is -
    Code:
    sub QHTM_Refresh( byval hQHTM as long )
     
      'Purpose : Causes the QHTM window to be re-drawn
      '
      'Remarks : If the QHTM window moves from a state where it is using one or more scrollbars to
      '          a state where a scroll bar is unneeded, junk gets displayed in the vacated scroll
      '          bar area. It was noticed that this is always cured by a manual resize of the QHTM 
      '          window, so this procedure just emulates that.
      '
      '          Later : fixed in newer versions of the control
      '
      local uRect  as RECT
      local HiPart as long
      local LoPart as long
     
      GetClientRect hQHTM, uRect
      HiPart = uRect.nBottom - uRect.nTop
      LoPart = uRect.nRight - uRect.nLeft
     
      SendMessage hQHTM, %WM_SIZE, %SIZE_RESTORED, MAKDWD( LoPart, HiPart )
     
      InvalidateRect hQHTM, byval %NULL, %TRUE
      UpdateWindow hQHTM
     
    end sub
    Just a thought - have you tried 'non-breaking space' characters in place of underscores to prevent wrapping ?
    (All attempts to include the character here failed miserably - I must brush up on my UBB code !)

    >I hope Russ can continue to support and develop it

    From what I can gather, he's working pretty much full-time on it, certainly at the moment. He's
    very enthused about it. I've had a good look at the competition over the last couple of years, and
    for me as a PowerBASIC developer, QHTM is by far the best option. If by chance you use Delphi or
    C++ Builder, there is an excellent (but comparatively weighty) alternative at http://www.pbear.com

    Regards,

    Paul



    [This message has been edited by Paul Noble (edited July 13, 2001).]

    Leave a comment:


  • Keith Waters
    replied
    Semen

    You never cease to amaze me. Some one posts a problem and you promptly supply code. I will study your code and I am sure it will help me a lot. Many thanks.

    Paul

    I'd suspected there must be a refresh procedure but I've never been able to find it and I could not find it in the link you gave. Anyway, I appreciate you replying.

    Actually, I've got round the problem another way. I need tables in which the content does not wrap. Since QHTM does not support the nowrap attribute I've inserted unbroken strings of the underscore character in one row of the table to forcible impose a limiting minimum column width.

    BTW I think I will be purchasing the full QHTM soon. There are problems with it, of course, but it is such an excellent control. I hope Russ can continue to support and develop it.

    Keith


    ------------------

    Leave a comment:


  • Paul Noble
    replied
    Hi Keith,

    'Fraid the mouse wheel is beyond my ken at the moment, but I tried a quick test using
    table widths as percentages, and wasn't able to reproduce the problem (although it's
    obviously occurring).

    Pending an answer from Russ, the workaround that comes to mind is to just refresh the
    QHTM window on receipt of a WM_SYSCOMMAND \ SC_RESTORE. With the page sizes I've used
    to date, a refresh is instantaneous/flicker-free.

    There's a QHTM_Refresh() procedure in the include file at
    http://www.gipsysoft.com/qhtm/using/...sic/PBQHTM.inc .


    - Paul

    Leave a comment:


  • Semen Matusovski
    replied
    Keith --
    Try this. On my PC (Win2000 SP2) I was not able to use PgUp/PgDn also and I used super-class.
    Can't understand, why scrolling messages come to first window.
    Bug in my code ? Don't see.

    BTW, about bugs - see "third party add-ons"...
    Unf., not a big choice - similar dll is actually a good idea.

    Code:
       #Compile Exe
       #Register None
       #Dim All
       #Include "Win32Api.Inc"
       
       $TestHtm = "Test.htm"
    
        '----QHTM declares -----------------
    
       $QHTM_CLASSNAME = "QHTM_Window_Class_001"
       
       ' Zoom constants, minimum, maximum And default.
       %QHTM_ZOOM_MIN     = 0
       %QHTM_ZOOM_MAX     = 4
       %QHTM_ZOOM_DEFAULT = 2
    
       Type tagNMQHTM
          hdr As NMHDR
          pcszLinkText As Asciiz Ptr
          resReturnValue As Long
       End Type
    
        ' Sent whenever a link is clicked.
        ' Set resReturnValue to FALSE To prevent QHTM From starting the user agent associated with the link
        ' This would be used if you had encoded some of your own links To internal functions In the HTML
        %QHTMN_HYPERLINK = 1
    
        ' Load a HTML Page From the resources
        ' SendMessage hwnd, %QHTM_LOAD_FROM_RESOURCE, hInst, Name
        %QHTM_LOAD_FROM_RESOURCE = %WM_USER + 1
    
        ' Load the HTML From a file on disk.
        ' SendMessage hwnd, %QHTM_LOAD_FROM_FILE, 0, pcszName
        %QHTM_LOAD_FROM_FILE = %WM_USER + 2
    
        'Sets an Option - see the values QHTM_OPT_* For further information
        ' SendMessage hwnd, %QHTM_SET_OPTION, nOptionIndex, OptionValue
        %QHTM_SET_OPTION = %WM_USER + 3
    
        ' Gets an Option - see the values QHTM_OPT_* For further information
        ' OptionValue = SendMessage(hwnd, %QHTM_GET_OPTION, nOptionIndex, 0)
        %QHTM_GET_OPTION = %WM_USER + 4
    
        ' Goto a link with the HTML control. Used when you want to display a HTML document
        ' not from the start but at a named section within the document.
        ' SendMessage hwnd, %QHTM_GOTO_LINK, 0, pcszLinkName
        %QHTM_GOTO_LINK = %WM_USER + 5
    
        ' Get and set the scroll position of the control.
        %QHTM_GET_SCROLL_POS = %WM_USER + 6
        %QHTM_SET_SCROLL_POS = %WM_USER + 7
    
        ' Get the title length From the HTML document
        ' SendMessage hwnd, %QHTM_SET_HTML_TITLE, nBufferLength, pszBuffer
        ' returns the number of characters To store the title.
        %QHTM_GET_HTML_TITLE_LENGTH = %WM_USER + 8
    
        ' Get the title From the HTML document
        ' SendMessage hwnd, %QHTM_SET_HTML_TITLE, nBufferLength, pszBuffer
        ' No return value
        %QHTM_GET_HTML_TITLE = %WM_USER + 9
    
        ' Set/Get the HTML tooltips state.
        ' SendMessage hwnd, %QHTM_SET_OPTION, %QHTM_OPT_TOOLTIPS, bEnable
        %QHTM_OPT_TOOLTIPS = 1
        ' SendMessage hwnd, %QHTM_SET_OPTION, %QHTM_OPT_ZOOMLEVEL, nLevel
        ' nLevel can be between QHTM_ZOOM_MIN And QHTM_ZOOM_MAX defined above
        %QHTM_OPT_ZOOMLEVEL = 2
    
    
        ' Call this to initialise the Quick HTML control.
        Declare Function QHTM_Initialize Lib "qhtmlight.dll" Alias "QHTM_Initialize" _
           (ByVal hInst As Dword) As Long
    
        ' Enable coolTips in an application that currently uses the Win32 tool tip control.
        Declare Function QHTM_EnableCooltips Lib "qhtmlight.dll" Alias "QHTM_EnableCooltips" _
           () As Long
    
        ' Call this To Create a New Print context Using a zoom level
        Declare Function QHTM_PrintCreateContext Lib "qhtmlight.dll" Alias "QHTM_PrintCreateContext" _
           (ByVal uZoomLevel As Dword) As Dword
    
        ' Call this To destroy a Print context
        Declare Function QHTM_PrintDestroyContext Lib "qhtmlight.dll" Alias "QHTM_PrintDestroyContext" _
           (ByVal Dword) As Long
    
        'Call this To Set the HTML
        Declare Function QHTM_PrintSetText Lib "qhtmlight.dll" Alias "QHTM_PrintSetText" _
           (ByVal ctx As Dword, pcszText As Asciiz) As Long
    
        ' Call this To Set the HTML ftom a file
        Declare Function QHTM_PrintSetTextFile Lib "qhtmlight.dll" Alias "QHTM_PrintSetTextFile" _
           (ByVal ctx As Dword, pcszFilename As Asciiz) As Long
    
        ' Call this To Set the HTML ftom a resource
        Declare Function QHTM_PrintSetTextResource Lib "qhtmlight.dll" Alias "QHTM_PrintSetTextResource" _
           (ByVal ctx As Dword, ByVal hInst As Dword, pcszName As Asciiz) As Long
    
        ' Call this To layout the HTML. Returns the number of pages In nPages
        Declare Function QHTM_PrintLayout Lib "qhtmlight.dll" Alias "QHTM_PrintLayout" _
           (ByVal ctx As Dword, ByVal dc As Dword, pRect As RECT, nPages As Long) As Long
    
        ' Call To Print a Page of the HTML To a dc
        Declare Function QHTM_PrintPage  Lib "qhtmlight.dll" Alias "QHTM_PrintPage" _
           (ByVal ctx As Dword, hDC As Dword, ByVal nPage As Dword, prDest As RECT) As Long
    
        ' Using a zoom level
        Declare Function QHTM_PrintGetHTMLHeight Lib "qhtmlight.dll" Alias "QHTM_PrintGetHTMLHeight" _
           (ByVal hDC As Dword, pcszText As Asciiz, ByVal nMaxWidth As Long, ByVal uZoomLevel As Dword) As Long
    
        ' Set where QHTM gets it's resources for the hand cursor and the "no image" image. Maybe more later.
        Declare Sub QHTM_SetResources Lib "qhtmlight.dll" Alias "QHTM_SetResources" _
           (ByVal hInst As Dword, ByVal uArrowCursorID As Dword, ByVal uNoImageBitmapID As Dword)
    
        '----End of QHTM declares -------------------------------------------
    
        Function CreateSuperClass(OldClassName As String, NewClassName As String, lpfnNewWndProc As Long, cbWndExtra As Long) As Long
           Local wc As WNDCLASSEX
           wc.cbSize = SizeOf(wc)
           If GetClassInfoEx(ByVal GetModuleHandle(""), ByVal StrPtr(OldClassName), wc) Then
              CallWindowProc lpfnNewWndProc, 0, 0, wc.lpfnWndProc, wc.cbWndExtra
              wc.hInstance = GetModuleHandle(ByVal 0&)
              wc.lpszClassName = StrPtr(NewClassName)
              wc.lpfnWndProc = lpfnNewWndProc
              wc.cbWndExtra = wc.cbWndExtra + cbWndExtra
              Function = RegisterClassEx(wc)
           End If
       End Function
    
        CallBack Function QHTML_Proc
           Static OldProc As Long, OffsetWndExtra As Long
           If CbHndl = 0 Then OldProc = CbWparam: OffsetWndExtra = CbLparam: Exit Function
           SetWindowText GetParent(CbHndl), "hWnd = " + Str$(CbHndl)
           Select Case CbMsg
             Case %WM_KEYDOWN
                Select Case CbWparam
                   Case %VK_PGDN: PostMessage CbHndl, %WM_VSCROLL, %SB_PAGEDOWN, 0
                   Case %VK_PGUP: SendMessage CbHndl, %WM_VSCROLL, %SB_PAGEUP, 0
                   Case %VK_DOWN: SendMessage CbHndl, %WM_VSCROLL, %SB_LINEDOWN, 0
                   Case %VK_UP  : SendMessage CbHndl, %WM_VSCROLL, %SB_LINEUP, 0
                End Select
                Exit Function
             Case %WM_MOUSEWHEEL
                If GetSystemMetrics(%SM_MOUSEWHEELPRESENT) Then
                   Dim j As Integer
                   j = HiWrd(CbWparam)
                   If (LoWrd(CbWparam) And %MK_MBUTTON) = %MK_MBUTTON Then ' If middle button is pushed - fast scrolling
                      If j > 0 Then SendMessage CbHndl, %WM_VSCROLL, %SB_PAGEDOWN, 0 Else _
                                    SendMessage CbHndl, %WM_VSCROLL, %SB_PAGEUP, 0
                   Else
                      If j > 0 Then SendMessage CbHndl, %WM_VSCROLL,  %SB_LINEDOWN, 0 Else _
                                    SendMessage CbHndl, %WM_VSCROLL,  %SB_LINEUP,   0
                   End If
               End If
               Exit Function
          End Select
          Function = CallWindowProc(OldProc, CbHndl, CbMsg, CbWparam, CbLparam)
       End Function
    
       %ID_QHTM1 = 101
       %ID_QHTM2 = 102
    
       CallBack Function DlgProc
           Dim txt As Static String, sHtmlFile As String, i As Long
           Select Case CbMsg
              Case %WM_INITDIALOG
                 QHTM_Initialize GetModuleHandle("")
                 CreateSuperClass $QHTM_CLASSNAME, "QHTML", CodePtr(QHTML_Proc), 4
                 
                 Control Add "QHTML", CbHndl, %ID_QHTM1, "", 10, 10, 400, 160,%WS_TABSTOP Or %WS_VISIBLE Or %WS_CHILD,%WS_EX_CLIENTEDGE
                 Control Add "QHTML", CbHndl, %ID_QHTM2, "", 10, 180, 400, 80, %WS_TABSTOP Or %WS_VISIBLE Or %WS_CHILD,%WS_EX_CLIENTEDGE
                 Control Add Button, CbHndl,  %IDOK, "Nothing", 110, 270, 200, 15
                 
                 txt = "<body bgcolor=#00FF00>"
                 For i = 2 To 7
                    txt = txt + "<font size=" + Format$(i) + " face=Verdana>Size=" + Format$(i) + "<br>" + $CRLF
                 Next
                 For i = 10 To 36 Step 2
                    txt = txt + "<font size=" + Format$(i) + "pt face=Verdana>Size=" + Format$(i) + "pt<br>" + $CRLF
                 Next
    
                 SetWindowText GetDlgItem(CbHndl, %ID_QHTM2), ByVal StrPtr(txt)
    
                 sHtmlFile = $TestHtm
                 SendDlgItemMessage CbHndl, %ID_QHTM1,%QHTM_LOAD_FROM_FILE, 0, StrPtr(sHtmlFile)
    
              Case %WM_NOTIFY
                 Dim pNMQHTM As tagNMQHTM Ptr
                 If CbCtl= %ID_QHTM1 Then
                    pNMQHTM = CbLparam
                    If @pNMQHTM.hdr.code =%QHTMN_HYPERLINK Then
                       MsgBox @[email protected]
                       @pNMQHTM.resReturnValue = 0
                    End If
                 End If
           End Select
        End Function
    
        Function PbMain
          Dim hDlg As Long, Msg As tagMsg
          Dialog New 0, "QHTM test" ,,, 420, 300,%WS_CAPTION Or %WS_SYSMENU To hDlg
          Dialog Show Modal hDlg Call DlgProc
        End Function

    ------------------
    E-MAIL: [email protected]

    [This message has been edited by Semen Matusovski (edited July 13, 2001).]

    Leave a comment:


  • Keith Waters
    replied
    I've just noticed that QHTM does respond to the mouse wheel on my
    home machine. I also note that MsWheel is running on this machine
    but not, I presume, on my office machine. That must explain the
    difference. But I still have the problem of enabling mouse wheel
    scrolling in my application when its on a system that does not have
    MsWheel running.

    Thanks,
    Keith

    ------------------

    Leave a comment:


  • Keith Waters
    started a topic QHTM mousewheel

    QHTM mousewheel

    I'm evaluating the QHTM control and note that it does not scroll with the mouse wheel. I've subclassed the control and so it should be easy to intercept and process WM_MOUSEWHEEL. Is this the correct approach and does anyone have experience of doing this. I seem to recall Semen posted some mouse wheel code that I must study.

    By the way, I've experienced a problem with QHTM's handling of tables with column widths set as percentage values. The problem occurs when resizing the window as follows.

    Run the program initially with a narrow (small width) size so that the text in the table wraps.

    Now drag the edge of the program window to make it wider until the text in the table is no longer wrapped.

    Click the program's Maximise button

    Click the program's Restore button.

    The text in the table is now wrapped causing areas of white space in the table and no amount of fiddling with the window size restores it to what is was before the maximise.

    I've emailed gipsysoft about it. I wonder if anyone else has noticed this.

    Keith Waters


    ------------------
Working...
X