Imported from young8290/xinqing-ime (
moodflow_tsf/res/AGENTS.md). Install upstream withnpx skills add young8290/xinqing-ime --skill res. Copyright stays with the author.
res/ - Resource Files
Purpose
Resource files for the TSF DLL, including icon and version information template. These files are compiled into the DLL binary at build time via the resource compiler (RC.exe). version.rc.in 是 CMake 模板,构建时自动替换版本号变量生成 version.rc。
Key Files
| File | Description |
|---|---|
resource.rc |
Resource script defining icon resource (index 0 = moodflow_input.ico) |
version.rc.in |
CMake 版本资源模板;configure_file 将 @APP_VERSION_*@ 占位符替换为实际版本号后输出到 build 目录的 version.rc,写入 DLL 的 VERSIONINFO 文件属性 |
moodflow_input.ico |
Icon image displayed in Windows language bar and settings |
Resource Content
resource.rc
// Moodflow TSF Resource File
// Icon resource for input method display in Windows settings
// Icon index 0 - Main input method icon
0 ICON "moodflow_input.ico"
Purpose:
- Defines a single icon resource (index 0)
- Icon is displayed in:
- Windows language bar when Moodflow 输入法 is active
- Windows Settings > Time & Language > Input Method list
- IME selector dropdown
Resource IDs:
0- Main icon for input method
moodflow_input.ico
Format: Standard Windows ICO file (multiple resolutions)
Required Sizes:
- 16x16 (language bar)
- 32x32 (settings, larger context)
- 48x48 (high DPI support)
- 256x256 (Windows 11 modern UI)
Best Practices:
- Use clear, recognizable visual design (Chinese character or windmill motif)
- Provide high-contrast color palette for accessibility
- Test icon visibility on taskbar at all DPI scales (96, 120, 144, 192 DPI)
For AI Agents
Working In This Directory
When modifying resources:
- Icon format - Use standard ICO file with PNG-compressed data for modern Windows
- Multiple resolutions - Include 16x16, 32x32, 48x48, and 256x256 in single .ico file
- High DPI - Test icons at 150% (144 DPI) and 200% (192 DPI) scaling
- Transparency - Use alpha channel for smooth anti-aliasing and transparency
- Color depth - 32-bit RGBA recommended for best quality and transparency support
Adding Resources
To add new resources to resource.rc:
// String resources
STRINGTABLE
BEGIN
IDS_APP_NAME, L"Moodflow 输入法"
IDS_APP_DESCRIPTION, L"Windows TSF Chinese Input Method"
END
// Dialog resource (if needed)
IDD_ABOUT DIALOGEX 0, 0, 256, 200, WS_POPUP | WS_CAPTION
STYLE DS_SHELLFONT
CAPTION "About Moodflow 输入法"
FONT 9, "MS Shell Dlg 2"
BEGIN
DEFPUSHBUTTON "OK", IDOK, 100, 180, 50, 14
LTEXT "Version 1.0", IDC_STATIC, 10, 10, 100, 14
END
Resource Compiler Flags
In CMakeLists.txt, RC.exe is invoked with:
rc.exe /d UNICODE /d _UNICODE /fo resource.res resource.rc
Flags:
/d UNICODE- Enable Unicode support/d _UNICODE- Define _UNICODE macro/fo- Output filename (resource.res)
Testing Resources
Verify Icon Display:
- Build DLL:
cmake --build . --config Release - Register:
regsvr32 moodflow_tsf.dll - Open Windows Settings > Time & Language > Input Method
- Check Moodflow 输入法 appears with correct icon
- Switch to input method
- Verify language bar shows icon at 16x16
- Test at different DPI scales (150%, 200%)
Verify No Resource Errors:
# After build, check for resource warnings
dumpbin /resources moodflow_tsf.dll | findstr "Icon"
Dependencies
Internal
resource.rcincludesmoodflow_input.icovia ICON statement
External
- Windows Resource Compiler (RC.exe) - part of Windows SDK
- Icon editor tools (not part of build, used offline):
- GIMP
- Paint.NET
- Photoshop
- Icon Editor (Visual Studio built-in)
Common Tasks
Creating High-Quality Icons
- Design in 256x256 as primary
- Export multiple sizes:
- 256x256 (primary)
- 128x128 (high DPI fallback)
- 64x64 (explorer view)
- 48x48 (settings, medium)
- 32x32 (settings, small, language bar double-size)
- 16x16 (language bar actual)
- Apply anti-aliasing at each size
- Keep transparency via alpha channel
- Use ICO format - package all sizes in single .ico file
version.rc.in 模板说明
版本信息通过 CMake configure_file 机制自动注入,不需要手工编辑:
# CMakeLists.txt 调用:
configure_file(res/version.rc.in ${CMAKE_BINARY_DIR}/version.rc @ONLY)
模板中的占位符(如 @APP_VERSION_MAJOR@、@APP_VERSION_STR@)由 CMake 替换为:
-DAPP_VERSION_MAJOR/MINOR/PATCH/BUILD参数值-DAPP_VERSION_STR字符串(如"1.0.0")
验证 DLL 版本信息:
wmic datafile where name="<path>\\moodflow_tsf.dll" get Version
# 或在 PowerShell 中:
(Get-Item "build\moodflow_tsf.dll").VersionInfo.FileVersion