CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  C++ Builder >  基础类

怎样修改分辩率???

楼主SharpKing515(不穿内裤)2002-08-25 22:48:03 在 C++ Builder / 基础类 提问

我要在程序运行的时候修改屏幕的分辩率,但不知怎么做,,,,,, 问题点数:30、回复次数:3Top

1 楼joshstone(软体动物)回复于 2002-08-25 23:11:17 得分 30

#include   <vcl.h>  
  #pragma   hdrstop  
   
  #include   "Unit1.h"  
  //---------------------------------------------------------------------------  
  #pragma   package(smart_init)  
  #pragma   resource   "*.dfm"  
  TForm1   *Form1;  
  //---------------------------------------------------------------------------  
  __fastcall   TForm1::TForm1(TComponent*   Owner)  
                  :   TForm(Owner)  
  {  
  }  
  bool   setres(int   x,int   y)  
  {       TDeviceMode         lpDevMode;  
          if(   EnumDisplaySettings(NULL,0,&     lpDevMode))  
          {                       lpDevMode.dmFields     =     DM_PELSWIDTH     |     DM_PELSHEIGHT;  
                                  lpDevMode.dmPelsWidth     =     x;  
                                  lpDevMode.dmPelsHeight     =     y;  
                                  ChangeDisplaySettings(&lpDevMode,CDS_UPDATEREGISTRY);  
                                  SystemParametersInfo(SPI_SETDESKPATTERN,0,NULL,0);  
                                                                            //修改刷新率  
                                  lpDevMode.dmDisplayFrequency   =   75;  
                                  lpDevMode.dmFields   =DM_PELSWIDTH|DM_PELSHEIGHT|DM_BITSPERPEL|DM_DISPLAYFREQUENCY|DM_DISPLAYFLAGS;  
                                  return     ChangeDisplaySettings(&   lpDevMode,0);  
          }  
          else   return   false;  
  }  
  //---------------------------------------------------------------------------  
   
  void   __fastcall   TForm1::Button1Click(TObject   *Sender)  
  {  
  setres(StrToInt(Edit1->Text),StrToInt(Edit2->Text));  
  }  
  //---------------------------------------------------------------------------  
  void   __fastcall   TForm1::Button2Click(TObject   *Sender)  
  {  
  int     x,y;  
          x=GetSystemMetrics(SM_CXSCREEN);  
          y=GetSystemMetrics(SM_CYSCREEN);  
          //下面有该函数的比较全的解释  
          ShowMessage("显示器水平分辨率:"     +     AnsiString(x)     +     "\n\n显示器垂直分辨率:"     +     AnsiString(y));  
   
   
  }  
  //---------------------------------------------------------------------------  
  void   __fastcall   TForm1::Button3Click(TObject   *Sender)  
  {  
        int     x,y;  
          x=GetSystemMetrics(SM_CXBORDER);  
          y=GetSystemMetrics(SM_CYBORDER);  
          Memo1->Lines->Add(AnsiString(x)+"上"+AnsiString(y));  
  }  
  //---------------------------------------------------------------------------  
  Top

2 楼joshstone(软体动物)回复于 2002-08-25 23:12:32 得分 0

Specifies   the   system   metric   or   configuration   setting   to   retrieve.   All   SM_CX*   values   are   widths.   All   SM_CY*   values   are   heights.   The   following   values   are   defined:      
   
  Value Meaning  
  SM_ARRANGE Flags   specifying   how   the   system   arranged   minimized   windows.   For   more   information   about   minimized   windows,   see   the   following   Remarks   section.  
  SM_CLEANBOOT Value   that   specifies   how   the   system   was   started:0     Normal   boot1     Fail-safe   boot2     Fail-safe   with   network   bootFail-safe   boot   (also   called   SafeBoot)   bypasses   the   user's   startup   files.  
  SM_CMOUSEBUTTONS Number   of   buttons   on   mouse,   or   zero   if   no   mouse   is   installed.  
  SM_CXBORDER,    
  SM_CYBORDER The   width   and   height,   in   pixels,   of   a   window   border.   This   is   equivalent   to   the   SM_CXEDGE   value   for   windows   with   the   3-D   look.  
  SM_CXCURSOR,    
  SM_CYCURSOR Width   and   height,   in   pixels,   of   a   cursor.   These   are   the   cursor   dimensions   supported   by   the   current   display   driver.   The   system   cannot   create   cursors   of   other   sizes.    
  SM_CXDLGFRAME,  
  SM_CYDLGFRAME Same   as   SM_CXFIXEDFRAME   and   SM_CYFIXEDFRAME.  
  SM_CXDOUBLECLK,    
  SM_CYDOUBLECLK Width   and   height,   in   pixels,   of   the   rectangle   around   the   location   of   a   first   click   in   a   double-click   sequence.   The   second   click   must   occur   within   this   rectangle   for   the   system   to   consider   the   two   clicks   a   double-click.   (The   two   clicks   must   also   occur   within   a   specified   time.)  
  SM_CXDRAG,    
  SM_CYDRAG Width   and   height,   in   pixels,   of   a   rectangle   centered   on   a   drag   point   to   allow   for   limited   movement   of   the   mouse   pointer   before   a   drag   operation   begins.   This   allows   the   user   to   click   and   release   the   mouse   button   easily   without   unintentionally   starting   a   drag   operation.  
  SM_CXEDGE,    
  SM_CYEDGE Dimensions,   in   pixels,   of   a   3-D   border.   These   are   the   3-D   counterparts   of   SM_CXBORDER   and   SM_CYBORDER.  
  SM_CXFIXEDFRAME,  
  SM_CYFIXEDFRAME Thickness,   in   pixels,   of   the   frame   around   the   perimeter   of   a   window   that   has   a   caption   but   is   not   sizable.   SM_CXFIXEDFRAME   is   the   width   of   the   horizontal   border   and   SM_CYFIXEDFRAME   is   the   height   of   the   vertical   border.   Same   as   SM_CXDLGFRAME   and   SM_CYDLGFRAME.  
  SM_CXFRAME,  
  SM_CYFRAME Same   as   SM_CXSIZEFRAME   and   SM_CYSIZEFRAME.  
  SM_CXFULLSCREEN,   SM_CYFULLSCREEN Width   and   height   of   the   client   area   for   a   full-screen   window.   To   get   the   coordinates   of   the   portion   of   the   screen   not   obscured   by   the   tray,   call   the   SystemParametersInfo   function   with   the   SPI_GETWORKAREA   value.  
  SM_CXHSCROLL,   SM_CYHSCROLL Width,   in   pixels,   of   the   arrow   bitmap   on   a   horizontal   scroll   bar;   and   height,   in   pixels,   of   a   horizontal   scroll   bar.  
  SM_CXHTHUMB Width,   in   pixels,   of   the   thumb   box   in   a   horizontal   scroll   bar.  
  SM_CXICON,    
  SM_CYICON The   default   width   and   height,   in   pixels,   of   an   icon.   These   values   are   typically   32x32,   but   can   vary   depending   on   the   installed   display   hardware.The   LoadIcon   function   can   only   load   icons   of   these   dimensions.    
  SM_CXICONSPACING,   SM_CYICONSPACING Dimensions,   in   pixels,   of   a   grid   cell   for   items   in   large   icon   view.   Each   item   fits   into   a   rectangle   of   this   size   when   arranged.   These   values   are   always   greater   than   or   equal   to   SM_CXICON   and   SM_CYICON.  
  SM_CXMAXIMIZED,  
  SM_CYMAXIMIZED Default   dimensions,   in   pixels,   of   a   maximized   top-level   window.  
  SM_CXMAXTRACK,  
  SM_CYMAXTRACK Default   maximum   dimensions,   in   pixels,   of   a   window   that   has   a   caption   and   sizing   borders.   The   user   cannot   drag   the   window   frame   to   a   size   larger   than   these   dimensions.   A   window   can   override   these   values   by   processing   the   WM_GETMINMAXINFO   message.  
  SM_CXMENUCHECK,  
  SM_CYMENUCHECK Dimensions,   in   pixels,   of   the   default   menu   check-mark   bitmap.  
  SM_CXMENUSIZE,  
  SM_CYMENUSIZE Dimensions,   in   pixels,   of   menu   bar   buttons,   such   as   multiple   document   (MIDI)   child   close.  
  SM_CXMIN,    
  SM_CYMIN Minimum   width   and   height,   in   pixels,   of   a   window.  
  SM_CXMINIMIZED,  
  SM_CYMINIMIZED Dimensions,   in   pixels,   of   a   normal   minimized   window.  
  SM_CXMINSPACING  
  SM_CYMINSPACING Dimensions,   in   pixels,   of   a   grid   cell   for   minimized   windows.   Each   minimized   window   fits   into   a   rectangle   this   size   when   arranged.   These   values   are   always   greater   than   or   equal   to   SM_CXMINIMIZED   and   SM_CYMINIMIZED.  
  SM_CXMINTRACK,   SM_CYMINTRACK Minimum   tracking   width   and   height,   in   pixels,   of   a   window.   The   user   cannot   drag   the   window   frame   to   a   size   smaller   than   these   dimensions.   A   window   can   override   these   values   by   processing   the   WM_GETMINMAXINFO   message.  
  SM_CXSCREEN,    
  SM_CYSCREEN Width   and   height,   in   pixels,   of   the   screen.  
  SM_CXSIZE,    
  SM_CYSIZE Width   and   height,   in   pixels,   of   a   button   in   a   window's   caption   or   title   bar.  
  SM_CXSIZEFRAME,  
  SM_CYSIZEFRAME Thickness,   in   pixels,   of   the   sizing   border   around   the   perimeter   of   a   window   that   can   be   resized.   SM_CXSIZEFRAME   is   the   width   of   the   horizontal   border   and   SM_CYSIZEFRAME   is   the   height   of   the   vertical   border.   Same   as   SM_CXFRAME   and   SM_CYFRAME.  
  SM_CXSMICON,  
  SM_CYSMICON Recommended   dimensions,   in   pixels,   of   a   small   icon.   Small   icons   typically   appear   in   window   captions   and   in   small   icon   view.  
  SM_CXSMSIZE  
  SM_CYSMSIZE Dimensions,   in   pixels,   of   small   caption   buttons.  
  SM_CXVSCROLL,   SM_CYVSCROLL Width,   in   pixels,   of   a   vertical   scroll   bar;   and   height,   in   pixels,   of   the   arrow   bitmap   on   a   vertical   scroll   bar.  
  SM_CYCAPTION Height,   in   pixels,   of   normal   caption   area.  
  SM_CYKANJIWINDOW For   double-byte   character   set   versions   of   Windows,   height,   in   pixels,   of   the   Kanji   window   at   the   bottom   of   the   screen.  
  SM_CYMENU Height,   in   pixels,   of   single-line   menu   bar.  
  SM_CYSMCAPTION Height,   in   pixels,   of   a   small   caption.  
  SM_CYVTHUMB Height   ,   in   pixels,   of   the   thumb   box   in   a   vertical   scroll   bar.  
  SM_DBCSENABLED TRUE   or   nonzero   if   the   double-byte   character   set   (DBCS)   version   of   USER.EXE   is   installed;   FALSE,   or   zero   otherwise.  
  SM_DEBUG TRUE   or   nonzero   if   the   debugging   version   of   USER.EXE   is   installed;   FALSE,   or   zero,   otherwise.  
  SM_MENUDROPALIGNMENT TRUE,   or   nonzero   if   drop-down   menus   are   right-aligned   relative   to   the   corresponding   menu-bar   item;   FALSE,   or   zero   if   they   are   left-aligned.  
  SM_MIDEASTENABLED TRUE   if   the   system   is   enabled   for   Hebrew/Arabic   languages.  
  SM_MOUSEPRESENT TRUE   or   nonzero   if   a   mouse   is   installed;   FALSE,   or   zero,   otherwise.  
  SM_MOUSEWHEELPRESENT Windows   NT   only:   TRUE   or   nonzero   if   a   mouse   with   a   wheel   is   installed;   FALSE,   or   zero,   otherwise.  
  SM_NETWORK The   least   significant   bit   is   set   if   a   network   is   present;   otherwise,   it   is   cleared.   The   other   bits   are   reserved   for   future   use.  
  SM_PENWINDOWS TRUE   or   nonzero   if   the   Microsoft   Windows   for   Pen   computing   extensions   are   installed;   zero,   or   FALSE,   otherwise.  
  SM_SECURE TRUE   if   security   is   present,   FALSE   otherwise.  
  SM_SHOWSOUNDS TRUE   or   nonzero   if   the   user   requires   an   application   to   present   information   visually   in   situations   where   it   would   otherwise   present   the   information   only   in   audible   form;   FALSE,   or   zero,   otherwise.  
  SM_SLOWMACHINE TRUE   if   the   computer   has   a   low-end   (slow)   processor,   FALSE   otherwise.  
  SM_SWAPBUTTON TRUE   or   nonzero   if   the   meanings   of   the   left   and   right   mouse   buttons   are   swapped;   FALSE,   or   zero,   otherwise.  
  Top

3 楼joshstone(软体动物)回复于 2002-08-25 23:12:47 得分 0

Return   Values  
   
  If   the   function   succeeds,   the   return   value   is   the   requested   system   metric   or   configuration   setting.  
  If   the   function   fails,   the   return   value   is   zero.   GetLastError   does   not   provide   extended   error   information.  
   
  Remarks  
   
  System   metrics   may   vary   from   display   to   display.    
  The   SM_ARRANGE   setting   specifies   how   the   system   arranges   minimized   windows,   and   consists   of   a   starting   position   and   a   direction.   The   starting   position   can   be   one   of   the   following   values.  
   
  Value Meaning  
  ARW_BOTTOMLEFT Start   at   lower-left   corner   of   screen   (default   position).  
  ARW_BOTTOMRIGHT Start   at   lower-right   corner   of   screen.   Equivalent   to   ARW_STARTRIGHT.  
  ARW_HIDE Hide   minimized   windows   by   moving   them   off   of   the   visible   area   of   the   screen.  
  ARW_TOPLEFT Start   at   upper-left   corner   of   screen.   Equivalent   to   ARV_STARTTOP.  
  ARW_TOPRIGHT Start   at   upper-right   corner   of   screen.   Equivalent   to   ARW_STARTTOP   |   SRW_STARTRIGHT.  
     
   
  The   direction   in   which   to   arrange   can   be   one   of   the   following   values.  
   
  Value Meaning  
  ARW_DOWN Arrange   vertically,   top   to   bottom.  
  ARW_LEFT Arrange   horizontally,   left   to   right.  
  ARW_RIGHT Arrange   horizontally,   right   to   left.  
  ARW_UP Arrange   vertically,   bottom   to   top.  
  Top

相关问题

  • 怎样知道屏幕的分辩率?
  • 在delphi中如何修改显示器的分辩率与刷新频率?
  • 怎样在程序中改变系统的分辩率???
  • 怎样用API函数改变屏幕的分辩率?(VC)
  • 分辩率问题??
  • 如何更改分辩率?
  • 关于屏幕分辩率?
  • 不同分辩率下?
  • 怎样在网页中放一副图片,无论怎样改变显示器分辩率,或浏览器窗口大小,都能居中显示?
  • 使用C++Builder4做成的form为什么在相同分辩率的不同机子上显示不同?我应怎样改进程序?

关键词

  • lpdevmode
  • dm
  • tform
  • pragma

得分解答快速导航

  • 帖主:SharpKing515
  • joshstone

相关链接

  • CSDN Blog
  • 技术文档
  • 代码下载
  • 第二书店
  • 读书频道

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo