Announcement

Collapse
No announcement yet.

painting problem (copying listview image)

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

  • Chris Holbrook
    replied
    Originally posted by Chris Holbrook View Post
    Just picking through the messages to find the culprit.
    Got it! the culprit is .....ME! I did not realise the "black hole" nature of the WM_INITDIALOG handler.

    Leave a comment:


  • Michael Mattias
    replied
    That's why I qualfied that solution vis-a-vis its use with the dialog classes.

    As with any other tool, the use of the dialog class and its support functions both giveth and taketh away.

    Maybe you need to create a superclassed window off the dialog base class and intercept WM_PAINT or WM_ERASEBKGND or something?


    MCM

    Leave a comment:


  • Chris Holbrook
    replied
    Originally posted by Michael Mattias View Post
    You can set the window class' hBrushBackground to an image using CreatePatternBrush.
    That would do the trick if you were painting the whole of the client area, actually I use it to draw the grid in the code generator (Hagsten's idea not mine).

    The problem with this one is apparently the dialog gets drawn OK but something then reverts it to the background color. Just picking through the messages to find the culprit.

    Leave a comment:


  • Chris Holbrook
    replied
    &HAE appears to be involved in painting the Non-Client area, my mistake. Still not documented.

    Leave a comment:


  • Michael Mattias
    replied
    You can set the window class' hBrushBackground to an image using CreatePatternBrush.

    Don't know that you can do that with the dialog classes but it works great with registered class windows.

    Leave a comment:


  • Chris Holbrook
    replied
    message identifier &HAE - what is it?

    I suspect that this message is involved in painting a dialog's client area background but can find no reference to it. Any ideas please?

    Leave a comment:


  • Michael Mattias
    replied
    I don't understand why you perform PaintW on *both* WM_ERASEBKGND *AND* WM_PAINT.

    Then again these mixed DDT and SDK things always confuse me.

    Leave a comment:


  • Chris Holbrook
    replied
    MCM - 1 & 2 don't do it either.

    3 - this sets the background for a listview. I'm trying to grab the listview bitmap and place it in the dialogs's DC, sort of the opposite of what LVM_SETBKIMAGE does.

    Leave a comment:


  • Michael Mattias
    replied
    These are just some ideas....totally untested

    1.
    WM_ERASEBKGND
    Return Value

    An application should return nonzero if it erases the background; otherwise, it should return zero.
    You don't.

    2.
    Shouldn't you be doing a GetClientRect rather then GetWidnowRect? You are BitBlt'ing entire Window area.

    3.
    It might be easier to handle making the background of a listview control equal a BMP by using the LVM_SETBKIMAGE message and letting Windows handle all the messy stuff.

    MCM

    Leave a comment:


  • Chris Holbrook
    started a topic painting problem (copying listview image)

    painting problem (copying listview image)

    The application below (compileable example PBWin 8.04, PBWIn 9.0) does not paint all of the the right hand side of the dialog with a copy of the listview on the left hand side - it just paints the scrollbar. It only gets fully painted if the dialog is dragged off-screen or overlaid by another window.

    I wonder what I'm doing wrong?
    Code:
    #COMPILE EXE
    #DIM ALL
    
    #INCLUDE "WIN32API.INC"
    #INCLUDE "COMMCTRL.INC"
    
    %IDD_DIALOG1         =  101
    %IDC_LV = 1001
    %IDC_LABEL1          = 1002
    '-------------------------------------------------------------------------
    ' PBforms standard code
    FUNCTION SampleListView(BYVAL hDlg AS DWORD, BYVAL lID AS LONG, BYVAL lColCnt AS LONG, BYVAL lRowCnt AS LONG) AS LONG
        LOCAL lCol   AS LONG
        LOCAL lRow   AS LONG
        LOCAL hCtl   AS DWORD
        LOCAL tLVC   AS LV_COLUMN
        LOCAL tLVI   AS LV_ITEM
        LOCAL szBuf  AS ASCIIZ * 32
        LOCAL lStyle AS LONG
    
        CONTROL HANDLE hDlg, lID TO hCtl
    
        lStyle = ListView_GetExtendedListViewStyle(hCtl)
        ListView_SetExtendedListViewStyle hCtl, lStyle OR %LVS_EX_FULLROWSELECT OR %LVS_EX_GRIDLINES
    
        ' Load column headers.
        tLVC.mask    = %LVCF_FMT OR %LVCF_TEXT OR %LVCF_SUBITEM
        tLVC.fmt     = %LVCFMT_LEFT
        tLVC.pszText = VARPTR(szBuf)
        FOR lCol = 0 TO lColCnt - 1
            szBuf       = USING$("Column #", lCol)
            tLVC.iOrder = lCol
            ListView_InsertColumn hCtl, lCol, tLVC
        NEXT lCol
    
        ' Load sample data.
        FOR lRow = 0 TO lRowCnt - 1
            tLVI.stateMask = %LVIS_FOCUSED
            tLVI.pszText   = VARPTR(szBuf)
            tLVI.iItem     = lRow
            FOR lCol = 0 TO lColCnt - 1
                szBuf         = USING$("Column # Row #", lCol, lRow)
                tLVI.iSubItem = lCol
                tLVI.lParam   = lRow
                IF lCol = 0 THEN
                    tLVI.mask = %LVIF_TEXT OR %LVIF_PARAM OR %LVIF_STATE
                    ListView_InsertItem hCtl, tLVI
                ELSE
                    tLVI.mask = %LVIF_TEXT
                    ListView_SetItem hCtl, tLVI
                END IF
            NEXT lCol
        NEXT lRow
    
        ' Auto size columns.
        FOR lCol = 0 TO lColCnt - 2
            ListView_SetColumnWidth hCtl, lCol, %LVSCW_AUTOSIZE
        NEXT lCol
        ListView_SetColumnWidth hCtl, lColCnt - 1, %LVSCW_AUTOSIZE_USEHEADER
    END FUNCTION
    
    '--------------------------------------------------------------------------
    CALLBACK FUNCTION ShowDIALOG1Proc()
        STATIC  hLV             AS DWORD
        LOCAL   hDCLV, hDC      AS DWORD
        LOCAL   r               AS RECT
        LOCAL   ps              AS PAINTSTRUCT
        LOCAL   lresult         AS LONG
        SELECT CASE AS LONG CBMSG
            CASE %WM_INITDIALOG
                hLV = getdlgitem(CBHNDL, %IDC_LV)
                getwindowrect CBHNDL, r
                r.nleft = 185: r.ntop = 10
                invalidaterect CBHNDL, r, %false
    
            CASE %WM_ERASEBKGND
                getDC CBHNDL TO  hDC
                GOSUB PaintW
                releaseDC CBHNDL, hDC
    
            CASE %WM_PAINT
                beginpaint CBHNDL, ps TO hDC
                GOSUB paintW
                endpaint CBHNDL, ps
        END SELECT
    
        EXIT FUNCTION
    paintW:
        getDC hLV TO  hDCLV
        getwindowrect hLV, r
        bitblt hDC, 185, 10, r.nright - r.nleft, r.nbottom - r.ntop,_
               hDCLV, 0, 0, %SRCCOPY TO lresult
        releaseDC hLV, HDCLV
        RETURN
    END FUNCTION
    '------------------------------------------------------
    FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
        LOCAL lRslt AS LONG
        LOCAL hDlg  AS DWORD
    
        DIALOG NEW hParent, "List View                               ListView Image", _
                     97, 168, 243, 166, %WS_SYSMENU, TO hDlg
        CONTROL ADD "SysListView32", hDlg, %IDC_LV, "SysListView32_1", _
                    5, 5, 115, 135, _
                    %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %LVS_REPORT OR %LVS_SHOWSELALWAYS ,_
                    %WS_EX_LEFT OR %WS_EX_CLIENTEDGE OR %WS_EX_RIGHTSCROLLBAR
                    
        SampleListView hDlg, %IDC_LV, 2, 10
    
        DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
    
        FUNCTION = lRslt
    END FUNCTION
    '----------------------------------------------------------------------------
    FUNCTION PBMAIN()
        InitCommoncontrols
    
        ShowDIALOG1 %HWND_DESKTOP
    END FUNCTION
Working...
X