全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1234
推到 Plurk!
推到 Facebook!

旋轉的問題

尚未結案
kraen4468
初階會員


發表:66
回覆:112
積分:35
註冊:2003-12-04

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-02-26 16:54:53 IP:61.222.xxx.xxx 未訂閱
 DeviceMode.dmSize = SizeOf(TDeviceMode);
DeviceMode.dmPelsWidth = Width;
DeviceMode.dmPelsHeight = Height;
DeviceMode.dmFields = DM_PELSWIDTH || DM_PELSHEIGHT;
Result = ChangeDisplaySettings(DeviceMode,CDS_UPDATEREGISTRY);
上面的code是我從Delphi翻過來的可是一直沒辨法過 ~我還在學習狀態希望多多向您學習~ 發表人 - taishyang 於 2004/02/26 17:08:29
kraen4468
初階會員


發表:66
回覆:112
積分:35
註冊:2003-12-04

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-02-27 11:12:09 IP:61.222.xxx.xxx 未訂閱
LONG ChangeDisplaySettings(
  LPDEVMODE lpDevMode,  // graphics mode
  DWORD dwflags         // graphics mode options
);
lpDevMode 
[in] Pointer to a DEVMODE structure that describes the new graphics mode. If lpDevMode is NULL, all the values currently in the registry will be used for the display setting. Passing NULL for the lpDevMode parameter and 0 for the dwFlags parameter is the easiest way to return to the default mode after a dynamic mode change. 
The dmSize member of DEVMODE must be initialized to the size, in bytes, of the DEVMODE structure. The dmDriverExtra member of DEVMODE must be initialized to indicate the number of bytes of private driver data following the DEVMODE structure. In addition, you can use any or all of the following members of the DEVMODE structure. 
DEVMODE DeviceMode;
我在lpDevMode裡填DeviceMode不對了嗎還是型態的問題呢 ~我還在學習狀態希望多多向您學習~
kraen4468
初階會員


發表:66
回覆:112
積分:35
註冊:2003-12-04

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-02-27 11:28:09 IP:61.222.xxx.xxx 未訂閱
上面的po我沒有分段sorry  
lpDevMode[in] Pointer to a DEVMODE structure that describes
the new graphics mode. If lpDevMode is NULL, all the values
currently in the registry will be used for the display setting.
 Passing NULL for the lpDevMode parameter and 0 for the dwFlags
 parameter is the easiest way to return to the default mode after a
 dynamic mode change. 
The dmSize member of DEVMODE must be initialized to the size, in \bytes, of the DEVMODE structure. The dmDriverExtra member of
 DEVMODE must be initialized to indicate the number of bytes of 
private driver data following the DEVMODE structure. In addition,
 you can use any or all of the following members of the DEVMODE 
structure.  
~我還在學習狀態希望多多向您學習~
axsoft
版主


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

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-02-27 12:07:21 IP:61.218.xxx.xxx 未訂閱
 
kraen4468 您好:
您要的是這個嗎?
   
  HDC hDCScreen = GetDC(NULL);
  int horres=GetDeviceCaps(hDCScreen,HORZRES);
  int vertres=GetDeviceCaps(hDCScreen,VERTRES);
  int freq=GetDeviceCaps(hDCScreen,VREFRESH);
  ReleaseDC(NULL, hDCScreen);
  horres=1024;
  vertres=768;
  DEVMODE dm;
  ZeroMemory(&dm, sizeof(DEVMODE));
  dm.dmSize = sizeof(DEVMODE);
  dm.dmPelsWidth = horres;
  dm.dmPelsHeight = vertres;
  dm.dmDisplayFrequency = freq;
  dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
  ChangeDisplaySettings(&dm, 0);
/*生活是一種藝術,用心生活才能享受生活*/
kraen4468
初階會員


發表:66
回覆:112
積分:35
註冊:2003-12-04

發送簡訊給我
#5 引用回覆 回覆 發表時間:2004-02-27 13:06:34 IP:61.222.xxx.xxx 未訂閱
可以Component可是沒有動作也 我把horres=800;vertres=600;也沒有變化 ~我還在學習狀態希望多多向您學習~
axsoft
版主


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

發送簡訊給我
#6 引用回覆 回覆 發表時間:2004-02-27 13:17:06 IP:61.218.xxx.xxx 未訂閱
引言: 可以Component可是沒有動作也 我把horres=800;vertres=600;也沒有變化 ~我還在學習狀態希望多多向您學習~
您是要改變螢慕解析度嗎?參考這個範例試試吧! http://www.bytesandmore.de/rad/cpp/snipp/sc03020.php
/*生活是一種藝術,用心生活才能享受生活*/
發表人 - axsoft 於 2004/02/27 13:18:40
kraen4468
初階會員


發表:66
回覆:112
積分:35
註冊:2003-12-04

發送簡訊給我
#7 引用回覆 回覆 發表時間:2004-02-27 14:13:40 IP:61.222.xxx.xxx 未訂閱
可以在問你一個問題嗎? 我看了一回而結果裡面講的跟我一開始寫的都沒辨法搭上 可以幫我找我寫的這一段好嗎 還是初學者請多多指教 ~我還在學習狀態希望多多向您學習~
axsoft
版主


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

發送簡訊給我
#8 引用回覆 回覆 發表時間:2004-02-27 15:44:12 IP:61.218.xxx.xxx 未訂閱
引言: 可以在問你一個問題嗎? 我看了一回而結果裡面講的跟我一開始寫的都沒辨法搭上 可以幫我找我寫的這一段好嗎 還是初學者請多多指教 ~我還在學習狀態希望多多向您學習~
老實說...您的發問...我到現在好還沒搞清楚您的需求...我只看到ChangeDisplaySettings() API其他真的不知你想問甚麼?< > 建議您發問時寫清楚需求....不然看的人真的在瞎子摸象....跌跌撞撞...< > 標題叫旋轉的問題?...是螢幕旋轉還是地球旋轉呀....搞不懂....] [>生活是一種藝術,用心生活才能享受生活*/[/
kraen4468
初階會員


發表:66
回覆:112
積分:35
註冊:2003-12-04

發送簡訊給我
#9 引用回覆 回覆 發表時間:2004-02-27 15:45:49 IP:61.222.xxx.xxx 未訂閱
板主可以幫我看一下code嗎 這是delphi的程式
unit sw_resolution;    interface    uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;    type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;    var
  Form1: TForm1;    function SetScreenResolution(Width, Height: integer): Longint;      implementation    {$R *.dfm}    function SetScreenResolution(Width, Height: integer): Longint;
var
  DeviceMode: TDeviceMode;
begin
  with DeviceMode do
  begin
    dmSize := SizeOf(TDeviceMode);
    dmPelsWidth := Width;
    dmPelsHeight := Height;
    dmFields := DM_PELSWIDTH or DM_PELSHEIGHT;
  end;
  Result := ChangeDisplaySettings(DeviceMode, CDS_UPDATEREGISTRY);
end;    procedure TForm1.Button1Click(Sender: TObject);
begin
  SetScreenResolution(800, 600);
end;    procedure TForm1.Button2Click(Sender: TObject);
begin
  SetScreenResolution(1024, 768);
end;    end.
這是我轉成c  的程式
[code]
//---------------------------------------------------------------------------
#include 
#pragma hdrstop
#include "winuser.h"
#include "wingdi.h"
#include "rotation1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
DEVMODE DeviceMode1;
int Result;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
long int __fastcall TForm1::SetScreenResolution(int Height,int Width)
{
DeviceMode1.dmSize = sizeof(TDeviceMode);
DeviceMode1.dmPelsWidth = Width;
DeviceMode1.dmPelsHeight = Height;
DeviceMode1.dmFields = DM_PELSWIDTH || DM_PELSHEIGHT;
Result = ChangeDisplaySettings(DeviceMode1 ,CDS_UPDATEREGISTRY);
}
//---------------------------------------------------------------------------    void __fastcall TForm1::Button2Click(TObject *Sender)
{
SetScreenResolution(800,600);
}
//---------------------------------------------------------------------------    void __fastcall TForm1::Button1Click(TObject *Sender)
{
SetScreenResolution(1024,768);
}
//---------------------------------------------------------------------------
~我還在學習狀態希望多多向您學習~
kraen4468
初階會員


發表:66
回覆:112
積分:35
註冊:2003-12-04

發送簡訊給我
#10 引用回覆 回覆 發表時間:2004-02-27 16:44:29 IP:61.222.xxx.xxx 未訂閱
sorry我問的不清不楚 我在po一次在解析度的問題上面 ~我還在學習狀態希望多多向您學習~
axsoft
版主


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

發送簡訊給我
#11 引用回覆 回覆 發表時間:2004-02-27 18:37:51 IP:61.218.xxx.xxx 未訂閱
改成這樣吧! 也建議您把標題改成"如何改變螢幕解析度"    
以下程式碼在Windows XP Professionl   C   Builder 6 Sp4 編譯測試OK        //---------------------------------------------------------------------------    #include 
#pragma hdrstop    #include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
DEVMODE DeviceMode1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
 void __fastcall SetScreenResolution(int Width,int Height,int Frequency)
{
     int Result;
     
     DeviceMode1.dmSize = sizeof(TDeviceMode);
     DeviceMode1.dmPelsWidth = Width;                
     DeviceMode1.dmPelsHeight = Height;
     DeviceMode1.dmDisplayFrequency=Frequency;
     DeviceMode1.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
     Result = ChangeDisplaySettings(&DeviceMode1,CDS_UPDATEREGISTRY);         if(Result==0)
               ShowMessage(" 螢幕解析度變更成功");
     else
               ShowMessage(" 螢幕解析度變更失敗");    }
//---------------------------------------------------------------------------    void __fastcall TForm1::Button1Click(TObject *Sender)
{     SetScreenResolution(1024,768,60);    }
//---------------------------------------------------------------------------
/*生活是一種藝術,用心生活才能享受生活*/
發表人 - axsoft 於 2004/02/27 18:58:15
kraen4468
初階會員


發表:66
回覆:112
積分:35
註冊:2003-12-04

發送簡訊給我
#12 引用回覆 回覆 發表時間:2004-02-27 19:05:55 IP:61.222.xxx.xxx 未訂閱
對不起板主不是故意找查 我試了好多變還是不形 有什麼地方要特別注意的嗎 ~我還在學習狀態希望多多向您學習~
axsoft
版主


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

發送簡訊給我
#13 引用回覆 回覆 發表時間:2004-02-27 19:37:44 IP:61.218.xxx.xxx 未訂閱
引言: 對不起板主不是故意找查 我試了好多變還是不形 有什麼地方要特別注意的嗎 ~我還在學習狀態希望多多向您學習~
請說明您的作業環境,Win9x/Me/NT系列作業系統我是沒試過... Windows2k/XP/2003應該可以很正常Work 這是我寫的範例,跟上面的Source Code是一樣的 http://delphi.ktop.com.tw/loadfile.php?TOPICID=14271561&CC=319179 您再試試吧!
/*生活是一種藝術,用心生活才能享受生活*/
kraen4468
初階會員


發表:66
回覆:112
積分:35
註冊:2003-12-04

發送簡訊給我
#14 引用回覆 回覆 發表時間:2004-02-27 19:56:59 IP:61.222.xxx.xxx 未訂閱
謝謝板主花那麼多的時間幫忙 真是很不好意思 ~小弟十分感積 ~我還在學習狀態希望多多向您學習~
系統時間:2024-05-05 18:55:03
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!