add way to set custom icon from .dll, and add keys icon for dialog
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
+4
-1
@@ -9,9 +9,12 @@
|
||||
|
||||
#include "version.h"
|
||||
|
||||
#define IDI_MAINFRAME 103
|
||||
#define IDD_MAINFRAME 100
|
||||
|
||||
#define IDC_MAINFRAME 103
|
||||
#define IDI_SMALL 203
|
||||
#define IDI_MAINFRAME IDC_MAINFRAME
|
||||
|
||||
#ifndef IDC_STATIC
|
||||
#define IDC_STATIC -1
|
||||
#endif // IDC_STATIC
|
||||
|
||||
+2
-1
@@ -95,7 +95,8 @@ END
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_MAINFRAME ICON "xp_activate32.ico"
|
||||
IDI_MAINFRAME ICON "xp_activate32.ico"
|
||||
IDI_SMALL ICON "keys.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Russian (Russia) resources
|
||||
|
||||
+76
-13
@@ -972,6 +972,60 @@ INT_PTR CALLBACK DialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
HANDLE LoadImageFromDLL(LPCWSTR dllName,
|
||||
UINT resourceId,
|
||||
UINT imgType,
|
||||
int width,
|
||||
int height,
|
||||
UINT flags) {
|
||||
// Load the .dll module from supplied name
|
||||
HMODULE hModule = LoadLibraryW(dllName);
|
||||
if (!hModule) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Load the image using LoadImageW
|
||||
HANDLE hImage;
|
||||
hImage = LoadImageW(
|
||||
hModule, // hinst
|
||||
MAKEINTRESOURCEW(resourceId), // resource name/id
|
||||
imgType,
|
||||
width,
|
||||
height,
|
||||
flags);
|
||||
|
||||
// We can free the module after loading unless caller wants otherwise
|
||||
if (hImage) {
|
||||
FreeLibrary(hModule);
|
||||
}
|
||||
|
||||
return hImage;
|
||||
}
|
||||
|
||||
HICON getDialogIcon(bool use_custom_icon, int resource, int x, int y) {
|
||||
HICON icon;
|
||||
// Get key icon
|
||||
static const LPCWSTR dll_name = L"shell32.dll";
|
||||
if (use_custom_icon) {
|
||||
icon = (HICON)LoadImageFromDLL(
|
||||
dll_name,
|
||||
resource,
|
||||
IMAGE_ICON,
|
||||
x,
|
||||
y,
|
||||
LR_DEFAULTCOLOR);
|
||||
} else {
|
||||
icon = (HICON)LoadImage(
|
||||
GetModuleHandle(NULL),
|
||||
MAKEINTRESOURCE(IDI_SMALL), // Our normal telephone icon
|
||||
IMAGE_ICON,
|
||||
x,
|
||||
y,
|
||||
LR_DEFAULTCOLOR);
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
||||
std::wstring getVersionW() {
|
||||
std::wostringstream ostr;
|
||||
ostr << MAJOR_VERSION << L"." << MINOR_VERSION << L"." << BUILD_VERSION;
|
||||
@@ -984,23 +1038,32 @@ int main() {
|
||||
INITCOMMONCONTROLSEX cc = {sizeof(INITCOMMONCONTROLSEX), ICC_STANDARD_CLASSES};
|
||||
InitCommonControlsEx(&cc);
|
||||
int i;
|
||||
for (i = 0; i < 14; i++)
|
||||
|
||||
for (i = 0; i < 14; i++) {
|
||||
LoadString(NULL, i, strings[i], sizeof(strings[i]) / sizeof(strings[i][0]));
|
||||
for (i = 0; i < 2; i++)
|
||||
hIcon[i] = (HICON)LoadImage(
|
||||
GetModuleHandle(NULL),
|
||||
MAKEINTRESOURCE(1),
|
||||
IMAGE_ICON,
|
||||
GetSystemMetrics(i ? SM_CXICON : SM_CXSMICON),
|
||||
GetSystemMetrics(i ? SM_CYICON : SM_CYSMICON),
|
||||
0);
|
||||
}
|
||||
|
||||
int x, y;
|
||||
for (i = 0; i < 2; i++) {
|
||||
x = GetSystemMetrics(i ? SM_CXICON : SM_CXSMICON);
|
||||
y = GetSystemMetrics(i ? SM_CYICON : SM_CYSMICON);
|
||||
hIcon[i] = getDialogIcon(false, 194, x, y);
|
||||
}
|
||||
|
||||
INT_PTR status = DialogBox(NULL, MAKEINTRESOURCE(100), NULL, &DialogProc);
|
||||
for (i = 0; i < 2; i++)
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
DestroyIcon(hIcon[i]);
|
||||
if (LicenseAgent)
|
||||
}
|
||||
|
||||
if (LicenseAgent) {
|
||||
LicenseAgent->Release();
|
||||
if (ComInitialized)
|
||||
CoUninitialize();
|
||||
}
|
||||
|
||||
if (ComInitialized) {
|
||||
CoUninitialize();
|
||||
}
|
||||
|
||||
std::cout << "status = " << status << std::endl;
|
||||
ExitProcess(status);
|
||||
}
|
||||
|
||||
@@ -95,4 +95,12 @@ static void PutIdToSystem(HWND hDlg);
|
||||
|
||||
INT_PTR CALLBACK DialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
std::wstring getVersionW();
|
||||
|
||||
HANDLE LoadImageFromDLL(UINT resourceId,
|
||||
UINT imgType,
|
||||
int width,
|
||||
int height,
|
||||
UINT flags);
|
||||
|
||||
#endif // XP_ACTIVATE32_H_
|
||||
|
||||
@@ -147,6 +147,7 @@
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="src/keys.ico" />
|
||||
<Image Include="src/xp_activate32.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="src/keys.ico">
|
||||
<Filter>Resource Files</Filter>
|
||||
</Image>
|
||||
<Image Include="src/xp_activate32.ico">
|
||||
<Filter>Resource Files</Filter>
|
||||
</Image>
|
||||
|
||||
Reference in New Issue
Block a user