Not
Bu sayfaya erişim yetkilendirme gerektiriyor. Oturum açmayı veya dizinleri değiştirmeyi deneyebilirsiniz.
Bu sayfaya erişim yetkilendirme gerektiriyor. Dizinleri değiştirmeyi deneyebilirsiniz.
Çakışan, açılan veya alt pencere oluştururken CreateWindowEx işlevini kullanarak ve WS_HSCROLL, WS_VSCROLL veya her iki stili belirterek standart kaydırma çubukları ekleyebilirsiniz.
Bilmeniz gerekenler
Teknolojileri
Önkoşullar
- C/C++
- Windows Kullanıcı Arayüzü Programlama
Talimatlar
Kaydırma Çubuğu Oluşturma
Aşağıdaki örnek, standart yatay ve dikey kaydırma çubuklarıyla bir pencere oluşturur.
hwnd = CreateWindowEx(
0, // no extended styles
g_szWindowClass, // global string containing name of window class
g_szTitle, // global string containing title bar text
WS_OVERLAPPEDWINDOW |
WS_HSCROLL | WS_VSCROLL, // window styles
CW_USEDEFAULT, // default horizontal position
CW_USEDEFAULT, // default vertical position
CW_USEDEFAULT, // default width
CW_USEDEFAULT, // default height
(HWND) NULL, // no parent for overlapped windows
(HMENU) NULL, // use the window class menu
g_hInst, // global instance handle
(PVOID) NULL // pointer not needed
);
Bu kaydırma çubuklarının mesajlarını işlemek için, ana pencere yordamına uygun kodu eklemeniz gerekir.
SCROLLBAR pencere sınıfını belirterek kaydırma çubuğu oluşturmak için createWindowExişlevinikullanabilirsiniz. Bu, SBS_HORZ veya SBS_VERT pencere stili olarak belirtilip belirtilmediğinden bağlı olarak yatay veya dikey bir kaydırma çubuğu oluşturur. Kaydırma çubuğunun boyutu ve ana penceresine göre konumu da belirtilebilir.
Aşağıdaki örnek, üst pencerenin istemci alanının alt kısmına yerleştirilmiş bir yatay kaydırma çubuğu oluşturur.
// Description:
// Creates a horizontal scroll bar along the bottom of the parent
// window's area.
// Parameters:
// hwndParent - handle to the parent window.
// sbHeight - height, in pixels, of the scroll bar.
// Returns:
// The handle to the scroll bar.
HWND CreateAHorizontalScrollBar(HWND hwndParent, int sbHeight)
{
RECT rect;
// Get the dimensions of the parent window's client area;
if (!GetClientRect(hwndParent, &rect))
return NULL;
// Create the scroll bar.
return (CreateWindowEx(
0, // no extended styles
L"SCROLLBAR", // scroll bar control class
(PTSTR) NULL, // no window text
WS_CHILD | WS_VISIBLE // window styles
| SBS_HORZ, // horizontal scroll bar style
rect.left, // horizontal position
rect.bottom - sbHeight, // vertical position
rect.right, // width of the scroll bar
sbHeight, // height of the scroll bar
hwndParent, // handle to main window
(HMENU) NULL, // no menu
g_hInst, // instance owning this window
(PVOID) NULL // pointer not needed
));
}
İlgili konular