I am trying to change the color of background and bar in a win 32 progress bar in the following way :

HWND hwndPB =CreateWindowEx(0, PROGRESS_CLASS, NULL,
    WS_CHILD | WS_VISIBLE |PBS_SMOOTHREVERSE | PBS_MARQUEE ,
    20, 50, 275, 20,
    hwndDlg, NULL,NULL , NULL);

SetWindowLongPtr(hwndDlg,GWLP_USERDATA,reinterpret_cast<LONG_PTR>(hwndPB));
SendMessage(hwndPB,(UINT)PBM_SETBKCOLOR,0,RGB(200,200,200));
SendMessage(hwndPB,(UINT) PBM_SETBARCOLOR,0,(LPARAM)RGB(100,100,100));
SendMessage(hwndPB,(UINT) PBM_SETMARQUEE,(WPARAM) TRUE,(LPARAM)50 );

I guess this is not working because of the visual themes being enabled. Can anybody suggest me a way to get it done or disable the visual styles. I am using VS 2008. Also, its a non mfc application.

有帮助吗?

解决方案

You can disable themes for an individual control by calling SetWindowTheme. For your progress bar, disable the theming like this:

SetWindowTheme(hwndPB, "", "");

Once you have disabled the theming, you'll be able to control the colors.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top