我需要帮助更改代码以设置直接img路径而不是“打开文件对话框”。 [英] I need help changing a code to set direct img path rather than "open file dialog"

查看:82
本文介绍了我需要帮助更改代码以设置直接img路径而不是“打开文件对话框”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想点击按钮并设置路径\\myfile.jpg例如



如何编辑此代码以获取这样做而不是打开文件对话框来选择它。





void CSampleDlg :: OnBnClickedBkopen()

{

UNICODECHAR fn [512];

OPENFILENAME ofn;

UNICODECHAR szFile [512];





ZeroMemory(&ofn,sizeof(ofn));

ofn.lStructSize = sizeof(ofn);

ofn.hwndOwner = this-> m_hWnd;

ofn.lpstrFile = szFile;

wcscpy_s(ofn.lpstrFile,512,L\\\);

ofn.nMaxFile = 260;

ofn.lpstrFilter = L图像文件(bmp,jpg,tif,png,gif,pdf)\ 0 * .bmp; *。jpg; * .tif; * .tiff; * .png; * .gif; * .pdf \ 0 ;

ofn.nFilterIndex = 1;

ofn.lpstrFileTitle = NULL;

ofn.nMaxFileTitle = 0;

ofn.lpstrInitialDir = NULL;

ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY | OFN_NONETWORKBUTTON | OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; //显示打开文件对话框



如果(!GetOpenFileName(&ofn))返回;





wcscpy_s(fn,512,ofn.lpstrFile);



////////

wchar_t str [100];

if(m_cbScale.IsWindowEnabled())

{

if(m_cbScale.GetCurSel()< 1 )//自动缩放

{

NsOCR-> Cfg_SetOption(CfgObj,BT_DEFAULT,LImgAlizer / AutoScale,L1);

NsOCR-> Cfg_SetOption(CfgObj,BT_DEFAULT,LImgAlizer / ScaleFactor,L1.0); //默认比例如果无法自动检测到

}

其他//固定比例

{

NsOCR- > Cfg_SetOption(CfgObj,BT_DEFAULT,LImgAlizer / AutoScale,L0);

m_cbScale.GetWindowTextW(str,100);

NsOCR-> Cfg_SetOption(CfgObj,BT_DEFAULT,LImgAlizer / ScaleFactor,str);

}

}



////

//注意:还有其他可能的方法将图像加载到NSOCR

int res = NsOCR-> Img_LoadFile(ImgObj,fn);

I'd like to just click the button and have a path set \\myfile.jpg for example

How can I edit this code to get this done instead of "open file dialog" to select it.


void CSampleDlg::OnBnClickedBkopen()
{
UNICODECHAR fn[512];
OPENFILENAME ofn;
UNICODECHAR szFile[512];


ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = this->m_hWnd;
ofn.lpstrFile = szFile;
wcscpy_s(ofn.lpstrFile, 512, L"\0\0");
ofn.nMaxFile = 260;
ofn.lpstrFilter = L"Image Files (bmp,jpg,tif,png,gif,pdf)\0*.bmp;*.jpg;*.tif;*.tiff;*.png;*.gif;*.pdf\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY | OFN_NONETWORKBUTTON | OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;// show open file dialog

if (!GetOpenFileName(&ofn)) return;


wcscpy_s(fn, 512, ofn.lpstrFile);

////////
wchar_t str[100];
if (m_cbScale.IsWindowEnabled())
{
if (m_cbScale.GetCurSel() < 1) //autoscaling
{
NsOCR->Cfg_SetOption(CfgObj, BT_DEFAULT, L"ImgAlizer/AutoScale", L"1");
NsOCR->Cfg_SetOption(CfgObj, BT_DEFAULT, L"ImgAlizer/ScaleFactor", L"1.0"); //default scale if cannot detect it automatically
}
else //fixed scaling
{
NsOCR->Cfg_SetOption(CfgObj, BT_DEFAULT, L"ImgAlizer/AutoScale", L"0");
m_cbScale.GetWindowTextW(str, 100);
NsOCR->Cfg_SetOption(CfgObj, BT_DEFAULT, L"ImgAlizer/ScaleFactor", str);
}
}

////
//note: there are other possible ways to load image to NSOCR
int res = NsOCR->Img_LoadFile(ImgObj, fn);

推荐答案

问题是我真的新的编码,不知道如何做到这一点任何一个例子都会很多。
Problem is I'm really new to coding and not sure how to do this any example would be much apriciated.


这篇关于我需要帮助更改代码以设置直接img路径而不是“打开文件对话框”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆