📄 velvetdlg.cpp
字号:
// VelvetDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Velvet.h"
#include "VelvetDlg.h"
#include "windows.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CVelvetDlg dialog
CVelvetDlg::CVelvetDlg(CWnd* pParent /*=NULL*/)
: CDialog(CVelvetDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CVelvetDlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CVelvetDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CVelvetDlg)
DDX_Control(pDX, IDC_LIST1, m_CList);
DDX_Control(pDX, IDC_RADIO1, m_Radio1);
DDX_Control(pDX, IDC_COMBO_silk, m_Combo_silk);
DDX_Control(pDX, IDC_COMBO_velvet, m_Combo_velvet);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CVelvetDlg, CDialog)
//{{AFX_MSG_MAP(CVelvetDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CVelvetDlg message handlers
BOOL CVelvetDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// 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
// TODO: Add extra initialization here
((CButton*)GetDlgItem(IDC_RADIO1))->SetCheck(1);
((CButton*)GetDlgItem(IDC_RADIO3))->SetCheck(1);
m_Combo_silk.AddString("185");
m_Combo_silk.AddString("177");
m_Combo_silk.AddString("169");
m_Combo_silk.AddString("161");
m_Combo_silk.AddString("153");
m_Combo_silk.AddString("145");
m_Combo_silk.AddString("137");
m_Combo_silk.AddString("129");
m_Combo_silk.AddString("121");
m_Combo_silk.AddString("113");
m_Combo_silk.AddString("105");
m_Combo_silk.AddString("097");
m_Combo_silk.AddString("089");
m_Combo_silk.SetCurSel(0);
m_Combo_velvet.AddString("110");
m_Combo_velvet.AddString("104");
m_Combo_velvet.AddString("098");
m_Combo_velvet.AddString("092");
m_Combo_velvet.AddString("086");
m_Combo_velvet.AddString("080");
m_Combo_velvet.AddString("074");
m_Combo_velvet.AddString("068");
m_Combo_velvet.SetCurSel(0);
m_CList.InsertColumn(0,"小时",LVCFMT_CENTER,40,0);
m_CList.InsertColumn(1,"行情",LVCFMT_CENTER,110,1);
m_CList.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
return TRUE; // return TRUE unless you set the focus to a control
}
void CVelvetDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CVelvetDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CVelvetDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CVelvetDlg::OnOK()
{
// TODO: Add extra validation here
CString str,temp_silk,temp_velvet;
int time,temp_time; //记录跳数
int flag_silk;
int flag_velvet;
char ch[5];
UpdateData();
//time=m_edit;
m_CList.DeleteAllItems();
for(time=1;time<25;time++)
{
temp_time=time; //保存时间信息
if(GetCheckedRadioButton(IDC_RADIO1,IDC_RADIO2)==IDC_RADIO1)
{
flag_silk=1;
if(m_Combo_silk.GetCurSel()+time<m_Combo_silk.GetCount())
m_Combo_silk.GetLBText(time+m_Combo_silk.GetCurSel(),temp_silk); //行情不变向
else
{
time=time-(m_Combo_silk.GetCount()-(m_Combo_silk.GetCurSel()+1));
flag_silk=1-flag_silk;
while(time>(m_Combo_silk.GetCount()-1))
{
time=time-(m_Combo_silk.GetCount()-1);
flag_silk=1-flag_silk;
}
if(flag_silk)
m_Combo_silk.GetLBText(time,temp_silk);
else
m_Combo_silk.GetLBText(m_Combo_silk.GetCount()-1-time,temp_silk);
}
}
else
{
flag_silk=0;
if(m_Combo_silk.GetCurSel()-time>=0)
m_Combo_silk.GetLBText(m_Combo_silk.GetCurSel()-time,temp_silk);
else
{
time=time-m_Combo_silk.GetCurSel();
flag_silk=1-flag_silk;
while(time>(m_Combo_silk.GetCount()-1))
{
time=time-(m_Combo_silk.GetCount()-1);
flag_silk=1-flag_silk;
}
if(flag_silk)
m_Combo_silk.GetLBText(time,temp_silk);
else
m_Combo_silk.GetLBText(m_Combo_silk.GetCount()-1-time,temp_silk);
}
}
//time=m_edit;
time=temp_time; //恢复时间保证二者时间相同
if(GetCheckedRadioButton(IDC_RADIO3,IDC_RADIO4)==IDC_RADIO3)
{
flag_velvet=1;
if(m_Combo_velvet.GetCurSel()+time<m_Combo_velvet.GetCount())
m_Combo_velvet.GetLBText(time+m_Combo_velvet.GetCurSel(),temp_velvet);
else
{
time=time-(m_Combo_velvet.GetCount()-(m_Combo_velvet.GetCurSel()+1));
flag_velvet=1-flag_velvet;
while(time>(m_Combo_velvet.GetCount()-1))
{
time=time-(m_Combo_velvet.GetCount()-1);
flag_velvet=1-flag_velvet;
}
if(flag_velvet)
m_Combo_velvet.GetLBText(time,temp_velvet);
else
m_Combo_velvet.GetLBText(m_Combo_velvet.GetCount()-1-time,temp_velvet);
}
}
else
{
flag_velvet=0;
if(m_Combo_velvet.GetCurSel()-time>=0)
m_Combo_velvet.GetLBText(m_Combo_velvet.GetCurSel()-time,temp_velvet);
else
{
time=time-m_Combo_velvet.GetCurSel();
flag_velvet=1-flag_velvet;
while(time>(m_Combo_velvet.GetCount()-1))
{
time=time-(m_Combo_velvet.GetCount()-1);
flag_velvet=1-flag_velvet;
}
if(flag_velvet)
m_Combo_velvet.GetLBText(time,temp_velvet);
else
m_Combo_velvet.GetLBText(m_Combo_velvet.GetCount()-1-time,temp_velvet);
}
}
//UpdateData(false);
switch(flag_silk)
{
case 0:temp_silk=temp_silk+"降,";
break;
case 1:temp_silk=temp_silk+"升,";
}
switch(flag_velvet)
{
case 0:temp_velvet=temp_velvet+"降";
break;
case 1:temp_velvet=temp_velvet+"升";
}
str="丝"+temp_silk+"布"+temp_velvet;
m_CList.InsertItem(temp_time-1,itoa(temp_time,ch,10));
m_CList.SetItemText(temp_time-1,1,str);
// Sleep(1000);
time=temp_time; //保证循序继续执行,不至于死
}
//*************************************************************8
//CDialog::OnOK();
}
void CVelvetDlg::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
POSITION pos;
int i;
CString str;
pos=m_CList.GetFirstSelectedItemPosition();
if(pos==NULL)
return;
i=m_CList.GetNextSelectedItem(pos);
str=m_CList.GetItemText(i,1);
MessageBox(str);
*pResult = 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -