Bonjour,
J'essaye sous Windows 8 de changer la couleur du titre et du fond d'une fenêtre (Zone non client) . J'ai repris du code trouvé sur le net.
Voici les éléments
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
BEGIN_MESSAGE_MAP(CPersoMessageBoxTimer,CDialog)
    ON_WM_CTLCOLOR()
    ON_MESSAGE(WM_NCPAINT,OnNCPaint)
    ON_MESSAGE(WM_NCACTIVATE,OnNCActivate)
END_MESSAGE_MAP()
 
afx_msg LRESULT CPersoMessageBoxTimer::OnNCPaint (WPARAM wParam, LPARAM lParam)
{
    char P_lpTitleText[100];
 
    //DefWindowProc(WM_NCPAINT, wParam, lParam);
 
    this->GetWindowText(P_lpTitleText, 100);
 
    if (wParam)
        DrawCaptionBar(this->m_hWnd,GetWindowLong(this->m_hWnd, GWL_STYLE),    P_lpTitleText,D_ACTIVEBAR);
    else
        DrawCaptionBar(this->m_hWnd,GetWindowLong(this->m_hWnd, GWL_STYLE),P_lpTitleText,D_INACTIVEBAR);
 
 
    return TRUE;
}
 
void CPersoMessageBoxTimer::DrawCaptionBar(HWND P_hWnd, DWORD P_dwStyle, LPSTR P_lpTitleText,WORD P_ActiveBar)
{
    HDC hDC;
    RECT rc2, rc3;
    LOGBRUSH lb;
    HBRUSH hbr, hbrOld;
    LOGPEN lp;
    COLORREF crRGBValue = NULL;
    COLORREF crRGBValue2 = NULL;
 
    HPEN pen,penOld;
 
    hDC = ::GetWindowDC(P_hWnd);
 
    ::GetWindowRect(P_hWnd, &rc2);
 
    //------------------------------- dessin encadrement fenêtre
 
    crRGBValue = (P_ActiveBar == D_ACTIVEBAR) ?
    couleur_fenetre_tour_MD2i : RGB(235, 235, 235);
 
    lb.lbStyle = BS_SOLID;
    lb.lbColor = crRGBValue;
    lb.lbHatch = NULL;
 
    hbr = CreateBrushIndirect(&lb);
 
    lp.lopnColor = crRGBValue;
    lp.lopnStyle = PS_SOLID;
    lp.lopnWidth.x = 1;
 
    pen = CreatePenIndirect(&lp);
 
    hbrOld = (HBRUSH) ::SelectObject(hDC, hbr);
    penOld = (HPEN) ::SelectObject(hDC,pen);
 
    Rectangle(hDC, 0, 0, rc2.right - rc2.left, 31);
    Rectangle(hDC, 0, 31, 8, rc2.bottom - rc2.top);
    Rectangle(hDC, rc2.right - rc2.left-8, 31, rc2.right - rc2.left, rc2.bottom - rc2.top);
    Rectangle(hDC, 8, rc2.bottom - rc2.top-8, rc2.right-8, rc2.bottom - rc2.top);
 
    hbr =  (HBRUSH) ::SelectObject(hDC, hbrOld);
    pen =  (HPEN) ::SelectObject(hDC,penOld);
 
    DeleteObject(hbr);
    DeleteObject(pen);
 
    crRGBValue2 = (P_ActiveBar == D_ACTIVEBAR) ?
    couleur_fenetre_cadre_MD2i : RGB(235, 235, 235);
 
    lp.lopnColor = crRGBValue2;
    lp.lopnStyle = PS_SOLID;
    lp.lopnWidth.x = 1;
 
    pen = CreatePenIndirect(&lp);
    penOld = (HPEN) ::SelectObject(hDC,pen);
 
    MoveToEx(hDC,8, 31,(LPPOINT) NULL);
    LineTo(hDC,rc2.right - rc2.left-8, 31);
    LineTo(hDC,rc2.right - rc2.left-8, rc2.bottom - rc2.top - 8);
    LineTo(hDC,8, rc2.bottom - rc2.top - 8);
    LineTo(hDC,8,31);
 
    pen =  (HPEN) ::SelectObject(hDC,penOld);
 
    DeleteObject(pen);
 
 
    SetBkColor(hDC, crRGBValue);
 
    rc3.left=0;
    rc3.top=0;
    rc3.right=rc2.right - rc2.left;
    rc3.bottom=rc2.bottom - rc2.top;
 
    DrawText(hDC, P_lpTitleText, -1, (LPRECT)&rc3, DT_CENTER);
 
    ::ReleaseDC(P_hWnd, hDC);
 
    return;
}
Mon souci est que la fenêtre retrouve un look vista avec les bords hauts arrondis.
Merci