mirror of
https://github.com/WCBROW01/WinPowerDMS.git
synced 2025-12-12 02:18:05 -05:00
Create an application icon.
It's quick and dirty but it works well enough.
This commit is contained in:
@ -28,7 +28,7 @@ BOOL DisplayModeEquals(const DISPLAY_MODE* a, const DISPLAY_MODE* b) {
|
|||||||
// I hate parsing the string here, but the alternative requires extra memory management.
|
// I hate parsing the string here, but the alternative requires extra memory management.
|
||||||
static DISPLAY_MODE GetModeFromCB(HWND hComboBox) {
|
static DISPLAY_MODE GetModeFromCB(HWND hComboBox) {
|
||||||
DISPLAY_MODE mode = { 0 };
|
DISPLAY_MODE mode = { 0 };
|
||||||
size_t selectedIndex = SendMessage(hComboBox, CB_GETCURSEL, 0, 0);
|
LRESULT selectedIndex = SendMessage(hComboBox, CB_GETCURSEL, 0, 0);
|
||||||
if (selectedIndex != CB_ERR) {
|
if (selectedIndex != CB_ERR) {
|
||||||
LRESULT len = SendMessage(hComboBox, CB_GETLBTEXTLEN, selectedIndex, 0);
|
LRESULT len = SendMessage(hComboBox, CB_GETLBTEXTLEN, selectedIndex, 0);
|
||||||
if (len != CB_ERR) {
|
if (len != CB_ERR) {
|
||||||
@ -203,13 +203,13 @@ static DISPLAY_MODE GetCurrentDisplayMode(void) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static INT_PTR CALLBACK PrefsDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) {
|
static INT_PTR CALLBACK PrefsDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||||
HWND hComboBatt = GetDlgItem(hDlg, IDC_COMBO_BATT);
|
HWND hComboBatt = GetDlgItem(hDlg, IDC_COMBO_BATT);
|
||||||
HWND hComboAC = GetDlgItem(hDlg, IDC_COMBO_AC);
|
HWND hComboAC = GetDlgItem(hDlg, IDC_COMBO_AC);
|
||||||
HWND hCheckBattWarning = GetDlgItem(hDlg, IDC_CHECK_BATT_WARNING);
|
HWND hCheckBattWarning = GetDlgItem(hDlg, IDC_CHECK_BATT_WARNING);
|
||||||
HWND hCheckStartup = GetDlgItem(hCheckBattWarning, IDC_CHECK_STARTUP);
|
HWND hCheckStartup = GetDlgItem(hCheckBattWarning, IDC_CHECK_STARTUP);
|
||||||
|
|
||||||
switch (message) {
|
switch (uMsg) {
|
||||||
case WM_INITDIALOG: {
|
case WM_INITDIALOG: {
|
||||||
// devMode object that will be enumerated
|
// devMode object that will be enumerated
|
||||||
DEVMODE devMode;
|
DEVMODE devMode;
|
||||||
@ -217,7 +217,7 @@ static INT_PTR CALLBACK PrefsDialogProc(HWND hDlg, UINT message, WPARAM wParam,
|
|||||||
devMode.dmSize = sizeof(devMode);
|
devMode.dmSize = sizeof(devMode);
|
||||||
|
|
||||||
size_t modeCount = 0;
|
size_t modeCount = 0;
|
||||||
int modeNum = 0;
|
DWORD modeNum = 0;
|
||||||
DISPLAY_MODE lastMode = { 0 };
|
DISPLAY_MODE lastMode = { 0 };
|
||||||
while (EnumDisplaySettings(NULL, modeNum++, &devMode)) {
|
while (EnumDisplaySettings(NULL, modeNum++, &devMode)) {
|
||||||
DISPLAY_MODE currentMode = {
|
DISPLAY_MODE currentMode = {
|
||||||
@ -372,12 +372,13 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||||||
AppendMenu(hMenu, MF_STRING, ID_TRAY_EXIT, L"Exit");
|
AppendMenu(hMenu, MF_STRING, ID_TRAY_EXIT, L"Exit");
|
||||||
|
|
||||||
// Setup tray icon
|
// Setup tray icon
|
||||||
|
HICON hTrayIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPICON));
|
||||||
nid.cbSize = sizeof(NOTIFYICONDATA);
|
nid.cbSize = sizeof(NOTIFYICONDATA);
|
||||||
nid.hWnd = hWnd;
|
nid.hWnd = hWnd;
|
||||||
nid.uID = TRAY_ICON_ID;
|
nid.uID = TRAY_ICON_ID;
|
||||||
nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
|
nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
|
||||||
nid.uCallbackMessage = WM_TRAYICON;
|
nid.uCallbackMessage = WM_TRAYICON;
|
||||||
nid.hIcon = LoadIcon(NULL, IDI_APPLICATION); // Replace this with my own icon at some point
|
nid.hIcon = hTrayIcon;
|
||||||
wcscpy_s(nid.szTip, sizeof(nid.szTip) / sizeof(nid.szTip[0]), L"WinPowerDMS");
|
wcscpy_s(nid.szTip, sizeof(nid.szTip) / sizeof(nid.szTip[0]), L"WinPowerDMS");
|
||||||
|
|
||||||
Shell_NotifyIcon(NIM_ADD, &nid);
|
Shell_NotifyIcon(NIM_ADD, &nid);
|
||||||
@ -389,5 +390,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||||||
DispatchMessage(&msg);
|
DispatchMessage(&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DestroyIcon(hTrayIcon);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
BIN
WinPowerDMS/WinPowerDMS.ico
Normal file
BIN
WinPowerDMS/WinPowerDMS.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
Binary file not shown.
@ -136,6 +136,9 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="WinPowerDMS.rc" />
|
<ResourceCompile Include="WinPowerDMS.rc" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Image Include="WinPowerDMS.ico" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
</Filter>
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="main.c">
|
<ClCompile Include="WinPowerDMS.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@ -29,4 +29,9 @@
|
|||||||
<Filter>Resource Files</Filter>
|
<Filter>Resource Files</Filter>
|
||||||
</ResourceCompile>
|
</ResourceCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Image Include="WinPowerDMS.ico">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</Image>
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@ -3,6 +3,7 @@
|
|||||||
// Used by WinPowerDMS.rc
|
// Used by WinPowerDMS.rc
|
||||||
//
|
//
|
||||||
#define IDD_PREFSDIALOG 101
|
#define IDD_PREFSDIALOG 101
|
||||||
|
#define IDI_APPICON 106
|
||||||
#define IDC_COMBO_BATT 1001
|
#define IDC_COMBO_BATT 1001
|
||||||
#define IDC_COMBO_AC 1002
|
#define IDC_COMBO_AC 1002
|
||||||
#define IDC_BUTTON_TEST_BATT 1003
|
#define IDC_BUTTON_TEST_BATT 1003
|
||||||
@ -16,7 +17,7 @@
|
|||||||
//
|
//
|
||||||
#ifdef APSTUDIO_INVOKED
|
#ifdef APSTUDIO_INVOKED
|
||||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
#define _APS_NEXT_RESOURCE_VALUE 104
|
#define _APS_NEXT_RESOURCE_VALUE 107
|
||||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||||
#define _APS_NEXT_CONTROL_VALUE 1008
|
#define _APS_NEXT_CONTROL_VALUE 1008
|
||||||
#define _APS_NEXT_SYMED_VALUE 101
|
#define _APS_NEXT_SYMED_VALUE 101
|
||||||
|
|||||||
Reference in New Issue
Block a user