procedure TMainForm.newwinprocedure(var msg: tmessage);
var
bmpheight,bmpwidth:integer;
i,j:integer;
begin
msg.Result:=callwindowproc(oldwinproc,clienthandle,msg.Msg,msg.WParam,msg.LParam);
if msg.Msg=wm_erasebkgnd then
begin
bmpwidth:=mainform.Image1.Width;
bmpheight:=mainform.image1.Height;
if (bmpwidth<>0)and(bmpheight<>0) then
begin
outcanvas.Handle:=msg.WParam;
for i:=0 to mainform.ClientWidth div bmpwidth do
for j:=0 to mainform.ClientHeight div bmpheight do
outcanvas.Draw(i*bmpwidth,j*bmpheight,mainform.Image1.Picture.Graphic);
end;
end;
end;procedure TMainForm.FormCreate(Sender: TObject);
begin
newwinproc:=makeobjectinstance(newwinprocedure);
oldwinproc:=pointer(setwindowlong(clienthandle,gwl_wndproc,cardinal(newwinproc)));
outcanvas:=tcanvas.Create;
end;
在WIN2000,DELPHI6,17'纯平中全屏中不能显示为整个界面,图片为800*600.

解决方案 »

  1.   

    bmpwidth
    bmpheight
    不要取image1的宽和高
    取screen.Width/screen.height
      

  2.   

    Screen是Delphi的全局变量,不用你定义
      

  3.   

    Screen你直接用就行了,不用你操作怎么去定义的,这是它的定义:
    在FORMS.PAS单元中:  Screen: TScreen;
    这是TScreen的定义:TScreen = class(TComponent)
      private
        FFonts: TStrings;
        FImes: TStrings;
        FDefaultIme: string;
        FDefaultKbLayout: HKL;
        FPixelsPerInch: Integer;
        FCursor: TCursor;
        FCursorCount: Integer;
        FForms: TList;
        FCustomForms: TList;
        FDataModules: TList;
        FMonitors: TList;
        FCursorList: PCursorRec;
        FDefaultCursor: HCURSOR;
        FActiveControl: TWinControl;
        FActiveCustomForm: TCustomForm;
        FActiveForm: TForm;
        FLastActiveControl: TWinControl;
        FLastActiveCustomForm: TCustomForm;
        FFocusedForm: TCustomForm;
        FSaveFocusedList: TList;
        FHintFont: TFont;
        FIconFont: TFont;
        FMenuFont: TFont;
        FAlignLevel: Word;
        FControlState: TControlState;
        FOnActiveControlChange: TNotifyEvent;
        FOnActiveFormChange: TNotifyEvent;
        procedure AlignForm(AForm: TCustomForm);
        procedure AlignForms(AForm: TCustomForm; var Rect: TRect);
        procedure AddDataModule(DataModule: TDataModule);
        procedure AddForm(AForm: TCustomForm);
        procedure CreateCursors;
        procedure DeleteCursor(Index: Integer);
        procedure DestroyCursors;
        function FindMonitor(Handle: HMONITOR): TMonitor;
        procedure IconFontChanged(Sender: TObject);
        function GetCustomFormCount: Integer;
        function GetCustomForms(Index: Integer): TCustomForm;
        function GetCursors(Index: Integer): HCURSOR;
        function GetDataModule(Index: Integer): TDataModule;
        function GetDataModuleCount: Integer;
        function GetDefaultIME: String;
        function GetDesktopTop: Integer;
        function GetDesktopLeft: Integer;
        function GetDesktopHeight: Integer;
        function GetDesktopWidth: Integer;
        function GetDesktopRect: TRect;
        function GetWorkAreaRect: TRect;
        function GetWorkAreaHeight: Integer;
        function GetWorkAreaLeft: Integer;
        function GetWorkAreaTop: Integer;
        function GetWorkAreaWidth: Integer;
        function GetImes: TStrings;
        function GetHeight: Integer;
        function GetMonitor(Index: Integer): TMonitor;
        function GetMonitorCount: Integer;
        function GetFonts: TStrings;
        function GetForm(Index: Integer): TForm;
        function GetFormCount: Integer;
        procedure GetMetricSettings;
        function GetWidth: Integer;
        procedure InsertCursor(Index: Integer; Handle: HCURSOR);
        procedure RemoveDataModule(DataModule: TDataModule);
        procedure RemoveForm(AForm: TCustomForm);
        procedure SetCursors(Index: Integer; Handle: HCURSOR);
        procedure SetCursor(Value: TCursor);
        procedure SetHintFont(Value: TFont);
        procedure SetIconFont(Value: TFont);
        procedure SetMenuFont(Value: TFont);
        procedure UpdateLastActive;
      public
        constructor Create(AOwner: TComponent); override;
        destructor Destroy; override;
        procedure DisableAlign;
        procedure EnableAlign;
        function MonitorFromPoint(const Point: TPoint;
          MonitorDefault: TMonitorDefaultTo = mdNearest): TMonitor;
        function MonitorFromRect(const Rect: TRect;
          MonitorDefault: TMonitorDefaultTo = mdNearest): TMonitor;
        function MonitorFromWindow(const Handle: THandle;
          MonitorDefault: TMonitorDefaultTo = mdNearest): TMonitor;
        procedure Realign;
        procedure ResetFonts;
        property ActiveControl: TWinControl read FActiveControl;
        property ActiveCustomForm: TCustomForm read FActiveCustomForm;
        property ActiveForm: TForm read FActiveForm;
        property CustomFormCount: Integer read GetCustomFormCount;
        property CustomForms[Index: Integer]: TCustomForm read GetCustomForms;
        property Cursor: TCursor read FCursor write SetCursor;
        property Cursors[Index: Integer]: HCURSOR read GetCursors write SetCursors;
        property DataModules[Index: Integer]: TDataModule read GetDataModule;
        property DataModuleCount: Integer read GetDataModuleCount;
        property MonitorCount: Integer read GetMonitorCount;
        property Monitors[Index: Integer]: TMonitor read GetMonitor;
        property DesktopRect: TRect read GetDesktopRect;
        property DesktopHeight: Integer read GetDesktopHeight;
        property DesktopLeft: Integer read GetDesktopLeft;
        property DesktopTop: Integer read GetDesktopTop;
        property DesktopWidth: Integer read GetDesktopWidth;
        property WorkAreaRect: TRect read GetWorkAreaRect;
        property WorkAreaHeight: Integer read GetWorkAreaHeight;
        property WorkAreaLeft: Integer read GetWorkAreaLeft;
        property WorkAreaTop: Integer read GetWorkAreaTop;
        property WorkAreaWidth: Integer read GetWorkAreaWidth;
        property HintFont: TFont read FHintFont write SetHintFont;
        property IconFont: TFont read FIconFont write SetIconFont;
        property MenuFont: TFont read FMenuFont write SetMenuFont;
        property Fonts: TStrings read GetFonts;
        property FormCount: Integer read GetFormCount;
        property Forms[Index: Integer]: TForm read GetForm;
        property Imes: TStrings read GetImes;
        property DefaultIme: string read GetDefaultIme;
        property DefaultKbLayout: HKL read FDefaultKbLayout;
        property Height: Integer read GetHeight;
        property PixelsPerInch: Integer read FPixelsPerInch;
        property Width: Integer read GetWidth;
        property OnActiveControlChange: TNotifyEvent
          read FOnActiveControlChange write FOnActiveControlChange;
        property OnActiveFormChange: TNotifyEvent
          read FOnActiveFormChange write FOnActiveFormChange;
      end;