| 158 | } |
| 159 | |
| 160 | const theme_cfg* LoadThemeConfig() { |
| 161 | static BOOL config_loaded = FALSE; |
| 162 | static theme_cfg _cfg; |
| 163 | |
| 164 | if (config_loaded) return &_cfg; |
| 165 | config_loaded = TRUE; |
| 166 | |
| 167 | HMODULE hm = nullptr; |
| 168 | GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCTSTR)LoadThemeConfig, &hm); |
| 169 | WCHAR path[MAX_PATH]; |
| 170 | GetModuleFileNameW(hm, path, MAX_PATH); |
| 171 | CStringW inifn(path); |
| 172 | inifn.Append(L".ini"); |
| 173 | |
| 174 | if (!std::filesystem::exists(inifn.GetString())) { |
| 175 | std::ofstream configFile; |
| 176 | configFile.open(inifn.GetString()); |
| 177 | configFile << "menubar_textcolor = 200,200,200" << std::endl; |
| 178 | configFile << "menubar_textcolor_disabled = 160,160,160" << std::endl; |
| 179 | configFile << "menubar_bgcolor = 48,48,48" << std::endl; |
| 180 | configFile << "menubaritem_bgcolor = 48,48,48" << std::endl; |
| 181 | configFile << "menubaritem_bgcolor_hot = 62,62,62" << std::endl; |
| 182 | configFile << "menubaritem_bgcolor_selected = 62,62,62" << std::endl; |
| 183 | configFile.close(); |
| 184 | } |
| 185 | |
| 186 | inipp::Ini<char> ini; |
| 187 | std::ifstream is(inifn.GetString()); |
| 188 | ini.parse(is); |
| 189 | is.close(); |
| 190 | std::ostringstream oss; |
| 191 | ini.generate(oss); |
| 192 | |
| 193 | #define _PARSE_COLOR(x) \ |
| 194 | { \ |
| 195 | int r, g, b; \ |
| 196 | char comma; \ |
| 197 | std::stringstream ss(ini.sections[""][#x]); \ |
| 198 | ss >> r >> comma >> g >> comma >> b; \ |
| 199 | _cfg.x = RGB(r, g, b); \ |
| 200 | } |
| 201 | |
| 202 | _PARSE_COLOR(menubar_textcolor) |
| 203 | _PARSE_COLOR(menubar_textcolor_disabled) |
| 204 | _PARSE_COLOR(menubar_bgcolor) |
| 205 | _PARSE_COLOR(menubaritem_bgcolor) |
| 206 | _PARSE_COLOR(menubaritem_bgcolor_hot) |
| 207 | _PARSE_COLOR(menubaritem_bgcolor_selected) |
| 208 | |
| 209 | _cfg.menubar_bgbrush = CreateSolidBrush(_cfg.menubar_bgcolor); |
| 210 | _cfg.menubaritem_bgbrush = CreateSolidBrush(_cfg.menubaritem_bgcolor); |
| 211 | _cfg.menubaritem_bgbrush_hot = CreateSolidBrush(_cfg.menubaritem_bgcolor_hot); |
| 212 | _cfg.menubaritem_bgbrush_selected = CreateSolidBrush(_cfg.menubaritem_bgcolor_selected); |
| 213 | |
| 214 | return &_cfg; |
| 215 | } |
| 216 | |
| 217 | // https://stackoverflow.com/questions/39261826/change-the-color-of-the-title-bar-caption-of-a-win32-application |
no outgoing calls
no test coverage detected