为什么j和k没有值?

Jacktar 2001-08-29 11:39:55
void CTimerDlg::OnSelendokHour()
{
// TODO: Add your control notification handler code here
int i,j,k
i=m_data.GetCurSel ();//m_data、m_hour和m_minu都是一个下拉列表.
j=m_hour.GetCurSel ();
k=m_minu.GetCurSel ();
CTime t(0,0,0,j,k,0);
time[i]=t;

}
...全文
179 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
Jacktar 2001-08-31
  • 打赏
  • 举报
回复
谢谢大家,问题已解决了
cococut 2001-08-30
  • 打赏
  • 举报
回复
void CTimerDlg::OnSelendokHour()
{
// TODO: Add your control notification handler code here
int i,j,k
i=m_data.GetCurSel ();//m_data、m_hour和m_minu都是一个下拉列表.
//////////////////////////
j=m_hour.GetCurSel ();
char tempbuf[100];
m_hour.GetLBText(j,tempbuf);
int hournum = atoi(tempbuf);
/////////////////////////////////
k=m_minu.GetCurSel ();
CTime t(0,0,0,hournum,k,0);
time[i]=t;

}
试试!
Jacktar 2001-08-30
  • 打赏
  • 举报
回复
谁能帮我看一下以上代,有些什么错误,谢谢大家
Jacktar 2001-08-29
  • 打赏
  • 举报
回复
在OnInitDialog()中我以经初始化了。i中有值,j和k都没有值,这是为什么,请高指点。
fandh 2001-08-29
  • 打赏
  • 举报
回复
下拉列表初始化了吗?
Jacktar 2001-08-29
  • 打赏
  • 举报
回复
谁知道这个问题?
Jacktar 2001-08-29
  • 打赏
  • 举报
回复
这是我写得定时器代码,有2个CEdit框--(1个用来显示当前时间,另1个用显示定时的时间)和1个用来修改或建立定时时间的按钮,还有3个下拉列表其中一个是表示第几个定时点(共32个),另外2个是表示小时和分钟的请高手帮看一下。
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()

/////////////////////////////////////////////////////////////////////////////
// CTimerDlg dialog

CTimerDlg::CTimerDlg(CWnd* pParent /*=NULL*/)
: CDialog(CTimerDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CTimerDlg)
m_currenttime = _T("");
m_timing = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CTimerDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);

//{{AFX_DATA_MAP(CTimerDlg)
DDX_Control(pDX, IDC_HOUR, m_hour);
DDX_Control(pDX, IDC_MIN, m_minu);
DDX_Control(pDX, IDC_ADD, m_add);
DDX_Control(pDX, IDC_DATA, m_data);
DDX_Text(pDX, IDC_EDIT2, m_currenttime);
DDX_Text(pDX, IDC_TIMING, m_timing);
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CTimerDlg, CDialog)
//{{AFX_MSG_MAP(CTimerDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_TIMER()
ON_CBN_SELENDOK(IDC_DATA, OnSelendokData)
ON_CBN_SELENDOK(IDC_HOUR, OnSelendokHour)
ON_CBN_SELENDOK(IDC_MIN, OnSelendokMin)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTimerDlg message handlers

BOOL CTimerDlg::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);
AfxGetMainWnd()->SetTimer(1,100,NULL);

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);
}
}
char string[4];
for (int i=0;i<=32;i++)
{
m_data.SetCurSel (i);
_itoa(i,string,10);
m_data.AddString (string);
}
for(int j=0;j<24;j++)
{
m_hour.SetCurSel (j);
_itoa(j,string,10);
m_hour.AddString (string);
}
for(int k=0;k<60;k++)
{
m_minu.SetCurSel (k);
_itoa(k,string,10);
m_minu.AddString (string);
}


// 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


return TRUE; // return TRUE unless you set the focus to a control
}

void CTimerDlg::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 CTimerDlg::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 CTimerDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}



CString CTimerDlg::display(int number)
{
CString change;
if(number/10==0)
change.Format ("0%d",number);
else
change.Format ("%d",number);
return(change);

}





void CTimerDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CDialog::OnTimer(nIDEvent);
SYSTEMTIME st;
GetLocalTime(&st);
CString time;
time.Format ("%s:%s:%s",display(st.wHour),display(st.wMinute),display(st.wSecond));
m_currenttime=time;
UpdateData(false);
}




void CTimerDlg::OnSelendokData()
{
// TODO: Add your control notification handler code here
int i;
i=m_data.GetCurSel ();
if(time[i]==NULL)
{
m_add.SetWindowText ("修改");
m_timing.Format ("%s",time[i].Format ("%H:%M:%s"));
}
}


void CTimerDlg::OnSelendokHour()
{
// TODO: Add your control notification handler code here
int i,j;
i=m_data.GetCurSel ();

j=m_hour.GetCurSel ();
k=m_minu.GetCurSel ();
CTime t(0,0,0,j,k,0);
time[i]=t;

}

void CTimerDlg::OnSelendokMin()
{
// TODO: Add your control notification handler code here
}
djhdu 2001-08-29
  • 打赏
  • 举报
回复
看不出来!
fandh 2001-08-29
  • 打赏
  • 举报
回复
j=-1,k=-1?
fandh 2001-08-29
  • 打赏
  • 举报
回复
是不是m_data 初始化了其他的没有?
outer2000 2001-08-29
  • 打赏
  • 举报
回复
gettxt
outer2000 2001-08-29
  • 打赏
  • 举报
回复
first you need setcursel
fsb_12345 2001-08-29
  • 打赏
  • 举报
回复
代码太少,没法找错
fandh 2001-08-29
  • 打赏
  • 举报
回复
等一下,我。。。。。。。。。。。。。

16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧