1 Star 0 Fork 0

soui3-demo/SlogViewer

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
EditConfigDlg.cpp 1.41 KB
一键复制 编辑 原始数据 按行查看 历史
huangjianxiong 提交于 2019-11-08 11:06 . adapter to soui3
#include "stdafx.h"
#include "EditConfigDlg.h"
#include <helper/SAutoBuf.h>
CEditConfigDlg::CEditConfigDlg(void):SHostDialog(UIRES.LAYOUT.dlg_edit_config),m_pSciter(NULL)
{
}
CEditConfigDlg::~CEditConfigDlg(void)
{
}
static char bom_utf8[3]={0xef,0xbb,0xbf};
BOOL CEditConfigDlg::OnInitDialog(HWND wndFocus, LPARAM lInitParam)
{
SStringW strConfig=SApplication::getSingleton().GetAppDir();
strConfig += L"\\config.xml";
SRealWnd * pRealWnd = FindChildByID2<SRealWnd>(R.id.real_scilexer);
SASSERT(pRealWnd);
m_pSciter = (CScintillaWnd *)pRealWnd->GetUserData();
m_pSciter->SendMessage(SCI_USEPOPUP,0,0);
FILE *f = _wfopen(strConfig,L"rb");
if(f)
{
fseek(f,0,SEEK_END);
int nLen = ftell(f);
fseek(f,0,SEEK_SET);
char *buf = (char*)malloc(nLen+1);
fread(buf,1,nLen,f);
fclose(f);
buf[nLen] = 0;
if(memcmp(buf,bom_utf8,3)==0)
{
m_pSciter->SendMessage(SCI_SETTEXT,0,(LPARAM)(LPCSTR)buf+3);
}else
{
m_pSciter->SendMessage(SCI_SETTEXT,0,(LPARAM)(LPCSTR)buf);
}
free(buf);
}
return TRUE;
}
void CEditConfigDlg::OnSave()
{
unsigned int len = m_pSciter->SendMessage(SCI_GETTEXT, 0, 0);
char *chText = new char[len];
m_pSciter->SendMessage(SCI_GETTEXT, len, (LPARAM)chText);
SStringW strConfig=SApplication::getSingleton().GetAppDir();
strConfig += L"\\config.xml";
FILE *f =_wfopen(strConfig,L"w+b");
if(f)
{
fwrite(chText,1,len-1,f);
fclose(f);
}
delete []chText;
EndDialog(IDOK);
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/soui3-demo/SlogViewer.git
git@gitee.com:soui3-demo/SlogViewer.git
soui3-demo
SlogViewer
SlogViewer
master

搜索帮助