Results 1 to 10 of 10

Thread: form transparent...

  1. #1

    form transparent...

    hi, how can make a delphi form as an alpha mask sprite and hide the delphi form and all stuff?? i want to create a person or something moving on windows desktop with mouse and when you click some thing appear..any one has an idea how to remove de form background thanks in advance..

  2. #2

    Re: form transparent...

    Well, cross posting doesnt really help.

    However, doing it with D3D/OpenGL in the realm of Phoenix is not that easy, i suppose you have to take a screenshot and use that as a texture.

    For making a standard VCL form transparent check the following:

    http://delphi.about.com/cs/adptips19...ltip0899_5.htm
    Amnoxx

    Oh, and this code appears to be an approximate replacement for return(random() & 0x01);

    Phoenix Wiki
    http://www.phoenixlib.net/

    Phoenix Forum
    http://www.pascalgamedevelopment.com/viewforum.php?f=71

  3. #3

    Re: form transparent...

    This is not a specific Phoenix question. I have moved it to the Graphics section.

  4. #4

    Re: form transparent...

    This is very old code of mine, it basically keeps drawing straight horizontal lines (to create invisible region) until it meets pixel that is not colored as transparent. Transparent color is taken from coord 0,0 of bitmap.
    [pascal]function CreateBitmapRgn(c: TCanvas; Width,Height: Word): HRGN;
    var p: array[0..30000] of TPoint;
    vertex: array[0..10000] of integer;
    trc,i,j,pm: integer; drawing: boolean;
    begin
    pm:=-1; drawing:=false; trc:=c.Pixels[0,0];
    for j:=0 to height-1 do
    for i:=0 to width-1 do
    if (c.Pixels[i,j]=trc) or (i>=width-1) then begin
    if drawing then begin
    drawing:=false;
    p[pm*3+1]:=point(i,j); p[pm*3+2]:=point(i,j+1);
    end;
    end else if not drawing then begin
    drawing:=true;
    inc(pm); vertex[pm]:=3; p[pm*3]:=point(i,j);
    end;
    result:=CreatePolyPolygonRgn(p,vertex,pm+1,WINDING );
    end;[/pascal]

    After that use SetWindowRgn() function with region given from this and you can make even human shaped form but it might be too slow like this if you want to animate it.

    To original question; "No" not DelphiX, Phoenix, SDL or any other graphics library can make form transparent. Window is handled by operating system that in this case might be Windows, hence use Windows API.

  5. #5

    Re: form transparent...

    well thanks, i think it's very easier to do it with flash.

  6. #6

    Re: form transparent...

    Quote Originally Posted by pixin
    well thanks, i think it's very easier to do it with flash.
    Don't know about flash, but i guess some ways are possible as seen there:
    http://www.wave-access.com/Public_en...Projector.aspx

  7. #7

    Re: form transparent...

    Actually, it's very easy...

    Start a new app and place the following in the formCreate:

    [pascal]MakeInvisible(form1);[/pascal]

    Add the following procedure:

    [pascal]procedure MakeInvisible(const Form: TCustomForm);
    var
    hRgn: Cardinal;
    i: Integer;
    begin
    with Form do
    begin
    BorderStyle := bsNone;
    hRgn := CreateRectRgn(0, 0, 0, 0);
    for i := 0 to ControlCount - 1 do
    with Controls[i].BoundsRect do
    CombineRgn(hRgn, hRgn, CreateRectRgn(Left, Top, Right, Bottom), RGN_OR);
    SetWindowRgn(handle, hRgn, True);

    end;
    end;[/pascal]

    Then in form onPaint:

    [pascal]PaintDesktop(Canvas.Handle);[/pascal]

    That's it, your form is invisible


    Wake up from the dream and live your life to the full

  8. #8

    Re: form transparent...

    That code only leaves rectangular areas if i see right?

  9. #9

    Re: form transparent...

    User137: I'm not sure what you mean, it makes the whole form transparent. It doesn't leave any rectangular areas.
    Wake up from the dream and live your life to the full

  10. #10

    Re: form transparent...

    Quote Originally Posted by Wizard
    User137: I'm not sure what you mean, it makes the whole form transparent. It doesn't leave any rectangular areas.
    Yes it does. You use CreateRectRgn for each visible control but it doesn't look for non-rectangular images.

    Code:
    for i := 0 to ControlCount - 1 do 
     with Controls[i].BoundsRect do 
      CombineRgn(hRgn, hRgn, CreateRectRgn(Left, Top, Right, Bottom), RGN_OR);
    I will see if i could optimize my function maybe... if theres time.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •