zoukankan      html  css  js  c++  java
  • 窗口自动靠边程序演示

    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;

  • 相关阅读:
    centos7 mysql 数据库备份与还原
    Centos 7 搭建wordpress
    Centos 7 安装 mysql5.7
    linux 搭建php网站许愿墙
    GNOME桌面的安装
    cetnos 7 ntp服务的安装与配置
    Tornado初探
    Mysql报错 Cannot load from mysql.proc
    zabbix install
    PYPY_GC
  • 原文地址:https://www.cnblogs.com/shengshuai/p/autoSize.html
Copyright © 2011-2022 走看看