• 窗口自动靠边程序演示


    HICON hIcon=::ExtractIcon(AfxGetInstanceHandle(),_T("NotePad.exe"),0);
    if (hIcon &&hIcon!=(HICON)-1)
    {
    pDC->DrawIcon(10,10,hIcon);

    }
    DestroyIcon(hIcon);
    十一、窗口自动靠边程序演示
    BOOL AdjustPos(CRect* lpRect)
    {//自动靠边
    int iSX=GetSystemMetrics(SM_CXFULLSCREEN);
    int iSY=GetSystemMetrics(SM_CYFULLSCREEN);
    RECT rWorkArea;
    BOOL bResult = SystemParametersInfo(SPI_GETWORKAREA, sizeof(RECT), &rWorkAre
    a, 0);
    CRect rcWA;
    if(!bResult)
    {//如果调用不成功就利用GetSystemMetrics获取屏幕面积
    rcWA=CRect(0,0,iSX,iSY);
    }
    else
    rcWA=rWorkArea;
    int iX=lpRect->left;
    int iY=lpRect->top;

    if(iX < rcWA.left + DETASTEP && iX!=rcWA.left)
    {//调整左
    //pWnd->SetWindowPos(NULL,rcWA.left,iY,0,0,SWP_NOSIZE);
    lpRect->OffsetRect(rcWA.left-iX,0);
    AdjustPos(lpRect);
    return TRUE;
    }
    if(iY < rcWA.top + DETASTEP && iY!=rcWA.top)
    {//调整上
    //pWnd->SetWindowPos(NULL ,iX,rcWA.top,0,0,SWP_NOSIZE);
    lpRect->OffsetRect(0,rcWA.top-iY);
    AdjustPos(lpRect);
    return TRUE;
    }
    if(iX + lpRect->Width() > rcWA.right - DETASTEP && iX !=rcWA.right-lpRect->W

    idth())
    {//调整右
    //pWnd->SetWindowPos(NULL ,rcWA.right-rcW.Width(),iY,0,0,SWP_NOSIZE);
    lpRect->OffsetRect(rcWA.right-lpRect->right,0);
    AdjustPos(lpRect);
    return TRUE;
    }
    if(iY + lpRect->Height() > rcWA.bottom - DETASTEP && iY !=rcWA.bottom-lpRect
    ->Height())
    {//调整下
    //pWnd->SetWindowPos(NULL ,iX,rcWA.bottom-rcW.Height(),0,0,SWP_NOSIZE);
    lpRect->OffsetRect(0,rcWA.bottom-lpRect->bottom);
    return TRUE;
    }
    return FALSE;
    }
    //然后在ONMOVEING事件中使用所下过程调用

    CRect r=*pRect;
    AdjustPos(&r);
    *pRect=(RECT)r;

  • 相关阅读:
    个人电脑软件清单
    Apache代理80端口
    使用eclipse转换普通项目为web项目
    项目范围管理的重要性
    Ant 风格路径表达式(转)
    jquery autoComplete的使用代码一则
    Java 遍历一个对象的属性 将非空属性赋值给另一个对象
    Eclipse 安装应用SVN地址
    (转)C的代码是如何变成程序的
    (转)编译和链接的区别
  • 原文地址:https://www.cnblogs.com/shengshuai/p/autoSize.html
Copyright © 2020-2023  润新知