这是我的代码,内容也就是在状态栏中加一些信息,测试用的MesasgeBox()也不执行啊 : BOOL CBitBookDlg::OnInitDialog() { MessageBox("OnInit"); 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
int indicators[3]; indicators[0]=rect.Width()/2; indicators[1]=rect.Width()*3/4; indicators[2]=rect.Width(); m_StatusBarCtrl.SetParts(3,&indicators[0]); str.LoadString(IDS_COMPANY); m_StatusBarCtrl.SetText(str,0,0); m_StatusBarCtrl.SetText("当前操作员:"+app->m_sUserName,1,0); m_StatusBarCtrl.SetText(s,2,0); this->SetTimer(12,1000,NULL); InitPurview(); return TRUE; // return TRUE unless you set the focus to a control }
dlg.Domodal;
这两句已经调用了OnInitDialog()。
CMyDlg dlg;
dlg.Domodal;
但是跟踪调试的时候发现没有调用OnInitDialog(),
在里面写的初始化代码也都没执行
不知什么原因?
BOOL CBitBookDlg::OnInitDialog()
{
MessageBox("OnInit");
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
CTime t=CTime::GetCurrentTime();
CString s=t.Format("%H:%M:%S");
CBitBookApp* app=(CBitBookApp*)::AfxGetApp();
s="当前系统时间:"+s;
CString str; CRect rect;
this->GetClientRect(&rect); m_StatusBarCtrl.Create(WS_CHILD|WS_VISIBLE|CCS_BOTTOM,rect,this,ID_STATUS_BAR_CTRL);
int indicators[3];
indicators[0]=rect.Width()/2;
indicators[1]=rect.Width()*3/4;
indicators[2]=rect.Width();
m_StatusBarCtrl.SetParts(3,&indicators[0]); str.LoadString(IDS_COMPANY); m_StatusBarCtrl.SetText(str,0,0);
m_StatusBarCtrl.SetText("当前操作员:"+app->m_sUserName,1,0);
m_StatusBarCtrl.SetText(s,2,0); this->SetTimer(12,1000,NULL);
InitPurview(); return TRUE; // return TRUE unless you set the focus to a control
}