P
Purple_Apple
Guest
Good day to all. When I resize the window, the progress bar "creeps" away from its place. Why? Example is below.

This is when I do the triangulation right after the application loads. That is, this is the default window size. And below, the view after the window has, for example, been opened to full screen.

As you can see, the progress bar "has crawled" to the left. Below is the source code for creating a progress bar.
HWND TrackTriProgress(HWND hwndParent)
{
RECT rcClient; // Client area of parent window.
RECT r1; // Status bar rectangular.
int cyVScroll; // Height of scroll bar arrow.
HWND hwndPB; // Handle of progress bar.
// Ensure that the common control DLL is loaded, and create a progress bar
// along the bottom of the client area of the parent window.
//
// Base the height of the progress bar on the height of a scroll bar arrow.
InitCommonControls();
GetClientRect(hwndParent, &rcClient);
SendMessage(g_hWndStatusbar, SB_GETRECT, 1, (LPARAM)&r1);
cyVScroll = GetSystemMetrics(SM_CYVSCROLL);
// Create progressbar.
hwndPB = CreateWindowEx(
0,
PROGRESS_CLASS,
(LPTSTR)NULL,
WS_CHILD | WS_VISIBLE | PBS_SMOOTH,
r1.left + 3, // Locate progress bar in the right section of status bar.
r1.top + 3,
r1.right - r1.left, cyVScroll,
g_hWndStatusbar, // Status bar is a parent window of progress bar/
(HMENU)0,
hInst,
NULL
);
// Return progress bar created.
return hwndPB;
}
Below the source code for controlling of progress bar location in application window and in particular in the status bar.
HWND g_hWndToolbar; // toolbar.
HWND g_hWndStatusbar; // statusbar.
HWND g_hWndProgressbar; // progressbar.
. . . . . . . . . . . . . . . . . . . . . .
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
. . . . . . . . . . . . . . . . . . .
case WM_CREATE:
{
// Create toolbar.
g_hWndToolbar = CreateSimpleToolbar(hWnd);
// Create statusbar.
g_hWndStatusbar = DoCreateStatusBar(hWnd, (int)ID_STATUS, GetModuleHandle(NULL), STATUS_BAR_PARTS);
// Create progressbar.
g_hWndProgressbar = TrackTriProgress(hWnd);
. . . . . . . . . . . . . . . . . . . . . . . .
}
break;
case WM_SIZE:
// Change size of toolbar.
SendMessage(g_hWndToolbar, TB_AUTOSIZE, 0, 0);
// Change size of statusbar.
int nWidth;
int nWidths[STATUS_BAR_PARTS];
nWidth = LOWORD(lParam);
nWidths[0] = 1 * nWidth / STATUS_BAR_PARTS;
nWidths[1] = 2 * nWidth / STATUS_BAR_PARTS;
SendMessage(g_hWndStatusbar, SB_SETPARTS, STATUS_BAR_PARTS, (LPARAM)nWidths);
SendMessage(g_hWndStatusbar, WM_SIZE, 0, 0);
// Change size of progressbar.
SendMessage(g_hWndProgressbar, WM_SIZE, 0, 0);
. . . . . . . . . . . . . . . . . . . . . . . . . .
break;
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
}
}
What needs to be done so that when the size of the application window is changed, the progress bar remains in its place where it should be located? I will be very grateful for your help.
Continue reading...

This is when I do the triangulation right after the application loads. That is, this is the default window size. And below, the view after the window has, for example, been opened to full screen.

As you can see, the progress bar "has crawled" to the left. Below is the source code for creating a progress bar.
HWND TrackTriProgress(HWND hwndParent)
{
RECT rcClient; // Client area of parent window.
RECT r1; // Status bar rectangular.
int cyVScroll; // Height of scroll bar arrow.
HWND hwndPB; // Handle of progress bar.
// Ensure that the common control DLL is loaded, and create a progress bar
// along the bottom of the client area of the parent window.
//
// Base the height of the progress bar on the height of a scroll bar arrow.
InitCommonControls();
GetClientRect(hwndParent, &rcClient);
SendMessage(g_hWndStatusbar, SB_GETRECT, 1, (LPARAM)&r1);
cyVScroll = GetSystemMetrics(SM_CYVSCROLL);
// Create progressbar.
hwndPB = CreateWindowEx(
0,
PROGRESS_CLASS,
(LPTSTR)NULL,
WS_CHILD | WS_VISIBLE | PBS_SMOOTH,
r1.left + 3, // Locate progress bar in the right section of status bar.
r1.top + 3,
r1.right - r1.left, cyVScroll,
g_hWndStatusbar, // Status bar is a parent window of progress bar/
(HMENU)0,
hInst,
NULL
);
// Return progress bar created.
return hwndPB;
}
Below the source code for controlling of progress bar location in application window and in particular in the status bar.
HWND g_hWndToolbar; // toolbar.
HWND g_hWndStatusbar; // statusbar.
HWND g_hWndProgressbar; // progressbar.
. . . . . . . . . . . . . . . . . . . . . .
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
. . . . . . . . . . . . . . . . . . .
case WM_CREATE:
{
// Create toolbar.
g_hWndToolbar = CreateSimpleToolbar(hWnd);
// Create statusbar.
g_hWndStatusbar = DoCreateStatusBar(hWnd, (int)ID_STATUS, GetModuleHandle(NULL), STATUS_BAR_PARTS);
// Create progressbar.
g_hWndProgressbar = TrackTriProgress(hWnd);
. . . . . . . . . . . . . . . . . . . . . . . .
}
break;
case WM_SIZE:
// Change size of toolbar.
SendMessage(g_hWndToolbar, TB_AUTOSIZE, 0, 0);
// Change size of statusbar.
int nWidth;
int nWidths[STATUS_BAR_PARTS];
nWidth = LOWORD(lParam);
nWidths[0] = 1 * nWidth / STATUS_BAR_PARTS;
nWidths[1] = 2 * nWidth / STATUS_BAR_PARTS;
SendMessage(g_hWndStatusbar, SB_SETPARTS, STATUS_BAR_PARTS, (LPARAM)nWidths);
SendMessage(g_hWndStatusbar, WM_SIZE, 0, 0);
// Change size of progressbar.
SendMessage(g_hWndProgressbar, WM_SIZE, 0, 0);
. . . . . . . . . . . . . . . . . . . . . . . . . .
break;
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
}
}
What needs to be done so that when the size of the application window is changed, the progress bar remains in its place where it should be located? I will be very grateful for your help.
Continue reading...