📄 xzbm1dlg.cpp
字号:
// xzbm1dlg.cpp : implementation file
//
#include "stdafx.h"
#include "xxgl.h"
#include "xzbm1dlg.h"
#include "strt.h"
#include "ext.h"
#include "func.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
static int out_flag;
Cxzbm1dlg::Cxzbm1dlg(CWnd* pParent /*=NULL*/)
: CDialog(Cxzbm1dlg::IDD, pParent)
{
out_flag = 0;
}
void Cxzbm1dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Cxzbm1dlg)
DDX_Control(pDX, IDC_LIST1, m_list);
DDX_Control(pDX, IDC_pyjx, m_pyjx);
//}}AFX_DATA_MAP
CBitmap *bitmap;
CBitmap *bitmap1;
HBITMAP hbitmap;
HBITMAP hbitmap1;
bitmap = new CBitmap();
bitmap1 = new CBitmap();
bitmap->LoadBitmap(IDB_qr);
bitmap1->LoadBitmap(IDB_qx);
hbitmap = (*bitmap).operator HBITMAP();
hbitmap1 = (*bitmap1).operator HBITMAP();
CWnd *wn;
CWnd *wn1;
wn = GetDlgItem(IDOK);
wn1 = GetDlgItem(IDCANCEL);
// wn2 = GetDlgItem(IDOK3);
WPARAM wParam;
LPARAM lParam;
wParam = (WPARAM) LOWORD(BS_LEFT | BS_BITMAP); // style
lParam = MAKELPARAM(TRUE, 0); // redraw flag
wn->SendMessage(BM_SETIMAGE, IMAGE_BITMAP,(long)hbitmap);
wn1->SendMessage(BM_SETIMAGE, IMAGE_BITMAP,(long)hbitmap1);
m_pyjx.SetText("");
m_pyjx.SetSelText(g_xzbm_pass_buf);
OnChangepyjx();
}
BEGIN_MESSAGE_MAP(Cxzbm1dlg, CDialog)
//{{AFX_MSG_MAP(Cxzbm1dlg)
ON_LBN_SELCHANGE(IDC_LIST1, OnSelchangeList1)
ON_LBN_DBLCLK(IDC_LIST1, OnDblclkList1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Cxzbm1dlg message handlers
BEGIN_EVENTSINK_MAP(Cxzbm1dlg, CDialog)
//{{AFX_EVENTSINK_MAP(Cxzbm1dlg)
ON_EVENT(Cxzbm1dlg, IDC_pyjx, 1 /* Change */, OnChangepyjx, VTS_NONE)
ON_EVENT(Cxzbm1dlg, IDC_pyjx, -602 /* KeyDown */, OnKeyDownpyjx, VTS_PI2 VTS_I2)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
void Cxzbm1dlg::OnChangepyjx()
{
int i,j,k,l,p,flag,sel_flag,ret;
CString str;
char bb[200];
char buf[40];
char buf1[50];
char bu[10];
char bu1[50];
GetDlgItemText(IDC_pyjx,buf,20);
l = strlen(buf);
if (l > 0){
for (i=0;i<l;i++){
if ((buf[i] >= 'A')&&(buf[i] <= 'Z')){
buf[i] -= 'A';
buf[i] += 'a';
}
if ((buf[i] < 'a')||(buf[i] > 'z')){
buf[i] = 0;
m_pyjx.SetText("");
m_pyjx.SetSelText(buf);
}
}
}
if (strlen(buf) > 10){
buf[10] = 0;
m_pyjx.SetText("");
m_pyjx.SetSelText(buf);
}
m_list.ResetContent();
i = 0;
k = 0;
GetDlgItemText(IDC_pyjx,str);
strcpy(buf,str.GetBuffer(40));
for (i=0;i<l;i++){
if ((buf[i] >= 'A')&&(buf[i] <= 'Z')){
buf[i] -= 'A';
buf[i] += 'a';
}
}
strcpy(bu,buf);
FILE *fpe,*fpe1;
fpe = fopen("c:\\xxsbgl\\bmpydyb.dat","rb");
fpe1 = fopen("c:\\xxsbgl\\bmpydyb1.dat","rb");
i = 0;
j = 0;
if (fpe != NULL){
ret = fscanf(fpe,"%s\n",buf);
while (ret > 0){
if (strlen(buf) != 0){
if (i % 2 == 1){
if (strstr(buf,bu) != NULL){
m_list.AddString(bu1);
}
j ++;
}
else{
strcpy(bu1,buf);
}
i ++;
}
ret = fscanf(fpe,"%s\n",buf);
}
fclose(fpe);
}
i = 0;
j = 0;
if (fpe1 != NULL){
ret = fscanf(fpe1,"%s\n",buf);
while (ret > 0){
if (strlen(buf) != 0){
if (i % 2 == 1){
if (strstr(buf,bu) != NULL){
m_list.AddString(bu1);
}
j ++;
}
else{
strcpy(bu1,buf);
}
i ++;
}
ret = fscanf(fpe1,"%s\n",buf);
}
fclose(fpe1);
}
}
void Cxzbm1dlg::OnSelchangeList1()
{
}
void Cxzbm1dlg::OnKeyDownpyjx(short FAR* KeyCode, short Shift)
{
short key;
int cur;
key = *KeyCode;
if (key == 40){
cur = m_list.GetCurSel();
if (cur < 0){
cur = 0;
}
else
cur ++;
m_list.SetCurSel(cur);
}
else if (key == 38){
cur = m_list.GetCurSel();
if (cur < 1){
cur = 0;
}
else
cur --;
m_list.SetCurSel(cur);
}
else if (key == 13){
OnOK();
}
}
void Cxzbm1dlg::OnOK()
{
int n,i;
char buf[100];
n = m_list.GetCount();
if (n == 1){
m_list.GetText(0,buf);
strcpy(g_xzbm,buf);
}
else{
n = m_list.GetCurSel();
if (n < 0){
MessageBox("对不起,您没有选择设备,不能退出.",MB_OK);
CWnd *wnd;
wnd = GetDlgItem(IDC_pyjx);
wnd->SetFocus();
return ;
}
m_list.GetText(n,buf);
strcpy(g_xzbm,buf);
}
out_flag = 1;
CDialog::OnOK();
}
void Cxzbm1dlg::OnDblclkList1()
{
OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -