Status bar erstellen???[!! solved !!]
-
Hallo und Guten Tag.
Ich versuch nun schon eine geraume Zeit so eine Statusbar zu erstellen und im Fenster anzuzeigen.
Ich erstelle also ein Window handle so
bool CreateStatusBar(const TCHAR *szClassName, HWND hwndParent, HINSTANCE hInstance, WNDPROC proc, short id, HWND *phwnd) { WNDCLASS wc = { NULL }; wc.hbrBackground = (HBRUSH)GetStockObject(COLOR_BTNFACE); wc.hInstance = hInstance; wc.lpfnWndProc = proc; wc.lpszClassName = szClassName; wc.style = CS_VREDRAW | CS_HREDRAW; if(!RegisterClass(&wc)){ MessageBox(NULL, TEXT("Requires Windows NT!"), TEXT("Statusbar."), MB_ICONERROR | MB_OK); return false; } HWND hwnd = CreateWindow(szClassName, NULL, WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP, 0,0,0,0, hwndParent, (HMENU) id, hInstance, NULL); if(hwnd) phwnd[id] = hwnd; else return false; return true; }und die Proc dazu ist auch ganz einfach
LRESULT CALLBACK StatusProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { HWND hParent; RECT rParent; HDC hdcParent = NULL, hdc = NULL; TEXTMETRIC tm; int x, y, width, height, cyChar; switch(msg) { case WM_CREATE: hParent = (HWND)GetWindowLong(hwnd, GWL_HWNDPARENT); hdcParent = GetDC(hParent); GetTextMetrics(hdcParent, &tm); cyChar = tm.tmHeight + tm.tmExternalLeading; GetClientRect(hParent, &rParent); x = rParent.left; y = rParent.bottom; width = rParent.right; height = cyChar; MoveWindow(hwnd, x, y-height, width, height, false); return 0; } return DefWindowProc(hwnd, msg, wParam, lParam); }Oder mach ich das total falsch?
Eine vordefinierte Klasse gibt es nicht, ich hab die MSDN schon durch, von oben bis unten. Da steht nur STATUSCLASSNAME für den Klassennamen. Dann nehme ich mal an, ich muss die Klasse selbst erstellen.Kann mir jemand weiter helfen???
Danke und Gruß
Alex
-
ok, ich habs doch noch geschafft.
Anscheinent muss man vorher
... InitCommonControls(); ...aufrufen. Und dann kann man auch
STATUSCLASSNAMEals Klassennamen verwenden.
Danke
Alex