No announcement yet.

How to trap %EN_VSCROLL?

  • Filter
  • Time
  • Show
Clear All
new posts

  • Egbert Zijlema
    Thanks folks,

    The solution is as simple as beautiful weather (as the Dutch use to say): don't use a transparent BkMode.
    Who the hack ever told me that was the one and only way?
    Anyhow, problem solved thanks to Semen's example.

    mailto:[email protected][email protected]</A>

    Leave a comment:

  • Semen Matusovski
    Egbert --
    1) EN_VSCROLL sounds as RichEdit relative.
    2) It's not a problem to receive WM_VSCROLL, if to subclass edit control.
    3) Transparent is good for static text only.
    4) If you have no bitmap as background, you can use a code, which I posted somehow.
    BTW, add %WM_VSCROLL into SuperEditProc and you will receive scrolling events.

       #Compile Exe
       #Register None
       #Dim All
       #Include "WIN32API.INC"
       %ID_TEXT = 101
       CallBack Function SuperEditProc
          Static OldProc As Long, OffsetWndExtra As Long
          If CbHndl = 0 Then OldProc = CbWparam: OffsetWndExtra = CbLparam: Exit Function
          Select Case CbMsg
             Case %WM_CHAR, %WM_LBUTTONDOWN, %WM_RBUTTONDOWN: Exit Function
          End Select
          Function = CallWindowProc(OldProc, CbHndl, CbMsg, CbWparam, CbLparam)
       End Function
       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 0&, ByVal StrPtr(OldClassName), wc) Then
             CallWindowProc lpfnNewWndProc, 0, 0, wc.lpfnWndProc, wc.cbWndExtra
             wc.hInstance = GetModuleHandle("")
             wc.lpszClassName = StrPtr(NewClassName)
             wc.lpfnWndProc = lpfnNewWndProc
             wc.cbWndExtra = wc.cbWndExtra + cbWndExtra
             Function = RegisterClassEx(wc)
          End If
       End Function
       CallBack Function DlgProc
          Static BkgClr As Long, BkgBrush As Long
          Select Case CbMsg
             Case %WM_INITDIALOG
                PostMessage CbHndl, %WM_USER + 401, 0, 0
             Case %WM_USER + 401, %WM_SETTINGCHANGE
                BkgClr = GetSysColor(%COLOR_BTNFACE)
                If BkgBrush Then DeleteObject BkgBrush
                BkgBrush = CreateSolidBrush(BkgClr)
             Case %WM_DESTROY
                DeleteObject BkgBrush
             Case %WM_CTLCOLOREDIT
                If GetDlgCtrlId(CbLparam) = %ID_TEXT Then
                   SetBkColor CbWparam, BkgClr
                   SetTextColor CbWparam, %Blue
                   Function = BkgBrush
                End If
          End Select
      End Function
      Function PbMain
         If IsFalse(CreateSuperClass("EDIT", "SuperEdit", CodePtr(SuperEditProc), 4)) Then Exit Function
         Dim Txt As String, i As Long
         For i = 1 To 100: Txt = Txt + "Line" + Str$(i) + $CRLF: Next
         Local hDlg As Long
         Dialog New 0, "Disabled Text", , , 220, 120, %WS_CAPTION Or %WS_SYSMENU Or %WS_MAXIMIZEBOX To hDlg
         Control Add Button, hDlg, 201, "Nothing", 60, 95, 100, 15
         Control Add "SuperEdit", hDlg, %ID_TEXT, Txt, 10, 10, 200, 60, %WS_CHILD Or %WS_VISIBLE _
         Dialog Show Modal hDlg Call DlgProc
      End Function
    E-MAIL: [email protected]

    Leave a comment:

  • Jules Marchildon
    one, thing first, you say this window is transparent as in %ws_ex_transparent or
    are you setting the text background mode to %transparent like this...

        case %wm_initdialog
            lb.lbstyle = %bs_solid
            lb.lbcolor = rgb(192,255,255)
            hbrush = createbrushindirect(lb)
        case %wm_ctlcoloredit
            setbkmode cbwparam, %transparent
            function = hbrush
    found semens example that clears things up for you. try his example...
      #compile exe
       #register none
       #dim all
       #include ""
       %idc_edit = 100
       $readme = "c:\pbdll60\readme.txt"
       callback function dlgproc
          static hbrush as long, hedit as long
          select case cbmsg
             case %wm_initdialog
                local buffer as string, hfile as long
                hfile = freefile
                errclear: open $readme for binary as hfile
                if err = 0 then get$ hfile, lof(hfile), buffer: close hfile
                control add textbox, cbhndl, %idc_edit, buffer, 5, 5, 385, 275, _
                    %ws_hscroll or %ws_vscroll or %es_multiline or %es_autohscroll or _
                    %es_autovscroll or %es_wantreturn, %ws_ex_clientedge
                hedit = getdlgitem(cbhndl, %idc_edit)
                setfocus hedit
                hbrush = createsolidbrush(rgb(192, 255, 255))
             case %wm_destroy
                deleteobject hbrush
             case %wm_ctlcoloredit
                if cblparam = hedit then setbkcolor cbwparam, rgb(192, 255, 255): function = hbrush
          end select
       end function
       function pbmain
          local hdlg as long
          dialog new 0, ",,,400, 300, %ws_sysmenu or %ws_minimizebox or %ds_center to hdlg
          dialog show modal hdlg call dlgproc
       end function

    also better to read this thread, cut and pasted from poffs...

    'forum: powerbasic for windows
    'topic: edit box background color
    'name: jim seekamp, member
    'date: may 01, 2000 08:25 am


    [this message has been edited by jules marchildon (edited august 07, 2001).]

    Leave a comment:

  • Egbert Zijlema
    I know, Jules. And if the edit control were a label, I would'nt have any problem.
    An edit control, as you might know, contains more text than it can display at the same time. Therefore you need a scroll. Well, the big question is: how do you trap the beginning of your scroll event in order to erase the background at the right time?

    mailto:[email protected][email protected]</A>

    [This message has been edited by Egbert Zijlema (edited August 07, 2001).]

    Leave a comment:

  • Jules Marchildon

    With a transparent background, you need to erase the background image
    first then the text will appear correctly.


    Leave a comment:

  • Egbert Zijlema
    started a topic How to trap %EN_VSCROLL?

    How to trap %EN_VSCROLL?


    My app. has a TRANSPARENT (colored) edit control. When trying to scroll the text vertically (using the scrollbar)
    the content of the control is mixed up. My app. needs to repaint the control, most likely using InvalidateRect / Updatewindow. But how?
    I don't succeed to intercept the notification message, %WM_COMMAND should receive when clicking on the scroll bar.
    When clicking in the control itself I can trap its ID and its handle, no problem, but during a click on the vertical scroll
    bar %WM_COMMAND seems to return nothing, not even my empty Messagebox used for debugging.
    BTW: I also tried to intercept %SC_VSCROLL in %WM_SYSCOMMAND. Same thing: no 'answer'.

    mailto:[email protected][email protected]</A>