ListBox Style bei WND - WND wird nicht komplett gezeichnet
-
Hallo,
habe mir mal die Splitter Funktion von einem Boardie angeschaut und eines der beiden Childs zu einer Listbox gemacht (linkes Fenster), leider wird die Listbox mittels MoveWindow und der FrameHight nicht über die komlette FrameHight gezeichnet, sodern nur soweit, dass eine ganze Anzahl von Listbox-Items zu sehen sind. Ist die FrameHight um z.B. einen Pixel größer, als n * Anzahl Listbox-Itmes, dann wird unter der Listbox ein grauer Bereich sichtbar.
Kann man der Listbox irgendwelche Parameter mitgeben, sodass diese auch ein Listbox-Item abgeschnitten darstellt und das ChildFenster somit bis zum unteren Rand kommt?
Wenn ich das FrameWindow soweit verändere (mit der Maus), dass eine ganze Anzahl hineinpasst, dann schauts gut aus, das könnte man ja noch berechnen, aber wenn man den Frame maximiert, hat man keine Chance mehr.
Danke im Voraus
BusterHier mal mein modifiziereter, lauffähiger Code:
#include <windows.h> LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); const char szAppName[] = "Splitter"; HINSTANCE hInstance; HWND hwndMain; HWND hwndChild1; HWND hwndChild2; int nSplitterPos = 100; int nSplitterBorder = 2; int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int nShowCmd) { WNDCLASSEX wc; MSG msg; // // Register our main window class // wc.cbSize = sizeof(wc); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInst; wc.hIcon = LoadIcon (NULL, IDI_APPLICATION); wc.hCursor = LoadCursor (NULL, IDC_SIZEWE); wc.hbrBackground = (HBRUSH)(COLOR_3DFACE+1);; wc.lpszMenuName = 0; wc.lpszClassName = szAppName; wc.hIconSm = LoadIcon (NULL, IDI_APPLICATION); RegisterClassEx(&wc); hInstance = hInst; // // Create the main window. This window // will host two child controls. // hwndMain = CreateWindowEx(0, // extended style (not needed) szAppName, // window class name szAppName, // window caption WS_OVERLAPPEDWINDOW| WS_CLIPCHILDREN, // window style CW_USEDEFAULT, // initial x position CW_USEDEFAULT, // initial y position CW_USEDEFAULT, // initial x size CW_USEDEFAULT, // initial y size NULL, // parent window handle NULL, // use window class menu hInst, // program instance handle NULL); // creation parameters ShowWindow(hwndMain, nShowCmd); while(GetMessage(&msg, NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return 0; } void SizeWindowContents(int nWidth, int nHeight) { //We will get SetScrollInfo's called by the listview, because //it has been changed in size MoveWindow ( hwndChild1, 0, 0, nSplitterPos, nHeight, TRUE ); MoveWindow ( hwndChild2, nSplitterPos + nSplitterBorder, 0, nWidth - nSplitterPos - nSplitterBorder, nHeight, TRUE ); } LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CREATE: hwndChild1 = CreateWindowEx(WS_EX_CLIENTEDGE, "ListBox", "", WS_VISIBLE | WS_CHILD | WS_HSCROLL | WS_VSCROLL, 0,0,0,0,hwnd, 0, hInstance, 0); hwndChild2 = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "", WS_VISIBLE|WS_CHILD, 0,0,0,0,hwnd, 0, hInstance, 0); for (int i = 0; i < 100; i++) SendMessage(hwndChild1, LB_ADDSTRING, 0, (LPARAM) "TestString"); return 0; case WM_SIZE: SizeWindowContents(LOWORD(lParam), HIWORD(lParam)); return 0; case WM_CLOSE: DestroyWindow(hwnd); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; default: break; } return DefWindowProc(hwnd, msg, wParam, lParam); }
-
LBS_NOINTEGRALHEIGHT
Specifies that the size of the list box is exactly the size specified by the application when it created the list box. Normally, the system sizes a list box so that the list box does not display partial items.
-
@ kwoTx,
funzt, DANKE !!!
Buster
-
Hallo,
nochmals eine Frage zur ListBox, wie kann man die horizontale Scrollleiste aktivieren? Wie oben im Code zu sehen, ist WS_HSCROLL gesetzt.
Ich bekomme lediglich die vertikale zu sehen, obwohl in beiden Richtungen genug Daten reingestopft wurden.
Danke
Buster
-
-
hättest auch direkt auf eure seite verlinken können *grins*
-
King,
THX
SubClassing, ahso ...., mal mit befassen.Buster