Red de conocimiento informático - Aprendizaje de programación - Cómo hacer que el fondo del control deslizante sea transparente en MFC

Cómo hacer que el fondo del control deslizante sea transparente en MFC

CDC?*pDC=CDC::FromHandle(::GetDC(/* Aquí está el identificador del control */));

pDC-gt; ; //transparent ?

:GetStockObject(NULL_BRUSH);?

Tengo una función aquí, espero que te sea útil

/** ** ************************************************* *** ***********

Nombre de la función: yan_se_tou_ming

Función de función: hacer transparente el área de color especificada

Parámetros de la función :

HWND?hwnd, identificador de ventana

int?tou_ming_de_yan_se, el color que será transparente

int?tou_ming_du=0?Transparency, el valor predeterminado es 0, totalmente transparente

Valor de retorno: ¿Devuelve VERDADERO correctamente? Devuelve FALSO en caso de error

/************************************** **** ***********/

/*****VC6.0 necesita agregar el siguiente código al frente********* *******

#define?WS_EX_LAYERED?0x00080000

#define?LWA_COLORKEY?0x00000001

#define?LWA_ALPHA?0x00000002

typedef?BOOL?(FAR ? WINAPI?*LAYERFUNC)(HWND, COLORREF, BYTE, DWORD);

BOOL?SetLayeredWindowAttributes(HWND?hwnd, COLORREF?crKey, BYTE?bAlpha, DWORD? dwFlags)

{

LAYERFUNC?SetLayer;

HMODULE?hmod?=?LoadLibrary("user32.dll");

SetLayer=(LAYERFUNC) GetProcAddress(hmod, "SetLayeredWindowAttributes");

BOOL?bReturn?=?SetLayer(hwnd, crKey, bAlpha, dwFlags);

FreeLibrary( hmod);

regresar? bReturn;

}

//************************ ************ ****************************/

// ¿Se puede agregar en OnPaint? Agregar este código en OnInitDialog no es válido

BOOL?yan_se_tou_ming(HWND?hwnd, int?tou_ming_de_yan_se, int?tou_ming_du=0)

{

int?FengGe= GetWindowLong(hwnd, GWL_EXSTYLE );

if(FengGe==0)

{

return?FALSE;

}

DWORD?(SetLayeredWindowAttributes(hwnd, tou_ming_de_yan_se, tou_ming_du, flag)==0)

{

¿regresar?