我最小化的时候想做一些操作,但是小弟刚学VC,不知道在什么地方添加代码,请尽量详细点

解决方案 »

  1.   

    void OnSize(UINT type, CSize size)
    {
    if (type == SIZE_MINIMIZED)
                     { // 最小化时
    ShowWindow(SW_HIDE);
                    }
    UpdateLayout();
    }
      

  2.   

    void CTestDlg::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();
    }
    }
      

  3.   

    cat_dog(东方软件) 
    我最小化的时候是想让窗口不要显示在任务栏上,我在里面插入了ShowWindow(SW_HIDE);怎么不行呀!
      

  4.   

    Semigod() 你给我的代码天在什么地方?老抱错
    error C2660: 'ShowWindow' : function does not take 1 parameters
    error C2065: 'UpdateLayout' : undeclared identifier
      

  5.   

    给窗口设置WS_EX_TOOLWINDOW 扩展风格,并且去掉WS_EX_APPWINDOW风格。
    ModifyStyleEx(WS_EX_APPWINDOW,WS_EX_TOOLWINDOW);隐藏窗口
    ShowWindow(SW_HIDE);
    如果直接用showwindow需要加个窗口句柄参数ShowWindow(hwnd,SW_HIDE);
    或者hwnd->ShowWindow(SW_HIDE);
      

  6.   

    在Windows Massenge里添加WM_SIZE消息响应函数。
    Wizard自动生成OnSize函数。
      

  7.   

    ModifyStyleEx(WS_EX_APPWINDOW, 0);
    hwnd->ShowWindow(SW_HIDE);
      

  8.   

    添加到xxxApp类的初始化函数最后
    BOOL CServerApp::InitInstance()//单文档
    BOOL CASDDlg::OnInitDialog()//对话框