// CDlgMgr.cpp: 实现文件 // #include "pch.h" #include "scanner-check.h" #include "CDlgMgr.h" #include "afxdialogex.h" #include "CDlgInput.h" #include #include #include #include // CDlgMgr 对话框 static std::wstring vid_pid_edit_org_proc = L"vid_pid_edit_org_proc"; static wchar_t* hex = L"\uFF10\uFF11\uFF12\uFF13\uFF14\uFF15\uFF16\uFF17\uFF18\uFF19\uFF21\uFF22\uFF23\uFF24\uFF25\uFF26"; static std::string jsontext1("{\"global\":{\"device_type\":\"G139-G239\",\"option_count\":75},\"restore\":{\"category\":\"base\",\"title\":\"\\u6062\\u590d\\u9ed8\\u8ba4\\u8bbe\\u7f6e\",\"desc\":\"\\u6062\\u590d\\u9ed8\\u8ba4\\u8bbe\\u7f6e\",\"type\":\"button\",\"cur\":\"button\",\"default\":\"button\",\"size\":0},\"help\":{\"category\":\"advanced\",\"title\":\"\\u5e2e\\u52a9\",\"desc\":\"\\u663e\\u793a\\u8f6f\\u4ef6\\u5e2e\\u52a9\\u6587\\u6863\",\"type\":\"button\",\"cur\":\"true\",\"default\":\"true\",\"size\":4},\"grp-1\":{\"category\":\"base\",\"title\":\"\\u57fa\\u672c\\u8bbe\\u7f6e\",\"type\":\"group\"},\"is-multiout\":{\"category\":\"base\",\"title\":\"\\u591a\\u6d41\\u8f93\\u51fa\",\"desc\":\"\\u540c\\u65f6\\u8f93\\u51fa\\u591a\\u79cd\\u989c\\u8272\\u6a21\\u5f0f\\u7684\\u56fe\\u50cf\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"multiout-type\":{\"category\":\"base\",\"title\":\"\\u591a\\u6d41\\u8f93\\u51fa\\u7c7b\\u578b\",\"desc\":\"\\u9009\\u62e9\\u591a\\u6d41\\u8f93\\u51fa\\u7684\\u7c7b\\u578b\",\"type\":\"string\",\"cur\":\"\\u5f69\\u8272+\\u7070\\u5ea6+\\u9ed1\\u767d\",\"default\":\"\\u5f69\\u8272+\\u7070\\u5ea6+\\u9ed1\\u767d\",\"size\":32,\"range\":[\"\\u5f69\\u8272+\\u7070\\u5ea6+\\u9ed1\\u767d\",\"\\u5f69\\u8272+\\u7070\\u5ea6\",\"\\u5f69\\u8272+\\u9ed1\\u767d\",\"\\u7070\\u5ea6+\\u9ed1\\u767d\"],\"depend_or\":[\"is-multiout==true\"]},\"mode\":{\"category\":\"base\",\"title\":\"\\u989c\\u8272\\u6a21\\u5f0f\",\"desc\":\"\\u9009\\u62e9\\u8272\\u5f69\\u6a21\\u5f0f\",\"type\":\"string\",\"cur\":\"24\\u4f4d\\u5f69\\u8272\",\"default\":\"24\\u4f4d\\u5f69\\u8272\",\"size\":32,\"range\":[\"24\\u4f4d\\u5f69\\u8272\",\"256\\u7ea7\\u7070\\u5ea6\",\"\\u9ed1\\u767d\",\"\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"],\"depend_or\":[\"is-multiout!=true\"]},\"binary-threshold\":{\"category\":\"base\",\"title\":\"\\u9ed1\\u767d\\u56fe\\u50cf\\u9608\\u503c\",\"desc\":\"\\u9ad8\\u4e8e\\u8be5\\u9608\\u503c\\u4e3a1\\uff08\\u767d\\uff09\\uff0c\\u4f4e\\u4e8e\\u8be5\\u9608\\u503c\\u4e3a0\\uff08\\u9ed1\\uff09\",\"type\":\"int\",\"cur\":127,\"default\":127,\"size\":4,\"range\":{\"min\":0,\"max\":255},\"depend_or\":[\"is-multiout==true\",\"mode==\\u9ed1\\u767d\"]},\"reverse-bw\":{\"category\":\"base\",\"title\":\"\\u9ed1\\u767d\\u56fe\\u50cf\\u53cd\\u8272\\u8f93\\u51fa\",\"desc\":\"\\u8f93\\u51fa\\u7684\\u9ed1\\u767d\\u56fe\\u50cf\\u4ee5\\u201c1\\u201d\\u4ee3\\u8868\\u9ed1\\u8272\\uff0c\\u201c0\\u201d\\u4ee3\\u8868\\u767d\\u8272\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_or\":[\"is-multiout==true\",\"mode==\\u9ed1\\u767d\"]},\"filter\":{\"category\":\"base\",\"title\":\"\\u7070\\u5ea6\\u6216\\u9ed1\\u767d\\u56fe\\u50cf - \\u9664\\u8272\\u4e0e\\u589e\\u5f3a\",\"desc\":\"\\u6d88\\u9664\\u6216\\u589e\\u5f3a\\u6307\\u5b9a\\u8272\\u5f69\",\"type\":\"string\",\"cur\":\"\\u4e0d\\u9664\\u8272\",\"default\":\"\\u4e0d\\u9664\\u8272\",\"size\":24,\"range\":[\"\\u4e0d\\u9664\\u8272\",\"\\u9664\\u7ea2\\u8272\",\"\\u9664\\u7eff\\u8272\",\"\\u9664\\u84dd\\u8272\",\"\\u7ea2\\u8272\\u589e\\u5f3a\",\"\\u7eff\\u8272\\u589e\\u5f3a\",\"\\u84dd\\u8272\\u589e\\u5f3a\"],\"depend_and\":[\"is-multiout!=true\",\"mode!=24\\u4f4d\\u5f69\\u8272\",\"!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]},\"is-rid-multiout-red\":{\"category\":\"base\",\"title\":\"24\\u4f4d\\u5f69\\u8272\\u56fe\\u50cf - \\u591a\\u6d41\\u8f93\\u51fa\\u9664\\u7ea2\",\"desc\":\"\\u540c\\u65f6\\u8f93\\u51fa\\u5f69\\u8272\\u56fe\\u50cf\\u548c\\u7070\\u5ea6\\u9664\\u7ea2\\u56fe\\u50cf\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"is-multiout!=true\",\"mode!=256\\u7ea7\\u7070\\u5ea6\",\"!=\\u9ed1\\u767d\",\"!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]},\"is-rid-answer-sheet-red\":{\"category\":\"base\",\"title\":\"24\\u4f4d\\u5f69\\u8272\\u56fe\\u50cf - \\u7b54\\u9898\\u5361\\u9664\\u7ea2\",\"desc\":\"\\u8f93\\u51fa\\u9664\\u7ea2\\u5f69\\u8272\\u56fe\\u50cf\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"is-multiout!=true\",\"mode!=256\\u7ea7\\u7070\\u5ea6\",\"!=\\u9ed1\\u767d\",\"!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]},\"is-erase-bkg\":{\"category\":\"base\",\"title\":\"\\u80cc\\u666f\\u79fb\\u9664\",\"desc\":\"\\u79fb\\u9664\\u6587\\u7a3f\\u80cc\\u666f\\u5e95\\u8272\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"is-multiout!=true\",\"mode!=256\\u7ea7\\u7070\\u5ea6\",\"!=\\u9ed1\\u767d\",\"!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]},\"bkg-color-range\":{\"category\":\"base\",\"title\":\" \\u80cc\\u666f\\u8272\\u5f69\\u6d6e\\u52a8\\u8303\\u56f4\",\"desc\":\"\\u4e0e\\u80cc\\u666f\\u5e95\\u8272\\u504f\\u5dee\\u5728\\u8be5\\u503c\\u8303\\u56f4\\u5185\\u7684\\u989c\\u8272\\uff0c\\u90fd\\u5c06\\u88ab\\u79fb\\u9664\",\"type\":\"int\",\"cur\":20,\"default\":20,\"size\":4,\"range\":{\"min\":1,\"max\":128},\"depend_or\":[\"is-erase-bkg==true\"]},\"sharpen\":{\"category\":\"base\",\"title\":\"\\u9510\\u5316\\u4e0e\\u6a21\\u7cca\",\"desc\":\"\\u9009\\u62e9\\u9510\\u5316\\u6548\\u679c\\u6216\\u6a21\\u7cca\\u6548\\u679c\",\"type\":\"string\",\"cur\":\"\\u65e0\",\"default\":\"\\u65e0\",\"size\":24,\"range\":[\"\\u65e0\",\"\\u9510\\u5316\",\"\\u8fdb\\u4e00\\u6b65\\u9510\\u5316\",\"\\u6a21\\u7cca\",\"\\u8fdb\\u4e00\\u6b65\\u6a21\\u7cca\"],\"depend_and\":[\"is-multiout!=true\",\"mode!=\\u9ed1\\u767d\",\"!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]},\"is-rid-morr\":{\"category\":\"base\",\"title\":\"\\u53bb\\u9664\\u6469\\u5c14\\u7eb9\",\"desc\":\"\\u53bb\\u9664\\u56fe\\u50cf\\u4e2d\\u7684\\u6469\\u5c14\\u7eb9\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"is-multiout!=true\",\"mode!=\\u9ed1\\u767d\",\"!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]},\"is-rid-grid\":{\"category\":\"base\",\"title\":\"\\u9664\\u7f51\\u7eb9\",\"desc\":\"\\u53bb\\u9664\\u56fe\\u50cf\\u4e2d\\u7684\\u7f51\\u7eb9\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"is-multiout!=true\",\"mode!=\\u9ed1\\u767d\",\"!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]},\"is-err-extension\":{\"category\":\"base\",\"title\":\"\\u9519\\u8bef\\u6269\\u6563\",\"desc\":\"\\u4ee5\\u70b9\\u9635\\u5f62\\u5f0f\\u6784\\u5efa\\u56fe\\u50cf\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_or\":[\"mode==\\u9ed1\\u767d\"]},\"is-noise-optimize\":{\"category\":\"base\",\"title\":\"\\u9ed1\\u767d\\u56fe\\u50cf\\u566a\\u70b9\\u4f18\\u5316\",\"desc\":\"\\u53bb\\u9664\\u56fe\\u50cf\\u4e2d\\u7684\\u5b64\\u7acb\\u9ed1\\u70b9\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_or\":[\"mode==\\u9ed1\\u767d\"]},\"noise-size\":{\"category\":\"base\",\"title\":\" \\u566a\\u70b9\\u4f18\\u5316\\u5c3a\\u5bf8\",\"desc\":\"\\u8bbe\\u7f6e\\u9700\\u8981\\u53bb\\u9664\\u7684\\u9ed1\\u8272\\u5b64\\u7acb\\u70b9\\u7684\\u8fde\\u901a\\u4e2a\\u6570\",\"type\":\"int\",\"cur\":30,\"default\":30,\"size\":4,\"range\":{\"min\":10,\"max\":50},\"depend_or\":[\"is-noise-optimize==true\"]},\"paper\":{\"category\":\"base\",\"title\":\"\\u7eb8\\u5f20\\u5c3a\\u5bf8\",\"desc\":\"\\u8bbe\\u7f6e\\u51fa\\u56fe\\u5927\\u5c0f\",\"type\":\"string\",\"cur\":\"\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"default\":\"\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"size\":48,\"range\":[\"A3\",\"8\\u5f00\",\"A4\",\"A4\\u6a2a\\u5411\",\"16\\u5f00\",\"16\\u5f00\\u6a2a\\u5411\",\"A5\",\"A5\\u6a2a\\u5411\",\"A6\",\"A6\\u6a2a\\u5411\",\"B4\",\"B5\",\"B5\\u6a2a\\u5411\",\"B6\",\"B6\\u6a2a\\u5411\",\"Letter\",\"Letter\\u6a2a\\u5411\",\"Double Letter\",\"LEGAL\",\"\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207\",\"\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\",\"\\u4e09\\u8054\\u8bd5\\u5377\"]},\"is-custom-area\":{\"category\":\"base\",\"title\":\"\\u81ea\\u5b9a\\u4e49\\u626b\\u63cf\\u533a\\u57df\",\"desc\":\"\\u81ea\\u5b9a\\u4e49\\u626b\\u63cf\\u533a\\u57df\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"paper!=\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"!=\\u4e09\\u8054\\u8bd5\\u5377\",\"!=\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\",\"!=\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207\"]},\"tl-x\":{\"category\":\"base\",\"title\":\"\\u626b\\u63cf\\u533a\\u57df\\u5de6\\u4fa7\\uff08mm\\uff09\",\"desc\":\"\\u81ea\\u5b9a\\u4e49\\u626b\\u63cf\\u533a\\u57df\\u5de6\\u4e0a\\u89d2x\\u5750\\u6807\",\"type\":\"float\",\"cur\":0.000000,\"default\":0.000000,\"size\":4,\"range\":{\"min\":0.000000,\"max\":210.000000},\"depend_and\":[\"is-custom-area==true\"]},\"br-x\":{\"category\":\"base\",\"title\":\"\\u626b\\u63cf\\u533a\\u57df\\u53f3\\u4fa7\\uff08mm\\uff09\",\"desc\":\"\\u81ea\\u5b9a\\u4e49\\u626b\\u63cf\\u533a\\u57df\\u53f3\\u4e0b\\u89d2x\\u5750\\u6807\",\"type\":\"float\",\"cur\":210.000000,\"default\":210.000000,\"size\":4,\"range\":{\"min\":0.000000,\"max\":210.000000},\"depend_and\":[\"is-custom-area==true\"]},\"tl-y\":{\"category\":\"base\",\"title\":\"\\u626b\\u63cf\\u533a\\u57df\\u4e0a\\u4fa7\\uff08mm\\uff09\",\"desc\":\"\\u81ea\\u5b9a\\u4e49\\u626b\\u63cf\\u533a\\u57df\\u5de6\\u4e0a\\u89d2y\\u5750\\u6807\",\"type\":\"float\",\"cur\":0.000000,\"default\":0.000000,\"size\":4,\"range\":{\"min\":0.000000,\"max\":297.000000},\"depend_and\":[\"is-custom-area==true\"]},\"br-y\":{\"category\":\"base\",\"title\":\"\\u626b\\u63cf\\u533a\\u57df\\u4e0b\\u4fa7\\uff08mm\\uff09\",\"desc\":\"\\u81ea\\u5b9a\\u4e49\\u626b\\u63cf\\u533a\\u57df\\u53f3\\u4e0b\\u89d2y\\u5750\\u6807\",\"type\":\"float\",\"cur\":297.000000,\"default\":297.000000,\"size\":4,\"range\":{\"min\":0.000000,\"max\":297.000000},\"depend_and\":[\"is-custom-area==true\"]},\"is-size-check\":{\"category\":\"base\",\"title\":\"\\u5c3a\\u5bf8\\u68c0\\u6d4b\",\"desc\":\"\\u68c0\\u6d4b\\u7eb8\\u5f20\\u5b9e\\u9645\\u5c3a\\u5bf8\\u4e0e\\u8bbe\\u7f6e\\u662f\\u5426\\u5339\\u914d\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_or\":[\"paper==A3\",\"==A4\",\"==A4\\u6a2a\\u5411\",\"==A5\",\"==A5\\u6a2a\\u5411\",\"==A6\",\"==A6\\u6a2a\\u5411\",\"==B4\",\"==B5\",\"==B5\\u6a2a\\u5411\",\"==B6\",\"==B6\\u6a2a\\u5411\",\"==Double Letter\",\"==LEGAL\",\"==Letter\",\"==Letter\\u6a2a\\u5411\"]},\"page\":{\"category\":\"base\",\"title\":\"\\u626b\\u63cf\\u9875\\u9762\",\"desc\":\"\\u8bbe\\u7f6e\\u9875\\u9762\\u626b\\u63cf\\u65b9\\u5f0f\",\"type\":\"string\",\"cur\":\"\\u53cc\\u9762\",\"default\":\"\\u53cc\\u9762\",\"size\":40,\"range\":[\"\\u5355\\u9762\",\"\\u53cc\\u9762\",\"\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\uff08\\u901a\\u7528\\uff09\",\"\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\uff08\\u53d1\\u7968\\u7eb8\\uff09\",\"\\u5bf9\\u6298\"]},\"blank-sensitivity\":{\"category\":\"base\",\"title\":\" \\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\u7075\\u654f\\u5ea6\",\"desc\":\"\\u6570\\u503c\\u8d8a\\u5927\\uff0c\\u5219\\u8d8a\\u5bb9\\u6613\\u8df3\\u8fc7\",\"type\":\"int\",\"cur\":50,\"default\":50,\"size\":4,\"range\":{\"min\":1,\"max\":100},\"depend_or\":[\"page==\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\uff08\\u901a\\u7528\\uff09\",\"==\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\uff08\\u53d1\\u7968\\u7eb8\\uff09\"]},\"fold-type\":{\"category\":\"base\",\"title\":\"\\u5bf9\\u6298\\u6a21\\u5f0f\",\"desc\":\"\",\"type\":\"string\",\"cur\":\"\\u5de6\\u53f3\\u5bf9\\u6298\",\"default\":\"\\u5de6\\u53f3\\u5bf9\\u6298\",\"size\":50,\"range\":[\"\\u5de6\\u53f3\\u5bf9\\u6298\",\"\\u4e0a\\u4e0b\\u5bf9\\u6298\",\"\\u81ea\\u52a8\\u5bf9\\u6298\"],\"depend_or\":[\"page==\\u5bf9\\u6298\"]},\"resolution\":{\"category\":\"base\",\"title\":\"\\u5206\\u8fa8\\u7387\",\"desc\":\"\\u8bbe\\u7f6e\\u626b\\u63cf\\u56fe\\u50cf\\u7684\\u5206\\u8fa8\\u7387\",\"type\":\"int\",\"cur\":200,\"default\":200,\"size\":4,\"range\":{\"min\":1,\"max\":600}},\"image-quality\":{\"category\":\"base\",\"title\":\"\\u753b\\u8d28\",\"desc\":\"\\u9009\\u62e9\\u626b\\u63cf\\u4eea\\u7684\\u753b\\u8d28\\u6a21\\u5f0f\",\"type\":\"string\",\"cur\":\"\\u901f\\u5ea6\\u4f18\\u5148\",\"default\":\"\\u901f\\u5ea6\\u4f18\\u5148\",\"size\":24,\"range\":[\"\\u901f\\u5ea6\\u4f18\\u5148\",\"\\u753b\\u8d28\\u4f18\\u5148\"],\"depend_or\":[\"resolution>=300\"]},\"is-exchange\":{\"category\":\"base\",\"title\":\"\\u4ea4\\u6362\\u6b63\\u53cd\\u9762\",\"desc\":\"\\u4ea4\\u6362\\u6bcf\\u5f20\\u6587\\u7a3f\\u7684\\u6b63\\u53cd\\u9762\\u51fa\\u56fe\\u987a\\u5e8f\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"page!=\\u5355\\u9762\"]},\"grp-2\":{\"category\":\"base\",\"title\":\"\\u4eae\\u5ea6\",\"type\":\"group\"},\"is-custom-gamma\":{\"category\":\"base\",\"title\":\"\\u542f\\u7528\\u8272\\u8c03\\u66f2\\u7ebf\",\"desc\":\"\\u81ea\\u5b9a\\u4e49\\u56fe\\u50cf\\u8272\\u8c03\\u6548\\u679c\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"brightness\":{\"category\":\"base\",\"title\":\"\\u4eae\\u5ea6\\u503c\",\"desc\":\"\\u8c03\\u6574\\u56fe\\u50cf\\u4eae\\u5ea6\",\"type\":\"int\",\"cur\":128,\"default\":128,\"size\":4,\"range\":{\"min\":1,\"max\":255},\"depend_and\":[\"is-custom-gamma==false\"]},\"contrast\":{\"category\":\"base\",\"title\":\"\\u5bf9\\u6bd4\\u5ea6\",\"desc\":\"\\u8c03\\u6574\\u56fe\\u50cf\\u5bf9\\u6bd4\\u5ea6\",\"type\":\"int\",\"cur\":4,\"default\":4,\"size\":4,\"range\":{\"min\":1,\"max\":7},\"depend_and\":[\"is-custom-gamma==false\"]},\"gamma\":{\"category\":\"base\",\"title\":\"\\u4f3d\\u9a6c\\u503c\",\"desc\":\"\\u8c03\\u6574\\u56fe\\u50cf\\u4f3d\\u739b\\u503c\",\"type\":\"float\",\"cur\":1.000000,\"default\":1.000000,\"size\":4,\"range\":{\"min\":0.010000,\"max\":5.000000},\"depend_and\":[\"is-custom-gamma==false\"]},\"grp-3\":{\"category\":\"base\",\"title\":\"\\u56fe\\u50cf\\u5904\\u7406\",\"type\":\"group\"},\"is-anti-skew\":{\"category\":\"base\",\"title\":\"\\u81ea\\u52a8\\u7ea0\\u504f\",\"desc\":\"\\u81ea\\u52a8\\u7ea0\\u6b63\\u6b6a\\u659c\\u9001\\u5165\\u7684\\u6587\\u7a3f\\u56fe\\u50cf\",\"type\":\"bool\",\"cur\":true,\"default\":true,\"size\":4,\"depend_or\":[\"page!=\\u5bf9\\u6298\"]},\"is-split\":{\"category\":\"b"); static std::string jsontext2("ase\",\"title\":\"\\u56fe\\u50cf\\u62c6\\u5206\",\"desc\":\"\\u81ea\\u52a8\\u62c6\\u5206\\u56fe\\u50cf\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"page!=\\u5bf9\\u6298\",\"!=\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\uff08\\u53d1\\u7968\\u7eb8\\uff09\",\"!=\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\uff08\\u901a\\u7528\\uff09\"]},\"is-erase-black-frame\":{\"category\":\"base\",\"title\":\"\\u6d88\\u9664\\u9ed1\\u6846\",\"desc\":\"\\u6d88\\u9664\\u6587\\u7a3f\\u8303\\u56f4\\u5916\\u7684\\u9ed1\\u8272\\u80cc\\u666f\",\"type\":\"bool\",\"cur\":true,\"default\":true,\"size\":4},\"bkg-fill-mode\":{\"category\":\"advanced\",\"title\":\"\\u80cc\\u666f\\u586b\\u5145\\u65b9\\u5f0f\",\"desc\":\"\\u9009\\u62e9\\u80cc\\u666f\\u586b\\u5145\\u65b9\\u5f0f\",\"type\":\"string\",\"cur\":\"\\u51f8\\u591a\\u8fb9\\u5f62\",\"default\":\"\\u51f8\\u591a\\u8fb9\\u5f62\",\"size\":40,\"range\":[\"\\u51f8\\u591a\\u8fb9\\u5f62\",\"\\u51f9\\u591a\\u8fb9\\u5f62\"],\"depend_or\":[\"is-erase-black-frame==true\"]},\"is-fill-color\":{\"category\":\"base\",\"title\":\"\\u8272\\u5f69\\u586b\\u5145\",\"desc\":\"\\u542f\\u7528\\u540e\\u9ed1\\u6846\\u90e8\\u5206\\u5c06\\u586b\\u5145\\u4e3a\\u6587\\u7a3f\\u5e95\\u8272\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"is-erase-black-frame==true\"]},\"threshold\":{\"category\":\"advanced\",\"title\":\"\\u9608\\u503c\",\"desc\":\"\\u6587\\u7a3f\\u5e95\\u8272\\u4e0e\\u9ed1\\u8272\\u80cc\\u666f\\u7070\\u5ea6\\u503c\\u7684\\u5dee\\u503c\\u5927\\u4e8e\\u8be5\\u503c\\uff0c\\u624d\\u4f1a\\u88ab\\u8bc6\\u522b\\u4e3a\\u6587\\u7a3f\",\"type\":\"int\",\"cur\":40,\"default\":40,\"size\":4,\"range\":{\"min\":30,\"max\":50},\"depend_or\":[\"is-erase-black-frame==true\",\"paper==\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\",\"==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207\",\"is-anti-skew==true\"]},\"anti-noise-level\":{\"category\":\"advanced\",\"title\":\"\\u80cc\\u666f\\u6297\\u566a\\u7b49\\u7ea7\",\"desc\":\"\\u80fd\\u591f\\u5bb9\\u5fcd\\u7684\\u80cc\\u666f\\u6742\\u8272\\u6761\\u7eb9\\u7684\\u5bbd\\u5ea6\",\"type\":\"int\",\"cur\":8,\"default\":8,\"size\":4,\"range\":{\"min\":1,\"max\":20},\"depend_or\":[\"is-erase-black-frame==true\",\"paper==\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\",\"==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207\",\"is-anti-skew==true\"]},\"margin\":{\"category\":\"advanced\",\"title\":\"\\u8fb9\\u7f18\\u7f29\\u8fdb\",\"desc\":\"\\u5bfb\\u627e\\u6587\\u7a3f\\u8fb9\\u7f18\\u65f6\\u5bf9\\u8fb9\\u7f18\\u7684\\u4fb5\\u5165\\u7a0b\\u5ea6\",\"type\":\"int\",\"cur\":5,\"default\":5,\"size\":4,\"range\":{\"min\":5,\"max\":30},\"depend_or\":[\"is-erase-black-frame==true\",\"paper==\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207\",\"==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\",\"is-anti-skew==true\"]},\"is-dark-sample\":{\"category\":\"base\",\"title\":\"\\u6df1\\u8272\\u6837\\u5f20\",\"desc\":\"\\u542f\\u7528\\u8be5\\u6a21\\u5f0f\\u9632\\u6b62\\u6df1\\u8272\\u5e95\\u8272\\u7684\\u6587\\u7a3f\\u56fe\\u50cf\\u88ab\\u8bef\\u5904\\u7406\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"page!=\\u5bf9\\u6298\",\"is-erase-black-frame!=true\",\"paper!=\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"!=\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\",\"!=\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207\",\"is-anti-skew!=true\"]},\"is-anti-permeate\":{\"category\":\"base\",\"title\":\"\\u9632\\u6b62\\u6e17\\u900f\",\"desc\":\"\\u9632\\u6b62\\u80cc\\u9762\\u56fe\\u6848\\u6e17\\u900f\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"permeate-level\":{\"category\":\"base\",\"title\":\" \\u9632\\u6b62\\u6e17\\u900f\\u7b49\\u7ea7\",\"desc\":\"\\u9009\\u62e9\\u9632\\u6b62\\u6e17\\u900f\\u7684\\u7b49\\u7ea7\",\"type\":\"string\",\"cur\":\"\\u8f83\\u5f31\",\"default\":\"\\u8f83\\u5f31\",\"size\":16,\"range\":[\"\\u5f31\",\"\\u8f83\\u5f31\",\"\\u4e00\\u822c\",\"\\u8f83\\u5f3a\",\"\\u5f3a\"],\"depend_or\":[\"is-anti-permeate==true\"]},\"is-rid-hole-l\":{\"category\":\"base\",\"title\":\"\\u7a7f\\u5b54\\u79fb\\u9664\\u2014\\u5de6\\u4fa7\",\"desc\":\"\\u7a7f\\u5b54\\u5728\\u7eb8\\u5f20\\u4e0a\\u7684\\u5de6\\u4fa7\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"search-hole-range-l\":{\"category\":\"base\",\"title\":\" \\u5de6\\u4fa7\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"desc\":\"\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"type\":\"float\",\"cur\":0.100000,\"default\":0.100000,\"size\":4,\"range\":{\"min\":0.000000,\"max\":0.500000},\"depend_and\":[\"is-rid-hole-l==true\"]},\"is-rid-hole-r\":{\"category\":\"base\",\"title\":\"\\u7a7f\\u5b54\\u79fb\\u9664\\u2014\\u53f3\\u4fa7\",\"desc\":\"\\u7a7f\\u5b54\\u5728\\u7eb8\\u5f20\\u4e0a\\u7684\\u53f3\\u4fa7\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"search-hole-range-r\":{\"category\":\"base\",\"title\":\" \\u53f3\\u4fa7\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"desc\":\"\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"type\":\"float\",\"cur\":0.100000,\"default\":0.100000,\"size\":4,\"range\":{\"min\":0.000000,\"max\":0.500000},\"depend_and\":[\"is-rid-hole-r==true\"]},\"is-rid-hole-t\":{\"category\":\"base\",\"title\":\"\\u7a7f\\u5b54\\u79fb\\u9664\\u2014\\u4e0a\\u4fa7\",\"desc\":\"\\u7a7f\\u5b54\\u5728\\u7eb8\\u5f20\\u7684\\u4e0a\\u90e8\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"search-hole-range-t\":{\"category\":\"base\",\"title\":\" \\u4e0a\\u4fa7\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"desc\":\"\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"type\":\"float\",\"cur\":0.100000,\"default\":0.100000,\"size\":4,\"range\":{\"min\":0.000000,\"max\":0.500000},\"depend_and\":[\"is-rid-hole-t==true\"]},\"is-rid-hole-b\":{\"category\":\"base\",\"title\":\"\\u7a7f\\u5b54\\u79fb\\u9664\\u2014\\u4e0b\\u4fa7\",\"desc\":\"\\u7a7f\\u5b54\\u5728\\u7eb8\\u5f20\\u7684\\u4e0b\\u90e8\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"search-hole-range-b\":{\"category\":\"base\",\"title\":\" \\u4e0b\\u4fa7\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"desc\":\"\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"type\":\"float\",\"cur\":0.100000,\"default\":0.100000,\"size\":4,\"range\":{\"min\":0.000000,\"max\":0.500000},\"depend_and\":[\"is-rid-hole-b==true\"]},\"grp-4\":{\"category\":\"base\",\"title\":\"\\u9001\\u7eb8\\u65b9\\u5f0f\\u8bbe\\u7f6e\",\"type\":\"group\"},\"is-wait-scan\":{\"category\":\"base\",\"title\":\"\\u5f85\\u7eb8\\u626b\\u63cf\",\"desc\":\"\\u542f\\u7528\\u540e\\uff0c\\u6587\\u7a3f\\u653e\\u5165\\u626b\\u63cf\\u4eea\\u65f6\\u5c06\\u81ea\\u52a8\\u542f\\u52a8\\u626b\\u63cf\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"scan-mode\":{\"category\":\"base\",\"title\":\"\\u626b\\u63cf\\u5f20\\u6570\",\"desc\":\"\\u9009\\u62e9\\u6307\\u5b9a\\u6570\\u91cf\\u626b\\u63cf\\u6216\\u8fde\\u7eed\\u626b\\u63cf\",\"type\":\"string\",\"cur\":\"\\u8fde\\u7eed\\u626b\\u63cf\",\"default\":\"\\u8fde\\u7eed\\u626b\\u63cf\",\"size\":32,\"range\":[\"\\u8fde\\u7eed\\u626b\\u63cf\",\"\\u626b\\u63cf\\u6307\\u5b9a\\u5f20\\u6570\"],\"depend_and\":[\"is-wait-scan==false\"]},\"scan-count\":{\"category\":\"base\",\"title\":\" \\u626b\\u63cf\\u6570\\u91cf\",\"desc\":\"\\u626b\\u63cf\\u6307\\u5b9a\\u6570\\u91cf\",\"type\":\"int\",\"cur\":1,\"default\":1,\"size\":4,\"depend_and\":[\"is-wait-scan==false\",\"scan-mode==\\u626b\\u63cf\\u6307\\u5b9a\\u5f20\\u6570\"]},\"direction\":{\"category\":\"base\",\"title\":\"\\u6587\\u7a3f\\u65b9\\u5411\",\"desc\":\"\\u8bbe\\u7f6e\\u56fe\\u50cf\\u7684\\u65b9\\u5411\",\"type\":\"string\",\"cur\":\"0\\u00b0\",\"default\":\"0\\u00b0\",\"size\":40,\"range\":[\"0\\u00b0\",\"90\\u00b0\",\"180\\u00b0\",\"-90\\u00b0\",\"\\u81ea\\u52a8\\u6587\\u672c\\u65b9\\u5411\\u8bc6\\u522b\\u00b0\"]},\"is-rotate-bkg-180\":{\"category\":\"base\",\"title\":\"\\u80cc\\u9762\\u65cb\\u8f6c180\\u00b0\",\"desc\":\"\\u80cc\\u9762\\u626b\\u63cf\\u7684\\u56fe\\u50cf\\u65cb\\u8f6c180\\u00b0\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"page!=\\u5355\\u9762\",\"!=\\u5bf9\\u6298\",\"direction!=\\u81ea\\u52a8\\u6587\\u672c\\u65b9\\u5411\\u8bc6\\u522b\\u00b0\"]},\"is-ultrosonic\":{\"category\":\"base\",\"title\":\"\\u8d85\\u58f0\\u6ce2\\u68c0\\u6d4b\",\"desc\":\"\\u68c0\\u6d4b\\u662f\\u5426\\u51fa\\u73b0\\u53cc\\u5f20\\u9001\\u5165\",\"type\":\"bool\",\"cur\":true,\"default\":true,\"size\":4},\"double-feed\":{\"category\":\"base\",\"title\":\"\\u53cc\\u5f20\\u56fe\\u7247\\u5904\\u7406\",\"desc\":\"\\u68c0\\u6d4b\\u5230\\u53cc\\u5f20\\u8fdb\\u7eb8\\u540e\\u7684\\u5904\\u7406\\u65b9\\u5f0f\",\"type\":\"string\",\"cur\":\"\\u4e22\\u5f03\\u56fe\\u50cf\\u5e76\\u505c\\u6b62\\u626b\\u63cf\",\"default\":\"\\u4e22\\u5f03\\u56fe\\u50cf\\u5e76\\u505c\\u6b62\\u626b\\u63cf\",\"size\":40,\"range\":[\"\\u4e22\\u5f03\\u56fe\\u50cf\\u5e76\\u505c\\u6b62\\u626b\\u63cf\",\"\\u4e0a\\u4f20\\u56fe\\u50cf\\u5e76\\u505c\\u6b62\\u626b\\u63cf\"],\"depend_or\":[\"is-ultrosonic==true\"]},\"is-staple\":{\"category\":\"base\",\"title\":\"\\u88c5\\u8ba2\\u68c0\\u6d4b\",\"desc\":\"\\u68c0\\u6d4b\\u662f\\u5426\\u51fa\\u73b0\\u7c98\\u8fde\\u9001\\u5165\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"is-check-askew\":{\"category\":\"base\",\"title\":\"\\u6b6a\\u659c\\u68c0\\u6d4b\",\"desc\":\"\\u68c0\\u6d4b\\u662f\\u5426\\u51fa\\u73b0\\u6b6a\\u659c\\u9001\\u5165\",\"type\":\"bool\",\"cur\":true,\"default\":true,\"size\":4},\"askew-range\":{\"category\":\"base\",\"title\":\"\\u6b6a\\u659c\\u5bb9\\u5fcd\\u5ea6\",\"desc\":\"\\u503c\\u8d8a\\u5c0f\\uff0c\\u80fd\\u5bb9\\u5fcd\\u5f97\\u9001\\u5165\\u6587\\u7a3f\\u6b6a\\u659c\\u89d2\\u5ea6\\u8d8a\\u5c0f\",\"type\":\"int\",\"cur\":3,\"default\":3,\"size\":4,\"range\":{\"min\":1,\"max\":5},\"depend_or\":[\"is-check-askew==true\"]},\"is-check-dog-ear\":{\"category\":\"base\",\"title\":\"\\u6298\\u89d2\\u68c0\\u6d4b\",\"desc\":\"\\u68c0\\u6d4b\\u6587\\u7a3f\\u662f\\u5426\\u5b58\\u5728\\u6298\\u89d2\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"dog-ear-size\":{\"category\":\"base\",\"title\":\" \\u6298\\u89d2\\u5927\\u5c0f\",\"desc\":\"\\u503c\\u8d8a\\u5c0f\\uff0c\\u80fd\\u68c0\\u6d4b\\u5230\\u7684\\u6298\\u89d2\\u8d8a\\u5c0f\",\"type\":\"int\",\"cur\":70,\"default\":70,\"size\":4,\"range\":{\"min\":0,\"max\":100},\"depend_or\":[\"is-check-dog-ear==true\"]},\"feed-strength\":{\"category\":\"base\",\"title\":\"\\u5206\\u7eb8\\u5f3a\\u5ea6\",\"desc\":\"\\u8bbe\\u7f6e\\u626b\\u63cf\\u4eea\\u7684\\u5206\\u7eb8\\u529b\\u5ea6\",\"type\":\"string\",\"cur\":\"\\u5f31\",\"default\":\"\\u5f31\",\"size\":16,\"range\":[\"\\u5f31\",\"\\u4e00\\u822c\",\"\\u5f3a\"]},\"time-to-sleep\":{\"category\":\"base\",\"title\":\"\\u4f11\\u7720\\u65f6\\u95f4\",\"desc\":\"\\u8bbe\\u7f6e\\u626b\\u63cf\\u4eea\\u7684\\u4f11\\u7720\\u65f6\\u95f4\",\"type\":\"string\",\"cur\":\"\\u4e0d\\u4f11\\u7720\",\"default\":\"\\u4e0d\\u4f11\\u7720\",\"size\":24,\"range\":[\"\\u4e0d\\u4f11\\u7720\",\"\\u4e94\\u5206\\u949f\",\"\\u5341\\u5206\\u949f\",\"\\u534a\\u5c0f\\u65f6\",\"\\u4e00\\u5c0f\\u65f6\",\"\\u4e24\\u5c0f\\u65f6\",\"\\u56db\\u5c0f\\u65f6\"]},\"is-auto-strength\":{\"category\":\"base\",\"title\":\"\\u81ea\\u52a8\\u5206\\u7eb8\\u5f3a\\u5ea6\",\"desc\":\"\\u626b\\u63cf\\u4eea\\u81ea\\u52a8\\u4fee\\u6b63\\u5206\\u7eb8\\u529b\\u5ea6\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"feed-strength-value\":{\"category\":\"base\",\"title\":\" \\u8fdb\\u7eb8\\u5931\\u8d25\\u7387\",\"desc\":\"\\u9ad8\\u4e8e\\u8be5\\u503c\\u65f6\\u626b\\u63cf\\u4eea\\u5c06\\u8c03\\u6574\\u5206\\u7eb8\\u529b\\u5ea6\",\"type\":\"float\",\"cur\":0.100000,\"default\":0.100000,\"size\":4,\"range\":{\"min\":0.100000,\"max\":0.900000},\"depend_or\":[\"is-auto-strength==true\"]}}"); #define PARAM_VID ((DWORD_PTR)1) #define PARAM_PID ((DWORD_PTR)2) #define PARAM_SPEED ((DWORD_PTR)3) #define FIND_DATA(ctrl, count, data, ind) \ { \ ind = -1; \ for(int i = 0; i < (ctrl).##count(); ++i) \ { \ if((ctrl).GetItemData(i) == DWORD_PTR(data))\ { \ ind = i; \ break; \ } \ } \ } IMPLEMENT_DYNAMIC(CDlgMgr, CDialogEx) CDlgMgr::CDlgMgr(CWnd* pParent /*=nullptr*/) : CDialogEx(IDD_MANAGER, pParent) , lst_param_trigger_sel_chg_(false) { } CDlgMgr::~CDlgMgr() { } static bool is_checked(CWnd* ctrl) { return ((CButton*)ctrl)->GetCheck() == BST_CHECKED; } static bool is_checked(CDialogEx* dlg, UINT id) { return is_checked(dlg->GetDlgItem(id)); } static void set_checked(CWnd* ctrl, bool checked) { ((CButton*)ctrl)->SetCheck(checked ? BST_CHECKED : BST_UNCHECKED); } static void set_checked(CDialogEx* dlg, UINT id, bool checked) { return set_checked(dlg->GetDlgItem(id), checked); } static LRESULT vid_pid_edit_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) { wchar_t now[40] = { 0 }; int len = 0, sel = 0, max_len = 4; bool all_digit = true; WNDPROC wndproc = (WNDPROC)GetPropW(hwnd, vid_pid_edit_org_proc.c_str()); std::wstring buf(L""); if (!wndproc) wndproc = DefWindowProcW; switch (msg) { case WM_CHAR: GetWindowTextW(hwnd, now, _countof(now)); len = lstrlenW(now); sel = SendMessage(hwnd, EM_GETSEL, 0, 0); sel = ((sel >> 16) & 0x0ff) - (sel & 0x0ffff); if (wp >= ' ' && len - sel >= max_len) return 0; if (wp >= '0' && wp <= '9') wp = hex[wp - '0']; else if (wp >= 'A' && wp <= 'F') wp = hex[wp - 'A' + 10]; else if (wp >= 'a' && wp <= 'f') wp = hex[wp - 'a' + 10]; else if(wp >= ' ') return 0; break; //case WM_COPY: // return 0; case WM_PASTE: { size_t l = 0; if (file_util::get_clipboard(NULL, &l, CF_UNICODETEXT) == ERROR_INSUFFICIENT_BUFFER) { buf.resize(l + 4); l++; if (file_util::get_clipboard(&buf[0], &l, CF_UNICODETEXT)) l = 0; } if (l == 0) return 0; lp = (LPARAM)&buf[0]; msg = WM_SETTEXT; } case WM_SETTEXT: for (int i = 0; len < max_len + 1 && i < lstrlenW((wchar_t*)lp); ++i) { wchar_t ch = ((wchar_t*)lp)[i]; if (ch >= '0' && ch <= '9') now[len++] = hex[ch - '0']; else if (ch >= 'A' && ch <= 'F') { now[len++] = hex[ch - 'A' + 10]; all_digit = false; } else if (ch >= 'a' && ch <= 'f') { now[len++] = hex[ch - 'a' + 10]; all_digit = false; } else break; } if(len == 0) return 0; if (/*len == max_len + 1 &&*/ all_digit) { sel = _wtoi(now); //if (sel <= 0x0ffff) { now[max_len] = 0; for (int l = max_len - 1; l >= 0; --l, sel >>= 4) now[l] = hex[sel % 16]; } //else // now[max_len] = 0; } lp = (LPARAM)now; break; } return wndproc(hwnd, msg, wp, lp); } static void set_vid_pid_proc(HWND hwnd) { SetPropW(hwnd, vid_pid_edit_org_proc.c_str(), (HANDLE)(FARPROC)GetWindowLong(hwnd, GWL_WNDPROC)); SetWindowLong(hwnd, GWL_WNDPROC, (LONG)(FARPROC)vid_pid_edit_proc); } static WORD vid_pid_edit_value(HWND hwnd) { wchar_t text[40] = { 0 }; int off = 10; WORD vpid = 0; GetWindowTextW(hwnd, text + off, _countof(text) - off - 1); for (int i = 0; text[off + i]; ++i) { const wchar_t* ptr = NULL; text[0] = text[off + i]; ptr = wcsstr(hex, text); if (!ptr) break; vpid <<= 4; vpid += ptr - hex; } return vpid; } void CDlgMgr::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); DDX_Control(pDX, IDC_LIST1, list_); DDX_Control(pDX, IDC_COMBO_ITEM, combo_); DDX_Control(pDX, IDC_IPADDRESS1, ip_); DDX_Control(pDX, IDC_LIST_PARAM, lst_write_down_); DDX_Control(pDX, IDC_LIST_PARAM_TEST, lst_param_); DDX_Control(pDX, IDC_COMBO_PARAM, combo_param_); DDX_Control(pDX, IDC_COMBO_PARAM_VAL, combo_param_val_); DDX_Control(pDX, IDC_COMBO_PARAM2, combo_param2_); DDX_Control(pDX, IDC_COMBO_PARAM3, combo_param_val2_); DDX_Control(pDX, IDC_COMBO_DEVICE, combo_device_); } BEGIN_MESSAGE_MAP(CDlgMgr, CDialogEx) ON_BN_CLICKED(IDC_CHECK2, &CDlgMgr::OnBnClickedCheckReport) ON_MESSAGE(WM_USER + 1, &CDlgMgr::OnDisableIPCtrl) ON_BN_CLICKED(IDC_BUTTON_MAINTAIN, &CDlgMgr::OnBnClickedButtonMaintain) ON_BN_CLICKED(IDC_BUTTON_ADD, &CDlgMgr::OnBnClickedButtonAdd) ON_CBN_SELCHANGE(IDC_COMBO_ITEM, &CDlgMgr::OnCbnSelchangeComboItem) ON_NOTIFY(NM_DBLCLK, IDC_LIST1, &CDlgMgr::OnNMDblclkList1) ON_BN_CLICKED(IDC_BUTTON_ADD_ALL, &CDlgMgr::OnBnClickedButtonAddAll) ON_WM_DROPFILES() // ON_WM_GETDLGCODE() ON_COMMAND(ID_LIST_PASTE_CLIPBOARD, &CDlgMgr::OnListPasteClipboard) ON_NOTIFY(NM_RCLICK, IDC_LIST1, &CDlgMgr::OnNMRClickList1) ON_COMMAND(ID_LIST_CLEAR, &CDlgMgr::OnListClear) ON_BN_CLICKED(IDC_BUTTON_ADD_PARAM, &CDlgMgr::OnBnClickedButtonAddParam) ON_BN_CLICKED(IDC_BUTTON_CLEAR_ALL, &CDlgMgr::OnBnClickedButtonClearAll) ON_CBN_SELCHANGE(IDC_COMBO_PARAM, &CDlgMgr::OnCbnSelchangeComboParam) ON_NOTIFY(NM_CLICK, IDC_LIST_PARAM, &CDlgMgr::OnLvnItemchangedListParam) ON_NOTIFY(NM_DBLCLK, IDC_LIST_PARAM, &CDlgMgr::OnNMDblclkListParam) ON_BN_CLICKED(IDC_BUTTON_ADD_PARAM2, &CDlgMgr::OnBnClickedButtonAddParam2) ON_BN_CLICKED(IDC_BUTTON_ADD_PARAM3, &CDlgMgr::OnBnClickedButtonAddParam3) ON_CBN_SELCHANGE(IDC_COMBO_PARAM2, &CDlgMgr::OnCbnSelchangeComboParam2) ON_NOTIFY(NM_CLICK, IDC_LIST_PARAM_TEST, &CDlgMgr::OnNMClickListParamTest) ON_NOTIFY(NM_DBLCLK, IDC_LIST_PARAM_TEST, &CDlgMgr::OnNMDblclkListParamTest) ON_NOTIFY(NM_CLICK, IDC_LIST1, &CDlgMgr::OnNMClickList1) ON_BN_CLICKED(IDC_BUTTON_REFRESH, &CDlgMgr::OnBnClickedButtonRefresh) END_MESSAGE_MAP() static DWORD WINAPI disable_ip_ctrl(LPVOID lp) { Sleep(500); PostMessage((HWND)lp, WM_USER + 1, 0, 0); return 0; } LRESULT CDlgMgr::OnDisableIPCtrl(WPARAM, LPARAM) { OnBnClickedCheckReport(); return 0; } // CDlgMgr 消息处理程序 BOOL CDlgMgr::OnInitDialog() { CDialogEx::OnInitDialog(); std::vector cols; LSTCOL col; col.align = 0; col.title = L"\u5E8F\u53F7"; col.width = 40; cols.push_back(col); col.title = L"\u6D4B\u8BD5\u9879\u76EE"; col.width = 160; cols.push_back(col); col.title = L"\u6D4B\u8BD5\u5DE5\u4F4D"; col.width = 60; cols.push_back(col); col.title = L"\u5458\u5DE5\u6743\u9650"; col.width = 60; cols.push_back(col); col.title = L"\u8054\u673A"; col.width = 40; cols.push_back(col); col.title = L"\u5931\u8D25\u5219\u505C\u6B62"; col.width = 80; cols.push_back(col); init_list_ctrl(&list_, cols); cols.clear(); col.title = L"\u53C2\u6570\u540D\u79F0"; col.width = 120; cols.push_back(col); col.title = L"\u53C2\u6570\u503C"; col.width = 160; cols.push_back(col); init_list_ctrl(&lst_write_down_, cols); init_list_ctrl(&lst_param_, cols); set_vid_pid_proc(GetDlgItem(IDC_EDIT_VID_SRC)->m_hWnd); set_vid_pid_proc(GetDlgItem(IDC_EDIT_PID_SRC)->m_hWnd); SetDlgItemInt(IDC_EDIT_VID_SRC, 0x3072); SetDlgItemInt(IDC_EDIT_PID_SRC, 0x200); std::wstring jsn(L""); get_sane_config(jsn); sane_cfg_ = known_file_util::create_jsonW(); load_sane_config(jsn); GetDlgItem(IDC_EDIT_PARAM_VAL)->ShowWindow(SW_HIDE); combo_device_.SetCurSel(1); return TRUE; // 除非将焦点设置到控件,否则返回 TRUE } void CDlgMgr::OnBnClickedCheckReport() { // TODO: 在此添加控件通知处理程序代码 bool enable = is_checked(this, IDC_CHECK2); GetDlgItem(IDC_IPADDRESS1)->EnableWindow(enable); GetDlgItem(IDC_IPADDRESS1)->ShowWindow(SW_SHOW); GetDlgItem(IDC_EDIT_IP)->ShowWindow(SW_HIDE); GetDlgItem(IDC_EDIT_PORT)->EnableWindow(enable); GetDlgItem(IDC_EDIT_DB)->EnableWindow(enable); if (enable) GotoDlgCtrl(GetDlgItem(IDC_IPADDRESS1)); } void CDlgMgr::OnBnClickedButtonMaintain() { // TODO: 在此添加控件通知处理程序代码 ::PostMessage(GetParent()->m_hWnd, WM_TO_ITEM_MGR_TAB, 0, 0); } void CDlgMgr::OnBnClickedButtonRefresh() { // TODO: 在此添加控件通知处理程序代码 if (::MessageBoxW(m_hWnd, L"刷新测试项,需要清空列表,要继续刷新吗?", L"Warning", MB_YESNO | MB_ICONQUESTION) != IDYES) return; OnBnClickedButtonClearAll(); ::PostMessage(GetParent()->m_hWnd, WM_REFRESH_TEST_ITEM, 0, 0); } void CDlgMgr::OnBnClickedButtonAdd() { // TODO: 在此添加控件通知处理程序代码 wchar_t text[128] = { 0 }; int ind = -1, sel = combo_.GetCurSel(); known_file_util::IJsonW* json = (known_file_util::IJsonW*)combo_.GetItemData(sel); if (::GetWindowTextW(GetDlgItem(IDC_COMBO_ITEM)->m_hWnd, text, _countof(text) - 1) == 0) return; // sn title station priv online fatal ind = find_list_item(&list_, text, 1); if (ind == -1) { const wchar_t* val = NULL; int col = 1, nv = 0; bool man = false; ind = list_.InsertItem(list_.GetItemCount(), std::to_wstring(list_.GetItemCount() + 1).c_str()); if (json->get_value(L"title", &val)) list_.SetItemText(ind, col++, val); else col++; if(json->get_value(L"station", &val)) list_.SetItemText(ind, col++, val); else col++; if(json->get_value(L"authority", nv)) list_.SetItemText(ind, col++, std::to_wstring(nv).c_str()); else col++; json->get_value(L"man", man); list_.SetItemText(ind, col++, man ? L"false" : L"true"); json->get_value(L"err-level", &val); list_.SetItemText(ind, col++, wcscmp(val, L"fatal") ? L"false" : L"true"); list_.SetItemData(ind, (DWORD_PTR)json); json->add_ref(); } select_list_item(&list_, ind); } void CDlgMgr::OnCbnSelchangeComboItem() { // TODO: 在此添加控件通知处理程序代码 wchar_t text[128]; int ind = -1; ::GetWindowTextW(GetDlgItem(IDC_COMBO_ITEM)->m_hWnd, text, _countof(text) - 1); ind = find_list_item(&list_, text, 1); if(ind != -1) select_list_item(&list_, ind); } void CDlgMgr::OnNMDblclkList1(NMHDR* pNMHDR, LRESULT* pResult) { LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast(pNMHDR); // TODO: 在此添加控件通知处理程序代码 POINT pos = { 0 }; RECT r = { 0 }; GetCursorPos(&pos); list_.ScreenToClient(&pos); r.left = list_.HitTest(pos); if (r.left != -1) { std::vector width; int ind = r.left, hpos = list_.GetScrollPos(SB_HORZ); known_file_util::IJsonW* json = (known_file_util::IJsonW*)list_.GetItemData(ind); for (int i = 0; i < list_.GetHeaderCtrl()->GetItemCount(); ++i) { RECT r = { 0 }; list_.GetHeaderCtrl()->GetItemRect(i, &r); width.push_back(r.right - r.left); } pos.x += hpos; for (int i = 0; i < width.size(); ++i) { if (pos.x <= width[i]) { wchar_t text[128] = { 0 }; if (i < 2) { DWORD_PTR data = NULL; if (remove_prompt(&list_, ind, 1, L"\u5220\u9664\u6D4B\u8BD5\u9879\u76EE\uFF1F", &data)) { known_file_util::IJsonW* json = (known_file_util::IJsonW*)data; if(json) json->release(); for (; ind < list_.GetItemCount(); ++ind) { swprintf_s(text, _countof(text) - 1, L"%u", ind + 1); list_.SetItemText(ind, 0, text); } } } else if (i < 4) { CDlgInput dlg; dlg.val_ = get_list_item_text(&list_, ind, i); dlg.title_ = get_list_column_title(&list_, i); if (dlg.DoModal() == IDOK) { list_.SetItemText(ind, i, dlg.val_.c_str()); if (i == 2) json->set_value(L"station", dlg.val_.c_str()); else json->set_value(L"authority", _wtoi(dlg.val_.c_str())); } } else { list_.GetItemText(ind, i, text, _countof(text) - 1); if (wcscmp(text, L"true")) { list_.SetItemText(ind, i, L"true"); if (i == 4) json->set_value(L"man", false); else json->set_value(L"err-level", L"fatal"); } else { list_.SetItemText(ind, i, L"false"); if (i == 4) json->set_value(L"man", true); else json->set_value(L"err-level", L"ignore"); } } break; } pos.x -= width[i]; } } *pResult = 0; } void CDlgMgr::OnBnClickedButtonAddAll() { // TODO: 在此添加控件通知处理程序代码 for (int i = 0; i < combo_.GetCount(); ++i) { combo_.SetCurSel(i); OnCbnSelchangeComboItem(); OnBnClickedButtonAdd(); } } void CDlgMgr::init_test_items(known_file_util::IJsonW* json) { int ind = 1; for (int i = 0; i < combo_.GetCount(); ++i) ((known_file_util::IJsonW*)combo_.GetItemData(i))->release(); combo_.ResetContent(); known_file_util::IJsonW* item = json->first_child(); while (item) { known_file_util::IJsonW* data = NULL; std::wstring text(L""); const wchar_t* val = NULL; int cb_ind = 0; item->to_string(got_wstr, &text); item->release(); data = known_file_util::create_jsonW(text.c_str()); if (data) { data->get_value(L"title", &val); if (val) { cb_ind = combo_.AddString(val); combo_.SetItemData(cb_ind, (DWORD_PTR)data); } else { data->release(); } } item = json->next_child(); } } INTER_MODULE_CALLBACK(got_wstr) { *((std::wstring*)param) += std::wstring((const wchar_t*)data, len / 2); return inter_module_data::SET_RESULT_CONTINUE; } void init_list_ctrl(CListCtrl* lst, const std::vector& cols) { while (lst->DeleteColumn(0)); for (const auto& v : cols) { lst->InsertColumn(lst->GetHeaderCtrl()->GetItemCount(), v.title.c_str(), v.align, v.width); } lst->SetExtendedStyle((lst->GetExStyle() | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES) & (~LVS_EX_CHECKBOXES)); lst->ModifyStyle(0, LVS_SINGLESEL); } std::wstring get_list_item_text(CListCtrl* lst, int item, int col) { int len = 10, size = len; wchar_t* buf = new wchar_t[len]; while (lst->GetItemText(item, col, buf, len - 1) == len - 2) { len *= 2; delete[] buf; buf = new wchar_t[len]; } std::wstring ret(buf); delete[] buf; return ret; } std::wstring get_list_column_title(CListCtrl* lst, int col) { HDITEMW item = { 0 }; wchar_t buf[256] = { 0 }; item.cchTextMax = _countof(buf) - 1; item.pszText = buf; item.mask = LVIF_TEXT; lst->GetHeaderCtrl()->GetItem(col, &item); return buf; } int find_list_item(CListCtrl* lst, const wchar_t* find, int col) { for (int i = 0; i < lst->GetItemCount(); ++i) { if (get_list_item_text(lst, i, col) == find) return i; } return -1; } int get_list_selected_item(CListCtrl* lst) { POSITION pos = lst->GetFirstSelectedItemPosition(); return lst->GetNextSelectedItem(pos); } void select_list_item(CListCtrl* lst, int item) { lst->SetItemState(item, LVNI_FOCUSED | LVIS_SELECTED, LVNI_FOCUSED | LVIS_SELECTED); lst->EnsureVisible(item, FALSE); } WORD vid_pid_from_hex(const wchar_t* hex, bool* ok) { WORD id = 0; bool good = true; if (!ok) ok = &good; *ok = true; while (*hex == L' ' || *hex == L'\t') hex++; for (int i = 0; i < 4; ++i) { if (*hex >= L'0' && *hex <= L'9') { id <<= 4; id += *hex - L'0'; } else if (*hex >= L'a' && *hex <= L'f') { id <<= 4; id += *hex - L'a' + 10; } else if (*hex >= L'A' && *hex <= L'F') { id <<= 4; id += *hex - L'A' + 10; } else { *ok = false; break; } hex++; } if (*ok) { while (*hex == L' ' || *hex == L'\t') hex++; *ok = *hex == 0; } return id; } void set_sane_config(known_file_util::IJsonW* sane, known_file_util::IJsonW* cfg, std::wstring& val) { const wchar_t* type = NULL; if (sane->get_value(L"type", &type) && type) { if (wcscmp(type, L"bool") == 0) { cfg->set_value(sane->key(), val == L"true"); } else if (wcscmp(type, L"int") == 0) { cfg->set_value(sane->key(), _wtoi(val.c_str())); } else if (wcscmp(type, L"int") == 0) { cfg->set_value(sane->key(), _wtof(val.c_str())); } else // string { cfg->set_value(sane->key(), val.c_str()); } } } void get_sane_config(std::wstring& cfg) { coding_util::utf8_2_unicode((jsontext1 + jsontext2).c_str(), got_wstr, &cfg); } void on_combo_param_changed(HWND dlg, CComboBox* param_ctrl, CComboBox* val_ctrl, CListCtrl* lst, UINT edit_id, bool lst_trigger) { int ind = param_ctrl->GetCurSel(), item = -1; DWORD_PTR data = param_ctrl->GetItemData(ind); ShowWindow(GetDlgItem(dlg, edit_id), SW_HIDE); val_ctrl->ShowWindow(SW_HIDE); // if(!lst_param_trigger_sel_chg_) { wchar_t text[128] = { 0 }; ::GetWindowTextW(param_ctrl->m_hWnd, text, _countof(text) - 1); item = find_list_item(lst, text); if (item != -1 && !lst_trigger) select_list_item(lst, item); } if (data == PARAM_VID || data == PARAM_PID || data == PARAM_SPEED) { ShowWindow(GetDlgItem(dlg, edit_id), SW_SHOW); if (item != -1) { ::SetDlgItemTextW(dlg, edit_id, get_list_item_text(lst, item, 1).c_str()); } SetFocus(GetDlgItem(dlg, edit_id)); } else { known_file_util::IJsonW* jsn = (known_file_util::IJsonW*)data, * range = NULL; const wchar_t* val = NULL; jsn->get_value(L"range", &range); if (range) { int l = 0; double lf = .0f; if (range->get_value(L"min", l) || range->get_value(L"min", lf)) { ShowWindow(GetDlgItem(dlg, edit_id), SW_SHOW); if (item != -1) { ::SetDlgItemTextW(dlg, edit_id, get_list_item_text(lst, item, 1).c_str()); } SetFocus(GetDlgItem(dlg, edit_id)); } else { val_ctrl->ShowWindow(SW_SHOW); val_ctrl->ResetContent(); jsn->get_value(L"type", &val); if (val) { if (wcscmp(val, L"int") == 0) { if (range->members()) { known_file_util::JSONMEMW m = range->first_member(known_file_util::JV_INT); val_ctrl->AddString(std::to_wstring(m.int_val).c_str()); for (int i = 1; i < range->members(); ++i) { m = range->next_member(); val_ctrl->AddString(std::to_wstring(m.int_val).c_str()); } } } else if (wcscmp(val, L"float") == 0) { if (range->members()) { known_file_util::JSONMEMW m = range->first_member(known_file_util::JV_FLOAT); val_ctrl->AddString(std::to_wstring(m.double_val).c_str()); for (int i = 1; i < range->members(); ++i) { m = range->next_member(); val_ctrl->AddString(std::to_wstring(m.double_val).c_str()); } } } else // string { if (range->members()) { known_file_util::JSONMEMW m = range->first_member(known_file_util::JV_STRING); val_ctrl->AddString(m.str_val); for (int i = 1; i < range->members(); ++i) { m = range->next_member(); val_ctrl->AddString(m.str_val); } } } if (item != -1) { std::wstring str(get_list_item_text(lst, item, 1)); item = val_ctrl->FindStringExact(-1, str.c_str()); } else item = 0; val_ctrl->SetCurSel(item); } } range->release(); } else { jsn->get_value(L"type", &val); if (val && wcscmp(val, L"bool") == 0) { val_ctrl->ShowWindow(SW_SHOW); val_ctrl->ResetContent(); val_ctrl->AddString(TEXT("true")); val_ctrl->AddString(TEXT("false")); if (item != -1) { std::wstring str(get_list_item_text(lst, item, 1)); item = val_ctrl->FindStringExact(-1, str.c_str()); } else item = 0; val_ctrl->SetCurSel(item); } else { ShowWindow(GetDlgItem(dlg, edit_id), SW_SHOW); if (item != -1) { ::SetDlgItemTextW(dlg, edit_id, get_list_item_text(lst, item, 1).c_str()); } SetFocus(GetDlgItem(dlg, edit_id)); } } } } int add_param(HWND dlg, CComboBox* param_ctrl, CComboBox* val_ctrl, CListCtrl* lst, UINT edit_id) { wchar_t val[128] = { 0 }; int ind = -1; DWORD_PTR data = param_ctrl->GetItemData(param_ctrl->GetCurSel()); bool added = false; known_file_util::IJsonW* jsn = (known_file_util::IJsonW*)data, * child = NULL; const wchar_t* type = NULL; ::GetWindowTextW(param_ctrl->m_hWnd, val, _countof(val) - 1); ind = find_list_item(lst, val); if (ind == -1) { ind = lst->InsertItem(lst->GetItemCount(), val); added = true; } if (val_ctrl->IsWindowVisible()) { ::GetWindowTextW(val_ctrl->m_hWnd, val, _countof(val) - 1); jsn->get_value(L"type", &type); } else { ::GetDlgItemTextW(dlg, edit_id, val, _countof(val) - 1); if (data == PARAM_VID || data == PARAM_PID) { bool ok = false; wchar_t* ptr = val; int id = vid_pid_from_hex(ptr, &ok); if (!ok) { ::MessageBoxW(dlg, L"\uFF36\uFF29\uFF24\u2014\uFF30\uFF29\uFF24\u5FC5\u987B\u4E3A\uFF14\u4F4D\uFF11\uFF16\u8FDB\u5236\u6570\u636E\uFF01", L"Error", MB_OK | MB_ICONSTOP); if (added) lst->DeleteItem(ind); SetFocus(GetDlgItem(dlg, edit_id)); return - 1; } } else if (data == PARAM_SPEED) { } else// if (data != PARAM_VID && data != PARAM_PID && data != PARAM_SPEED) { jsn->get_value(L"type", &type); if (jsn->get_value(L"range", &child)) { double l = .0f, u = .0f; if (wcscmp(type, L"int") == 0) { int nl = 0, nu = 0; child->get_value(L"min", nl); child->get_value(L"max", nu); l = nl; u = nu; } else if (wcscmp(type, L"float") == 0) { child->get_value(L"min", l); child->get_value(L"max", u); } if (_wtof(val) < l || _wtof(val) > u) { if (wcscmp(type, L"int") == 0) swprintf_s(val, _countof(val) - 1, L"\u6570\u503C\u5FC5\u987B\u5728\uFF3B%d, %d\uFF3D\u4E4B\u95F4\uFF01", (int)l, (int)u); else swprintf_s(val, _countof(val) - 1, L"\u6570\u503C\u5FC5\u987B\u5728\uFF3B%f, %f\uFF3D\u4E4B\u95F4\uFF01", l, u); ::MessageBoxW(dlg, val, L"Error", MB_OK | MB_ICONWARNING); SetFocus(GetDlgItem(dlg, edit_id)); if (added) lst->DeleteItem(ind); return -1; } } if (wcscmp(type, L"int") == 0) { swprintf_s(val, _countof(val) - 1, L"%d", (int)(_wtof(val) + .5f)); } } } lst->SetItemText(ind, 1, val); lst->SetItemData(ind, data); return ind; } static int find_template(CComboBox* cb, const wchar_t* name, known_file_util::IJsonW** json = NULL) { const wchar_t* val = NULL; for (int i = 0; i < cb->GetCount(); ++i) { known_file_util::IJsonW* jsn = (known_file_util::IJsonW*)cb->GetItemData(i); jsn->get_value(L"name", &val); if (wcscmp(name, val) == 0) { if (json) *json = jsn; return i; } } return -1; } std::wstring CDlgMgr::export_config(bool *ok, bool used_in_code, int code_ver) { known_file_util::IJsonW * jsn = known_file_util::create_jsonW(), * child = NULL; wchar_t text[256] = { 0 }; bool result = false; if (!ok) ok = &result; *ok = false; if (!used_in_code) { WORD vid_f = vid_pid_edit_value(GetDlgItem(IDC_EDIT_VID_SRC)->m_hWnd), pid_f = vid_pid_edit_value(GetDlgItem(IDC_EDIT_PID_SRC)->m_hWnd), vid_t = 0, pid_t = 0, sleep = 0, // GetDlgItemInt(IDC_EDIT_SLEEP), speed = 0, // GetDlgItemInt(IDC_EDIT_SPEED), port = 0; bool report = is_checked(GetDlgItem(IDC_CHECK2)), has_vid = false, has_pid = false, has_speed = false; BYTE ip1 = 0, ip2 = 0, ip3 = 0, ip4 = 0; if (!vid_f) { GotoDlgCtrl(GetDlgItem(IDC_EDIT_VID_SRC)); jsn->release(); return L"\u8BF7\u91CD\u65B0\u8F93\u5165 \u6E90\uFF36\uFF29\uFF24\uFF01"; } if (!pid_f) { GotoDlgCtrl(GetDlgItem(IDC_EDIT_PID_SRC)); jsn->release(); return L"\u8BF7\u91CD\u65B0\u8F93\u5165 \u6E90\uFF30\uFF29\uFF24\uFF01"; } child = known_file_util::create_jsonW(); if (report) { ip_.GetAddress(ip1, ip2, ip3, ip4); port = GetDlgItemInt(IDC_EDIT_PORT); ::GetDlgItemTextW(m_hWnd, IDC_EDIT_DB, text, _countof(text) - 1); std::wstring url(text); swprintf_s(text, _countof(text) - 1, L"%u:", port); url.insert(0, text); swprintf_s(text, _countof(text) - 1, L"%u.%u.%u.%u:", ip1, ip2, ip3, ip4); url.insert(0, text); child->set_value(L"report-url", url.c_str()); } child->set_value(L"vid-org", vid_f); child->set_value(L"pid-org", pid_f); ::GetDlgItemTextW(m_hWnd, IDC_COMBO_DEVICE, text, _countof(text) - 1); child->set_value(L"type", text); known_file_util::IJsonW* write = known_file_util::create_jsonW(); for(int i = 0; i< lst_write_down_.GetItemCount(); ++i) { DWORD_PTR data = lst_write_down_.GetItemData(i); std::wstring text(get_list_item_text(&lst_write_down_, i, 1)); bool hex = true; if (data == PARAM_VID) { has_vid = true; vid_t = vid_pid_from_hex(text.c_str(), &hex); if (!hex) { select_list_item(&lst_write_down_, i); ::MessageBoxW(m_hWnd, L"目标VID输入非法,请更正!", L"Error", MB_OK | MB_ICONSTOP); vid_t = 0; break; } write->set_value(L"vid-to", vid_t); } else if (data == PARAM_PID) { has_pid = true; pid_t = vid_pid_from_hex(text.c_str(), &hex); if (!hex) { select_list_item(&lst_write_down_, i); ::MessageBoxW(m_hWnd, L"目标PID输入非法,请更正!", L"Error", MB_OK | MB_ICONSTOP); pid_t = 0; break; } write->set_value(L"pid-to", pid_t); } else if (data == PARAM_SPEED) { has_speed = true; speed = _wtoi(text.c_str()); write->set_value(L"speed-mode", speed); } else { set_sane_config((known_file_util::IJsonW*)data, write, text); } } child->set_value(L"write-down", write); jsn->set_value(L"global", child); write->release(); child->release(); if (!has_vid) { int ind = 0; FIND_DATA(combo_param_, GetCount, PARAM_VID, ind); if (ind != -1) { combo_param_.SetCurSel(ind); OnCbnSelchangeComboParam(); } jsn->release(); return L"没有输入目标VID!"; } if (!has_pid) { int ind = 0; FIND_DATA(combo_param_, GetCount, PARAM_PID, ind); if (ind != -1) { combo_param_.SetCurSel(ind); OnCbnSelchangeComboParam(); } jsn->release(); return L"没有输入目标PID!"; } if (!has_speed) { if (::MessageBoxW(m_hWnd, L"没有写入速度模式参数,是否返回设置?", L"缺少速度模式", MB_YESNO | MB_ICONQUESTION) == IDYES) { int ind = 0; FIND_DATA(combo_param_, GetCount, PARAM_SPEED, ind); if (ind != -1) { combo_param_.SetCurSel(ind); OnCbnSelchangeComboParam(); jsn->release(); return L"没有写入速度模式参数"; } } } if (vid_t == 0 || pid_t == 0) { jsn->release(); return L""; } } if (list_.GetItemCount() == 0) { jsn->release(); return L"\u6CA1\u6709\u8F93\u5165\u6709\u6548\u7684\u6D4B\u8BD5\u9879\u76EE\uFF01"; } for (size_t i = 0; i < list_.GetItemCount(); ++i) { known_file_util::IJsonW* item = (known_file_util::IJsonW*)list_.GetItemData(i); if (used_in_code) { known_file_util::IJsonW* c = known_file_util::create_jsonW(); const wchar_t* val = NULL; item->get_value(L"name", &val); c->set_value(L"name", val); c->set_value(L"ver", code_ver); jsn->set_value(std::to_wstring(i + 1).c_str(), c); c->release(); } else { jsn->set_value(std::to_wstring(i + 1).c_str(), item); } } std::wstring ret(L""); jsn->to_string(got_wstr, &ret); jsn->release(); if (used_in_code) { size_t pos = ret.find(L"\""); while (pos != std::string::npos) { ret.insert(pos, L"\\"); pos = ret.find(L"\"", pos + 2); } pos = ret.find(L"\\u"); while (pos != std::string::npos) { ret.insert(pos, L"\\"); pos = ret.find(L"\\u", pos + 3); } // divide into multi-lines with 16KB per line ... int lines = 1; wchar_t var[80] = { 0 }; pos = ret.length(); while (pos > 16 * 1024) { pos -= 12 * 1024; while (ret[pos - 1] == L'\\') pos++; lines++; swprintf_s(var, _countof(var) - 1, L"\");\r\nstatic std::wstring jsontext%d(L\"", lines); ret.insert(pos, var); } ret.insert(0, L"static std::string jsontext1(\""); ret += L"\");\r\n"; } *ok = true; return ret; } static void trans_code_json(std::wstring& json) { size_t pos = json.find(L"(\""); if (pos == std::wstring::npos) return; json.erase(0, pos + 2); pos = json.rfind(L'\"'); if (pos != std::wstring::npos) json.erase(pos); pos = 0; while ((pos = json.find(L"\\\""), pos) != std::wstring::npos) { json.erase(pos++, 1); } pos = 0; while ((pos = json.find(L"\\"), pos) != std::wstring::npos) { json.erase(pos++, 1); } } void CDlgMgr::add_param_from_config(CComboBox* param_ctrl, CComboBox* val_ctrl, UINT edit_id, known_file_util::IJsonW* sane, known_file_util::IJsonW* cfg, const wchar_t* key, void(CDlgMgr::* cb_change)(void), void(CDlgMgr::* add_func)(void)) { const wchar_t* type = NULL, * val = NULL; int ind = 0; sane->get_value(L"type", &type); FIND_DATA(*param_ctrl, GetCount, sane, ind); if (ind != -1) { param_ctrl->SetCurSel(ind); (this->*cb_change)(); if (wcscmp(type, L"bool") == 0) { bool bv = false; cfg->get_value(key, bv); ind = val_ctrl->FindStringExact(-1, bv ? L"true" : L"false"); val_ctrl->SetCurSel(ind); } else if (wcscmp(type, L"int") == 0) { cfg->get_value(key, ind); SetDlgItemInt(edit_id, ind); ind = val_ctrl->FindStringExact(-1, std::to_wstring(ind).c_str()); val_ctrl->SetCurSel(ind); } else if (wcscmp(type, L"float") == 0) { double dv = .0f; cfg->get_value(key, dv); SetDlgItemTextW(edit_id, std::to_wstring(dv).c_str()); ind = val_ctrl->FindStringExact(-1, std::to_wstring(dv).c_str()); val_ctrl->SetCurSel(ind); } else // string { cfg->get_value(key, &val); SetDlgItemTextW(edit_id, val); ind = val_ctrl->FindStringExact(-1, val); val_ctrl->SetCurSel(ind); } (this->*add_func)(); } } void CDlgMgr::reload(std::wstring& cont) { bool code_jsn = false; if (cont.find(L"static std::string") == 0) { trans_code_json(cont); code_jsn = true; } known_file_util::IJsonW* jsn = known_file_util::create_jsonW(); if (jsn->attach(cont.c_str())) { known_file_util::IJsonW* child = NULL; const wchar_t* val = NULL; int ind = 0, id = 0; jsn->get_value(L"global", &child); lst_write_down_.DeleteAllItems(); if (child) { if (child->get_value(L"type", &val) && val) { ind = combo_.FindStringExact(-1, val); if (ind == -1) ind = combo_.AddString(val); combo_.SetCurSel(ind); } if (child->get_value(L"vid-org", ind)) SetDlgItemInt(IDC_EDIT_VID_SRC, ind); if (child->get_value(L"pid-org", ind)) SetDlgItemInt(IDC_EDIT_PID_SRC, ind); known_file_util::IJsonW* write = NULL; child->get_value(L"write-down", &write); if (write) { known_file_util::IJsonW* wc = write->first_child(); while (wc) { if (wcscmp(wc->key(), L"vid-to") == 0) { write->get_value(wc->key(), id); FIND_DATA(combo_param_, GetCount, PARAM_VID, ind); if (ind != -1) { combo_param_.SetCurSel(ind); OnCbnSelchangeComboParam(); SetDlgItemInt(IDC_EDIT_PARAM_VAL, id); OnBnClickedButtonAddParam(); } } else if (wcscmp(wc->key(), L"pid-to") == 0) { write->get_value(wc->key(), id); FIND_DATA(combo_param_, GetCount, PARAM_PID, ind); if (ind != -1) { combo_param_.SetCurSel(ind); OnCbnSelchangeComboParam(); SetDlgItemInt(IDC_EDIT_PARAM_VAL, id); OnBnClickedButtonAddParam(); } } else if (wcscmp(wc->key(), L"speed-mode") == 0) { write->get_value(wc->key(), id); FIND_DATA(combo_param_, GetCount, PARAM_SPEED, ind); if (ind != -1) { combo_param_.SetCurSel(ind); OnCbnSelchangeComboParam(); SetDlgItemInt(IDC_EDIT_PARAM_VAL, id); OnBnClickedButtonAddParam(); } } else { known_file_util::IJsonW* sane = NULL; sane_cfg_->get_value(wc->key(), &sane); if (sane) { add_param_from_config(&combo_param_, &combo_param_val_, IDC_EDIT_PARAM_VAL, sane, write, wc->key(), &CDlgMgr::OnCbnSelchangeComboParam, &CDlgMgr::OnBnClickedButtonAddParam); sane->release(); } } } write->release(); } else { int nv = 0; if (child->get_value(L"vid-to", nv)) { FIND_DATA(combo_param_, GetCount, PARAM_VID, ind); if (ind != -1) { wchar_t hex[40] = { 0 }; swprintf_s(hex, _countof(hex) - 1, L"%04x", nv); combo_param_.SetCurSel(ind); OnCbnSelchangeComboParam(); ::SetDlgItemTextW(m_hWnd, IDC_EDIT_PARAM_VAL, hex); OnBnClickedButtonAddParam(); } } if (child->get_value(L"pid-to", nv)) { FIND_DATA(combo_param_, GetCount, PARAM_PID, ind); if (ind != -1) { wchar_t hex[40] = { 0 }; swprintf_s(hex, _countof(hex) - 1, L"%04x", nv); combo_param_.SetCurSel(ind); OnCbnSelchangeComboParam(); ::SetDlgItemTextW(m_hWnd, IDC_EDIT_PARAM_VAL, hex); OnBnClickedButtonAddParam(); } } if (child->get_value(L"speed-mode", nv)) { FIND_DATA(combo_param_, GetCount, PARAM_SPEED, ind); if (ind != -1) { combo_param_.SetCurSel(ind); OnCbnSelchangeComboParam(); SetDlgItemInt(IDC_EDIT_PARAM_VAL, nv); OnBnClickedButtonAddParam(); } } if (child->get_value(L"sleep-time", nv)) { ind = -1; for (int i = 0; i < combo_param_.GetCount(); ++i) { DWORD_PTR data = combo_param_.GetItemData(i); if (data != PARAM_VID && data != PARAM_PID && data != PARAM_SPEED) { known_file_util::IJsonW* jsn = (known_file_util::IJsonW*)data; if (wcscmp(jsn->key(), L"time-to-sleep") == 0) { ind = i; break; } } } if (ind != -1) { combo_param_.SetCurSel(ind); OnCbnSelchangeComboParam(); ind = combo_param_val_.FindStringExact(-1, L"\u4E94\u5206\u949F"); if (ind != -1) combo_param_val_.SetCurSel(ind); OnBnClickedButtonAddParam(); } } } child->release(); } OnListClear(); ind = 1; while (jsn->get_value(std::to_wstring(ind++).c_str(), &child)) { known_file_util::IJsonW* tpl = NULL; child->get_value(L"name", &val); if (child->get_value(L"ver", id)) ::PostMessage(GetParent()->m_hWnd, WM_SET_CODE_VER, 0, (LPARAM)id); id = find_template(&combo_, val, &tpl); if (tpl) { combo_.SetCurSel(id); OnBnClickedButtonAdd(); FIND_DATA(list_, GetItemCount, tpl, id); if (id != -1) { bool bv = false; int nv = 0; if (child->get_value(L"station", &val)) list_.SetItemText(id, 2, val); if (child->get_value(L"authority", nv)) list_.SetItemText(id, 3, std::to_wstring(nv).c_str()); if (child->get_value(L"man", bv)) list_.SetItemText(id, 4, bv ? L"false" : L"true"); if (child->get_value(L"err-level", &val)) list_.SetItemText(id, 5, wcscmp(val, L"fatal") ? L"false" : L"true"); known_file_util::IJsonW* param = NULL; child->get_value(L"param", ¶m); if (param) { known_file_util::IJsonW* c = param->first_child(); OnBnClickedButtonAddParam3(); while (c) { known_file_util::IJsonW* s = NULL; sane_cfg_->get_value(c->key(), &s); if (s) { add_param_from_config(&combo_param2_, &combo_param_val2_, IDC_EDIT_PARAM_VAL2, s, param, c->key(), &CDlgMgr::OnCbnSelchangeComboParam2, &CDlgMgr::OnBnClickedButtonAddParam2); s->release(); } c->release(); c = param->next_child(); } param->release(); } } } child->release(); } } jsn->release(); } bool CDlgMgr::load_sane_config(std::wstring& jsn_txt) { known_file_util::IJsonW* jsn = known_file_util::create_jsonW(jsn_txt.c_str()); if (jsn) { int ind = 0; sane_cfg_->release(); sane_cfg_ = jsn; combo_param_.ResetContent(); ind = combo_param_.AddString(L"\u76EE\u6807\uFF36\uFF29\uFF24"); combo_param_.SetItemData(ind, PARAM_VID); ind = combo_param_.AddString(L"\u76EE\u6807\uFF30\uFF29\uFF24"); combo_param_.SetItemData(ind, PARAM_PID); ind = combo_param_.AddString(L"\u901F\u5EA6\u6A21\u5F0F"); combo_param_.SetItemData(ind, PARAM_SPEED); combo_param2_.ResetContent(); jsn = sane_cfg_->first_child(); if (jsn) { jsn->release(); while ((jsn = sane_cfg_->next_child())) { const wchar_t* val = NULL; if (jsn->get_value(L"type", &val)) { if (wcscmp(val, L"button") && wcscmp(val, L"group")) { if (jsn->get_value(L"title", &val)) { while (*val == L' ') val++; if (wcscmp(jsn->key(), L"time-to-sleep") == 0) { ind = combo_param_.AddString(val); combo_param_.SetItemData(ind, (DWORD_PTR)jsn); } ind = combo_param2_.AddString(val); combo_param2_.SetItemData(ind, (DWORD_PTR)jsn); } } } jsn->release(); } } return true; } else { return false; } } void CDlgMgr::OnDropFiles(HDROP hDropInfo) { // TODO: 在此添加消息处理程序代码和/或调用默认值 wchar_t path[MAX_PATH] = { 0 }; std::wstring cont(L""); std::string bom(""); DragQueryFileW(hDropInfo, 0, path, _countof(path) - 1); file_util::load_file(path, got_str, &bom); coding_util::bom::to_unicode(bom.c_str(), bom.length(), got_wstr, &cont); reload(cont); __super::OnDropFiles(hDropInfo); } //UINT CDlgMgr::OnGetDlgCode() //{ // // TODO: 在此添加消息处理程序代码和/或调用默认值 // // return __super::OnGetDlgCode(); //} void CDlgMgr::OnListPasteClipboard() { // TODO: 在此添加命令处理程序代码 wchar_t* buf = NULL; size_t len = 0; if (file_util::get_clipboard(buf, &len, CF_UNICODETEXT) == ERROR_INSUFFICIENT_BUFFER) { buf = new wchar_t[len + 8]; memset(buf, 0, (len + 8) * 2); len++; if (file_util::get_clipboard(buf, &len, CF_UNICODETEXT) == ERROR_SUCCESS) { std::wstring cont(buf); reload(cont); } delete[] buf; } } void CDlgMgr::OnNMRClickList1(NMHDR* pNMHDR, LRESULT* pResult) { LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast(pNMHDR); // TODO: 在此添加控件通知处理程序代码 *pResult = 0; POINT pt = { 0 }; CMenu menu; menu.LoadMenuW(MAKEINTRESOURCE(IDR_MENU1)); GetCursorPos(&pt); menu.GetSubMenu(0)->TrackPopupMenu(0, pt.x, pt.y, this); } void CDlgMgr::OnListClear() { // TODO: 在此添加命令处理程序代码 for (int i = 0; i < list_.GetItemCount(); ++i) ((known_file_util::IJsonW*)list_.GetItemData(i))->release(); list_.DeleteAllItems(); } void CDlgMgr::add_param(CComboBox* param_ctrl, CComboBox* val_ctrl, CListCtrl* lst, UINT edit_id) { int item = ::add_param(m_hWnd, param_ctrl, val_ctrl, lst, edit_id); if (param_ctrl == &combo_param2_) { int ind = get_list_selected_item(&list_); if (ind != -1) { known_file_util::IJsonW* cfg = (known_file_util::IJsonW*)list_.GetItemData(ind), * param = NULL, * sane = (known_file_util::IJsonW*)lst_param_.GetItemData(item); std::wstring str(get_list_item_text(&lst_param_, item, 1)); const wchar_t* sv = NULL; if (!cfg->get_value(L"param", ¶m)) { param = known_file_util::create_jsonW(); cfg->set_value(L"param", param); } sane->get_value(L"type", &sv); if (wcscmp(sv, L"bool") == 0) { param->set_value(sane->key(), str == L"true"); } else if (wcscmp(sv, L"int") == 0) param->set_value(sane->key(), _wtoi(str.c_str())); else if (wcscmp(sv, L"float") == 0) param->set_value(sane->key(), _wtof(str.c_str())); else param->set_value(sane->key(), str.c_str()); param->release(); } } } void CDlgMgr::OnBnClickedButtonAddParam() { // TODO: 在此添加控件通知处理程序代码 add_param(&combo_param_, &combo_param_val_, &lst_write_down_, IDC_EDIT_PARAM_VAL); } void CDlgMgr::OnBnClickedButtonClearAll() { // TODO: 在此添加控件通知处理程序代码 OnListClear(); } void CDlgMgr::on_combo_param_changed(CComboBox* param_ctrl, CComboBox* val_ctrl, CListCtrl* lst, UINT edit_id) { ::on_combo_param_changed(m_hWnd, param_ctrl, val_ctrl, lst, edit_id, lst_param_trigger_sel_chg_); } void CDlgMgr::OnCbnSelchangeComboParam() { // TODO: 在此添加控件通知处理程序代码 on_combo_param_changed(&combo_param_, &combo_param_val_, &lst_write_down_, IDC_EDIT_PARAM_VAL); } void on_list_param_sel_changed(CComboBox* param_ctrl, CListCtrl* lst, int item, void(*cb_change_notify)(void*), void* param) { if (item != -1) { std::wstring str(get_list_item_text(lst, item, 0)); int ind = param_ctrl->FindStringExact(-1, str.c_str()); if (ind != -1) { param_ctrl->SetCurSel(ind); cb_change_notify(param); } } } std::wstring get_window_text(HWND wnd) { int l = GetWindowTextLength(wnd); wchar_t* buf = new wchar_t[l + 8]; l = GetWindowTextW(wnd, buf, l + 4); buf[l] = 0; std::wstring ret(buf); delete[] buf; return ret; } void replace(std::wstring& str, const wchar_t* now, const wchar_t* to_be) { size_t pos = str.find(now); int l0 = lstrlenW(now), l1 = lstrlenW(to_be); while (pos != std::wstring::npos) { str.replace(pos, l0, to_be); pos += l1; pos = str.find(now, pos); } } void CDlgMgr::notify_combo_param_changed(void* param) { struct _cb_chg { CDlgMgr* dlg; void(CDlgMgr::* cb_sel_change)(void); }; struct _cb_chg* chg = (struct _cb_chg*)param; chg->dlg->lst_param_trigger_sel_chg_ = true; (chg->dlg->*chg->cb_sel_change)(); chg->dlg->lst_param_trigger_sel_chg_ = false; } void CDlgMgr::on_list_param_sel_changed(CComboBox* param_ctrl, CListCtrl* lst, int item, void(CDlgMgr::* cb_sel_change)(void)) { struct { CDlgMgr* dlg; void(CDlgMgr::* cb_sel_change)(void); }param = { this, cb_sel_change }; ::on_list_param_sel_changed(param_ctrl, lst, item, &CDlgMgr::notify_combo_param_changed, ¶m); } void CDlgMgr::OnLvnItemchangedListParam(NMHDR* pNMHDR, LRESULT* pResult) { LPNMLISTVIEW pNMLV = reinterpret_cast(pNMHDR); // TODO: 在此添加控件通知处理程序代码 on_list_param_sel_changed(&combo_param_, &lst_write_down_, pNMLV->iItem, &CDlgMgr::OnCbnSelchangeComboParam); *pResult = 0; } bool CDlgMgr::remove_prompt(CListCtrl* lst, int item, int sub, const wchar_t* title, DWORD_PTR* data) { std::wstring text(get_list_item_text(lst, item, sub)); if (::MessageBoxW(m_hWnd, text.c_str(), L"\u5220\u9664\u521D\u59CB\u5316\u53C2\u6570\uFF1F", MB_YESNO | MB_ICONQUESTION) == IDYES) { if (data) *data = lst->GetItemData(item); lst->DeleteItem(item); return true; } else return false; } void CDlgMgr::OnNMDblclkListParam(NMHDR* pNMHDR, LRESULT* pResult) { LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast(pNMHDR); // TODO: 在此添加控件通知处理程序代码 if (pNMItemActivate->iItem != -1) { remove_prompt(&lst_write_down_, pNMItemActivate->iItem, 0, L"\u5220\u9664\u521D\u59CB\u5316\u53C2\u6570\uFF1F"); } *pResult = 0; } void CDlgMgr::OnBnClickedButtonAddParam2() { // TODO: 在此添加控件通知处理程序代码 add_param(&combo_param2_, &combo_param_val2_, &lst_param_, IDC_EDIT_PARAM_VAL2); } void CDlgMgr::OnBnClickedButtonAddParam3() { // TODO: 在此添加控件通知处理程序代码 int ind = get_list_selected_item(&list_); lst_param_.DeleteAllItems(); if (ind != -1) { known_file_util::IJsonW* json = (known_file_util::IJsonW*)list_.GetItemData(ind), * param = NULL; if (json) { json->get_value(L"param", ¶m); if (param) { param->clear(); param->release(); } } } } void CDlgMgr::OnCbnSelchangeComboParam2() { // TODO: 在此添加控件通知处理程序代码 on_combo_param_changed(&combo_param2_, &combo_param_val2_, &lst_param_, IDC_EDIT_PARAM_VAL2); } void CDlgMgr::OnNMClickListParamTest(NMHDR* pNMHDR, LRESULT* pResult) { LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast(pNMHDR); // TODO: 在此添加控件通知处理程序代码 on_list_param_sel_changed(&combo_param2_, &lst_param_, pNMItemActivate->iItem, &CDlgMgr::OnCbnSelchangeComboParam2); *pResult = 0; } void CDlgMgr::OnNMDblclkListParamTest(NMHDR* pNMHDR, LRESULT* pResult) { LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast(pNMHDR); // TODO: 在此添加控件通知处理程序代码 if (pNMItemActivate->iItem != -1) { known_file_util::IJsonW* json = (known_file_util::IJsonW*)lst_param_.GetItemData(pNMItemActivate->iItem); if (remove_prompt(&lst_param_, pNMItemActivate->iItem, 0, L"\u5220\u9664\u6D4B\u8BD5\u53C2\u6570\uFF1F")) { int ind = get_list_selected_item(&list_); if (ind != -1) { known_file_util::IJsonW* cfg = (known_file_util::IJsonW*)list_.GetItemData(ind), * child = NULL; if (cfg) { cfg->get_value(L"param", &child); if (child) { child->remove_value(json->key()); child->release(); } } } } } *pResult = 0; } void CDlgMgr::OnNMClickList1(NMHDR* pNMHDR, LRESULT* pResult) { LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast(pNMHDR); // TODO: 在此添加控件通知处理程序代码 if (pNMItemActivate->iItem != -1) { known_file_util::IJsonW* json = (known_file_util::IJsonW*)list_.GetItemData(pNMItemActivate->iItem), * param = NULL, * child = NULL, *sane = NULL; int ind = -1; lst_param_.DeleteAllItems(); json->get_value(L"param", ¶m); if (param) { known_file_util::JSONMEMW jm = param->first_member(); while (jm.type != known_file_util::JV_UNKNOWN) { sane_cfg_->get_value(jm.key, &sane); if (sane) { const wchar_t* val = NULL; sane->get_value(L"title", &val); sane->release(); ind = lst_param_.InsertItem(lst_param_.GetItemCount(), val); if (jm.type == known_file_util::JV_BOOL) lst_param_.SetItemText(ind, 1, jm.bool_val ? L"true" : L"false"); else if (jm.type == known_file_util::JV_INT) lst_param_.SetItemText(ind, 1, std::to_wstring(jm.int_val).c_str()); else if (jm.type == known_file_util::JV_FLOAT) lst_param_.SetItemText(ind, 1, std::to_wstring(jm.double_val).c_str()); else // string lst_param_.SetItemText(ind, 1, jm.str_val); } jm = param->next_member(); } param->release(); } } GetDlgItem(IDC_BUTTON_ADD_PARAM2)->EnableWindow(pNMItemActivate->iItem != -1); GetDlgItem(IDC_BUTTON_ADD_PARAM3)->EnableWindow(pNMItemActivate->iItem != -1); lst_param_.EnableWindow(pNMItemActivate->iItem != -1); *pResult = 0; }