[WinApi] problem z ListView

0

Stworzyłem okienko, w którym jest zawarte kolejne. Chcę zrobić coś na wzór total commandera tylko nie wiem jak się zabrać za przewijanie (nie musi obslugiwać myszki). Da się np stworzyć większe okno niż okno do którego jest przytwierdzone i je jakoś przewijać czy muszę wszystko przewijać? Co ze scrollbarem

no i drugie pytanie odnośnie kolorów:
Mam kolor pierwotnego okna zadeklarowane w konstruktorze klasy. Tworząc "pod okno" które chcę przewijać ma ono takie same kolory. Tworzyłem nową klasę jednak wtedy nie działa

chciałbym, żeby hLeftWindow miało inny kolor i dało się jakoś przewijać

z góry dziękuje.

/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/*  Make the class name into a global variable  */
char szClassName[ ] = "WindowsApp";

int WINAPI WinMain (HINSTANCE hThisInstance,HINSTANCE hPrevInstance,LPSTR lpszArgument,int nFunsterStil)

{
    RECT rc;
    HDC hdc;
    PAINTSTRUCT ps;
    HWND hwnd,hLeftWindow,hRightWindow;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX wincl,SubWindowClass;        /* Data structure for the windowclass */
    int i=0;



    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default color as the background of the window */
    wincl.hbrBackground = (HBRUSH) 2;

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&wincl))
        return 0;

    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           "Totalek 1.0",       /* Title Text */
           WS_OVERLAPPEDWINDOW, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           800,                 /* The programs width */
           600,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );







hLeftWindow = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           "Lewe",       /* Title Text */
           WS_CHILD | WS_VISIBLE | WS_BORDER, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           400,                 /* The programs width */
           600,                 /* and height in pixels */
           hwnd,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );
    /* Make the window visible on the screen */
    ShowWindow (hwnd, nFunsterStil);
 ////  MOJE  
 
   
    
  DetectDisks();

  strcpy(CurrDir1,"C:/MUZYKA/");
  strcpy(CurrDir2,"C:/");
  
  CreateDirList(CurrDir1);  
  CreateFilesList(CurrDir1); 
  
  hdc = BeginPaint( hLeftWindow, &ps );     
  SetBkMode(hdc, TRANSPARENT); 
  SetTextColor (hdc, RGB(255, 104, 25));   
    i=1;
  while (strlen(CurrDirectories1[i-1].name))
    {
       SetRect(&rc, 10, 10+(i*15), 300, 30+(i*15));
      // printf("%s \n",CurrDirectories1[i-1].name);
       DrawText(hdc, CurrDirectories1[i-1].name, -1, &rc, 0);
       i++;
    }
EndPaint( hLeftWindow, &ps );    
    


    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&messages);
    }

    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
}


/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)                  /* handle the messages */
    {
        case WM_DESTROY:
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            break;
        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}
0

Jeśli chodzi o przewijanie to zastosuj klasę LISTBOX, będą jednak pewnie potrzebne w niej kolumny. więc od razu najlepiej zabierz się za klasę LISTVIEW.
Jeśli chodzi o kolor danego okna, to musisz je ręcznie odmalować, tzn. obsłużyć komunikat WM_PAINT i kazać mu rysować prostokąt danego koloru. W przypadku okien których klasę tworzysz sam (taki jak w tym przypadku) sprawa jest prosta. W przypadku klas już isniejących, takich jak LISTBOX sprawa jest nieco bardziej skomplikowana.

0

Wielkie dzięki o to chodziło tylko potrzebuje go usprawnić.

  1. przy takim wywołaniu:
    ListView_SetExtendedListViewStyle(hRightWindow,LVS_EX_FULLROWSELECT) ;

wyskakuje błąd, że LVS_EX_FULLROWSELECT jest niezadeklarowane

  1. Jak zabolokować możliwośc zmiany rozmiaru kolumn?

  2. Jak zmienić kolory scrollbara i nagłówków kolumn, w ostateczności wstawić tam obrazek? Bo te windowsowe wyglądają strasznie.

1 użytkowników online, w tym zalogowanych: 0, gości: 1