事实上是这样,一般比较保险的法子是 theApp.GetMainWnd()

解决方案 »

  1.   

    建议你到www.ourcode.net网站找找,我想对于编程人员来说这是一个极好的网站
      

  2.   

    oicq8(龙飞):
    到处做广告,那个网站是不是你开的
      

  3.   

    请skyspeed()帮忙给看看:
    CAutoShutDownDlg::CAutoShutDownDlg(CWnd* pParent /*=NULL*/)
    : CDialog(CAutoShutDownDlg::IDD, pParent)
    {
    //{{AFX_DATA_INIT(CAutoShutDownDlg)
    m_Edit = _T("");
    //}}AFX_DATA_INIT
    // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
    m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
    nid.cbSize=sizeof(NOTIFYICONDATA);
    nid.hWnd=HWND(this);(此处试过好多种方法)
    if(!AfxGetMainWnd()) MessageBox("not null");
    nid.uID=ID_NOTIFYICON;
    nid.uFlags=NIF_ICON|NIF_MESSAGE|NIF_TIP;
    nid.uCallbackMessage=WM_NOTIFYICON;
    nid.hIcon=LoadIcon(AfxGetInstanceHandle(),LPSTR(ID_NOTIFYICON));
    strcpy(nid.szTip,"开始");
    }
    void CAutoShutDownDlg::OnStart() 
    {
    // TODO: Add your control notification handler code here
    TCHAR tip[15];
    m_cobHour.GetLBText(m_cobHour.GetCurSel(),m_Hour.GetBuffer(50));
    m_cobMinuite.GetLBText(m_cobMinuite.GetCurSel(),m_Minuite.GetBuffer(50));
        wsprintf(tip,"关机时间%s:%s",m_Hour,m_Minuite);
    strcpy(nid.szTip,tip);
    ShowWindow(SW_HIDE);
    Shell_NotifyIcon(NIM_ADD,&nid);}