PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: John Messingham on April 02, 2005, 01:54:24 PM

Title: WinLift and FireFly
Post by: John Messingham on April 02, 2005, 01:54:24 PM
I am working on a program using WinLift. When I add either a EGrid or siGrid to the main form and run the program, I have to click on the grid in order to get it to display.

Anybody got any clues?
Title: WinLift and FireFly
Post by: John Messingham on April 02, 2005, 01:56:21 PM
Ok, I had a brain wave. It seems to be linked to the %SKEFF_FASTDISPLAY option. The other options seem to work ok.
Title: WinLift and FireFly
Post by: Patrice Terrier on April 03, 2005, 10:40:26 AM
John,

Most PB's programmers including third party programmers fail to handle
the %WM_PRINT and %WM_PRINTCLIENT correctly, that's the problem.

Here is what MSDN says about it:
Quote
The WM_PRINT message is sent to a window to request that it draw itself in the specified device context, most commonly in a printer device context.

A window receives this message through its WindowProc function.

LRESULT CALLBACK WindowProc(
 HWND hwnd,       // handle to window
 UINT uMsg,       // WM_PRINT
 WPARAM wParam,   // handle to DC (HDC)
 LPARAM lParam    // drawing options
);


When you use the %SKEFF_FASTDISPLAY, WinLIFT creates a private memory DC (like with the new PB 8.01 GRAPHIC WINDOW) to boost graphic display, then when it needs to repaint the form it sends first
a %WM_PRINT message to all chidl controls asking them to paint themselves in the provided memory handle DC.

If the child control ignores the message then the result is what you got.
Title: WinLift and FireFly
Post by: Elias Montoya on April 12, 2005, 03:15:09 AM
Patrice, explain more, i will try to stick to this procedure... :)
Title: WinLift and FireFly
Post by: Patrice Terrier on April 12, 2005, 03:36:34 AM
Elias,

It is very simple, when you get either %WM_PRINT or %WM_PRINCLIENT
you must use the wParam as the DC you are requested to paint in.

Here is an example (look at the use of the wParam):

   CASE %WM_PAINT, %WM_PRINTCLIENT
        hOwner& = skPopupOwner(hWnd&): OwnerItem& = skItem(hOwner&)

        IF Win(OwnerItem&).MemBMP AND Win(OwnerItem&).Captured = 1 THEN
           CALL BeginPaint(hWnd&, ps)
           CALL EndPaint(hWnd&, ps)
           FUNCTION = 0: EXIT FUNCTION
        END IF

        CALL GetClientRect(hWnd&, rc)
        Xin& = rc.nRight - rc.nLeft: Yin& = rc.nBottom - rc.nTop

        SELECT CASE LONG CtrlType&

        CASE %CTRL_TOOLBAR

             IF Child(Item&).paintflag THEN ' To paint TOOLBAR with standard Get???FileName API

                CALL skChildoffset(hWnd&, ofX&, ofY&)
                IF wParam& = 0 THEN
                   CALL BeginPaint(hWnd&, ps): hDC& = ps.hDC
                ELSE
                   hDC& = wParam&
                END IF

              ' Create OFF screen bitmap to avoid flickering AND allow smooth display
              ' ---------------------------------------------------------------------
                hDCTemp& = skOFFscreen(hDC&, Xin&, Yin&, 1)
                hDCmem& = CreateCompatibleDC(hDCTemp&)
                hTmpBmp& = CreateCompatibleBitmap(hDCTemp&, Xin&, Yin&)
                CALL SelectObject(hDCmem&, hTmpBmp&)
                CALL skFillRect(hDCmem&, 0, 0, Xin&, Yin&, GetSysColor(%COLOR_3DFACE))
                Ret& = CallWindowProc(ChildMessage, Msg&, hDCmem&, lParam&)
                CALL skTileBlt(hDCTemp&, -ofX&, -ofY& - DeltaY&, ofx& + Xin&, ofY& + Yin&, skCtlBack)
                CALL skTransBltUseDC
                CALL skTransBlt(hDCTemp&, 0, 0, Xin&, Yin&, hDCmem&, 0, 0, GetSysColor(%COLOR_3DFACE))
                CALL DeleteDC(hDCmem&)
                CALL DeleteObject(hTmpBmp&)
              ' End of OFF screen drawing, fast BitBlt to the target display Window
              ' -------------------------------------------------------------------
                CALL skOFFscreen(0, 0, 0, 0)

                IF wParam& = 0 THEN CALL EndPaint(hWnd&, ps)

                IF Win(OwnerItem&).Effect = %SKEFF_SCREENSHOT THEN CALL skUpdateMemDC(hOwner&, hWnd&)

                FUNCTION = Ret&: EXIT FUNCTION
             END IF

             CALL skChildoffset(hWnd&, ofX&, ofY&)
             IF wParam& = 0 THEN
                CALL BeginPaint(hWnd&, ps): hDC& = ps.hDC
                DeltaY& = 2: Yin& = Yin& + DeltaY& + 1
             ELSE
                hDC& = wParam&
                DeltaY& = 2: Yin& = Yin& + DeltaY& + 1
             END IF

           ' Create OFF screen bitmap to avoid flickering AND allow smooth display
           ' ---------------------------------------------------------------------
             hDCTemp& = skOFFscreen(hDC&, Xin&, Yin&, 1)
             hDCmem& = CreateCompatibleDC(hDCTemp&)

             hTmpBmp& = CreateCompatibleBitmap(hDCTemp&, Xin&, Yin&)
             CALL SelectObject(hDCmem&, hTmpBmp&)
             CALL skFillRect(hDCmem&, 0, 0, Xin&, Yin&, GetSysColor(%COLOR_3DFACE))

             Ret& = CallWindowProc(ChildMessage, Msg&, hDCmem&, lParam&)

             CALL skTileBlt(hDCTemp&, -ofX&, -ofY& - DeltaY&, ofx& + Xin&, ofY& + Yin&, skCtlBack)

             CALL skTransBltUseDC
             CALL skTransBlt(hDCTemp&, 0, 0, Xin&, Yin&, hDCmem&, 0, 0, GetSysColor(%COLOR_3DFACE))

             CALL DeleteDC(hDCmem&)
             CALL DeleteObject(hTmpBmp&)
           ' End of OFF screen drawing, fast BitBlt to the target display Window
           ' -------------------------------------------------------------------
             CALL skOFFscreen(0, ofX&, ofY&, 0)

             IF wParam& = 0 THEN CALL EndPaint(hWnd&, ps)


Title: WinLift and FireFly
Post by: Elias Montoya on April 12, 2005, 06:05:16 PM
Very simple indeed. :)
i took note!

Elias :)