線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:3883
推到 Plurk!
推到 Facebook!

動態變更畫面解析度

 
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#1 引用回覆 回覆 發表時間:2002-07-16 12:18:42 IP:61.218.xxx.xxx 未訂閱
BCB 在執行時期,動態變更畫面解析度?我想讓程式可以在 800x600 與 1024x768 間切換。 使用 EnumDisplaySettings(). Windows GDI EnumDisplaySettings The EnumDisplaySettings function retrieves information about one of the graphics modes for a display device. To retrieve information for all the graphics modes of a display device, make a series of calls to this function. BOOL EnumDisplaySettings( LPCTSTR lpszDeviceName, // display device DWORD iModeNum, // graphics mode LPDEVMODE lpDevMode // graphics mode settings ); Parameters lpszDeviceName [in] Pointer to a null-terminated string that specifies the display device about whose graphics mode the function will obtain information. This parameter is either NULL or a DISPLAY_DEVICE.DeviceName returned from EnumDisplayDevices. A NULL value specifies the current display device on the computer on which the calling thread is running. Windows 95: lpszDeviceName must be NULL. iModeNum [in] Specifies the type of information to retrieve. This value can be a graphics mode index or one of the following values. Value Meaning ENUM_CURRENT_SETTINGS Retrieve the current settings for the display device. ENUM_REGISTRY_SETTINGS Retrieve the settings for the display device that are currently stored in the registry. Graphics mode indexes start at zero. To obtain information for all of a display device's graphics modes, make a series of calls to EnumDisplaySettings, as follows: Set iModeNum to zero for the first call, and increment iModeNum by one for each subsequent call. Continue calling the function until the return value is zero. When you call EnumDisplaySettings with iModeNum set to zero, the operating system initializes and caches information about the display device. When you call EnumDisplaySettings with iModeNum set to a non-zero value, the function returns the information that was cached the last time the function was called with iModeNum set to zero. lpDevMode [out] Pointer to a DEVMODE structure into which the function stores information about the specified graphics mode. Before calling EnumDisplaySettings, set the dmSize member to sizeof(DEVMODE), and set the dmDriverExtra member to indicate the size, in bytes, of the additional space available to receive private driver data. The EnumDisplaySettings function sets values for the following five DEVMODE members: * dmBitsPerPel * dmPelsWidth * dmPelsHeight * dmDisplayFlags * dmDisplayFrequency Return Values If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. Windows NT/2000/XP: To get extended error information, call GetLastError. Remarks The function fails if iModeNum is greater than the index of the display device's last graphics mode. As noted in the description of the iModeNum parameter, you can use this behavior to enumerate all of a display device's graphics modes. Windows 95/98/Me: EnumDisplaySettingsW is supported by the Microsoft Layer for Unicode. To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems. Requirements Windows NT/2000/XP: Included in Windows NT 4.0 and later. Windows 95/98/Me: Included in Windows 95 and later. Header: Declared in Winuser.h; include Windows.h. Library: Use User32.lib. Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000/XP. Also supported by Microsoft Layer for Unicode. See Also Device Contexts Overview, Device Context Functions, ChangeDisplaySettings, ChangeDisplaySettingsEx, CreateDC, CreateDesktop, DEVMODE, DISPLAY_DEVICE, EnumDisplayDevices 時間就是金錢 << 發問前請先找找舊文章 >>
Apollo.tw
一般會員


發表:3
回覆:4
積分:1
註冊:2002-07-11

發送簡訊給我
#2 引用回覆 回覆 發表時間:2002-07-16 23:19:59 IP:61.30.xxx.xxx 未訂閱
這好像只是列舉顯示卡支援型態吧?
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#3 引用回覆 回覆 發表時間:2002-07-17 09:12:39 IP:61.218.xxx.xxx 未訂閱
請注意這部分的設定     The EnumDisplaySettings function sets values for the following five DEVMODE members:    * dmBitsPerPel * dmPelsWidth * dmPelsHeight * dmDisplayFlags * dmDisplayFrequency    Return Values    您就可以知道它能做些甚麼事了!     時間就是金錢---[ 發問前請先找找舊文章]
HomeSound
中階會員


發表:44
回覆:178
積分:94
註冊:2002-08-31

發送簡訊給我
#4 引用回覆 回覆 發表時間:2002-09-06 00:45:00 IP:61.30.xxx.xxx 未訂閱
請注意這部分的設定 The EnumDisplaySettings function sets values for the following five DEVMODE members: * dmBitsPerPel * dmPelsWidth * dmPelsHeight * dmDisplayFlags * dmDisplayFrequency Return Values 您就可以知道它能做些甚麼事了! ------------------------------------ 小弟還是不會用勒,一般取出是這樣 DEVMODE DevMode; int rc,xmode; // List display enmunerations until fault. rc = 1; xmode = 0; do { rc=EnumDisplaySettings(NULL,xmode,&DevMode); if (rc != 0) { ListBox1->Items->Add (IntToStr(DevMode.dmPelsWidth) "X" IntToStr(DevMode.dmPelsHeight) "X" IntToStr(DevMode.dmDisplayFrequency) "Hz " IntToStr(DevMode.dmBitsPerPel) "-Bit"); } xmode ; } while (rc != 0); 但怎麼變呢? 請axsoft大大指教 還有用ChangeDisplaySettings(devM,0); 去變換的話,最底下的工作列沒有隨著變化,那該怎麼寫呢? 感謝不盡..
------
--==多看.多學.多聽==--
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#5 引用回覆 回覆 發表時間:2002-09-09 09:18:03 IP:61.218.xxx.xxx 未訂閱
引言: 小弟還是不會用勒,一般取出是這樣 DEVMODE DevMode; int rc,xmode; // List display enmunerations until fault. rc = 1; xmode = 0; do { rc=EnumDisplaySettings(NULL,xmode,&DevMode); if (rc != 0) { ListBox1->Items->Add (IntToStr(DevMode.dmPelsWidth) "X" IntToStr(DevMode.dmPelsHeight) "X" IntToStr(DevMode.dmDisplayFrequency) "Hz " IntToStr(DevMode.dmBitsPerPel) "-Bit"); } xmode ; } while (rc != 0); 但怎麼變呢? 請axsoft大大指教 還有用ChangeDisplaySettings(devM,0); 去變換的話,最底下的工作列沒有隨著變化,那該怎麼寫呢? 感謝不盡.. < face="Verdana, Arial, Helvetica"> 參考這一篇使用範例: http://delphi.ktop.com.tw/topic.php?TOPIC_ID=20129 聯盟----Visita網站http://www.vista.org.tw ---[ 發問前請先找找舊文章 ]---
HomeSound
中階會員


發表:44
回覆:178
積分:94
註冊:2002-08-31

發送簡訊給我
#6 引用回覆 回覆 發表時間:2002-09-10 18:50:45 IP:61.30.xxx.xxx 未訂閱
[/quote] 參考這一篇使用範例: http://delphi.ktop.com.tw/topic.php?TOPIC_ID=20129 [/quote] 發言之前已參考過,感謝Axsoft大大 還有用ChangeDisplaySettings(devM,0); 去變換的話,最底下的工作列沒有隨著變化,那該怎麼寫呢? 乎搭啦!
------
--==多看.多學.多聽==--
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#7 引用回覆 回覆 發表時間:2002-09-11 09:34:52 IP:61.218.xxx.xxx 未訂閱
引言: 發言之前已參考過,感謝Axsoft大大 還有用ChangeDisplaySettings(devM,0); 去變換的話,最底下的工作列沒有隨著變化,那該怎麼寫呢? 乎搭啦!
實在不知您所謂的工作列隨著變化是如何? 我提供下面用OPENGL的方法:
Params.Style=WS_POPUP|WS_CLIPCHILDREN
ChangeResolution(800,600);
Params.Width=800;
Params.Height=600;
Params.X=Params.Y=0;    //EnumDisplaySettings()是查詢顯示模式
//ChangeDisplaySettings()是Change顯示模式    BOOL ChangeResolution(DWORD w, DWORD h)
 {
  DEVMODE devMode;
  LONG modeSwitch;
  LONG i;
  CHAR buf[256];
  i = 0;
  do {
      modeSwitch = EnumDisplaySettings(NULL, i, &devMode);
      i  ;
     } while(( (devMode.dmBitsPerPel!=16)
            ||(devMode.dmPelsWidth != w)
            ||(devMode.dmPelsHeight != h) )
            && (modeSwitch) );
/* Okay see if we found a mode */
if (!modeSwitch) { }
else {
     modeSwitch = ChangeDisplaySettings(&devMode, 0);
     if (modeSwitch!=DISP_CHANGE_SUCCESSFUL)
        {
         //Might be running in Windows95, let's try without the hertz
         // change
         devMode.dmBitsPerPel = 16; 
         devMode.dmPelsWidth = w;
         devMode.dmPelsHeight = h;
         devMode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH |
         DM_PELSHEIGHT;
         modeSwitch = ChangeDisplaySettings(&devMode, 0);
        }
     }
return TRUE;
}     
聯盟----Visita網站http://www.vista.org.tw ---[ 發問前請先找找舊文章 ]--- 發表人 - axsoft 於 2002/09/11 09:35:45
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#8 引用回覆 回覆 發表時間:2002-09-11 09:43:51 IP:61.218.xxx.xxx 未訂閱
這是另外一個範例
    DEVMODE DevMod;    DevMod.dmSize = sizeof(DEVMODE);
DevMod.dmDriverExtra = 0;    EnumDisplaySettings(ENULL,ENUM_CURRENT_SETTINGS,&DevMod);
DevMod.dmPelsWidth = 640;
DevMod.dmPelsHeight = 480;
DevMod.dmFields |= DM_PELSWIDTH; // Might already be set, I don't know.
DevMod.dmFields |= DM_PELSHEIGHT; // Might already be set, I don't know.    ChangeDisplaySettings(&DevMod,CDS_FULLSCREEN);
聯盟----Visita網站http://www.vista.org.tw ---[ 發問前請先找找舊文章 ]---
HomeSound
中階會員


發表:44
回覆:178
積分:94
註冊:2002-08-31

發送簡訊給我
#9 引用回覆 回覆 發表時間:2002-09-12 12:12:31 IP:61.30.xxx.xxx 未訂閱
引言: >實在不知您所謂的工作列隨著變化是如何?
感謝axsoft大大的回答 小弟意思是說用右下工作列的小螢幕ICON作變換時 "開始鈕"這一整條bar("Shell_TrayWnd")會隨著變換, 但是用ChangeDisplaySettings後,不會隨著變化, 解析度變大還可以點一下,如果變小就點不到bar了. 乎搭啦!
------
--==多看.多學.多聽==--
RogerHer
一般會員


發表:11
回覆:39
積分:10
註冊:2002-03-13

發送簡訊給我
#10 引用回覆 回覆 發表時間:2002-11-11 13:44:28 IP:202.145.xxx.xxx 未訂閱
引言:引言: -------------------------------------------------------------------------------- >實在不知您所謂的工作列隨著變化是如何? -------------------------------------------------------------------------------- 感謝axsoft大大的回答 小弟意思是說用右下工作列的小螢幕ICON作變換時 "開始鈕"這一整條bar("Shell_TrayWnd")會隨著變換, 但是用ChangeDisplaySettings後,不會隨著變化, 解析度變大還可以點一下,如果變小就點不到bar了. 乎搭啦!
可以再加上 CDS_UPDATEREGISTRY 旗標及 SystemParametersInfo 更新 Registry
 
DEVMODE DevMod;
DevMod.dmSize = sizeof(DEVMODE);
DevMod.dmDriverExtra = 0;
EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&DevMod);
DevMod.dmPelsWidth = 640;
DevMod.dmPelsHeight = 480;
DevMod.dmFields |= DM_PELSWIDTH; // Might already be set, I don't know.
DevMod.dmFields |= DM_PELSHEIGHT; // Might already be set, I don't know.
ChangeDisplaySettings(&DevMod,CDS_FULLSCREEN | CDS_UPDATEREGISTRY  );
SystemParametersInfo(0,0,0,SPIF_SENDCHANGE  );
HomeSound
中階會員


發表:44
回覆:178
積分:94
註冊:2002-08-31

發送簡訊給我
#11 引用回覆 回覆 發表時間:2002-11-13 12:55:13 IP:61.30.xxx.xxx 未訂閱
引言: 可以再加上 CDS_UPDATEREGISTRY 旗標及 SystemParametersInfo 更新
感謝RogerHer大大回答 小弟想要的是即時變換,而非下次開機再更換 --==多看.多學.多聽==--
------
--==多看.多學.多聽==--
tender
初階會員


發表:23
回覆:90
積分:37
註冊:2002-09-26

發送簡訊給我
#12 引用回覆 回覆 發表時間:2002-11-16 15:54:56 IP:211.75.xxx.xxx 未訂閱
使用 EnumWindows API (Search in MSDN to use by yourself) 就可以了!! ^_^
HomeSound
中階會員


發表:44
回覆:178
積分:94
註冊:2002-08-31

發送簡訊給我
#13 引用回覆 回覆 發表時間:2002-11-18 00:36:12 IP:219.81.xxx.xxx 未訂閱
引言: 使用 EnumWindows API (Search in MSDN to use by yourself) 就可以了!! ^_^
抱歉tender大大列舉EnumWindows這個API 小弟不會用,還請指導指導,感謝您 --==多看.多學.多聽==--
------
--==多看.多學.多聽==--
系統時間:2024-03-28 20:25:16
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!