[gui] simple tabelle aus datenbank...



  • Hi,

    ich möchte aus den inhalten einer datenbank eine tabelle erstellen und diese im fenster ausgeben. grafisch muss das nicht top sein.. ich sollte nur die möglichkeiten haben den spalten eine feste breite zuzuweisen und ggf eine reihe anhand eines wertes aus der datenbank einzufärben (rot, grün,..)

    gibt es hier in der winapi eine simple möglichkeit?

    momentan habe ich einen simplen code der text ausgibt.. jedoch kann ich "textout" nicht auf eine feste breite definieren (sondern nur die position ansich) sonst könnte ich mir daraus ja eine tabelle bauen... 😉

    wie gesagt... einfach ein fester mit ner tabelle drin. mit nem simplen border, aut-wrap(zeilenumbruch) und fester breite der spalten...
    wie ich ein scrollbalken einbaue ist ne andere geschichte, mach ich mich später schlau...

    danke für tipps 😉

    vollstöndigkeitshalber anbei der bisherige quellcode

    #include <windows.h>
    #include <iostream>
    
    LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
    //Deklaration der Windows-Nachrichten-Prozedur
    
    int WINAPI WinMain (HINSTANCE hI, HINSTANCE hPrI, PSTR szCmdLine, int iCmdShow)
    {
        std::string szName;
        szName = "test";
    
        HBRUSH MyBrush = CreateSolidBrush( RGB( 240,240,240 ) );
    
    WNDCLASSA wc;
    
    wc.style         = CS_HREDRAW | CS_VREDRAW;   // CS = "class style"
    wc.lpfnWndProc   = WndProc;
    wc.cbClsExtra    = 0;
    wc.cbWndExtra    = 0;
    wc.hInstance     = hI;
    wc.hIcon         = LoadIcon (NULL, IDI_WINLOGO);
    wc.hCursor       = LoadCursor (NULL, IDC_ARROW);
    wc.hbrBackground = MyBrush;
    wc.lpszMenuName  = NULL;
    wc.lpszClassName = szName.c_str();
    
    RegisterClassA (&wc);
    
    HWND hwnd = CreateWindowA (szName.c_str(), "Server Statuscheck", WS_OVERLAPPEDWINDOW,
                              0, 0, 1024, 700, NULL, NULL, hI, NULL);
    
    ShowWindow   (hwnd, iCmdShow);
    UpdateWindow (hwnd);
    
    // Nachrichten-Schleife
    MSG msg;
        while (GetMessage (&msg, NULL, 0, 0))
        {
            TranslateMessage (&msg);
            DispatchMessage (&msg);
        }
    return msg.wParam;
    }
    
    // Windows-Nachrichten-Prozedur
    LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    HDC hdc;
    PAINTSTRUCT ps;
    
    switch (message)
    {
    case WM_PAINT:
        hdc = BeginPaint (hwnd, &ps);
        SetTextColor( hdc, RGB( 255,   0,  0) );  // rot
        SetBkColor  ( hdc, RGB( 255, 255,  0) );  // gelb
        TextOutA (hdc, 20, 20, "Ich bin ein Fenster.", 20);
        TextOutA (hdc, 40, 40, "Ich bin ein Fenster.", 20);
        EndPaint (hwnd, &ps);
        return 0;
    
    case WM_DESTROY:
        PostQuitMessage (0);
        return 0;
    }
    
    return DefWindowProc (hwnd, message, wParam, lParam);
    }
    

Anmelden zum Antworten