Bonjour,

J'ai créé un contrôle Rebar contenant une Toolbar, mais tout reste fixe, on ne peut rien déplacer avec la souris alors que ce composant est sensé s'utiliser pour générer des barres flottantes. Normalement il n'y a rien à gérer au niveau des messages souris pour déplacer la barre, vrai ou faux? Je pense que le déplacement devrait est géré comme pour une fenetre avec entête, mais il y a sans doute une option que j'ai zappée. Je n'ai pas trouvé sur MSDN.
Voici le code, bien sur c'est juste une démo. Merci pour votre aide

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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#define _WIN32_WINNT 0x500
#define _WIN32_IE 0x0500

#include <windows.h>
#include <commctrl.h>
#define IDM_NEW 1
#define IDM_OPEN 2

HWND hStdBar, hRebar;
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
HWND GenStdBar(HWND hParent);
HWND GenRebar (HWND hParent, HWND hChild);

char szClassName[ ] = "Test";

int WINAPI WinMain (HINSTANCE hThisInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR lpszArgument,
                     int nCmdShow)
{
    HWND hwnd;
    MSG messages;
    WNDCLASSEX wincl;

    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;
    wincl.style = CS_DBLCLKS;
    wincl.cbSize = sizeof (WNDCLASSEX);
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;
    wincl.cbClsExtra = 0;
    wincl.cbWndExtra = 0;
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    if (!RegisterClassEx (&wincl)) return 0;

    hwnd = CreateWindowEx (
           0,
           szClassName,
           "Test Rebar",
           WS_OVERLAPPEDWINDOW,
           CW_USEDEFAULT, CW_USEDEFAULT,1000,500,
           HWND_DESKTOP,
           NULL,
           hThisInstance,
           NULL
           );

    INITCOMMONCONTROLSEX initCtrl;           
    initCtrl.dwSize=sizeof(INITCOMMONCONTROLSEX);
    initCtrl.dwICC=ICC_BAR_CLASSES | ICC_COOL_CLASSES;
    InitCommonControlsEx(&initCtrl);

    hStdBar=GenStdBar(hwnd);
    hRebar=GenRebar(hwnd,hStdBar);
    ShowWindow (hwnd, SW_SHOWDEFAULT);

    while (GetMessage (&messages, NULL, 0, 0))
    {
        TranslateMessage(&messages);
        DispatchMessage(&messages);
    }
    return messages.wParam;
}

HWND GenRebar (HWND hParent, HWND hChild)   // crée controle REBAR
{
    HWND hRebar;
    HINSTANCE hAppInstance=(HINSTANCE) GetWindowLongPtr(hParent, GWLP_HINSTANCE);
    REBARBANDINFO rbBand;

    hRebar= CreateWindowEx (
        WS_EX_PALETTEWINDOW,
        REBARCLASSNAME,
        NULL,
        WS_CHILD | WS_VISIBLE | CCS_NOPARENTALIGN |
        WS_CLIPCHILDREN | RBS_VARHEIGHT | WS_DLGFRAME,
        0, 0, 200, 40,
        hParent,
        NULL,
        hAppInstance,
        NULL);

    rbBand.cbSize=sizeof(REBARBANDINFO);
    rbBand.fMask  = RBBIM_STYLE | RBBIM_TEXT| RBBIM_CHILD | RBBIM_CHILDSIZE;
    rbBand.fStyle = RBBS_CHILDEDGE | RBBS_GRIPPERALWAYS;
    rbBand.lpText = TEXT("  ");
    rbBand.hwndChild = hChild;
    rbBand.cxMinChild = 300;
    rbBand.cyMinChild = 30;
    rbBand.wID=0;

    SendMessage(hRebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand);

    return hRebar;
}


LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
        case WM_DESTROY:
            PostQuitMessage (0);
            break;
        default:
            return DefWindowProc (hwnd, message, wParam, lParam);
    }
    return 0;
}
HWND GenStdBar(HWND hParent)   // BARRE D'OUTIL POUR TEST (2 boutons)
{
    HWND hStd;
	HINSTANCE hAppInstance=(HINSTANCE) GetWindowLongPtr(hParent, GWLP_HINSTANCE);
	TBADDBITMAP tbab;
	TBBUTTON BtnStd[3];

	tbab.hInst =  HINST_COMMCTRL ;
    tbab.nID   =  IDB_STD_LARGE_COLOR;

	BtnStd[0].iBitmap = STD_FILENEW;
             BtnStd[0].idCommand = IDM_NEW;
             BtnStd[0].fsState = TBSTATE_ENABLED;
             BtnStd[0].fsStyle = TBSTYLE_BUTTON;
             BtnStd[0].dwData = 0;
             BtnStd[0].iString = SendMessage(hStd, TB_ADDSTRING, 0,(LPARAM)"Nouveau");

             BtnStd[1].iBitmap = STD_FILEOPEN;
             BtnStd[1].idCommand = IDM_OPEN;
             BtnStd[1].fsState = TBSTATE_ENABLED;
             BtnStd[1].fsStyle = TBSTYLE_BUTTON;
             BtnStd[1].dwData = 0;
             BtnStd[1].iString = SendMessage(hStd, TB_ADDSTRING, 0,(LPARAM)"Ouvrir");

             BtnStd[2].iBitmap = 0;
             BtnStd[2].idCommand = -1;
             BtnStd[2].fsState = 0;
             BtnStd[2].fsStyle = TBSTYLE_SEP;
             BtnStd[2].dwData = 0;
             BtnStd[2].iString = -1;

	hStd= CreateWindowEx(
			WS_EX_TOOLWINDOW,
			TOOLBARCLASSNAME,
			NULL,
            WS_CHILD | WS_VISIBLE | CCS_NORESIZE | CCS_NOPARENTALIGN | CCS_NODIVIDER | TBSTYLE_FLAT,
            20, 0, 150, 35,
			hParent,
			NULL,
			hAppInstance,
			NULL);

    SendMessage(hStd, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
    SendMessage(hStd, TB_ADDBITMAP, 0, (LPARAM)&tbab);
    SendMessage(hStd, TB_ADDBUTTONS, 3, (LPARAM)&BtnStd);
    SendMessage(hStd, TB_AUTOSIZE, 0, 0);

    return hStd;
}