lianxi

// ListTestDlg.h : header file
//

#if !defined(AFX_LISTTESTDLG_H__FFD2EAE7_77CF_4E65_BF32_570B4565E0CB__INCLUDED_)
#define AFX_LISTTESTDLG_H__FFD2EAE7_77CF_4E65_BF32_570B4565E0CB__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

/
// CListTestDlg dialog

class CListTestDlg : public CDialog
{
// Construction
public:
 CListTestDlg(CWnd* pParent = NULL); // standard constructor

// Dialog Data
 //{{AFX_DATA(CListTestDlg)
 enum { IDD = IDD_LISTTEST_DIALOG };
 CListCtrl m_listshowctrl;
 //}}AFX_DATA

 // ClassWizard generated virtual function overrides
 //{{AFX_VIRTUAL(CListTestDlg)
 protected:
 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
 //}}AFX_VIRTUAL

// Implementation
protected:
 HICON m_hIcon;

 // Generated message map functions
 //{{AFX_MSG(CListTestDlg)
 virtual BOOL OnInitDialog();
 afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
 afx_msg void OnPaint();
 afx_msg void OnButtonTest( NMHDR*   pNMHDR,   LRESULT*   pResult);
 afx_msg void OnButton2();
 //}}AFX_MSG
 DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the

previous line.

#endif // !defined

(AFX_LISTTESTDLG_H__FFD2EAE7_77CF_4E65_BF32_570B4565E0CB__INCLUDED_)
/

// ListTestDlg.cpp : implementation file
//

#include "stdafx.h"
#include "ListTest.h"
#include "ListTestDlg.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()

/
// CListTestDlg dialog

CListTestDlg::CListTestDlg(CWnd* pParent /*=NULL*/)
 : CDialog(CListTestDlg::IDD, pParent)
{
 //{{AFX_DATA_INIT(CListTestDlg)
  // NOTE: the ClassWizard will add member initialization here
 //}}AFX_DATA_INIT
 // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CListTestDlg::DoDataExchange(CDataExchange* pDX)
{
 CDialog::DoDataExchange(pDX);
 //{{AFX_DATA_MAP(CListTestDlg)
 DDX_Control(pDX, IDC_LIST_SHOW, m_listshowctrl);
 //}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CListTestDlg, CDialog)
 //{{AFX_MSG_MAP(CListTestDlg)
 ON_WM_SYSCOMMAND()
 ON_WM_PAINT()
  ON_BN_CLICKED(IDC_BUTTON_TEST, OnButtonTest)
 ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
 //}}AFX_MSG_MAP
ON_NOTIFY (NM_CUSTOMDRAW,   IDC_LIST_SHOW,   OnButtonTest)
END_MESSAGE_MAP()

/
// CListTestDlg message handlers

BOOL CListTestDlg::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
 m_listshowctrl.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);

    m_listshowctrl.InsertColumn(0,"",LVCFMT_LEFT,100);
  m_listshowctrl.InsertColumn(1,"1通道",LVCFMT_CENTER,100);
  m_listshowctrl.InsertColumn(2,"2通道",LVCFMT_CENTER,100);
  m_listshowctrl.InsertColumn(3,"3通道",LVCFMT_CENTER,100);
  m_listshowctrl.InsertColumn(4,"4通道",LVCFMT_CENTER,100);
  m_listshowctrl.InsertColumn(5,"5通道",LVCFMT_CENTER,100);
  m_listshowctrl.InsertColumn(6,"6通道",LVCFMT_CENTER,100);
 
  

   m_listshowctrl.InsertItem(0,"XX");
     m_listshowctrl.InsertItem(1,"1X");
  m_listshowctrl.InsertItem(2,"2X");
     m_listshowctrl.InsertItem(3,"3X");

 


 m_listshowctrl.SetItemText(0,1,"YY");
 m_listshowctrl.SetItemText(0,2,"ZZ");
 m_listshowctrl.SetItemText(0,3,"WW");
 m_listshowctrl.SetItemText(0,4,"RR");
 
 m_listshowctrl.SetItemText(1,1,"ee");
 m_listshowctrl.SetItemText(1,2,"pp");
 m_listshowctrl.SetItemText(1,3,"ff");
 m_listshowctrl.SetItemText(1,4,"gg");
 
 m_listshowctrl.SetItemText(2,1,"11");
 m_listshowctrl.SetItemText(2,2,"33");
 m_listshowctrl.SetItemText(2,3,"22");
 m_listshowctrl.SetItemText(2,4,"44");
 return TRUE;  // return TRUE  unless you set the focus to a control
}

void CListTestDlg::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 CListTestDlg::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.
//DEL HCURSOR CListTestDlg::OnQueryDragIcon()
//DEL {
//DEL  return (HCURSOR) m_hIcon;
//DEL }
int i = 0;
void CListTestDlg::OnButtonTest( NMHDR*   pNMHDR,   LRESULT*   pResult)
{
 // TODO: Add your control notification handler code here
 

 
 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
 *pResult = CDRF_DODEFAULT;
 if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
 {
  *pResult = CDRF_NOTIFYITEMDRAW;
 }
 else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
 {
  
  *pResult = CDRF_NOTIFYSUBITEMDRAW;
 }
 else if ( (CDDS_ITEMPREPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage )
 {
  
  COLORREF clrNewTextColor, clrNewBkColor;
  
  
  
  int nItem = static_cast<int>( pLVCD->nmcd.dwItemSpec );             

     //修改的行号
  CString strTemp = m_listshowctrl.GetItemText(nItem,pLVCD->iSubItem);

     //修改的文本、字符
  if(strTemp == ""||strTemp=="YY"||strTemp=="pp")
   
  {
  
   
    clrNewTextColor = RGB(0,255,0);
    clrNewBkColor = RGB(255,0,0);
   
   
  }
  else
  {
   
   clrNewTextColor = RGB(0,0,0);
   clrNewBkColor = RGB(255,255,255);
  }
  pLVCD->clrText = clrNewTextColor;
  pLVCD->clrTextBk = clrNewBkColor;
  
  
  // Tell Windows to paint the control itself.
   *pResult = CDRF_DODEFAULT;
  }
}

void CListTestDlg::OnButton2()
{
 // TODO: Add your control notification handler code here
  m_listshowctrl.SetItemText(3,1,"pp");
 
 m_listshowctrl.SetItemText(3,2,"YY");
 m_listshowctrl.SetItemText(3,3,"55");
 Sleep(1000);
}
///
 m_listctrl.SetExtendedStyle(m_listctrl.GetExtendedStyle()

|LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT|LVS_EX_CHECKBOXES);
  m_listctrl.InsertColumn(0,"FAIL_ODUINFO",LVCFMT_LEFT,100);
 m_listctrl.InsertColumn(01,"CASE",LVCFMT_LEFT,300);
// UpdateData();
// int n = m_listInfo.GetItemCount();
 
 m_listctrl.InsertItem(0,"df");
 m_listctrl.SetItemText(0,1,"fdf");
 m_listctrl.SetItemText(0,2,"dff");
 m_listctrl.InsertItem(1,"d22f");
 m_listctrl.SetItemText(1,1,"fd332f");
 m_listctrl.SetItemText(1,2,"d22ff");
// int   count   =   m_List.GetItemCount();  
//  for(int   i   =   0;i<count;i++)  
// {  
//  if(m_List.GetCheck(i))  
//  {  
                                                  /i被选重  
//   }  
//  }


// GetDlgItem(IDC_ID)->GetCheck();  
   
 // 或者映射一个变量,UpdateData之后去值就可以

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,让我帮您完成这个问题。 在上一个问题中,我们创建了一个主模块TicTacToeGUI。现在,我们需要创建lianxi模块,并将其与主模块连接起来,以便在登录按钮被点击时自动跳转到lianxi模块的登录界面。 以下是lianxi模块的代码示例: ```python import tkinter as tk class LoginGUI(tk.Toplevel): def __init__(self): super().__init__() self.title("登录") self.geometry("400x200") # 创建标签和输入框 username_label = tk.Label(self, text="用户名:") username_label.pack(pady=10) self.username_entry = tk.Entry(self) self.username_entry.pack() password_label = tk.Label(self, text="密码:") password_label.pack(pady=10) self.password_entry = tk.Entry(self, show="*") self.password_entry.pack() # 创建登录按钮 login_button = tk.Button(self, text="登录", command=self.login) login_button.pack(pady=10) def login(self): # 获取用户名和密码 username = self.username_entry.get() password = self.password_entry.get() # TODO: 在这里编写登录逻辑 # ... # 关闭登录窗口 self.destroy() ``` 在这个例子中,我们创建了一个新的tkinter窗口Toplevel,用于显示登录界面。该窗口包含两个标签和两个输入框,用于输入用户名和密码。我们还创建了一个登录按钮,用于触发login方法。 当用户点击登录按钮时,login方法将获取输入框中的用户名和密码,并执行一些登录逻辑。在这个例子中,我们只是打印了获取到的用户名和密码。最后,我们关闭登录窗口。 现在,我们需要将TicTacToeGUI和LoginGUI连接起来。我们将在TicTacToeGUI的构造函数中添加一个lambda函数,该函数将创建LoginGUI实例并将其设置为模态窗口。当用户点击登录按钮时,模态窗口将出现,并等待用户输入用户名和密码。当用户完成登录并关闭窗口时,程序将返回到TicTacToeGUI。 以下是更新后的TicTacToeGUI代码: ```python import tkinter as tk from lianxi import LoginGUI class TicTacToeGUI(tk.Tk): def __init__(self): super().__init__() self.title("井字棋游戏") self.geometry("400x200") # 创建标签,显示欢迎信息 welcome_label = tk.Label(self, text="欢迎来到井字棋游戏!") welcome_label.pack(pady=20) # 创建登录按钮 login_button = tk.Button(self, text="登录", command=lambda: self.show_login_gui()) login_button.pack(pady=10) # 创建游戏按钮 game_button = tk.Button(self, text="游戏") game_button.pack(pady=10) def show_login_gui(self): # 创建LoginGUI实例并设置为模态窗口 login_gui = LoginGUI() self.wait_window(login_gui) ``` 在这个例子中,我们添加了一个show_login_gui方法,该方法将创建LoginGUI实例并将其设置为模态窗口。我们将该方法绑定到登录按钮的命令中,并使用lambda函数来确保在点击按钮时调用该方法而不是在创建GUI时调用。 现在,当用户点击登录按钮时,程序将创建LoginGUI实例并将其设置为模态窗口,然后等待用户完成登录。当用户完成登录并关闭窗口时,程序将返回到TicTacToeGUI。 希望这可以帮助您回答第二个问题!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值