獲得螢幕大小

2021-09-08 17:02:45 字數 809 閱讀 9256

api:

要取得螢幕大小,可以用下面幾個函式:

int  cx   =  

getsystemmetrics( 

sm_cxfullscreen );

int  cy   =  

getsystemmetrics( 

sm_cyfullscreen );

通過上邊兩個函式獲取的是顯示螢幕的大小,但不包括工作列等區域

int  cx   =   

getsystemmetrics(   

sm_cxscreen   );   

int  cy   =   

getsystemmetrics(   

sm_cyscreen   );

這兩個函式獲取的是真正螢幕的大小。

mfc:

hdc hdc =  ::

getdc(

hwnd(

null));               

//得到螢幕dc  

int x  =  ::

getdevicecaps(hdc,

horzres);       

//寬  int y  =  ::

getdevicecaps(hdc,

vertres);        

//高   

:: releasedc(

hwnd(

null),hdc);                  

//釋放dc

Android 獲得螢幕大小

b size large align center android 獲得螢幕大小 align size b import android.util.displaymetrics private displaymetrics dm 螢幕解析度容器 dm new displaymetrics this....

獲得螢幕大小小結

螢幕的大小有兩種情形 1 整個螢幕的大小,包括工具欄的大小。方法是用函式 int winapi getsystemmetrics in int nindex 用法 int xscreen getsystemmetrics sm cxfullscreen screen width int yscree...

vc獲得顯示螢幕大小

int with getsystemmetrics sm cxfullscreen int heigh getsystemmetrics sm cyfullscreen 通過上邊兩個函式獲取的是顯示螢幕的大小,及不包括工作列等區域。int cx getsystemmetrics sm cxscree...