News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

How to get Parent Background and copy it into childs dc?

Started by fearless, September 27, 2014, 07:49:30 AM

Previous topic - Next topic

fearless

Been playing around with paint stuff lately, but came across an issue, and have been trying various things without any success, figured i should post up a question to see if someone knows how to acheive what im looking for.

At start of a custom controls creation, a brief flicker of white appears before painting occurs (ive tried ws_ex_transparent - which works, but then it flickers if the main window is resized)

I thought of trying to grab the current background (the parent of the contol before the control is displayed.), a small slice of it, a little rectangle to copy whats in that background and blt it into my controls dc before any painting occurs. At the moment ive tried handling this in the WM_CREATE and then later, directly in WM_PAINT. Heres a sample of the code im working with, maybe its something simple ive overlooked, but cant seem to get it working - maybe it cant work or wont work, but hopefully someone can post up any advice anyhow. Thanks in advance.

        Invoke GetDC, hRealParent
        mov hdcParent, eax
        Invoke CreateCompatibleDC, hdcParent
        mov hdcMemParent, eax
        Invoke CreateCompatibleBitmap, hdcParent, rect.right, rect.bottom
        mov hbmMemParent, eax
        Invoke SelectObject, hdcParent, hbmMemParent
        mov hOldBitmapParent, eax

        Invoke CreateCompatibleDC, hdc
        mov hdcMem, eax
        Invoke CreateCompatibleBitmap, hdc, rect.right, rect.bottom
        mov hbmMem, eax
        Invoke SelectObject, hdcMem, hbmMem
        mov hOldBitmap, eax
        Invoke GetClientRect, hWin, Addr rect
       
        Invoke BitBlt, hdcMemParent, 0, 0, rect.right, rect.bottom, hdcParent, 0, 0, SRCCOPY ; do i need to copy from hdc to memdc first, then back over to the controls dc?
        Invoke BitBlt, hdcMem, 0, 0, rect.right, rect.bottom, hdcMemParent, 0, 0, SRCCOPY ; am i taking into account proper co-ords for rect? not sure, think so, but nothing changes
        Invoke BitBlt, hdc, 0, 0, rect.right, rect.bottom, hdcMem, 0, 0, SRCCOPY

        Invoke ReleaseDC, hRealParent, hdcParent

dedndave

well, you can use GetWindowLong to find the background color of any window
it may be a brush handle, if that's how you created it
usually, you know the color, because you created it   :biggrin:

you should be able to use SystemParametersInfo to get the user-defined theme colors
should be one in there to get the default message box/dialog box background color

TouEnMasm

Can you post a sample showing the problem ?
Can be just a bad usage of messages .
Fa is a musical note to play with CL

sinsi


TouEnMasm


The site pointed by sinsi give a very good advice,prepare the dc before the paint message.
For a sample of this see:
http://masm32.com/board/index.php?topic=1917.msg19916#msg19916
It's a new thing called DCOBJECT.It's a structure filled with all you need to paint and this before paint.
Fa is a musical note to play with CL