申请会员申请ID:MonsterCent
1、申请ID:MonsterCent2、私人邮箱:leilei2000@live.cn
股票行情实时查看小工具:MarketView.exe。
需求说明:各种股票软件行情功能都需要切换到软件界面才能查看,私人电脑看倒罢了,对于上班族来说,被领导窥到那就嘿嘿嘿了。所以做了一个显示股票实施信息(文字)在屏幕,调用新浪股票api接口查询行情,并实时显示。当然软件必须可以最小化在托盘。
先上界面:
运行效果
实现:
采用MFC来做,简单
界面的什么的省略不讲
加入定时器定时刷新
void CMarketViewDlg::OnTimer(UINT_PTR nIDEvent)
{
// TODO:在此添加消息处理程序代码和/或调用默认值
CRect rtClient;
SystemParametersInfo(SPI_GETWORKAREA, 0, &rtClient, 0);//屏幕大小(不含任务栏)
int nScreenWidth = ::GetSystemMetrics(SM_CXSCREEN);//屏幕大小(含任务栏)
int nScreenHeigth = ::GetSystemMetrics(SM_CYSCREEN);
CRect rtTaskbar;//任务栏大小
rtTaskbar = rtClient;
rtTaskbar.top = rtClient.bottom;
rtTaskbar.bottom = nScreenHeigth;
if (m_stkcodes.IsEmpty()){
return;
}
CGetInternet myNet;
CString strUrl(_T(""));
strUrl.Format("http://hq.sinajs.cn/list=s_%s",m_stkcodes);
CString stkInfo = myNet.GetHttpCode(strUrl);
//var hq_str_s_sh600837="?????,13.750,0.090,0.66,20039,2748";
CString strPrint = GetFieldsByString(stkInfo);
int nLength = strPrint.GetLength() * 10;
CWindowDC wdc(NULL);
wdc.TextOutA(rtClient.right - nLength, rtTaskbar.top - 20, strPrint);
CDialogEx::OnTimer(nIDEvent);
}
// 1-代码 2-代码名称 3-最新价 4-涨跌 5-涨幅 6-总手 7-金额
CString CMarketViewDlg::GetFieldsByString(CString str){
UpdateData(TRUE);
CString strValue(_T(""));
CString strField(_T("")), strRight(_T(""));
//代码
strField = str.Mid(13, 8);
strValue.AppendFormat("代码:%s,", strField);
strRight = str.Right(str.GetLength() - str.Find("=") - 2);
//代码名称
strField = strRight.Left(strRight.Find(","));
strValue.AppendFormat("名称:%s,", strField);
strRight = strRight.Right(strRight.GetLength() - strRight.Find(",") - 1);
//最新价
strField = strRight.Left(strRight.Find(","));
float m_culprice = _ttof(strField);
strValue.AppendFormat("最新价:%s,", strField);
strRight = strRight.Right(strRight.GetLength() - strRight.Find(",") - 1);
//涨跌
strField = strRight.Left(strRight.Find(","));
strValue.AppendFormat("涨跌:%s,", strField);
strRight = strRight.Right(strRight.GetLength() - strRight.Find(",") - 1);
//涨幅
strField = strRight.Left(strRight.Find(","));
strValue.AppendFormat("涨幅:%s%%,", strField);
strRight = strRight.Right(strRight.GetLength() - strRight.Find(",") - 1);
//盈亏
strValue.AppendFormat("盈亏:%f,", m_amount*(m_culprice - m_costprice));
////总手
//strField = strRight.Left(strRight.Find(","));
//strValue.AppendFormat("总手-%s,", strField);
//strRight = strRight.Right(strRight.GetLength() - strRight.Find(",") - 1);
////金额
//strField = strRight.Left(strRight.Find("\""));
//strValue.AppendFormat("金额-%s,", strField);
return strValue;
}
新浪股票api接口,给个地址https://www.jianshu.com/p/108b8110a98c
只要对返回信息进行转换即可。使用CWindowDC 的textout把实时信息打印桌面,这样不管做什么都可以看到。
目前比较简易,没有加入快捷键、股票池什么的(只能看一只股票,但是我炒股从来就是一只干),后续有时间再弄吧。
上代码:
软件:
https://pan.baidu.com/s/13gBaFCC-YIDGmKyjP-9hAA密码76ai
抱歉,未能达到申请要求,申请不通过,可以关注论坛官方微信(吾爱破解论坛),等待开放注册通知。
页:
[1]