c#獲取當前螢幕大小或工作列的大小,不用api.
2009-02-26 18:37
使用systeminformation類就行了.
string currentscreensize_outtaskbar=systeminformation.workingarea.width.tostring() + "," +systeminformation.workingarea.height.tostring();
messagebox.show("當前的螢幕除工作列外的工作域大小為:"+currentscreensize_outtaskbar);
string currentscreensize=system.windows.forms.screen.primaryscreen.bounds.width.tostring() + "," + system.windows.forms.screen.primaryscreen.bounds.height.tostring();
messagebox.show("當前的螢幕包括工作列的工作域大小為:"+currentscreensize);
size outtaskbarsize = new size(systeminformation.workingarea.width, systeminformation.workingarea.height);
size screensize = new size(system.windows.forms.screen.primaryscreen.bounds.width, system.windows.forms.screen.primaryscreen.bounds.height);
size taskbarsize;
taskbarsize = new size(
(screensize.width - (screensize.width - outtaskbarsize.width)),
(screensize.height - outtaskbarsize.height)
);messagebox.show("工作列大小:" + taskbarsize.width + "," + taskbarsize.height);
using system.windows.forms;
獲取螢幕解析度
int sh = screen.primaryscreen.bounds.height;
int sw = screen.primaryscreen.bounds.width;
獲取視窗居中top和left
int thish=100;
int thisw=200;
int sh = (screen.primaryscreen.bounds.height - 30 - thish) / 2;
int sw = (screen.primaryscreen.bounds.width - 10 - thisw) / 2;
C 獲取螢幕大小或工作列大小
使用systeminformation類 當前的螢幕除工作列外的工作域大小 string currentscreensize outtaskbar systeminformation.workingarea.width.tostring systeminformation.workingarea.h...
工作列的大小
工作列大小的計算方法 寬度 和視窗寬度一樣 高度 視窗高度 工作區域高度 cwindowdc dc getdesktopwindow 取得桌面裝置控制代碼 int xres getdevicecaps dc,horzres 取得水平 int yres getdevicecaps dc,vertres...
MFC中獲取工作列大小
你可以這樣 hwnd hwnd getdesktopwindow rect rect getclientrect hwnd,rect 可以得到桌面大小 還有就是上面所說的 int nscreenwidth,nscreenheight nscreenwidth getsystemmetrics sm ...