Come usare Buddy Windows
Impostando altri controlli come finestre di contatto per una barra di avanzamento, è possibile posizionare automaticamente tali controlli alle estremità della barra di avanzamento come etichette.
La figura seguente mostra una barra di avanzamento orizzontale e verticale, entrambi con controlli statici come finestre di contatto.
Informazioni importanti
Tecnologie
Prerequisiti
- C/C++
- Programmazione dell'interfaccia utente di Windows
Istruzioni
Usa Buddy Windows
Nell'esempio di codice seguente vengono create le finestre di contatto illustrate nell'illustrazione.
void LabelTrackbarsWithBuddies(HWND hDlg)
{
HWND hwndTrackbar;
HWND hwndBuddy;
const int staticWidth = 50;
const int staticHeight = 20;
//======================================================
// For horizontal Trackbar.
hwndTrackbar = GetDlgItem(hDlg, IDC_SLIDER1);
hwndBuddy = CreateWindowEx(0, L"STATIC", L"Left", SS_RIGHT | WS_CHILD | WS_VISIBLE,
0, 0, staticWidth, staticHeight, hDlg, NULL, g_hInst, NULL);
SendMessage(hwndTrackbar, TBM_SETBUDDY, (WPARAM)TRUE, (LPARAM)hwndBuddy);
//-------------------------------------------------
hwndBuddy = CreateWindowEx(0, L"STATIC", L"Right", SS_LEFT | WS_CHILD | WS_VISIBLE,
0, 0, staticWidth, staticHeight, hDlg, NULL, g_hInst, NULL);
SendMessage(hwndTrackbar, TBM_SETBUDDY, (WPARAM)FALSE, (LPARAM)hwndBuddy);
//======================================================
// For vertical Trackbar.
hwndTrackbar = GetDlgItem(hDlg, IDC_SLIDER2);
hwndBuddy = CreateWindowEx(0, L"STATIC", L"Top", SS_CENTER | WS_CHILD | WS_VISIBLE,
0, 0, staticWidth, staticHeight, hDlg, NULL, g_hInst, NULL);
SendMessage(hwndTrackbar, TBM_SETBUDDY, (WPARAM)TRUE, (LPARAM)hwndBuddy);
//-------------------------------------------------
hwndBuddy = CreateWindowEx(0, L"STATIC", L"Bottom", SS_CENTER | WS_CHILD | WS_VISIBLE,
0, 0, staticWidth, staticHeight, hDlg, NULL, g_hInst, NULL);
SendMessage(hwndTrackbar, TBM_SETBUDDY, (WPARAM)FALSE, (LPARAM)hwndBuddy);
}
Osservazioni:
IDC_SLIDER1 e IDC_SLIDER2 sono barre di rilevamento create nell'editor di risorse.
Argomenti correlati
Commenti e suggerimenti
https://aka.ms/ContentUserFeedback.
Presto disponibile: Nel corso del 2024 verranno gradualmente disattivati i problemi di GitHub come meccanismo di feedback per il contenuto e ciò verrà sostituito con un nuovo sistema di feedback. Per altre informazioni, vedereInvia e visualizza il feedback per