Unit1.cpp
上传用户:lhxd_sz
上传日期:2014-10-02
资源大小:38814k
文件大小:1k
源码类别:

VC书籍

开发平台:

C++ Builder

  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "Unit1.h"
  5. //---------------------------------------------------------------------------
  6. #pragma package(smart_init)
  7. #pragma resource "*.dfm"
  8. TForm1 *Form1;
  9. //---------------------------------------------------------------------------
  10. __fastcall TForm1::TForm1(TComponent* Owner)
  11.         : TForm(Owner)
  12. {
  13.   TDeviceMode dv;
  14.   bool bl;
  15.   old_scr_width=Screen->Width;
  16.   old_scr_height=Screen->Height;
  17.   bl=EnumDisplaySettings(NULL,0,&dv);
  18.   if(bl)
  19.   {
  20.     dv.dmFields=DM_PELSWIDTH | DM_PELSHEIGHT;
  21.     dv.dmPelsWidth=1024;
  22.     dv.dmPelsHeight=768;
  23.     if(ChangeDisplaySettings(&dv,0)==DISP_CHANGE_SUCCESSFUL)
  24.       ShowMessage("屏幕分辩率已改为1024*768n但该程序关闭后会恢复到原状");
  25.   }
  26. }
  27. //---------------------------------------------------------------------------
  28. void __fastcall TForm1::FormDestroy(TObject *Sender)
  29. {
  30.   TDeviceMode dv;
  31.   bool bl;
  32.   bl=EnumDisplaySettings(NULL,0,&dv);
  33.   if(bl)
  34.   {
  35.     dv.dmFields=DM_PELSWIDTH | DM_PELSHEIGHT;
  36.     dv.dmPelsWidth=old_scr_width;
  37.     dv.dmPelsHeight=old_scr_height;
  38.     if(ChangeDisplaySettings(&dv,0)==DISP_CHANGE_SUCCESSFUL)
  39.       ShowMessage("屏幕恢复到原状");
  40.   }
  41. }
  42. //---------------------------------------------------------------------------