刚学DELPHI,请问:
1、怎么用TIMER实现窗口的渐隐藏效果,不知为什么总是实现不了?请大侠指点一段代码。
2、做了简单的WINDOWS关机画面,请问在WINDOW98下,怎么样实现将我做的关机窗口替代原来的关机窗口?

解决方案 »

  1.   

    procedure TFormDaisy.ButtonFadeOutClick(Sender: TObject);
      VAR
        Bitmap :  TBitmap;
        i      :  INTEGER;
        j      :  INTEGER;
        Row    :  pRGBTripleArray;
        RowBase:  pRGBTripleArray;
        step   :  INTEGER;
    begin
      Bitmap := TBitmap.Create;
      TRY
        Bitmap.PixelFormat := pf24bit;
        Bitmap.Width  := ImageRGB.Width;
        Bitmap.Height := ImageRGB.Height;    FOR step := 32 DOWNTO 0 DO
        BEGIN
          FOR j := 0 TO Bitmap.Height-1 DO
          BEGIN
            RowBase := BitmapBase.Scanline[j];
            Row     := Bitmap.Scanline[j];        FOR i := 0 TO Bitmap.Width-1 DO
            BEGIN                                          // 32 = 2^5
              Row[i].rgbtRed   :=  (step * RowBase[i].rgbtRed  ) SHR 5;
              Row[i].rgbtGreen :=  (step * RowBase[i].rgbtGreen) SHR 5;
              Row[i].rgbtBlue  :=  (step * RowBase[i].rgbtBlue ) SHR 5
            END
          END;      ImageRGB.Picture.Graphic := Bitmap;      // Use API calls to avoid flicker.
          // See VCL Repaint alternative in FadeIn
          InvalidateRect(FormDaisy.Handle, NIL {whole window},
                         FALSE {don't erase background});
          RedrawWindow(FormDaisy.Handle, NIL, 0, RDW_UPDATENOW);
        END
      FINALLY
        Bitmap.Free;
      END;
    end;
    procedure TFormDaisy.ButtonFadeInClick(Sender: TObject);
      VAR
        Bitmap :  TBitmap;
        i      :  INTEGER;
        j      :  INTEGER;
        Row    :  pRGBTripleArray;
        RowBase:  pRGBTripleArray;
        step   :  INTEGER;
    begin
      Bitmap := TBitmap.Create;
      TRY
        Bitmap.PixelFormat := pf24bit;
        Bitmap.Width  := ImageRGB.Width;
        Bitmap.Height := ImageRGB.Height;    FOR step := 0 TO 32 DO
        BEGIN
          FOR j := 0 TO Bitmap.Height-1 DO
          BEGIN
            RowBase := BitmapBase.Scanline[j];
            Row     := Bitmap.Scanline[j];        FOR i := 0 TO Bitmap.Width-1 DO
            BEGIN                                          // 32 = 2^5
              Row[i].rgbtRed   :=  (step * RowBase[i].rgbtRed  ) SHR 5;
              Row[i].rgbtGreen :=  (step * RowBase[i].rgbtGreen) SHR 5;
              Row[i].rgbtBlue  :=  (step * RowBase[i].rgbtBlue ) SHR 5
            END
          END;      // This is just as effective as the API calls.
          // (See API call alternative in FadeOut.)
          ImageRGB.Picture.Graphic := Bitmap;
          ImageRGB.Repaint
        END
      FINALLY
        Bitmap.Free;
      END;
    end;
      

  2.   

    第二题:我以前在一个杂志上看过,大概只要找到原来的关机画面的文件,把自己的图片(bmp的)用同名替换即可(具体名称忘记了,注意后缀名不常见)
      

  3.   

    对于您的第一个问题,其实可以用Windows API函数来解决,只要你窗体的OnClose事件中加入这样一条代码即可!AnimateWindow(Self.Handle, 250, aw_center or AW_Hide);注:其中250为窗体关闭的毫秒数。第二个问题偶没看懂!是Delphi中的问题吗?
      

  4.   

    大多数有关窗体大小,消隐都和Winapi函数有关
      

  5.   

    多谢,第二题的意思是:我利用DELPHI做了一个WINDOWS关机,重起的窗体,我想把这个窗体代替原来WINDOWS的窗体,请问怎么改?