Skip to content
This repository has been archived by the owner on Jan 7, 2025. It is now read-only.

Commit

Permalink
Load distro name and window caption from win32 resource
Browse files Browse the repository at this point in the history
  • Loading branch information
yumeyao committed Nov 27, 2020
1 parent 2ed9a93 commit 21269b8
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 6 deletions.
11 changes: 11 additions & 0 deletions DistroLauncher/DistributionInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
//

#include "stdafx.h"
#include "resource.h"

static std::wstring_view LoadStringFromResource(UINT resId, std::wstring_view defaultStr)
{
wchar_t* res;
int len = LoadStringW(GetModuleHandle(nullptr), resId, reinterpret_cast<LPWSTR>(&res), 0);
return len ? std::wstring_view(res, len) : defaultStr;
}

const std::wstring DistributionInfo::Name(LoadStringFromResource(IDS_DISTRO_NAME, L"MyDistribution"));
const std::wstring DistributionInfo::WindowTitle(LoadStringFromResource(IDS_WINDOW_CAPTION, L"My Distribution"));

bool DistributionInfo::CreateUser(std::wstring_view userName)
{
Expand Down
4 changes: 2 additions & 2 deletions DistroLauncher/DistributionInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ namespace DistributionInfo
//
// WARNING: This value must not change between versions of your app,
// otherwise users upgrading from older versions will see launch failures.
const std::wstring Name = L"MyDistribution";
extern const std::wstring Name;

// The title bar for the console window while the distribution is installing.
const std::wstring WindowTitle = L"My Distribution";
extern const std::wstring WindowTitle;

// Create and configure a user account.
bool CreateUser(std::wstring_view userName);
Expand Down
39 changes: 35 additions & 4 deletions DistroLauncher/DistroLauncher.rc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,36 @@
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// Neutral resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL

/////////////////////////////////////////////////////////////////////////////
//
// Icon
//

// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON1 ICON ".\\images\\icon.ico"


/////////////////////////////////////////////////////////////////////////////
//
// String Table
//

STRINGTABLE
BEGIN
IDS_DISTRO_NAME "MyDistribution"
END

#endif // Neutral resources
/////////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////////
// English (United States) resources

Expand Down Expand Up @@ -46,12 +76,13 @@ END

/////////////////////////////////////////////////////////////////////////////
//
// Icon
// String Table
//

// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON1 ICON ".\images\icon.ico"
STRINGTABLE
BEGIN
IDS_WINDOW_CAPTION "My Distribution"
END

#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 2 additions & 0 deletions DistroLauncher/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// Used by DistroInstaller.rc
//
#define IDI_ICON1 101
#define IDS_DISTRO_NAME 151
#define IDS_WINDOW_CAPTION 152

// Next default values for new objects
//
Expand Down

0 comments on commit 21269b8

Please sign in to comment.