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

Load distro name and window caption from win32 resource #84

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 150
#define IDS_WINDOW_CAPTION 1024

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