[Win32] Image en background efface les contrôles

Signaler
Messages postés
199
Date d'inscription
vendredi 16 avril 2004
Statut
Membre
Dernière intervention
28 février 2008
-
Messages postés
1905
Date d'inscription
mercredi 22 janvier 2003
Statut
Membre
Dernière intervention
17 septembre 2012
-
Bonjour, dans mon programme je voudrai placer un fond d'écran (à partir d'un BMP), plus précisement ceci dans ma HWND principale, en traitant le message WM_PAINT, voici le code :

case WM_PAINT:
        hDC = BeginPaint(hWnd, &Ps);
        hMemDC = CreateCompatibleDC(hDC);

        hBitmap = LoadBitmap(g_hInstance, MAKEINTRESOURCE(1337));
        if(hBitmap != NULL) MessageBox(hWnd, "Bitmap Chargé Valide !", "_DEBUG", MB_OK);

        SelectObject(hMemDC, hBitmap);
        BitBlt(hDC, 0, 0, 350, 350, hMemDC, 0, 0, SRCCOPY);

        DeleteDC(hMemDC);
        CloseHandle(hBitmap);
        EndPaint(hWnd, &Ps);
        break;

Le background est correctement copié sur ma fenêtre, tellement bien copié qu'on y voit même plusmes contrôles ! Je peux revoir un bouton si je clique dessus par exemple, sinon rien du tout, la totalité des contrôles n'est plus visible. J'aimerais un peu d'aide...

Merci beaucoup.

___________________
MVS - Most Valuable Student ( Microsoft)

2 réponses

Messages postés
571
Date d'inscription
samedi 3 avril 2004
Statut
Membre
Dernière intervention
5 décembre 2013

Il vaut mieux utliser le message WM_ERASEBKGND pour changer le fond
sinon quand j'ai eu ce probleme j'ai utlisé ce code juste apres


        //Rafraichissement des controls pour éviter qu'ils passent sous l'image

        HWND titest2;

        titest2 = ::FindWindowEx(hwnd,NULL,NULL,NULL);

        RECT retest;

        GetWindowRect(hwnd,&retest);

        while (::FindWindowEx(hwnd,titest2,NULL,NULL) != NULL) {

            titest2 = FindWindowEx(hwnd,titest2,NULL,NULL);

            ::GetWindowRect(titest2,&retest);

            ::InvalidateRect(titest2,NULL,false);

        }
Messages postés
1905
Date d'inscription
mercredi 22 janvier 2003
Statut
Membre
Dernière intervention
17 septembre 2012
3
Salut,

Rajoute le style WS_CLIPCHILDREN à ta fenêtre.<link href="../../../../css/ie4.css" type="text/css" rel="stylesheet" /><!-- @ --><link href="../../../../css/inetsdk.css" type="text/css" rel="stylesheet" /><!-- @ --><style type="text/css"><![CDATA[
PRE.clsCode { font-size:110%; }
PRE.clsSyntax { font-size:100%; }
TD DIV.clsBeta { display:none;}

A:link { color:#0000ff; text-decoration:underline;}
A:visited { color:#0000ff; text-decoration:underline;}
A:hover { color:#3366ff; text-decoration:underline;}
MSHelp\:link {
color:#0000ff;
text-decoration:underline;
cursor:hand;
hoverColor:#3366ff;
filterString: ;}
]]></style><link href="ms-help://Hx/HxRuntime/HxLink.css" type="text/css" rel="stylesheet" />

<xml id="_topicdata" pagetype="constants" proj="WinUIHXS" name="Window Styles" pubpath="/WinUI/WindowsUserInterface/Windowing/Windows/WindowReference/WindowStyles.htm"><!-- topic data --><root></root></xml>

<xml xmlns:mshelp="http://msdn.microsoft.com/mshelp"><mshelp:keyword index="A" term="_win32_Window_Styles"></mshelp:keyword><mshelp:keyword index="A" term="_win32_Window_Styles_cpp"></mshelp:keyword><mshelp:toctitle title="Window Styles "></mshelp:toctitle><mshelp:rltitle title="Window Styles "></mshelp:rltitle><mshelp:keyword index="F" term="Window Styles"></mshelp:keyword><mshelp:keyword index="K" term="Window Styles"></mshelp:keyword><mshelp:attr name="TopicType" value="kbRef"></mshelp:attr><mshelp:attr name="Locale" value="kbEnglish"></mshelp:attr><mshelp:attr name="DevLang" value="C++"></mshelp:attr><mshelp:attr name="Technology" value="WinUI"></mshelp:attr><mshelp:attr name="TechnologyVers" value="kbWinUI"></mshelp:attr><mshelp:attr name="DocSet" value="WCSDK"></mshelp:attr><mshelp:attr name="DocSet" value="LHSDK"></mshelp:attr><mshelp:attr name="DocSet" value="PSDK"></mshelp:attr><mshelp:attr name="TargetOS" value="Windows"></mshelp:attr><mshelp:attr name="TopicType" value="apiref"></mshelp:attr><mshelp:attr name="APIName" value="Window Styles"></mshelp:attr><mshelp:attr name="APIType" value="COM"></mshelp:attr><mshelp:attr name="TopicType" value="kbSyntax"></mshelp:attr><mshelp:vtopic name="WS_BORDER"></mshelp:vtopic><mshelp:keyword index="A" term="WS_BORDER" vtopic="WS_BORDER"></mshelp:keyword><mshelp:keyword index="K" term="WS_BORDER" vtopic="WS_BORDER"></mshelp:keyword><mshelp:vtopic name="WS_CAPTION"></mshelp:vtopic><mshelp:keyword index="A" term="WS_CAPTION" vtopic="WS_CAPTION"></mshelp:keyword><mshelp:keyword index="K" term="WS_CAPTION" vtopic="WS_CAPTION"></mshelp:keyword><mshelp:vtopic name="WS_CHILD"></mshelp:vtopic><mshelp:keyword index="A" term="WS_CHILD" vtopic="WS_CHILD"></mshelp:keyword><mshelp:keyword index="K" term="WS_CHILD" vtopic="WS_CHILD"></mshelp:keyword><mshelp:vtopic name="WS_CHILDWINDOW"></mshelp:vtopic><mshelp:keyword index="A" term="WS_CHILDWINDOW" vtopic="WS_CHILDWINDOW"></mshelp:keyword><mshelp:keyword index="K" term="WS_CHILDWINDOW" vtopic="WS_CHILDWINDOW"></mshelp:keyword><mshelp:vtopic name="WS_CLIPCHILDREN"></mshelp:vtopic><mshelp:keyword index="A" term="WS_CLIPCHILDREN" vtopic="WS_CLIPCHILDREN"></mshelp:keyword><mshelp:keyword index="K" term="WS_CLIPCHILDREN" vtopic="WS_CLIPCHILDREN"></mshelp:keyword><mshelp:vtopic name="WS_CLIPSIBLINGS"></mshelp:vtopic><mshelp:keyword index="A" term="WS_CLIPSIBLINGS" vtopic="WS_CLIPSIBLINGS"></mshelp:keyword><mshelp:keyword index="K" term="WS_CLIPSIBLINGS" vtopic="WS_CLIPSIBLINGS"></mshelp:keyword><mshelp:vtopic name="WS_DISABLED"></mshelp:vtopic><mshelp:keyword index="A" term="WS_DISABLED" vtopic="WS_DISABLED"></mshelp:keyword><mshelp:keyword index="K" term="WS_DISABLED" vtopic="WS_DISABLED"></mshelp:keyword><mshelp:vtopic name="WS_DLGFRAME"></mshelp:vtopic><mshelp:keyword index="A" term="WS_DLGFRAME" vtopic="WS_DLGFRAME"></mshelp:keyword><mshelp:keyword index="K" term="WS_DLGFRAME" vtopic="WS_DLGFRAME"></mshelp:keyword><mshelp:vtopic name="WS_GROUP"></mshelp:vtopic><mshelp:keyword index="A" term="WS_GROUP" vtopic="WS_GROUP"></mshelp:keyword><mshelp:keyword index="K" term="WS_GROUP" vtopic="WS_GROUP"></mshelp:keyword><mshelp:vtopic name="WS_HSCROLL"></mshelp:vtopic><mshelp:keyword index="A" term="WS_HSCROLL" vtopic="WS_HSCROLL"></mshelp:keyword><mshelp:keyword index="K" term="WS_HSCROLL" vtopic="WS_HSCROLL"></mshelp:keyword><mshelp:vtopic name="WS_ICONIC"></mshelp:vtopic><mshelp:keyword index="A" term="WS_ICONIC" vtopic="WS_ICONIC"></mshelp:keyword><mshelp:keyword index="K" term="WS_ICONIC" vtopic="WS_ICONIC"></mshelp:keyword><mshelp:vtopic name="WS_MAXIMIZE"></mshelp:vtopic><mshelp:keyword index="A" term="WS_MAXIMIZE" vtopic="WS_MAXIMIZE"></mshelp:keyword><mshelp:keyword index="K" term="WS_MAXIMIZE" vtopic="WS_MAXIMIZE"></mshelp:keyword><mshelp:vtopic name="WS_MAXIMIZEBOX"></mshelp:vtopic><mshelp:keyword index="A" term="WS_MAXIMIZEBOX" vtopic="WS_MAXIMIZEBOX"></mshelp:keyword><mshelp:keyword index="K" term="WS_MAXIMIZEBOX" vtopic="WS_MAXIMIZEBOX"></mshelp:keyword><mshelp:vtopic name="WS_MINIMIZE"></mshelp:vtopic><mshelp:keyword index="A" term="WS_MINIMIZE" vtopic="WS_MINIMIZE"></mshelp:keyword><mshelp:keyword index="K" term="WS_MINIMIZE" vtopic="WS_MINIMIZE"></mshelp:keyword><mshelp:vtopic name="WS_MINIMIZEBOX"></mshelp:vtopic><mshelp:keyword index="A" term="WS_MINIMIZEBOX" vtopic="WS_MINIMIZEBOX"></mshelp:keyword><mshelp:keyword index="K" term="WS_MINIMIZEBOX" vtopic="WS_MINIMIZEBOX"></mshelp:keyword><mshelp:vtopic name="WS_OVERLAPPED"></mshelp:vtopic><mshelp:keyword index="A" term="WS_OVERLAPPED" vtopic="WS_OVERLAPPED"></mshelp:keyword><mshelp:keyword index="K" term="WS_OVERLAPPED" vtopic="WS_OVERLAPPED"></mshelp:keyword><mshelp:vtopic name="WS_OVERLAPPEDWINDOW"></mshelp:vtopic><mshelp:keyword index="A" term="WS_OVERLAPPEDWINDOW" vtopic="WS_OVERLAPPEDWINDOW"></mshelp:keyword><mshelp:keyword index="K" term="WS_OVERLAPPEDWINDOW" vtopic="WS_OVERLAPPEDWINDOW"></mshelp:keyword><mshelp:vtopic name="WS_POPUP"></mshelp:vtopic><mshelp:keyword index="A" term="WS_POPUP" vtopic="WS_POPUP"></mshelp:keyword><mshelp:keyword index="K" term="WS_POPUP" vtopic="WS_POPUP"></mshelp:keyword><mshelp:vtopic name="WS_POPUPWINDOW"></mshelp:vtopic><mshelp:keyword index="A" term="WS_POPUPWINDOW" vtopic="WS_POPUPWINDOW"></mshelp:keyword><mshelp:keyword index="K" term="WS_POPUPWINDOW" vtopic="WS_POPUPWINDOW"></mshelp:keyword><mshelp:vtopic name="WS_SIZEBOX"></mshelp:vtopic><mshelp:keyword index="A" term="WS_SIZEBOX" vtopic="WS_SIZEBOX"></mshelp:keyword><mshelp:keyword index="K" term="WS_SIZEBOX" vtopic="WS_SIZEBOX"></mshelp:keyword><mshelp:vtopic name="WS_SYSMENU"></mshelp:vtopic><mshelp:keyword index="A" term="WS_SYSMENU" vtopic="WS_SYSMENU"></mshelp:keyword><mshelp:keyword index="K" term="WS_SYSMENU" vtopic="WS_SYSMENU"></mshelp:keyword><mshelp:vtopic name="WS_TABSTOP"></mshelp:vtopic><mshelp:keyword index="A" term="WS_TABSTOP" vtopic="WS_TABSTOP"></mshelp:keyword><mshelp:keyword index="K" term="WS_TABSTOP" vtopic="WS_TABSTOP"></mshelp:keyword><mshelp:vtopic name="WS_THICKFRAME"></mshelp:vtopic><mshelp:keyword index="A" term="WS_THICKFRAME" vtopic="WS_THICKFRAME"></mshelp:keyword><mshelp:keyword index="K" term="WS_THICKFRAME" vtopic="WS_THICKFRAME"></mshelp:keyword><mshelp:vtopic name="WS_TILED"></mshelp:vtopic><mshelp:keyword index="A" term="WS_TILED" vtopic="WS_TILED"></mshelp:keyword><mshelp:keyword index="K" term="WS_TILED" vtopic="WS_TILED"></mshelp:keyword><mshelp:vtopic name="WS_TILEDWINDOW"></mshelp:vtopic><mshelp:keyword index="A" term="WS_TILEDWINDOW" vtopic="WS_TILEDWINDOW"></mshelp:keyword><mshelp:keyword index="K" term="WS_TILEDWINDOW" vtopic="WS_TILEDWINDOW"></mshelp:keyword><mshelp:vtopic name="WS_VISIBLE"></mshelp:vtopic><mshelp:keyword index="A" term="WS_VISIBLE" vtopic="WS_VISIBLE"></mshelp:keyword><mshelp:keyword index="K" term="WS_VISIBLE" vtopic="WS_VISIBLE"></mshelp:keyword><mshelp:vtopic name="WS_VSCROLL"></mshelp:vtopic><mshelp:keyword index="A" term="WS_VSCROLL" vtopic="WS_VSCROLL"></mshelp:keyword><mshelp:keyword index="K" term="WS_VSCROLL" vtopic="WS_VSCROLL"></mshelp:keyword></xml>
<dt>