Skip to content

Commit

Permalink
Fix half of #196
Browse files Browse the repository at this point in the history
  • Loading branch information
katahiromz committed Jul 21, 2024
1 parent 1401689 commit bcdd769
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/MAddBitmapDlg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,16 @@ class MAddBitmapDlg : public MDialogBase
if (GetOpenFileNameW(&ofn))
{
SetDlgItemTextW(hwnd, edt1, szFile);

// If name was empty, use file title
WCHAR szText[MAX_PATH];
ComboBox_GetText(GetDlgItem(hwnd, cmb2), szText, _countof(szText));
if (!szText[0])
{
StringCchCopyW(szText, _countof(szText), szFile);
PathRemoveExtensionW(szText);
ComboBox_SetText(GetDlgItem(hwnd, cmb2), PathFindFileNameW(szText));
}
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/MAddCursorDlg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,16 @@ class MAddCursorDlg : public MDialogBase
DestroyCursor(m_hCursor);
m_hCursor = LoadCursorFromFile(szFile);
SendDlgItemMessage(hwnd, ico1, STM_SETIMAGE, IMAGE_CURSOR, LPARAM(m_hCursor));

// If name was empty, use file title
WCHAR szText[MAX_PATH];
ComboBox_GetText(GetDlgItem(hwnd, cmb2), szText, _countof(szText));
if (!szText[0])
{
StringCchCopyW(szText, _countof(szText), szFile);
PathRemoveExtensionW(szText);
ComboBox_SetText(GetDlgItem(hwnd, cmb2), PathFindFileNameW(szText));
}
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/MAddIconDlg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,16 @@ class MAddIconDlg : public MDialogBase
DestroyIcon(m_hIcon);
m_hIcon = ExtractIcon(GetModuleHandle(NULL), szFile, 0);
Static_SetIcon(GetDlgItem(hwnd, ico1), m_hIcon);

// If name was empty, use file title
WCHAR szText[MAX_PATH];
ComboBox_GetText(GetDlgItem(hwnd, cmb2), szText, _countof(szText));
if (!szText[0])
{
StringCchCopyW(szText, _countof(szText), szFile);
PathRemoveExtensionW(szText);
ComboBox_SetText(GetDlgItem(hwnd, cmb2), PathFindFileNameW(szText));
}
}
}

Expand Down
12 changes: 12 additions & 0 deletions src/MAddResDlg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,16 @@ class MAddResDlg : public MDialogBase
{
// set the file path
SetDlgItemTextW(hwnd, edt1, szFile);

// If name was empty, use file title
WCHAR szText[MAX_PATH];
ComboBox_GetText(GetDlgItem(hwnd, cmb2), szText, _countof(szText));
if (!szText[0])
{
StringCchCopyW(szText, _countof(szText), szFile);
PathRemoveExtensionW(szText);
ComboBox_SetText(GetDlgItem(hwnd, cmb2), PathFindFileNameW(szText));
}
}
}

Expand Down Expand Up @@ -396,6 +406,7 @@ class MAddResDlg : public MDialogBase
return;

// prefix --> m_cmb2
ComboBox_GetText(m_cmb2, szText, _countof(szText));
ComboBox_ResetContent(m_cmb2);
if (type != RT_STRING && type != RT_MESSAGETABLE)
{
Expand All @@ -405,6 +416,7 @@ class MAddResDlg : public MDialogBase
ComboBox_AddString(m_cmb2, table_entry.name.c_str());
}
}
ComboBox_SetText(m_cmb2, szText);
}

void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
Expand Down

0 comments on commit bcdd769

Please sign in to comment.