add json tools

This commit is contained in:
gb 2023-05-06 09:57:04 +08:00
parent acc4c2e8e9
commit dde8bc9a2a
30 changed files with 13942 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,62 @@
#pragma once
#include "afxdialogex.h"
#include <string>
#include <vector>
// CDlgLang 对话框
class CDlgLang : public CDialogEx
{
DECLARE_DYNAMIC(CDlgLang)
public:
CDlgLang(CWnd* pParent = nullptr); // 标准构造函数
virtual ~CDlgLang();
// 对话框数据
enum { IDD = IDD_LANGUAGE };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
virtual BOOL OnInitDialog();
bool select_code_page(int cp);
void add_2_list(void* lang_list, int id, bool unic);
int insert_item_2_list(const wchar_t* str, uint32_t id);
int find_hz_ID(const wchar_t* hz);
int find_list_item_by_ID(int id);
void on_hz_pak_initialized(bool success);
static bool find_repeat_in_vector(uint32_t val, void* param);
static bool find_repeat_in_list(uint32_t val, void* param);
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedButtonInitId();
afx_msg void OnCbnSelchangeLanguage();
afx_msg void OnNMDblclkList1(NMHDR* pNMHDR, LRESULT* pResult);
CComboBox lang_;
CListCtrl list_;
int cur_cp_;
typedef struct _base_map
{
int id;
std::wstring hz;
bool operator==(int i)
{
return id == i;
}
bool operator==(const wchar_t* t)
{
return hz == t;
}
}HZMAP;
std::vector<HZMAP> hz_;
afx_msg void OnBnClickedButtonSave();
afx_msg void OnBnClickedButtonAdd();
afx_msg void OnBnClickedButtonAddFile();
afx_msg void OnBnClickedButtonSaveExport();
afx_msg void OnBnClickedButtonBatchAdd();
};

View File

@ -0,0 +1,114 @@
// CDlgMain.cpp: 实现文件
//
#include "stdafx.h"
#include "hgjson.h"
#include "afxdialogex.h"
#include "CDlgMain.h"
#include "resource.h"
#include "hgjsonDlg.h"
#include "CDlgLang.h"
#include "DlgTwain.h"
#include "DlgOptJson.h"
// CDlgMain 对话框
IMPLEMENT_DYNAMIC(CDlgMain, CDialogEx)
CDlgMain::CDlgMain(CWnd* pParent /*=nullptr*/)
: CDialogEx(IDD_MAIN, pParent)
{
#ifndef _WIN32_WCE
EnableActiveAccessibility();
#endif
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
CDlgMain::~CDlgMain()
{
}
void CDlgMain::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_TAB1, tab_);
}
BOOL CDlgMain::OnInitDialog()
{
CDialogEx::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
LRESULT lret = 0;
CDialogEx* page = new ChgjsonDlg(this);
page->Create(ChgjsonDlg::IDD, this);
insert_page(page, L"\u626B\u63CF\u4EEA\u914D\u7F6E");
page = new CDlgLang(this);
page->Create(CDlgLang::IDD, this);
insert_page(page, L"\u8BED\u8A00\u5305\u5236\u4F5C");
page = new CDlgTwain(this);
page->Create(CDlgTwain::IDD, this);
insert_page(page, L"TWAIN");
page = new CDlgOptJson(this);
page->Create(CDlgOptJson::IDD, this);
insert_page(page, L"Opt-JSON");
tab_.SetCurSel(0);
OnTcnSelchangeTab1(NULL, &lret);
return TRUE; // return TRUE unless you set the focus to a control
}
void CDlgMain::insert_page(CDialogEx* page, const wchar_t* title)
{
RECT r = { 0 };
int ind = 0;
TCITEM item = { 0 };
GetDlgItem(IDC_STATIC_CHILD)->GetWindowRect(&r);
ScreenToClient(&r);
page->MoveWindow(&r);
page->ShowWindow(SW_HIDE);
ind = tab_.InsertItem(tab_.GetItemCount(), title);
item.lParam = (LPARAM)page;
item.mask = TCIF_PARAM;
tab_.SetItem(ind, &item);
}
BEGIN_MESSAGE_MAP(CDlgMain, CDialogEx)
ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, &CDlgMain::OnTcnSelchangeTab1)
ON_NOTIFY(TCN_SELCHANGING, IDC_TAB1, &CDlgMain::OnTcnSelchangingTab1)
END_MESSAGE_MAP()
// CDlgMain 消息处理程序
void CDlgMain::OnTcnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: 在此添加控件通知处理程序代码
*pResult = 0;
TCITEM item = { 0 };
item.mask = TCIF_PARAM;
tab_.GetItem(tab_.GetCurSel(), &item);
((CWnd*)item.lParam)->ShowWindow(SW_SHOW);
}
void CDlgMain::OnTcnSelchangingTab1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: 在此添加控件通知处理程序代码
*pResult = 0;
TCITEM item = { 0 };
item.mask = TCIF_PARAM;
tab_.GetItem(tab_.GetCurSel(), &item);
((CWnd*)item.lParam)->ShowWindow(SW_HIDE);
}

View File

@ -0,0 +1,30 @@
#pragma once
#include "afxdialogex.h"
// CDlgMain 对话框
class CDlgMain : public CDialogEx
{
DECLARE_DYNAMIC(CDlgMain)
public:
CDlgMain(CWnd* pParent = nullptr); // 标准构造函数
virtual ~CDlgMain();
// 对话框数据
enum { IDD = IDD_MAIN };
protected:
HICON m_hIcon;
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
virtual BOOL OnInitDialog();
void insert_page(CDialogEx* page, const wchar_t* title);
DECLARE_MESSAGE_MAP()
public:
CTabCtrl tab_;
afx_msg void OnTcnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnTcnSelchangingTab1(NMHDR* pNMHDR, LRESULT* pResult);
};

View File

@ -0,0 +1,441 @@
// DlgAddWords.cpp: 实现文件
//
#include "stdafx.h"
#include "hgjson.h"
#include "afxdialogex.h"
#include "DlgAddWords.h"
// CDlgAddWords 对话框
static bool is_id_existing(uint32_t id, void* param)
{
std::vector<sdk_util::LANGID>* lang = (std::vector<sdk_util::LANGID>*)param;
return std::find(lang->begin(), lang->end(), (int)id) != lang->end();
}
IMPLEMENT_DYNAMIC(CDlgAddWords, CDialogEx)
CDlgAddWords::CDlgAddWords(CWnd* pParent /*=nullptr*/)
: CDialogEx(IDD_BATCH_ADD_LANG, pParent)
{
}
CDlgAddWords::~CDlgAddWords()
{
}
void CDlgAddWords::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LIST1, words_);
}
BOOL CDlgAddWords::OnInitDialog()
{
CDialogEx::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
int ind = 0;
words_.InsertColumn(ind++, TEXT("No."), 0, 48);
words_.InsertColumn(ind++, TEXT("中文简体"), 0, 168);
words_.InsertColumn(ind++, TEXT("中文繁体"), 0, 168);
words_.InsertColumn(ind++, TEXT("英语"), 0, 250);
words_.SetExtendedStyle(words_.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_INFOTIP);
words_.ModifyStyle(0, LVS_SINGLESEL);
return TRUE; // return TRUE unless you set the focus to a control
}
void CDlgAddWords::open_pak(int lan_id)
{
file_util::PATHFILE file = { 0 };
if (file_util::browser_file(m_hWnd, &file, L"PAK file(*.pak)\0All Files(*.*)\0\0"))
{
set_lang_pak_file(file.path, lan_id);
}
}
void CDlgAddWords::set_lang_pak_file(const wchar_t* file, int lan_id)
{
std::vector<sdk_util::LANGIDW> lans;
int id = 0;
bool ok = false;
if (sdk_util::load_lang_pak(file, lans, &id))
{
if (id == lan_id || lan_id == 0)
{
ok = true;
if (id == 936)
{
::SetDlgItemTextW(m_hWnd, IDC_EDIT_HZ_PAK, file);
lan_hz_ = std::move(lans);
}
else if (id == 950)
{
::SetDlgItemTextW(m_hWnd, IDC_EDIT_HZT, file);
lan_hzt_ = std::move(lans);
}
else if (id == 20127)
{
::SetDlgItemTextW(m_hWnd, IDC_EDIT_ENGLISH, file);
lan_eng_ = std::move(lans);
}
else
ok = false;
}
}
if (!ok && lan_id)
::MessageBoxW(m_hWnd, file, L"不是指定的语言包", MB_OK | MB_ICONERROR);
}
void CDlgAddWords::set_code_file(const wchar_t* file, bool tip)
{
std::wstring unic(sdk_util::load_file(file));
if (unic.find(L"unsigned char g_chinese[] = {") == std::wstring::npos)
{
if(tip)
::MessageBoxW(m_hWnd, file, L"不是指定的简体中文语言头文件", MB_OK | MB_ICONERROR);
}
else
::SetDlgItemTextW(m_hWnd, IDC_EDIT_CODE, file);
}
bool CDlgAddWords::add_words(const wchar_t* pak_file, std::vector<int>& ids, std::string& cont, int lan_id, int src_col, bool init_id)
{
std::vector<sdk_util::LANGIDW> prev;
int id = 0;
if (sdk_util::load_lang_pak(pak_file, prev, &id))
{
if (id == lan_id)
{
std::vector<sdk_util::LANGID> now;
for (auto& v : prev)
{
sdk_util::LANGID item;
item.cp = id;
item.id = v.id;
coding_util::unicode_2_utf8(v.unic.c_str(), sdk_util::got_str, &item.utf8);
now.push_back(std::move(item));
}
for (int i = 0; i < words_.GetItemCount(); ++i)
{
wchar_t text[256] = { 0 };
sdk_util::LANGID item;
words_.GetItemText(i, src_col, text, _countof(text) - 1);
if (init_id)
{
ids.push_back(sdk_util::make_string_id(text, &is_id_existing, &now));
}
item.cp = lan_id;
item.id = ids[i];
coding_util::unicode_2_utf8(text, sdk_util::got_str, &item.utf8);
now.push_back(std::move(item));
}
cont = "";
sdk_util::save_2_lang_pak(m_hWnd, now, lan_id, &cont, false);
return true;
}
::MessageBoxW(m_hWnd, L"语言包不匹配", L"错误", MB_OK | MB_ICONSTOP);
}
else
::MessageBoxW(m_hWnd, pak_file, L"文件加载失败", MB_OK | MB_ICONSTOP);
return false;
}
bool CDlgAddWords::update_head_file(const wchar_t* file, const std::string& cont)
{
int bom = sdk_util::BOM_ANSI;
std::wstring code(sdk_util::load_file(file, &bom)), ar(L"unsigned char g_chinese[] = {");
size_t pos = code.find(L"unsigned char g_chinese[] = {"), end = 0;
if (pos == std::wstring::npos)
return false;
for (int i = 0; i < cont.length(); ++i)
{
unsigned char ch = cont[i];
wchar_t buf[20] = { 0 };
swprintf_s(buf, _countof(buf) - 1, L"0x%02X", ch);
if ((i % 16) == 0)
{
if (i)
ar += L",";
ar += L"\r\n";
}
else if ((i % 8) == 0)
{
if (i)
ar += L",";
ar += L" ";
}
else if (i)
ar += L", ";
ar += buf;
}
ar += L"\r\n};\r\n";
end = code.find(L";", pos);
if (end == std::wstring::npos)
code.erase(pos);
else
code.erase(pos, end - pos + 1);
code.insert(pos, ar);
ar = file;
file_util::force_move_file(file, (ar + L".bak").c_str());
bom = sdk_util::save_file(file, code, bom);
if(bom)
file_util::force_move_file((ar + L".bak").c_str(), file);
return bom == 0;
}
BEGIN_MESSAGE_MAP(CDlgAddWords, CDialogEx)
ON_BN_CLICKED(IDC_BUTTON_BROWSE_HZ, &CDlgAddWords::OnBnClickedButtonBrowseHz)
ON_BN_CLICKED(IDC_BUTTON_BROWSE_HZT, &CDlgAddWords::OnBnClickedButtonBrowseHzt)
ON_BN_CLICKED(IDC_BUTTON_BROWSE_ENG, &CDlgAddWords::OnBnClickedButtonBrowseEng)
ON_BN_CLICKED(IDC_BUTTON_BROWSE_CODE, &CDlgAddWords::OnBnClickedButtonBrowseCode)
ON_BN_CLICKED(IDC_BUTTON_ADD, &CDlgAddWords::OnBnClickedButtonAdd)
ON_BN_CLICKED(IDC_BUTTON_DEL, &CDlgAddWords::OnBnClickedButtonDel)
ON_BN_CLICKED(IDC_BUTTON_CLEAR, &CDlgAddWords::OnBnClickedButtonClear)
ON_BN_CLICKED(IDC_BUTTON_UPDATE, &CDlgAddWords::OnBnClickedButtonUpdate)
ON_WM_DROPFILES()
ON_NOTIFY(NM_DBLCLK, IDC_LIST1, &CDlgAddWords::OnNMDblclkList1)
END_MESSAGE_MAP()
// CDlgAddWords 消息处理程序
void CDlgAddWords::OnDropFiles(HDROP hDropInfo)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
wchar_t path[MAX_PATH] = { 0 };
int cnt = DragQueryFileW(hDropInfo, -1, path, _countof(path) - 1);
for (int i = 0; i < cnt; ++i)
{
int len = DragQueryFileW(hDropInfo, i, path, _countof(path) - 1);
std::wstring file(path, len), ext(file);
STR_FILE_EXTENSION(ext);
if (wcsicmp(ext.c_str(), L"pak") == 0)
{
set_lang_pak_file(file.c_str());
}
else if (wcsicmp(ext.c_str(), L"h") == 0)
{
set_code_file(file.c_str(), false);
}
}
CDialogEx::OnDropFiles(hDropInfo);
}
void CDlgAddWords::OnNMDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
// TODO: 在此添加控件通知处理程序代码
*pResult = 0;
wchar_t text[256] = { 0 };
words_.GetItemText(pNMItemActivate->iItem, 1, text, _countof(text) - 1);
::SetDlgItemTextW(m_hWnd, IDC_EDIT_HZ_WORD, text);
words_.GetItemText(pNMItemActivate->iItem, 2, text, _countof(text) - 1);
::SetDlgItemTextW(m_hWnd, IDC_EDIT_HZT_WORD, text);
words_.GetItemText(pNMItemActivate->iItem, 3, text, _countof(text) - 1);
::SetDlgItemTextW(m_hWnd, IDC_EDIT_ENG_WORD, text);
}
void CDlgAddWords::OnBnClickedButtonBrowseHz()
{
// TODO: 在此添加控件通知处理程序代码
open_pak(936);
}
void CDlgAddWords::OnBnClickedButtonBrowseHzt()
{
// TODO: 在此添加控件通知处理程序代码
open_pak(950);
}
void CDlgAddWords::OnBnClickedButtonBrowseEng()
{
// TODO: 在此添加控件通知处理程序代码
open_pak(20127);
}
void CDlgAddWords::OnBnClickedButtonBrowseCode()
{
// TODO: 在此添加控件通知处理程序代码
file_util::PATHFILE file = { 0 };
if (file_util::browser_file(m_hWnd, &file, L"Header file(*.h)\0\0"))
{
set_code_file(file.path);
}
}
void CDlgAddWords::OnBnClickedButtonAdd()
{
// TODO: 在此添加控件通知处理程序代码
std::wstring hz(sdk_util::get_wnd_text(m_hWnd, IDC_EDIT_HZ_WORD)),
hzt(sdk_util::get_wnd_text(m_hWnd, IDC_EDIT_HZT_WORD)),
eng(sdk_util::get_wnd_text(m_hWnd, IDC_EDIT_ENG_WORD));
wchar_t text[256] = { 0 };
int item = 0;
for (int i = 0; i < words_.GetItemCount(); ++i)
{
words_.GetItemText(i, 1, text, _countof(text) - 1);
if (hz == text)
{
::MessageBoxW(m_hWnd, text, L"词条已经存在", MB_OK | MB_ICONSTOP);
return;
}
}
item = words_.InsertItem(words_.GetItemCount(), std::to_wstring(words_.GetItemCount() + 1).c_str());
words_.SetItemText(item, 1, hz.c_str());
words_.SetItemText(item, 2, hzt.c_str());
words_.SetItemText(item, 3, eng.c_str());
}
void CDlgAddWords::OnBnClickedButtonDel()
{
// TODO: 在此添加控件通知处理程序代码
for (int i = 0; i < words_.GetItemCount(); ++i)
{
if (words_.GetItemState(i, LVIF_STATE) & LVIS_SELECTED)
{
words_.DeleteItem(i--);
}
}
for (int i = 0; i < words_.GetItemCount(); ++i)
words_.SetItemText(i, 0, std::to_wstring(i + 1).c_str());
}
void CDlgAddWords::OnBnClickedButtonClear()
{
// TODO: 在此添加控件通知处理程序代码
words_.DeleteAllItems();
}
void CDlgAddWords::OnBnClickedButtonUpdate()
{
// TODO: 在此添加控件通知处理程序代码
if (words_.GetItemCount() == 0)
{
::MessageBoxW(m_hWnd, L"No words should be added into language packet!", L"None", MB_OK);
return;
}
std::wstring hzf(sdk_util::get_wnd_text(m_hWnd, IDC_EDIT_HZ_PAK)),
hztf(sdk_util::get_wnd_text(m_hWnd, IDC_EDIT_HZT)),
engf(sdk_util::get_wnd_text(m_hWnd, IDC_EDIT_ENGLISH)),
hf(sdk_util::get_wnd_text(m_hWnd, IDC_EDIT_CODE));
bool hzb(file_util::is_file_existing(hzf.c_str())),
hztb(file_util::is_file_existing(hztf.c_str())),
engb(file_util::is_file_existing(engf.c_str())),
hb(file_util::is_file_existing(hf.c_str()));
if (!hzb)
{
::MessageBoxW(m_hWnd, hzf.c_str(), L"File Not Found", MB_OK | MB_ICONSTOP);
GotoDlgCtrl(GetDlgItem(IDC_EDIT_HZ_PAK));
return;
}
if (!hztb)
{
::MessageBoxW(m_hWnd, hztf.c_str(), L"File Not Found", MB_OK | MB_ICONSTOP);
GotoDlgCtrl(GetDlgItem(IDC_EDIT_HZT));
return;
}
if (!engb)
{
::MessageBoxW(m_hWnd, hzf.c_str(), L"File Not Found", MB_OK | MB_ICONSTOP);
GotoDlgCtrl(GetDlgItem(IDC_EDIT_ENGLISH));
return;
}
if (!hb)
{
::MessageBoxW(m_hWnd, hzf.c_str(), L"File Not Found", MB_OK | MB_ICONSTOP);
GotoDlgCtrl(GetDlgItem(IDC_EDIT_CODE));
return;
}
//
std::vector<int> ids;
std::string cont("");
int err = 0;
while (add_words(hzf.c_str(), ids, cont, 936, 1, true))
{
file_util::force_move_file(hzf.c_str(), (hzf + L".bak").c_str());
err = file_util::save_2_file(cont.c_str(), cont.length(), hzf.c_str());
if (err)
{
::MessageBoxW(m_hWnd, hzf.c_str(), L"Write file failed", MB_OK | MB_ICONERROR);
break;
}
// change head file ...
if (update_head_file(hf.c_str(), cont))
{
if (add_words(hztf.c_str(), ids, cont, 950, 2))
{
file_util::force_move_file(hztf.c_str(), (hztf + L".bak").c_str());
err = file_util::save_2_file(cont.c_str(), cont.length(), hztf.c_str());
if (err)
{
::MessageBoxW(m_hWnd, hztf.c_str(), L"Write file failed", MB_OK | MB_ICONERROR);
break;
}
if (add_words(engf.c_str(), ids, cont, 20127, 3))
{
file_util::force_move_file(engf.c_str(), (engf + L".bak").c_str());
err = file_util::save_2_file(cont.c_str(), cont.length(), engf.c_str());
}
}
else
err = -2;
}
else
{
err = -1;
}
break;
}
if (err == 0)
::MessageBoxW(m_hWnd, L"All languages have updated!", L"Congratulation", MB_OK | MB_ICONINFORMATION);
else
{
}
}

View File

@ -0,0 +1,115 @@
#pragma once
#include "afxdialogex.h"
// CDlgAddWords 对话框
#include <file/file_util.h>
#include <coding/coding.h>
#include <string>
#include <vector>
namespace sdk_util
{
typedef struct _lang_id
{
int id;
int cp;
std::string utf8;
bool operator==(int i)
{
return id == i;
}
bool operator<(struct _lang_id& r)
{
return id < r.id;
}
}LANGID;
typedef struct _lang_id_w
{
int id;
std::wstring unic;
bool operator==(int i)
{
return id == i;
}
bool operator==(const wchar_t* text)
{
return unic == text;
}
bool operator<(struct _lang_id& r)
{
return id < r.id;
}
}LANGIDW;
INTER_MODULE_CALLBACK(got_str);
INTER_MODULE_CALLBACK(got_wstr);
uint32_t make_string_id(const wchar_t* str, bool(*is_repeat)(uint32_t, void*), void* param);
void trim_left(std::wstring& str);
void trim_right(std::wstring& str);
unsigned pick_number(const wchar_t* str, const wchar_t** end, int type);
void convert_unicode(std::wstring& str);
LANGID* lang_info_from_cp(int cp);
LANGID* lang_info_from_ID(int id);
LANGID* lang_info_from_name(const char* utf8);
int save_2_lang_pak(HWND owner, std::vector<LANGID>& items, int cp = 936, std::string* raw_data = NULL, bool to_file = true);
bool parse_pak_digest(uint8_t* data, int* id);
bool parse_pak(uint8_t* data, std::vector<LANGIDW>& items);
bool load_lang_pak(const wchar_t* file, std::vector<LANGIDW>& items, int* id = NULL);
std::wstring get_wnd_text(HWND wnd);
std::wstring get_wnd_text(HWND dlg, UINT id);
enum
{
BOM_ANSI = 0,
BOM_UTF8,
BOM_UNICODE,
};
std::wstring load_file(const wchar_t* file, int* bom = NULL);
int save_file(const wchar_t* file, std::wstring& cont, int bom = BOM_UNICODE);
}
class CDlgAddWords : public CDialogEx
{
DECLARE_DYNAMIC(CDlgAddWords)
public:
CDlgAddWords(CWnd* pParent = nullptr); // 标准构造函数
virtual ~CDlgAddWords();
// 对话框数据
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_BATCH_ADD_LANG };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
virtual BOOL OnInitDialog();
void open_pak(int lan_id);
void set_lang_pak_file(const wchar_t* file, int lan_id = 0);
void set_code_file(const wchar_t* file, bool tip = true);
bool add_words(const wchar_t* pak_file, std::vector<int>& ids, std::string& cont, int lan_id, int src_col, bool init_id = false);
bool update_head_file(const wchar_t* file, const std::string& cont);
DECLARE_MESSAGE_MAP()
std::vector<sdk_util::LANGIDW> lan_hz_;
std::vector<sdk_util::LANGIDW> lan_hzt_;
std::vector<sdk_util::LANGIDW> lan_eng_;
public:
afx_msg void OnBnClickedButtonBrowseHz();
afx_msg void OnBnClickedButtonBrowseHzt();
afx_msg void OnBnClickedButtonBrowseEng();
afx_msg void OnBnClickedButtonBrowseCode();
afx_msg void OnBnClickedButtonAdd();
afx_msg void OnBnClickedButtonDel();
afx_msg void OnBnClickedButtonClear();
afx_msg void OnBnClickedButtonUpdate();
CListCtrl words_;
afx_msg void OnDropFiles(HDROP hDropInfo);
afx_msg void OnNMDblclkList1(NMHDR* pNMHDR, LRESULT* pResult);
};

View File

@ -0,0 +1,78 @@
// DlgInput.cpp : implementation file
//
#include "stdafx.h"
#include "hgjson.h"
#include "DlgInput.h"
#include "afxdialogex.h"
// CDlgInput dialog
IMPLEMENT_DYNAMIC(CDlgInput, CDialogEx)
CDlgInput::CDlgInput(CWnd* pParent /*=NULL*/)
: CDialogEx(CDlgInput::IDD, pParent)
, value_(_T("")), type_(INPUT_FOR_NAME)
{
}
CDlgInput::~CDlgInput()
{
}
void CDlgInput::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, value_);
}
BOOL CDlgInput::OnInitDialog()
{
CDialogEx::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
return TRUE; // return TRUE unless you set the focus to a control
}
BEGIN_MESSAGE_MAP(CDlgInput, CDialogEx)
ON_BN_CLICKED(IDOK, &CDlgInput::OnBnClickedOk)
END_MESSAGE_MAP()
// CDlgInput message handlers
void CDlgInput::OnBnClickedOk()
{
// TODO: Add your control notification handler code here
UpdateData();
if (value_.IsEmpty())
{
::MessageBoxW(m_hWnd, L"ÇëÊäÈëÄÚÈÝ", L"Error", MB_OK | MB_ICONSTOP);
GotoDlgCtrl(GetDlgItem(IDC_EDIT1));
return;
}
if (type_ == INPUT_FOR_NAME)
{
wchar_t text[128] = { 0 };
::GetDlgItemTextW(m_hWnd, IDC_EDIT1, text, _countof(text) - 1);
for (size_t i = 0; i < used_names_.size(); ++i)
{
if (used_names_[i] == text)
{
std::wstring t(used_names_[i] + L" is already used, choose another name, plz.");
::MessageBoxW(m_hWnd, t.c_str(), L"Sorry", MB_OK);
return;
}
}
}
CDialogEx::OnOK();
}

View File

@ -0,0 +1,31 @@
#pragma once
// CDlgInput dialog
#include <string>
#include <vector>
class CDlgInput : public CDialogEx
{
DECLARE_DYNAMIC(CDlgInput)
public:
CDlgInput(CWnd* pParent = NULL); // standard constructor
virtual ~CDlgInput();
// Dialog Data
enum { IDD = IDD_DIALOG1 };
std::vector<std::wstring> used_names_;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual BOOL OnInitDialog();
DECLARE_MESSAGE_MAP()
public:
CString value_;
enum { INPUT_FOR_NAME, INPUT_FOR_STRING, };
int type_;
afx_msg void OnBnClickedOk();
};

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,174 @@
#pragma once
// CDlgInput dialog
#include <string>
#include <vector>
#include <utility/known_file.h>
#include <coding/coding.h>
#include <file/file_util.h>
#include <sane/sane_ex.h>
namespace coding
{
typedef struct _clp_d
{
bool file;
std::wstring cont;
}CLPD, * LPCLPD;
INTER_MODULE_CALLBACK(get_string);
INTER_MODULE_CALLBACK(get_wstring);
INTER_MODULE_CALLBACK(get_clipboard_content);
std::wstring name_from_depend_exp(const std::wstring& depend_exp);
};
// Group: 基本设置;图像处理;送纸方式;高级设置;
//
// Cat: 图像处理;
//
class CDlgOptJson : public CDialogEx
{
DECLARE_DYNAMIC(CDlgOptJson)
CComboBox group_;
CComboBox cat_;
CComboBox affect_;
CComboBox unit_;
CComboBox type_;
CComboBox range_;
CComboBox def_val_;
CComboBox depend_;
CComboBox parent_;
CComboBox logic_;
CComboBox lower_;
CComboBox upper_;
CComboBox export_type_;
CListBox depends_;
CTreeCtrl tree_;
CMenu tree_menu_;
CImageList tree_img_;
std::wstring get_item_text(UINT id);
bool is_button_check(UINT id);
void set_button_check(UINT id, bool check);
public:
CDlgOptJson(CWnd* pParent = NULL); // standard constructor
virtual ~CDlgOptJson();
// Dialog Data
enum { IDD = IDD_NEW_JSON };
typedef struct _sane_opt_json
{
std::wstring name;
std::wstring title;
std::wstring desc;
std::wstring group;
std::wstring category;
std::wstring affect;
std::wstring unit;
std::wstring type;
std::string def_val;
std::wstring range_type;
std::vector<std::string> range;
std::wstring depend_oper;
std::vector<std::wstring> depends;
int ver;
int pos;
bool readonly;
bool open;
bool enable;
struct _sane_opt_json()
{
init(this);
}
struct _sane_opt_json(known_file_util::IJsonW* jsn)
{
if (!from_json(jsn))
{
init(this);
}
}
static void init(struct _sane_opt_json* opt)
{
opt->name = opt->title = opt->desc = L"";
opt->group = L"\u57FA\u672C\u8BBE\u7F6E";
opt->category = opt->unit = opt->affect = opt->depend_oper = opt->range_type = L"none";
opt->range.clear();
opt->depends.clear();
opt->def_val = "";
opt->type = L"int";
opt->ver = 1;
opt->pos = -1;
opt->readonly = false;
opt->open = true;
opt->enable = true;
}
static void affect_str(int& val, std::wstring& str, bool to_str)
{
static std::wstring affect_desc[] = { L"none", L"其它属性", L"图像参数", L"属性+参数" };
if (to_str)
{
int ind = val >> 1;
if (ind >= 0 && ind < _countof(affect_desc))
str = affect_desc[ind];
else
str = affect_desc[0];
}
else
{
val = 0;
for (int i = 0; i < _countof(affect_desc); ++i)
{
if (str == affect_desc[i])
val = i << 1;
}
}
}
known_file_util::IJsonW* to_json(void);
bool from_json(known_file_util::IJsonW* jsn);
}SANEOPT;
std::vector<SANEOPT> opts_;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual BOOL OnInitDialog();
void from_ui(SANEOPT& sop);
void to_ui(const SANEOPT& sop);
HTREEITEM insert_to_tree(const SANEOPT& opt);
void delete_from_tree(const wchar_t* name = NULL);
bool load_from_file(const wchar_t* path_file);
bool load_from_json_text(const wchar_t* txt, std::wstring* err_msg = NULL);
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnCbnDataTypeSelchange();
afx_msg void OnCbnRangeSelchange();
afx_msg void OnCbnDependSelchange();
afx_msg void OnCbnParentSelchange();
afx_msg void OnCbnLogicSelchange();
afx_msg void OnCbnSelchange();
afx_msg void OnPaste();
afx_msg void OnBnClickedButtonModify();
afx_msg void OnBnClickedButtonAdd();
afx_msg void OnTvnSelchangedTree2(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnNMRClickTree2(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnTvnSelchangingTree2(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnTreeLoadfile();
afx_msg void OnTreeLoadclipboard();
afx_msg void OnLbnDblclkListDepend();
afx_msg void OnBnClickedButtonSet();
afx_msg void OnTreeDelitem();
afx_msg void OnBnClickedButtonExport();
};

View File

@ -0,0 +1,217 @@
// DlgRange.cpp: 实现文件
//
#include "stdafx.h"
#include "hgjson.h"
#include "DlgRange.h"
#include "afxdialogex.h"
// CDlgRange 对话框
IMPLEMENT_DYNAMIC(CDlgRange, CDialogEx)
CDlgRange::CDlgRange(bool is_lst, CWnd* pParent /*=nullptr*/)
: CDialogEx(IDD_RANGE, pParent)
, is_list_(is_lst)
{
}
CDlgRange::~CDlgRange()
{
}
std::wstring CDlgRange::get_item_text(UINT id)
{
int l = GetDlgItem(id)->GetWindowTextLengthW();
wchar_t* buf = new wchar_t[l + 4];
l = GetDlgItem(id)->GetWindowTextW(buf, l + 2);
buf[l] = 0;
std::wstring ret(buf);
delete[] buf;
return std::move(ret);
}
void CDlgRange::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LIST1, list_);
}
BOOL CDlgRange::OnInitDialog()
{
CDialogEx::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
list_.SetExtendedStyle(list_.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_INFOTIP);
list_.InsertColumn(0, TEXT("Value lists"), 0, 177);
list_.InsertColumn(1, TEXT("Default"), 0, 48);
GetDlgItem(IDC_EDIT_VAL)->EnableWindow(is_list_);
list_.EnableWindow(is_list_);
GetDlgItem(IDC_BUTTON_ADD)->EnableWindow(is_list_);
GetDlgItem(IDC_EDIT_FROM)->EnableWindow(!is_list_);
GetDlgItem(IDC_EDIT_TO)->EnableWindow(!is_list_);
GetDlgItem(IDC_EDIT_STEP)->EnableWindow(!is_list_);
GetDlgItem(IDC_EDIT_INIT2)->EnableWindow(!is_list_);
if (is_list_)
{
for (auto& v: vals_)
{
int ind = list_.InsertItem(list_.GetItemCount(), v.c_str());
if (v == init_)
list_.SetItemText(ind, 1, L"yes");
}
}
else if(vals_.size() == 3)
{
SetDlgItemTextW(IDC_EDIT_FROM, vals_[0].c_str());
SetDlgItemTextW(IDC_EDIT_TO, vals_[1].c_str());
SetDlgItemTextW(IDC_EDIT_STEP, vals_[2].c_str());
SetDlgItemTextW(IDC_EDIT_INIT2, init_.c_str());
}
return TRUE; // return TRUE unless you set the focus to a control
}
BEGIN_MESSAGE_MAP(CDlgRange, CDialogEx)
ON_BN_CLICKED(IDC_BUTTON1, &CDlgRange::OnBnClickedButton1)
ON_BN_CLICKED(IDOK, &CDlgRange::OnBnClickedOk)
ON_NOTIFY(NM_DBLCLK, IDC_LIST1, &CDlgRange::OnNMDblclkList1)
END_MESSAGE_MAP()
// CDlgRange 消息处理程序
void CDlgRange::OnBnClickedButton1()
{
// TODO: 在此添加控件通知处理程序代码
std::wstring val(get_item_text(IDC_EDIT_VAL));
for (int i = 0; i < list_.GetItemCount(); ++i)
{
wchar_t buf[25] = { 0 };
list_.GetItemText(i, 0, buf, _countof(buf) - 1);
if (val == buf)
{
list_.SetItemState(i, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);
list_.SetSelectionMark(i);
return;
}
}
list_.InsertItem(list_.GetItemCount(), val.c_str());
}
void CDlgRange::OnBnClickedOk()
{
// TODO: 在此添加控件通知处理程序代码
vals_.clear();
if (is_list_)
{
if (init_.empty())
{
MessageBox(TEXT("请确定默认值!双击列表中的某项进行选择。 "), TEXT("No Default"), MB_OK);
return;
}
if(list_.GetItemCount() == 0)
{
MessageBox(TEXT("没有输入有效的值列表"), TEXT("No Value"), MB_OK);
return;
}
for (int i = 0; i < list_.GetItemCount(); ++i)
{
wchar_t buf[256] = { 0 };
list_.GetItemText(i, 0, buf, _countof(buf) - 1);
vals_.push_back(buf);
}
}
else
{
std::wstring val(get_item_text(IDC_EDIT_FROM));
if (val.empty())
{
MessageBox(TEXT("没有输入有效初始值"), TEXT("No Value"), MB_OK);
GotoDlgCtrl(GetDlgItem(IDC_EDIT_FROM));
return;
}
vals_.push_back(val);
val = get_item_text(IDC_EDIT_TO);
if (val.empty())
{
MessageBox(TEXT("没有输入有效终止值"), TEXT("No Value"), MB_OK);
GotoDlgCtrl(GetDlgItem(IDC_EDIT_TO));
return;
}
vals_.push_back(val);
val = get_item_text(IDC_EDIT_STEP);
if (val.empty())
{
MessageBox(TEXT("没有输入有效步长值"), TEXT("No Value"), MB_OK);
GotoDlgCtrl(GetDlgItem(IDC_EDIT_TO));
return;
}
vals_.push_back(val);
init_ = get_item_text(IDC_EDIT_INIT2);
if (init_.empty())
{
MessageBox(TEXT("没有输入有效默认值"), TEXT("No Value"), MB_OK);
GotoDlgCtrl(GetDlgItem(IDC_EDIT_INIT2));
return;
}
}
CDialogEx::OnOK();
}
void CDlgRange::OnNMDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
// TODO: 在此添加控件通知处理程序代码
*pResult = 0;
POINT pos = { 0 };
int item = -1;
GetCursorPos(&pos);
list_.ScreenToClient(&pos);
item = list_.HitTest(pos);
if (item != -1)
{
wchar_t buf[256] = { 0 };
int ret = 0;
list_.GetItemText(item, 0, buf, _countof(buf) - 1);
ret = ::MessageBoxW(m_hWnd, L"是否将该项设置为默认值?\r\nYes: 是\r\nNo: 删除该项\r\nCancel: 放弃操作", buf, MB_YESNOCANCEL);
if (ret == IDYES)
{
init_ = buf;
for (int i = 0; i < list_.GetItemCount(); ++i)
{
list_.SetItemText(i, 1, i == item ? L"yes" : L"");
}
}
else if (ret == IDNO)
{
list_.DeleteItem(item);
}
}
}

View File

@ -0,0 +1,38 @@
#pragma once
// CDlgRange 对话框
#include <string>
#include <vector>
class CDlgRange : public CDialogEx
{
DECLARE_DYNAMIC(CDlgRange)
std::wstring get_item_text(UINT id);
public:
CDlgRange(bool is_lst, CWnd* pParent = nullptr); // 标准构造函数
virtual ~CDlgRange();
// 对话框数据
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_RANGE };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
virtual BOOL OnInitDialog();
DECLARE_MESSAGE_MAP()
public:
std::vector<std::wstring> vals_;
std::wstring init_;
bool is_list_;
afx_msg void OnBnClickedButton1();
CListCtrl list_;
afx_msg void OnBnClickedOk();
afx_msg void OnNMDblclkList1(NMHDR* pNMHDR, LRESULT* pResult);
};

View File

@ -0,0 +1,886 @@
// DlgInput.cpp : implementation file
//
#include "stdafx.h"
#include "hgjson.h"
#include "DlgTwain.h"
#include "afxdialogex.h"
#include <algorithm>
#include <file/file_util.h>
#include <coding/coding.h>
namespace util
{
enum
{
BOM_ANSI,
BOM_UTF8,
BOM_UNICODE,
};
static INTER_MODULE_CALLBACK(got_str)
{
*(std::string*)param += std::string(data, len);
return inter_module_data::SET_RESULT_CONTINUE;
}
static INTER_MODULE_CALLBACK(got_wstr)
{
*(std::wstring*)param += std::wstring((const wchar_t*)data, len / 2);
return inter_module_data::SET_RESULT_CONTINUE;
}
static bool is_space(wchar_t ch)
{
return ch == L' ' || ch == L'\t' || ch == L'\r' || ch == L'\n';
}
static bool is_var_char(wchar_t ch, bool allow_num)
{
return ch == L'_' ||
(ch >= L'0' && ch <= L'9' && allow_num) ||
(ch >= L'a' && ch <= L'z') ||
(ch >= L'A' && ch <= L'Z');
}
static bool skip_space(const wchar_t** str)
{
const wchar_t* bgn = *str;
while (is_space(str[0][0]))
(*str)++;
return *str > bgn;
}
static void to_line_head(const wchar_t** str)
{
while (str[0][0] != L'\n')
(*str)--;
}
static void erase_multiline_comment(std::wstring& cont)
{
for (int i = 0; i < cont.length(); ++i)
{
if (cont[i] == L'/')
{
if (cont[i + 1] == L'/')
{
std::wstring val(L"");
int next = 0;
coding_util::pick_line(cont.c_str() + i, got_wstr, &val, &next);
i += next;
}
else if (cont[i + 1] == L'*')
{
size_t pos = cont.find(L"*/", i + 2);
if (pos++ == std::wstring::npos)
{
cont.erase(i);
break;
}
else
cont.erase(i, pos - i + 1);
}
}
}
}
static void transform_hz(std::wstring& hz)
{
int prev = -1;
std::string inner("");
for (int i = 0; i < hz.length() - 3; ++i)
{
if (hz[i] == L'\\')
{
if (hz[i + 1] == L'u')
{
}
else if (hz[i + 1] == L'x')
{
}
else if (hz[i + 1] >= L'0' && hz[i + 1] <= L'7')
{
if (hz[i + 2] >= L'0' && hz[i + 2] <= L'7' &&
hz[i + 3] >= L'0' && hz[i + 3] <= L'7')
{
if (prev == -1)
prev = i;
char ch = (hz[i + 1] - L'0') * 64 + (hz[i + 2] - L'0') * 8 + hz[i + 3] - L'0';
inner.append(1, ch);
i += 3;
}
}
}
else
{
if (inner.length())
{
std::wstring trans(L"");
coding_util::utf8_2_unicode(inner.c_str(), got_wstr, &trans);
hz.replace(prev, i - prev, trans);
i = prev + trans.length();
}
prev = -1;
inner = "";
}
}
if (inner.length())
{
std::wstring trans(L"");
coding_util::utf8_2_unicode(inner.c_str(), got_wstr, &trans);
hz.replace(prev, hz.length() - prev, trans);
}
}
static std::wstring now(void)
{
time_t t = time(NULL);
tm* pt = localtime(&t);
wchar_t buf[40] = { 0 };
swprintf_s(buf, _countof(buf) - 1, L"%04d-%02d-%02d %02d:%02d:%02d",
pt->tm_year + 1900, pt->tm_mon + 1, pt->tm_mday, pt->tm_hour, pt->tm_min, pt->tm_sec);
return buf;
}
static std::wstring get_text(HWND wnd)
{
int len = GetWindowTextLengthW(wnd);
wchar_t * buf = new wchar_t[len + 128];
std::wstring ret(L"");
len = ::GetWindowTextW(wnd, buf, len + 20);
buf[len] = 0;
ret = buf;
delete[] buf;
return std::move(ret);
}
static void append_log(const wchar_t* log, HWND edit, bool scroll_last)
{
std::wstring text(std::move(get_text(edit))), cur(now() + L": "), str(log), space(L"");
size_t pos = str.find(L"\r\n");
space.append(cur.length() * 2, L' ');
while (pos != std::wstring::npos && pos < str.length() - 2)
{
str.insert(pos + 2, space);
pos = str.find(L"\r\n", pos + space.length() + 2);
}
text += cur + str;
::SetWindowTextW(edit, text.c_str());
if (scroll_last)
::SendMessage(edit, EM_LINESCROLL, 0, ::SendMessageW(edit, EM_GETLINECOUNT, 0, 0));
else
::SendMessageW(edit, EM_LINESCROLL, 0, (LPARAM)::GetPropW(edit, L"stop_line"));
}
static std::wstring load_file(const wchar_t* file, int *bom)
{
std::wstring cont(L"");
std::string raw("");
file_util::load_file(file, got_str, &raw);
if (raw.empty())
return false;
if (bom)
*bom = coding_util::bom::is_unicode(raw.c_str(), NULL) ? BOM_UNICODE : (coding_util::bom::is_utf8(raw.c_str()) ? BOM_UTF8 : BOM_ANSI);
coding_util::bom::to_unicode(raw.c_str(), raw.length(), got_wstr, &cont);
return std::move(cont);
}
static bool save_file(const wchar_t* file, const wchar_t* cont, int bom, std::wstring* bak = NULL)
{
std::string raw("");
if (bom == BOM_UNICODE)
coding_util::bom::from_unicode(cont, lstrlenW(cont) * 2, got_str, &raw);
else if (bom == BOM_UTF8)
{
std::string utf8("");
coding_util::unicode_2_utf8(cont, got_str, &utf8);
coding_util::bom::from_utf8(utf8.c_str(), utf8.length(), got_str, &raw);
}
else
coding_util::unicode_2_ansi(cont, got_str, &raw);
if (bak)
{
*bak = file;
*bak += L".bak";
file_util::force_copy_file(file, bak->c_str());
}
return file_util::save_2_file(raw.c_str(), raw.length(), file) == 0;
}
std::string u2a(const wchar_t* u, bool to_utf8 = false)
{
std::string a("");
if (to_utf8)
coding_util::unicode_2_utf8(u, got_str, &a);
else
coding_util::unicode_2_ansi(u, got_str, &a);
return std::move(a);
}
std::wstring a2u(const char* a, bool from_utf8 = false)
{
std::wstring u(L"");
if (from_utf8)
coding_util::utf8_2_unicode(a, got_wstr, &u);
else
coding_util::ansi_2_unicode(a, got_wstr, &u);
return std::move(u);
}
static std::wstring get_sane_opt_title(const wchar_t* key, const std::wstring& cont)
{
size_t pos = cont.find(key);
std::wstring title(L"");
while (pos != std::wstring::npos)
{
if (pos)
{
int check = pos - 1;
if (cont[check] == L' ' || cont[check] == L'\t')
{
const wchar_t* l = cont.c_str() + check;
to_line_head(&l);
skip_space(&l);
if (wcsstr(l, L"#define") == l)
{
l += 7;
skip_space(&l);
if (wcsstr(l, key) == l)
{
l += lstrlenW(key);
if (skip_space(&l) && *l++ == L'\"')
{
while (*l != L'\r' && *l != L'\n' && *l != L'\"' && *l != 0)
title.append(1, *l++);
transform_hz(title);
break;
}
}
}
}
}
pos += lstrlenW(key);
pos = cont.find(key, pos);
}
return std::move(title);
}
static void get_sane_opts(const wchar_t* file, std::vector<SANEOPT>& opts)
{
std::wstring tf(file), name(L"\r\n"), title(L"\r\n")
, pre_n(L"SANE_STD_OPT_NAME_"), pre_t(L"OPTION_TITLE_"), define(L"#define")
, line(L""), val(L"");
std::string bom("");
SANEOPT opt;
int off = 0, next = 0;
STR_PARENT_FOLDER(tf);
tf += L"\\sane_option_definitions.h";
STR_TO_ABSOLUTE_PATH(tf);
file_util::load_file(file, got_str, &bom);
if (bom.empty())
return;
coding_util::bom::to_unicode(bom.c_str(), bom.length(), got_wstr, &name);
erase_multiline_comment(name);
bom = "";
file_util::load_file(tf.c_str(), got_str, &bom);
if (bom.empty())
return;
coding_util::bom::to_unicode(bom.c_str(), bom.length(), got_wstr, &title);
bom = "";
erase_multiline_comment(title);
// search ...
coding_util::pick_line(name.c_str(), got_wstr, &line, &next);
while (line.length() || next)
{
size_t pos = line.find(define);
if (pos == 0 && line.length() > define.length() && is_space(line[define.length()]))
{
const wchar_t* str = line.c_str() + define.length(), * bgn = NULL;;
util::skip_space(&str);
if (wcsstr(str, pre_n.c_str()) == str)
{
bgn = str;
str += pre_n.length();
while (is_var_char(*str, true))
str++;
opt.name_key = std::wstring(bgn, str - bgn);
if (util::skip_space(&str) && *str++ == L'\"')
{
bgn = str;
while (*str != L'\"')
str++;
opt.name = std::wstring(bgn, str - bgn);
str++;
util::skip_space(&str);
if (wcsstr(str, L"//") == str)
{
str += 2;
util::skip_space(&str);
if (wcsstr(str, pre_t.c_str()) == str)
{
bgn = str;
str += pre_t.length();
while (is_var_char(*str, true))
str++;
opt.title_key = std::wstring(bgn, str - bgn);
opt.title = std::move(get_sane_opt_title(opt.title_key.c_str(), title));
opts.push_back(opt);
}
}
}
}
}
off += next;
line = L"";
coding_util::pick_line(name.c_str() + off, got_wstr, &line, &next);
}
}
static bool pick_option_id_function(std::wstring& code, int* off = NULL, const wchar_t* api_decl = L"scanner::init_options_id(void)", const wchar_t* ret = L"int")
{
std::wstring api(api_decl);
size_t pos = code.find(api);
const wchar_t* l = NULL;
while (pos != std::wstring::npos)
{
l = code.c_str() + pos;
to_line_head(&l);
skip_space(&l);
if (wcsstr(l, ret) == l)
{
l += lstrlenW(ret);
if (skip_space(&l))
{
if (wcsstr(l, api.c_str()) == l)
{
int bgn = 0, end = 0;
coding_util::pick_value(l, L"{", L"}", &bgn, &end);
if (end > bgn)
{
api = std::wstring(l + bgn, end - bgn + 1);
if (off)
*off = l + bgn - code.c_str();
code = std::move(api);
return true;
}
}
}
}
pos += api.length();
pos = code.find(api, pos);
}
return false;
}
static bool pick_twain_ex_enum(std::wstring& code, int* start = NULL)
{
// enum CapTypeEx : unsigned short {
size_t pos = code.find(L"enum");
while (pos != std::wstring::npos)
{
const wchar_t* l = code.c_str() + pos;
to_line_head(&l);
skip_space(&l);
if (wcsstr(l, L"enum") == l)
{
l += 4;
if (skip_space(&l))
{
if (wcsstr(l, L"CapTypeEx") == l)
{
int bgn = 0, end = 0;
coding_util::pick_value(l, L"{", L"}", &bgn, &end);
if (start)
*start = l + bgn - code.c_str();
code = std::move(std::wstring(l + bgn, end - bgn + 1));
return true;
}
}
}
pos = code.find(L"enum", pos + 4);
}
return false;
}
static bool get_twain_id(const std::wstring& idtext, std::vector<OPTUSED>& used)
{
std::wstring pre(L"CAP_EX_SANE_"), line(L""), key(L"");
OPTUSED ou;
int off = 0, next = 0, id = 0x8801;
coding_util::pick_line(idtext.c_str(), got_wstr, &line, &next);
while (!line.empty() || next)
{
const wchar_t* bgn = line.c_str(), * l = bgn;
skip_space(&l);
if (wcsstr(l, pre.c_str()) == l)
{
l += pre.length();
bgn = l;
while (is_var_char(*l, true))
l++;
key = std::wstring(bgn, l - bgn);
ou.id_key = "";
coding_util::unicode_2_ansi(key.c_str(), got_str, &ou.id_key);
ou.id = id++;
used.push_back(ou);
}
off += next;
line.clear();
coding_util::pick_line(idtext.c_str() + off, got_wstr, &line, &next);
}
std::sort(used.begin(), used.end());
return true;
}
static void get_used_opts(const wchar_t* file, std::vector<OPTUSED>& used)
{
std::wstring key(L""), id(L""), idf(file), line(L""), pre_nk(L"SANE_STD_OPT_NAME_"), pre_ik(L"CAP_EX_SANE_"), setoid(L"SET_OPT_ID(");
std::string bom("");
OPTUSED ou;
int off = 0, next = 0;
STR_PARENT_FOLDER(idf);
idf += L"\\..\\..\\code_twain\\twain\\twain\\huagaods.cpp";
STR_TO_ABSOLUTE_PATH(idf);
file_util::load_file(file, got_str, &bom);
if (bom.empty())
return;
coding_util::bom::to_unicode(bom.c_str(), bom.length(), got_wstr, &key);
erase_multiline_comment(key);
bom = "";
file_util::load_file(idf.c_str(), got_str, &bom);
if (bom.empty())
return;
coding_util::bom::to_unicode(bom.c_str(), bom.length(), got_wstr, &id);
erase_multiline_comment(id);
get_twain_id(id, used);
if (!pick_option_id_function(key) || !pick_twain_ex_enum(id))
return;
bom = "";
coding_util::pick_line(key.c_str(), got_wstr, &line, &next);
while (!line.empty() || next > 0)
{
const wchar_t* l = line.c_str(), * bgn = NULL;
skip_space(&l);
if (wcsstr(l, L"else") == l)
{
l += 4;
skip_space(&l);
}
if (wcsstr(l, setoid.c_str()) == l)
{
l += setoid.length();
bgn = l;
if (is_var_char(*l++, false))
{
while (is_var_char(*l, true))
l++;
ou.id_key = "";
coding_util::unicode_2_ansi(std::wstring(bgn, l - bgn).c_str(), got_str, &ou.id_key);
skip_space(&l);
if (*l++ == L',')
{
skip_space(&l);
bgn = l;
if (is_var_char(*l++, false))
{
while (is_var_char(*l, true))
l++;
ou.name_key = std::wstring(bgn, l - bgn);
std::vector<OPTUSED>::iterator it = std::find(used.begin(), used.end(), ou.id_key.c_str());
if (it != used.end())
it->name_key = std::move(L"SANE_STD_OPT_NAME_" + ou.name_key);
}
}
}
}
off += next;
line = L"";
coding_util::pick_line(key.c_str() + off, got_wstr, &line, &next);
}
}
static bool add_2_huagaods_cpp(const wchar_t* file, const SANEOPT& sane, const OPTUSED& twain, std::wstring* msg)
{
int off = 0, next = 0, bom = BOM_ANSI;
std::wstring cont(std::move(load_file(file, &bom))), line(L""), lead(L"CAP_EX_SANE_");
if (cont.empty())
{
if (msg)
*msg = L"File 'huagaods.cpp' is not found or empty.";
return false;
}
line = cont;
if (pick_twain_ex_enum(line, &off))
{
size_t pos = line.rfind(L',');
const wchar_t* l = line.c_str() + pos, * bgn = NULL;
to_line_head(&l);
bgn = ++l;
skip_space(&l);
std::wstring en(bgn, l - bgn);
en += lead + a2u(twain.id_key.c_str()) + L",\t\t// " + now() + L" " + sane.title;
lead = line;
lead.insert(pos + 1, L"\r\n" + en);
cont.replace(off, line.length(), lead);
line = cont;
if (pick_option_id_function(line, &off, L"huagao_ds::init_support_caps_ex(void)", L"void"))
{
pos = line.rfind(L';');
l = line.c_str() + pos;
to_line_head(&l);
l++;
bgn = l;
skip_space(&l);
en = std::wstring(bgn, l - bgn);
en += L"ADD_SANE_CAP(";
en += a2u(twain.id_key.c_str());
en += L");\r\n";
lead = line + en;
cont.replace(off, line.length(), lead);
if (save_file(file, cont.c_str(), bom, &line))
{
if (msg)
*msg += std::wstring(L"Changed: ") + file + L"\r\n";
return true;
}
else if (msg)
*msg = L"Failed to save changes into file 'huagaods.cpp'.";
if (file_util::is_file_existing(line.c_str()))
file_util::force_move_file(line.c_str(), file);
}
else if (msg)
{
*msg = L"Failed to find function 'huagao_ds::init_support_caps_ex(void)' in huagaods.cpp.";
}
}
else if (msg)
{
*msg = L"Failed to find 'enum CapTypeEx' in huagaods.cpp.";
}
return false;
}
static bool add_2_scanner_codes(const wchar_t* cpp, const SANEOPT& sane, const OPTUSED& twain, std::wstring* msg)
{
int bom_c = BOM_ANSI, bom_h = BOM_ANSI;
std::wstring hf(cpp), code_c(load_file(cpp, &bom_c)), code_h(L""), tag(L"// SANE options ID ..."), val(L""), hbak(L""), cbak(L"");
size_t pos = hf.rfind(L'.');
const wchar_t *l = NULL, *bgn = NULL;
if (code_c.empty())
{
if (msg)
*msg = std::wstring(L"File '") + cpp + L"' is not found or empty.";
return false;
}
hf.erase(pos);
hf += L".h";
code_h = std::move(load_file(hf.c_str(), &bom_h));
if (code_h.empty())
{
if (msg)
*msg = std::wstring(L"File '") + hf + L"' is not found or empty.";
return false;
}
pos = code_h.find(tag);
if (pos == std::wstring::npos)
{
if (msg)
*msg = L"Cannot find tag '" + tag + L"' in file " + hf;
return false;
}
bgn = l = code_h.c_str() + pos;
to_line_head(&bgn);
bgn++;
val = L"\r\n" + std::wstring(bgn, l - bgn) + L"SANE_OPTION_ID(" + a2u(twain.id_key.c_str()) + L");";
code_h.insert(pos + tag.length(), val + L"\t\t// " + now() + L" " + sane.title);
if (save_file(hf.c_str(), code_h.c_str(), bom_h, &hbak))
{
code_h.clear();
pos = code_c.find(L"SANE_OPTION_ID_IMPLEMENT(");
if (pos != std::wstring::npos)
{
int off = 0;
val = L"SANE_OPTION_ID_IMPLEMENT(" + a2u(twain.id_key.c_str()) + L")\r\n";
code_c.insert(pos, val);
code_h = code_c;
if (pick_option_id_function(code_h, &off))
{
pos = code_h.find(L"op_id++;");
if (pos != std::wstring::npos)
{
l = bgn = code_h.c_str() + pos;
to_line_head(&bgn);
bgn++;
tag = sane.name_key;
if (tag.find(L"SANE_STD_OPT_NAME_") == 0)
tag.erase(0, lstrlenW(L"SANE_STD_OPT_NAME_"));
val = std::wstring(bgn, l - bgn) + L"else SET_OPT_ID(" + a2u(twain.id_key.c_str()) + L", " + tag + L", extension_none)\r\n";
off += bgn - code_h.c_str();
code_c.insert(off, val);
if (save_file(cpp, code_c.c_str(), bom_c, &cbak))
{
std::wstring s2t(hf);
STR_PARENT_FOLDER(s2t);
s2t += L"\\s2t_api.h";
code_h = std::move(load_file(s2t.c_str(), &bom_h));
if (!code_h.empty())
{
tag = L"// SANE options ID ...";
pos = code_h.find(tag);
if (pos == std::wstring::npos)
{
if (msg)
*msg = L"Cannot find tag '// SANE options ID ...' in file " + s2t;
return false;
}
bgn = l = code_h.c_str() + pos;
to_line_head(&bgn);
bgn++;
val = L"\r\n" + std::wstring(bgn, l - bgn) + L"SANE_OPTION_ID_API(" + a2u(twain.id_key.c_str()) + L");";
code_h.insert(pos + tag.length(), val + L"\t\t// " + now() + L" " + sane.title);
if (save_file(s2t.c_str(), code_h.c_str(), bom_h, &val))
{
if (msg)
*msg += std::wstring(L"Changed: ") + hf + L"\r\n" + L"Changed: " + cpp + L"\r\nChanged: " + s2t + L"\r\n";
return true;
}
else if (msg)
*msg = L"Failed to save changes into file: " + s2t;
if (file_util::is_file_existing(val.c_str()))
file_util::force_move_file(val.c_str(), s2t.c_str());
}
else if (msg)
*msg = std::wstring(L"File '") + s2t + L"' is not found or empty.";
}
else if (msg)
{
*msg = L"Failed to save changes into file: " + std::wstring(cpp);
}
if (file_util::is_file_existing(cbak.c_str()))
file_util::force_move_file(cbak.c_str(), cpp);
}
else if (msg)
{
*msg = L"Failed to find function 'scanner::init_options_id(void) - op_id++' in file: " + std::wstring(cpp);
}
}
else if (msg)
{
*msg = L"Failed to find function 'scanner::init_options_id(void)' in file: " + std::wstring(cpp);
}
}
else if (msg)
{
*msg = L"Failed to find 'SANE_OPTION_ID_IMPLEMENT' in file: " + std::wstring(cpp);
}
}
else if (msg)
{
*msg = L"Failed to save changes into file: " + hf;
}
if (file_util::is_file_existing(hbak.c_str()))
file_util::force_move_file(hbak.c_str(), hf.c_str());
return false;
}
}
// CDlgTwain dialog
IMPLEMENT_DYNAMIC(CDlgTwain, CDialogEx)
CDlgTwain::CDlgTwain(CWnd* pParent /*=NULL*/)
: CDialogEx(CDlgTwain::IDD, pParent)
{
}
CDlgTwain::~CDlgTwain()
{
}
void CDlgTwain::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_COMBO1, sane_);
}
BOOL CDlgTwain::OnInitDialog()
{
CDialogEx::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
return TRUE; // return TRUE unless you set the focus to a control
}
void CDlgTwain::on_sln_path_changed(void)
{
GetDlgItem(IDC_BUTTON_BROWSE)->EnableWindow(FALSE);
GetDlgItem(IDC_BUTTON_ADD)->EnableWindow(FALSE);
GetDlgItem(IDC_COMBO1)->EnableWindow(FALSE);
util::append_log(L"parsing SANE attributes ...\r\n", GetDlgItem(IDC_EDIT2)->m_hWnd, true);
sane_.ResetContent();
std::wstring path(util::get_text(GetDlgItem(IDC_EDIT1)->m_hWnd));
opts_.clear();
used_.clear();
STR_PARENT_FOLDER(path);
path += L"\\..\\..\\";
STR_TO_ABSOLUTE_PATH(path);
root_ = path;
util::get_sane_opts((path + L"sdk\\include\\sane\\sane_ex.h").c_str(), opts_);
if (opts_.size() == 0)
{
::MessageBoxW(m_hWnd, L"没有找到SANE属性定义。", L"错误", MB_OK | MB_ICONSTOP);
return;
}
for (auto& v : opts_)
sane_.AddString((v.title + L" (" + v.name + L")").c_str());
GetDlgItem(IDC_BUTTON_BROWSE)->EnableWindow(TRUE);
GetDlgItem(IDC_COMBO1)->EnableWindow(TRUE);
GetDlgItem(IDC_BUTTON_ADD)->EnableWindow(TRUE);
util::append_log((L"Found " + std::to_wstring(opts_.size()) + L" options\r\n").c_str(), GetDlgItem(IDC_EDIT2)->m_hWnd, true);
// find used ...
util::get_used_opts((path + L"code_twain\\sane\\scanner.cpp").c_str(), used_);
}
void CDlgTwain::synchronize_opt(const SANEOPT& opt)
{
OPTUSED ou;
std::wstring pre(L"SANE_STD_OPT_NAME_"), key(L""), msg(L"");
if (used_.size())
ou.id = used_[used_.size() - 1].id + 1;
else
ou.id = 0x8801;
ou.name_key = opt.name_key;
if (ou.name_key.find(pre) == 0)
key = ou.name_key.substr(pre.length());
else
key = ou.name_key;
std::transform(key.begin(), key.end(), key.begin(), tolower);
coding_util::unicode_2_ansi(key.c_str(), util::got_str, &ou.id_key);
std::vector<OPTUSED>::iterator it = std::find(used_.begin(), used_.end(), ou.id_key.c_str());
if (it != used_.end())
{
::MessageBoxW(m_hWnd, (opt.title + L" already synchronized into TWAIN.").c_str(), L"Error", MB_OK | MB_ICONINFORMATION);
return;
}
if (util::add_2_huagaods_cpp((root_ + L"code_twain\\twain\\twain\\huagaods.cpp").c_str(), opt, ou, &msg) &&
util::add_2_scanner_codes((root_ + L"code_twain\\sane\\scanner.cpp").c_str(), opt, ou, &msg))
{
used_.push_back(ou);
std::wstring tips(L"Added New TWAIN extended ATTR: CAP_EX_SANE_");
wchar_t hex[40] = { 0 };
coding_util::ansi_2_unicode(ou.id_key.c_str(), util::got_wstr, &tips);
swprintf_s(hex, _countof(hex) - 1, L" (ID: 0x%04x) - ", ou.id);
tips += hex + opt.title + L"\r\n";
util::append_log(tips.c_str(), GetDlgItem(IDC_EDIT2)->m_hWnd, true);
}
util::append_log(msg.c_str(), GetDlgItem(IDC_EDIT2)->m_hWnd, true);
}
BEGIN_MESSAGE_MAP(CDlgTwain, CDialogEx)
ON_BN_CLICKED(IDC_BUTTON_BROWSE, &CDlgTwain::OnBnClickedButtonBrowse)
ON_BN_CLICKED(IDC_BUTTON_ADD, &CDlgTwain::OnBnClickedButtonAdd)
END_MESSAGE_MAP()
// CDlgTwain message handlers
void CDlgTwain::OnBnClickedButtonBrowse()
{
// TODO: 在此添加控件通知处理程序代码
file_util::PATHFILE path = { 0 };
if (file_util::browser_file(m_hWnd, &path, L"Solution File(*.sln)\0\0"))
{
::SetDlgItemTextW(m_hWnd, IDC_EDIT1, path.path);
on_sln_path_changed();
}
}
void CDlgTwain::OnBnClickedButtonAdd()
{
// TODO: 在此添加控件通知处理程序代码
std::wstring text(util::get_text(sane_.m_hWnd));
std::string ansi("");
size_t pos = text.rfind(L'(');
if (pos++ == std::wstring::npos)
{
::MessageBoxW(m_hWnd, L"Invalid option name! (lost '()')", L"Error", MB_OK | MB_ICONSTOP);
return;
}
text.erase(0, pos);
pos = text.find(L")");
if (pos != std::wstring::npos)
text.erase(pos);
if (text.empty())
{
::MessageBoxW(m_hWnd, L"Invalid option name! (empty)", L"Error", MB_OK | MB_ICONSTOP);
return;
}
coding_util::unicode_2_ansi(text.c_str(), util::got_str, &ansi);
pos = sane_.GetCurSel();
synchronize_opt(opts_[pos]);
}

View File

@ -0,0 +1,66 @@
#pragma once
// CDlgTwain dialog
#include <string>
#include <vector>
typedef struct _san_opt
{
std::wstring name_key;
std::wstring name;
std::wstring title_key;
std::wstring title;
}SANEOPT;
typedef struct _opt_used
{
std::wstring name_key; // same as SANEOPT::name_key
std::string id_key;
int id; // ID of CAP_SANE_EX_xxx
bool operator==(const wchar_t* key)
{
return name_key == key;
}
bool operator==(const char* key)
{
return id_key == key;
}
bool operator==(const int eid)
{
return eid == id;
}
bool operator<(const struct _opt_used& r)
{
return id < r.id;
}
}OPTUSED;
class CDlgTwain : public CDialogEx
{
DECLARE_DYNAMIC(CDlgTwain)
public:
CDlgTwain(CWnd* pParent = NULL); // standard constructor
virtual ~CDlgTwain();
// Dialog Data
enum { IDD = IDD_ADD_TWAIN_ATTR };
std::vector<SANEOPT> opts_;
std::vector<OPTUSED> used_;
std::wstring root_;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual BOOL OnInitDialog();
void on_sln_path_changed(void);
void synchronize_opt(const SANEOPT& opt);
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedButtonBrowse();
afx_msg void OnBnClickedButtonAdd();
CComboBox sane_;
};

View File

@ -0,0 +1,99 @@
================================================================================
MICROSOFT FOUNDATION CLASS LIBRARY : hgjson Project Overview
===============================================================================
The application wizard has created this hgjson application for
you. This application not only demonstrates the basics of using the Microsoft
Foundation Classes but is also a starting point for writing your application.
This file contains a summary of what you will find in each of the files that
make up your hgjson application.
hgjson.vcxproj
This is the main project file for VC++ projects generated using an application wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
application wizard.
hgjson.vcxproj.filters
This is the filters file for VC++ projects generated using an Application Wizard.
It contains information about the association between the files in your project
and the filters. This association is used in the IDE to show grouping of files with
similar extensions under a specific node (for e.g. ".cpp" files are associated with the
"Source Files" filter).
hgjson.h
This is the main header file for the application. It includes other
project specific headers (including Resource.h) and declares the
ChgjsonApp application class.
hgjson.cpp
This is the main application source file that contains the application
class ChgjsonApp.
hgjson.rc
This is a listing of all of the Microsoft Windows resources that the
program uses. It includes the icons, bitmaps, and cursors that are stored
in the RES subdirectory. This file can be directly edited in Microsoft
Visual C++. Your project resources are in 1033.
res\hgjson.ico
This is an icon file, which is used as the application's icon. This
icon is included by the main resource file hgjson.rc.
res\hgjson.rc2
This file contains resources that are not edited by Microsoft
Visual C++. You should place all resources not editable by
the resource editor in this file.
/////////////////////////////////////////////////////////////////////////////
The application wizard creates one dialog class:
hgjsonDlg.h, hgjsonDlg.cpp - the dialog
These files contain your ChgjsonDlg class. This class defines
the behavior of your application's main dialog. The dialog's template is
in hgjson.rc, which can be edited in Microsoft Visual C++.
/////////////////////////////////////////////////////////////////////////////
Other Features:
ActiveX Controls
The application includes support to use ActiveX controls.
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named hgjson.pch and a precompiled types file named StdAfx.obj.
Resource.h
This is the standard header file, which defines new resource IDs.
Microsoft Visual C++ reads and updates this file.
hgjson.manifest
Application manifest files are used by Windows XP to describe an applications
dependency on specific versions of Side-by-Side assemblies. The loader uses this
information to load the appropriate assembly from the assembly cache or private
from the application. The Application manifest maybe included for redistribution
as an external .manifest file that is installed in the same folder as the application
executable or it may be included in the executable in the form of a resource.
/////////////////////////////////////////////////////////////////////////////
Other notes:
The application wizard uses "TODO:" to indicate parts of the source code you
should add to or customize.
If your application uses MFC in a shared DLL, you will need
to redistribute the MFC DLLs. If your application is in a language
other than the operating system's locale, you will also have to
redistribute the corresponding localized resources mfc110XXX.DLL.
For more information on both of these topics, please see the section on
redistributing Visual C++ applications in MSDN documentation.
/////////////////////////////////////////////////////////////////////////////

View File

@ -0,0 +1,103 @@
// hgjson.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "hgjson.h"
#include "CDlgMain.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// ChgjsonApp
BEGIN_MESSAGE_MAP(ChgjsonApp, CWinApp)
ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()
// ChgjsonApp construction
ChgjsonApp::ChgjsonApp()
{
// support Restart Manager
m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART;
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
// The one and only ChgjsonApp object
ChgjsonApp theApp;
// ChgjsonApp initialization
BOOL ChgjsonApp::InitInstance()
{
AfxOleInit();
// InitCommonControlsEx() is required on Windows XP if an application
// manifest specifies use of ComCtl32.dll version 6 or later to enable
// visual styles. Otherwise, any window creation will fail.
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// Set this to include all the common control classes you want to use
// in your application.
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
AfxEnableControlContainer();
// Create the shell manager, in case the dialog contains
// any shell tree view or shell list view controls.
CShellManager *pShellManager = new CShellManager;
// Activate "Windows Native" visual manager for enabling themes in MFC controls
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need
// Change the registry key under which our settings are stored
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
CDlgMain dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
else if (nResponse == -1)
{
TRACE(traceAppMsg, 0, "Warning: dialog creation failed, so application is terminating unexpectedly.\n");
TRACE(traceAppMsg, 0, "Warning: if you are using MFC controls on the dialog, you cannot #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS.\n");
}
// Delete the shell manager created above.
if (pShellManager != NULL)
{
delete pShellManager;
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}

View File

@ -0,0 +1,32 @@
// hgjson.h : main header file for the PROJECT_NAME application
//
#pragma once
#ifndef __AFXWIN_H__
#error "include 'stdafx.h' before including this file for PCH"
#endif
#include "resource.h" // main symbols
// ChgjsonApp:
// See hgjson.cpp for the implementation of this class
//
class ChgjsonApp : public CWinApp
{
public:
ChgjsonApp();
// Overrides
public:
virtual BOOL InitInstance();
// Implementation
DECLARE_MESSAGE_MAP()
};
extern ChgjsonApp theApp;

Binary file not shown.

View File

@ -0,0 +1,166 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{D3579C48-F5AB-4F15-9B49-A2970FBA76C5}</ProjectGuid>
<RootNamespace>hgjson</RootNamespace>
<Keyword>MFCProj</Keyword>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(ProjectDir)..\..\sdk\Include\;$(ProjectDir)..\..\..\..\sdk\Include\;$(IncludePath)</IncludePath>
<LibraryPath>$(ProjectDir)..\..\sdk\lib\;$(LibraryPath)</LibraryPath>
<IntDir>$(OutDir)$(ProjectName)\</IntDir>
<OutDir>$(ProjectDir)..\..\solution\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(ProjectDir)..\..\sdk\Include\;$(ProjectDir)..\..\..\..\sdk\Include\;$(IncludePath)</IncludePath>
<LibraryPath>$(ProjectDir)..\..\sdk\lib\;$(LibraryPath)</LibraryPath>
<IntDir>$(OutDir)$(ProjectName)\</IntDir>
<OutDir>$(ProjectDir)..\..\solution\$(Configuration)\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<Midl>
<MkTypLibCompatible>false</MkTypLibCompatible>
<ValidateAllParameters>true</ValidateAllParameters>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</Midl>
<ResourceCompile>
<Culture>0x0409</Culture>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<Midl>
<MkTypLibCompatible>false</MkTypLibCompatible>
<ValidateAllParameters>true</ValidateAllParameters>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</Midl>
<ResourceCompile>
<Culture>0x0409</Culture>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\..\code_device\hgdriver\hgdev\scanner_setting.h" />
<ClInclude Include="CDlgLang.h" />
<ClInclude Include="CDlgMain.h" />
<ClInclude Include="DlgAddWords.h" />
<ClInclude Include="DlgInput.h" />
<ClInclude Include="DlgOptJson.h" />
<ClInclude Include="DlgRange.h" />
<ClInclude Include="DlgTwain.h" />
<ClInclude Include="hgjson.h" />
<ClInclude Include="hgjsonDlg.h" />
<ClInclude Include="Resource.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\..\code_device\hgdriver\hgdev\scanner_setting.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="CDlgLang.cpp" />
<ClCompile Include="CDlgMain.cpp" />
<ClCompile Include="DlgAddWords.cpp" />
<ClCompile Include="DlgInput.cpp" />
<ClCompile Include="DlgOptJson.cpp" />
<ClCompile Include="DlgRange.cpp" />
<ClCompile Include="DlgTwain.cpp" />
<ClCompile Include="hgjson.cpp" />
<ClCompile Include="hgjsonDlg.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="hgjson.rc" />
</ItemGroup>
<ItemGroup>
<None Include="res\hgjson.rc2" />
</ItemGroup>
<ItemGroup>
<Image Include="res\bitmap1.bmp" />
<Image Include="res\hgjson.ico" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<ProjectExtensions>
<VisualStudio>
<UserProperties RESOURCE_FILE="hgjson.rc" />
</VisualStudio>
</ProjectExtensions>
</Project>

View File

@ -0,0 +1,114 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="hgjson.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="hgjsonDlg.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="DlgInput.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\code_device\hgdriver\hgdev\scanner_setting.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="CDlgMain.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="CDlgLang.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="DlgTwain.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="DlgAddWords.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="DlgOptJson.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="DlgRange.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="hgjson.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="hgjsonDlg.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DlgInput.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\code_device\hgdriver\hgdev\scanner_setting.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="CDlgMain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="CDlgLang.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DlgTwain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DlgAddWords.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DlgOptJson.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DlgRange.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="hgjson.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<None Include="res\hgjson.rc2">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Image Include="res\hgjson.ico">
<Filter>Resource Files</Filter>
</Image>
<Image Include="res\bitmap1.bmp">
<Filter>Resource Files</Filter>
</Image>
</ItemGroup>
</Project>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,190 @@
// hgjsonDlg.h : header file
//
#pragma once
#include "afxshelltreectrl.h"
#include "afxwin.h"
#include "afxcmn.h"
#include <vector>
#include <string>
#include <algorithm>
// ChgjsonDlg dialog
class ChgjsonDlg : public CDialogEx
{
// Construction
public:
ChgjsonDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
enum { IDD = IDD_HGJSON_DIALOG };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
public:
typedef struct _depend_item
{
std::wstring parent;
std::wstring logic_values; // include logic operator: "==2"
bool operator==(const wchar_t* name)
{
return wcscmp(name, parent.c_str()) == 0;
}
bool operator<(const struct _depend_item& r)
{
return parent < r.parent;
}
}DEPENDITEM;
enum range_type
{
RANGE_TYPE_NONE = 0,
RANGE_TYPE_RANGE,
RANGE_TYPE_LIST,
};
typedef struct _range
{
int type;
double lower;
double upper;
double step;
std::vector<std::wstring> queue;
}RANGE;
typedef struct _hg_item
{
std::wstring title;
std::wstring desc;
std::wstring type;
std::wstring init_val;
std::wstring group;
int index;
int bytes;
bool advanced;
bool readonly;
//bool deviceonly; // 只能在设备上操作的属性 - use readonly
bool visible;
int affect;
int position;
int field;
int unit;
bool depend_or; // or or and
std::vector<DEPENDITEM> depend;
RANGE range;
bool operator==(const wchar_t* name)
{
return wcscmp(name, title.c_str()) == 0;
}
struct _hg_item(const wchar_t* ti= L"")
{
title = ti ? ti : L"";
desc = L"";
type = L"bool";
init_val = L"true";
group = L"base";
bytes = 4;
advanced = readonly = /*deviceonly =*/ false;
visible = depend_or = true;
affect = position = field = unit = 0;
range.type = RANGE_TYPE_NONE;
}
}HGITEM;
typedef struct _def_h
{
std::wstring name;
std::wstring value;
std::wstring utf8_in_oct;
bool operator==(const std::wstring& n)
{
return name == n;
}
}DEFH;
std::vector<HGITEM> hg_items_;
bool show_tree_tooltips_;
bool show_list_tooltips_;
// Implementation
protected:
CMenu tree_menu_;
CMenu func_menu_;
CImageList tree_img_;
// Generated message map functions
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnPaste();
DECLARE_MESSAGE_MAP()
static void to_define_header(std::vector<DEFH>& defs, const wchar_t* str, const wchar_t* parent = NULL);
static std::string save_define_header_2_file(std::vector<DEFH>& defs, const wchar_t* file); // return BOM string
void init_control_statu(void);
void delete_tree_item(HTREEITEM root);
int find_config_item(const wchar_t* item_name);
int check_depend(const wchar_t* l, const wchar_t* r); // -1: l depends on r; 0: no depend; 1: r depends on l
void set_control_status(const HGITEM& item);
void* create_json(int item, std::vector<DEFH> *def_h = NULL, std::wstring* name = NULL);
std::string to_json_text(bool for_const = false, std::wstring *dev = NULL);
void add_item(void* jsn_root, void* jsn_obj, HTREEITEM parent, bool old_ver);
bool load_from_json_text(const wchar_t* txt, std::wstring* err_msg = NULL);
bool load_from_file(const wchar_t* path_file);
void get_all_names(HTREEITEM root, std::vector<std::wstring>& names, DWORD mask = 0);
void on_config_name_changed(const wchar_t* prev, const wchar_t* now);
HTREEITEM add_tree_item(const wchar_t* title, DWORD data, HTREEITEM parent = TVI_ROOT, HTREEITEM after = TVI_LAST);
void filter_tree_item(HTREEITEM item, const std::vector<HGITEM>& filter);
public:
afx_msg void OnTreeAddGroup();
afx_msg void OnTreeAddItem();
afx_msg void OnTreeDelItem();
CTreeCtrl tree_;
afx_msg void OnTreeAddProduct();
afx_msg void OnBnClickedButton3();
afx_msg void OnBnClickedButton1();
afx_msg void OnBnClickedButton2();
CListBox depends_;
CListCtrl constraint_list_;
afx_msg void OnCbnSelchangeDataType();
afx_msg void OnCbnSelchangeConstraintType();
afx_msg void OnCbnSelchangeDependItem();
afx_msg void OnCbnSelchangeLogic();
afx_msg void OnLvnEndlabeleditListValues(NMHDR *pNMHDR, LRESULT *pResult);
CComboBox type_;
CComboBox constraint_;
afx_msg void OnBnClickedDepend();
CComboBox logic_;
CComboBox depend_item_;
afx_msg void OnBnClickedButton4();
afx_msg void OnNMRClickMfcshelltree1(NMHDR *pNMHDR, LRESULT *pResult);
CComboBox combo_default_;
afx_msg void OnTvnSelchangedTree1(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnListmenuSetdefault();
afx_msg void OnListmenuDelete();
afx_msg void OnNMRClickListValues(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnLbnDblclkList3();
afx_msg void OnDropFiles(HDROP hDropInfo);
afx_msg void OnTreeRename();
afx_msg void OnTreeLoadfile();
afx_msg void OnLvnKeydownListValues(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnTvnKeydownTree1(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnTvnGetInfoTipTree1(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnLvnGetInfoTipListValues(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnTreeTooltips();
afx_msg void OnListmenuTooltips();
afx_msg void OnTreeExportCharConstants();
afx_msg void OnBnClickedToFile();
afx_msg void OnTreeLoadClipboard();
afx_msg void OnTreeUnifySequence();
CComboBox field_;
CComboBox unit_;
CComboBox group_;
CComboBox affect_;
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,8 @@
// stdafx.cpp : source file that includes just the standard includes
// hgjson.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

View File

@ -0,0 +1,54 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#pragma once
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
#include "targetver.h"
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
// turns off MFC's hiding of some common and often safely ignored warning messages
#define _AFX_ALL_WARNINGS
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#ifndef _AFX_NO_OLE_SUPPORT
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <afxcontrolbars.h> // MFC support for ribbons and control bars
#ifdef _UNICODE
#if defined _M_IX86
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_X64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif
#endif

View File

@ -0,0 +1,8 @@
#pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <SDKDDKVer.h>

Binary file not shown.