IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Delphi Discussion :

Griser une fenêtre en arrière plan


Sujet :

Delphi

  1. #21
    Membre émérite
    Avatar de Thierry Laborde
    Homme Profil pro
    N/A
    Inscrit en
    Avril 2002
    Messages
    1 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : N/A

    Informations forums :
    Inscription : Avril 2002
    Messages : 1 391
    Points : 2 529
    Points
    2 529
    Par défaut
    Du coup voila ce que j'ai changé (Il faut aussi tenir compte du BorderWidth) :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
        Delta := round((Application.mainform.Width-Application.MainForm.ClientWidth)/2)+ Screen.ActiveForm.BorderWidth;
        if Screen.ActiveForm.BorderStyle in [bsSingle,bsToolWindow] then
          Dec(Delta);
    Ca semble convenir, si tu peux faire des tests aussi. Je continue de voir si je trouve d'autres problèmes.

  2. #22
    Membre expert
    Avatar de aityahia
    Homme Profil pro
    CIEPTAL CARS SPA
    Inscrit en
    Mars 2006
    Messages
    1 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : Algérie

    Informations professionnelles :
    Activité : CIEPTAL CARS SPA
    Secteur : Transports

    Informations forums :
    Inscription : Mars 2006
    Messages : 1 938
    Points : 3 329
    Points
    3 329
    Par défaut
    on rajoute sa juste apres la definition du delta

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    if (Screen.ActiveForm.BorderStyle in [BsSingle,BsToolWindow]) then Delta := Delta-1;
    sa fonction j'ai fait le test avec tous les borderstyle

  3. #23
    Membre émérite
    Avatar de Thierry Laborde
    Homme Profil pro
    N/A
    Inscrit en
    Avril 2002
    Messages
    1 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : N/A

    Informations forums :
    Inscription : Avril 2002
    Messages : 1 391
    Points : 2 529
    Points
    2 529
    Par défaut
    je vois qu'on a eu la même idée au même moment...

  4. #24
    Membre émérite
    Avatar de Thierry Laborde
    Homme Profil pro
    N/A
    Inscrit en
    Avril 2002
    Messages
    1 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : N/A

    Informations forums :
    Inscription : Avril 2002
    Messages : 1 391
    Points : 2 529
    Points
    2 529
    Par défaut
    Du coup je récapitule l'unité :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    {*------------------------------------------------------------------------------
     Unité permettant de griser une form lorsqu'elle appelle un showmodal pour
     en afficher une autre
     
     @Author    tiki06 (Avec l'aide de Sub0)
     @Version   02-août-2006 Version initiale
    -------------------------------------------------------------------------------}
    Unit UGriserForm;
     
    Interface
     
    Uses Windows, Forms, Types, Graphics;
     
     
    const
      PIXELCOUNTMAX = 32768;
      WS_EX_LAYERED = $80000;
     
     
    type
      pRGBArray  = ^TRGBArray;
      TRGBArray   = ARRAY[0..PIXELCOUNTMAX-1] OF TRGBTriple;
     
     
     
    Procedure FusionerImage(FusionForm: TForm; BmpGrise: TBitmap);
    Function  CustomShowModal(Fenetre: TForm):integer;
     
     
    implementation
     
     
    {*------------------------------------------------------------------------------
      Fonction pour fusioner la form et l'image grisé
     
      @param    FusionForm       Form a fusioner
      @param    BmpGrise         Bitmap de l'image grisé
    -------------------------------------------------------------------------------}
    Procedure FusionerImage(FusionForm: TForm; BmpGrise: TBitmap);
    Var
      Size                : PSIZE;
      TopLeft, BmpTopLeft : TPoint;
      Blend               : TBlendFunction;
    Begin
      With FusionForm Do
      Begin
        SetWindowLong(Handle, GWL_EXSTYLE,
          GetWindowLong(Handle, GWL_EXSTYLE) Or WS_EX_LAYERED);
        New(Size);
        Size.cx := Width;
        Size.cy := Height;
        TopLeft := BoundsRect.TopLeft;
        BmpTopLeft := Point(0, 0);
        With Blend Do Begin
          BlendOp := 0;
          BlendFlags := 0;
          SourceConstantAlpha := 255;
          AlphaFormat := 0;
        End;
        BmpGrise.PixelFormat := pf32bit;
        UpdateLayeredWindow(Handle, GetDC(0), @TopLeft, Size,
          BmpGrise.Canvas.handle, @BmpTopLeft, 0, @Blend, 2);
      End;
    End;
     
    {*----------------------------------------------------------------------------
      Fonction pour afficher une fenêtre en showmodal et griser celle qui est
      active pendant l'appel du showmodal
     
      @param    Fenetre        Form a afficher en Showmodal
    -----------------------------------------------------------------------------}
    Function CustomShowModal(Fenetre: TForm):integer;
    var
      WindowHandle          : THandle;
      deviceContext         : HDC;
      BitmapForm            : Tbitmap;
      icolor                : integer;
      r,g,b                 : byte;
      iheight,iwidth        : integer;
      RowOriginal           : pRGBArray;
      FormGrise             : TForm;
      PosLeft,PosTop,Delta  : Integer;
    begin
      WindowHandle:= Screen.ActiveForm.Handle;
      deviceContext:= GetWindowDC(WindowHandle);
      try
        BitmapForm             := Tbitmap.Create;
        BitmapForm.PixelFormat := pf24bit;
        BitmapForm.Width       := Screen.ActiveForm.Width;
        BitmapForm.Height      := Screen.ActiveForm.Height;
     
        BitBlt(BitmapForm.Canvas.Handle, 0, 0, BitmapForm.Width, BitmapForm.Height,
          deviceContext, 0, 0, SRCCOPY);
     
      finally
        ReleaseDC(WindowHandle, deviceContext);
      end;
     
      for iHeight := 0 to BitmapForm.height-1 do
      begin
        RowOriginal  := pRGBArray(BitmapForm.Scanline[iHeight]);
        for iWidth := 0 to BitmapForm.width-1 do
        begin
          r:=RowOriginal[iWidth].rgbtRed;
          g:=RowOriginal[iWidth].rgbtGreen;
          b:=RowOriginal[iWidth].rgbtBlue;
          icolor:=(r+g+b) div 3;
          RowOriginal[iWidth].rgbtRed   := icolor;
          RowOriginal[iWidth].rgbtGreen := icolor;
          RowOriginal[iWidth].rgbtBlue  := icolor;
        end;
      end;
     
      FormGrise                := Tform.Create(Screen.ActiveForm);
      FormGrise.Name           := 'GrayscaleForm';
      FormGrise.Caption        := Screen.ActiveForm.Caption;
     
      if Screen.ActiveForm.FormStyle = FsMdiChild then
      begin
        PosTop                 := Screen.ActiveForm.ClientOrigin.Y-(Screen.ActiveForm.Height-Screen.ActiveForm.ClientHeight);
        PosLeft                := Screen.ActiveForm.ClientOrigin.X-(Screen.ActiveForm.Width-Screen.ActiveForm.ClientWidth);
        Delta                  := round((Application.mainform.Width-Application.MainForm.ClientWidth)/2)+ Screen.ActiveForm.BorderWidth;
        if Screen.ActiveForm.BorderStyle in [bsSingle,bsToolWindow] then
          Dec(Delta);
        FormGrise.Top          := PosTop+Delta;
        FormGrise.left         := PosLeft+Delta;
      end
      else
      Begin
        FormGrise.Top          := Screen.ActiveForm.Top;
        FormGrise.Left         := Screen.ActiveForm.Left;
      end;
      FormGrise.Width          := Screen.ActiveForm.Width;
      FormGrise.Height         := Screen.ActiveForm.Height;
      FormGrise.DoubleBuffered := True;
      FormGrise.BorderIcons    := Screen.ActiveForm.BorderIcons;
      FormGrise.BorderStyle    := Screen.ActiveForm.BorderStyle;
      FormGrise.Show;
     
      FusionerImage(FormGrise,BitmapForm);
      FormGrise.BringToFront;
     
      BitmapForm.Free;
     
      Result:=Fenetre.ShowModal;
      if FormGrise<>nil then FormGrise.Release;
    end;
     
     
    End.
    Ca me semble bien là, a moins que tu ais d'autres remarques.

  5. #25
    Membre expert
    Avatar de aityahia
    Homme Profil pro
    CIEPTAL CARS SPA
    Inscrit en
    Mars 2006
    Messages
    1 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : Algérie

    Informations professionnelles :
    Activité : CIEPTAL CARS SPA
    Secteur : Transports

    Informations forums :
    Inscription : Mars 2006
    Messages : 1 938
    Points : 3 329
    Points
    3 329
    Par défaut
    bien vu juste qu'il y a le probleme du caption qui persiste j'ai essayer de définire la caption avant le name mais c'est la meme chose.

  6. #26
    Membre émérite
    Avatar de Thierry Laborde
    Homme Profil pro
    N/A
    Inscrit en
    Avril 2002
    Messages
    1 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : N/A

    Informations forums :
    Inscription : Avril 2002
    Messages : 1 391
    Points : 2 529
    Points
    2 529
    Par défaut
    Pourtant j'ai rajouté ça :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    FormGrise.Caption        := Screen.ActiveForm.Caption;
    mais moi je ne vois plus de problème avec le caption. quels sont les problèmes que tu as encore. Le clignotement du caption, c'est ça ?

  7. #27
    Membre expert
    Avatar de aityahia
    Homme Profil pro
    CIEPTAL CARS SPA
    Inscrit en
    Mars 2006
    Messages
    1 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : Algérie

    Informations professionnelles :
    Activité : CIEPTAL CARS SPA
    Secteur : Transports

    Informations forums :
    Inscription : Mars 2006
    Messages : 1 938
    Points : 3 329
    Points
    3 329
    Par défaut
    oui exactement alors j'ai changer l'ordre je defini le cpation pui le non et toujour j'ai le meme probleme

  8. #28
    Membre expert
    Avatar de aityahia
    Homme Profil pro
    CIEPTAL CARS SPA
    Inscrit en
    Mars 2006
    Messages
    1 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : Algérie

    Informations professionnelles :
    Activité : CIEPTAL CARS SPA
    Secteur : Transports

    Informations forums :
    Inscription : Mars 2006
    Messages : 1 938
    Points : 3 329
    Points
    3 329
    Par défaut
    j'ai fait le test avec une form FsNormal sa marche tres bien c'est le faite que c'est une MdiChild

  9. #29
    Membre émérite
    Avatar de Thierry Laborde
    Homme Profil pro
    N/A
    Inscrit en
    Avril 2002
    Messages
    1 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : N/A

    Informations forums :
    Inscription : Avril 2002
    Messages : 1 391
    Points : 2 529
    Points
    2 529
    Par défaut
    Oui je viens de remarquer la même chose aussi. Par contre ça ne le fait en MDI que lorsque ta fiche MDI est agrandie complètement (En maximized), non ?

  10. #30
    Membre émérite
    Avatar de Thierry Laborde
    Homme Profil pro
    N/A
    Inscrit en
    Avril 2002
    Messages
    1 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : N/A

    Informations forums :
    Inscription : Avril 2002
    Messages : 1 391
    Points : 2 529
    Points
    2 529
    Par défaut
    Par contre ça a l'air mieux si on fait :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    FormGrise.Caption        := '';
    car en fait on à pas besoin de récupérer le caption, vu que l'on dessine l'image sur le canvas ensuite.

  11. #31
    Membre émérite
    Avatar de Thierry Laborde
    Homme Profil pro
    N/A
    Inscrit en
    Avril 2002
    Messages
    1 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : N/A

    Informations forums :
    Inscription : Avril 2002
    Messages : 1 391
    Points : 2 529
    Points
    2 529
    Par défaut
    c'est bon j'ai trouvé. des fois c'est les erreurs les plus bêtes que l'on ne voit pas. Il fallait tout simplement faire la fusion avant de faire le show de la form :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
      FusionerImage(FormGrise,BitmapForm);
      FormGrise.Show;
      FormGrise.BringToFront;

  12. #32
    Membre émérite
    Avatar de Thierry Laborde
    Homme Profil pro
    N/A
    Inscrit en
    Avril 2002
    Messages
    1 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : N/A

    Informations forums :
    Inscription : Avril 2002
    Messages : 1 391
    Points : 2 529
    Points
    2 529
    Par défaut
    Tu vois d'autres remarques ou ça te semble bon maintenant ?

  13. #33
    Membre expert
    Avatar de aityahia
    Homme Profil pro
    CIEPTAL CARS SPA
    Inscrit en
    Mars 2006
    Messages
    1 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : Algérie

    Informations professionnelles :
    Activité : CIEPTAL CARS SPA
    Secteur : Transports

    Informations forums :
    Inscription : Mars 2006
    Messages : 1 938
    Points : 3 329
    Points
    3 329
    Par défaut
    oups j'ai une exception

    a ce niveau quand la fennetre et MdiChild;

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    BmpGrise.PixelFormat := pf32bit;

  14. #34
    Membre émérite
    Avatar de Thierry Laborde
    Homme Profil pro
    N/A
    Inscrit en
    Avril 2002
    Messages
    1 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : N/A

    Informations forums :
    Inscription : Avril 2002
    Messages : 1 391
    Points : 2 529
    Points
    2 529
    Par défaut
    Ca te génére quoi comme excpetion. Moi j'ai fait une appli avec des fenêtre MDIChild qui appelle des fenêtres normales avec la fonction et ça fonctionne bien. TU as quoi exactement comme erreur ?

  15. #35
    Membre expert
    Avatar de aityahia
    Homme Profil pro
    CIEPTAL CARS SPA
    Inscrit en
    Mars 2006
    Messages
    1 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : Algérie

    Informations professionnelles :
    Activité : CIEPTAL CARS SPA
    Secteur : Transports

    Informations forums :
    Inscription : Mars 2006
    Messages : 1 938
    Points : 3 329
    Points
    3 329
    Par défaut
    Violation d'accée a l'adresse 00432194 dans le module project1....

  16. #36
    Membre émérite
    Avatar de Thierry Laborde
    Homme Profil pro
    N/A
    Inscrit en
    Avril 2002
    Messages
    1 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : N/A

    Informations forums :
    Inscription : Avril 2002
    Messages : 1 391
    Points : 2 529
    Points
    2 529
    Par défaut
    Et si tu mets la ligne en commentaire ça fonctionne bien ? et ca ne le fait que lorsque tu es en MDICHILD ? bizarre, car là on est dans la fusion du dessin sur la form, donc ça n'a aucunes importance que l'on soit en MDI ou pas. tu peux m'envoyer ton code que je fasse un test ? (Je t'envoi mon mail en MP)

  17. #37
    Membre expert
    Avatar de aityahia
    Homme Profil pro
    CIEPTAL CARS SPA
    Inscrit en
    Mars 2006
    Messages
    1 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : Algérie

    Informations professionnelles :
    Activité : CIEPTAL CARS SPA
    Secteur : Transports

    Informations forums :
    Inscription : Mars 2006
    Messages : 1 938
    Points : 3 329
    Points
    3 329
    Par défaut
    c'est bon sa marche y avais une erreur dans mon code c'est tres bien

    on peut déveloper l'unité en ajoutant un parametre [All, OwnerWindow] pour qu'on grise toutes les fenetres ouverte du projets, ou uniquement la fenetre appelante .

  18. #38
    Membre émérite
    Avatar de Thierry Laborde
    Homme Profil pro
    N/A
    Inscrit en
    Avril 2002
    Messages
    1 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : N/A

    Informations forums :
    Inscription : Avril 2002
    Messages : 1 391
    Points : 2 529
    Points
    2 529
    Par défaut
    C'est une bonne idée.

    En fait avant j'avais remarqué qu'il y avait un évenement ONModalBegin Et OnModalEnd dans Application. et donc je voulais surcharger ces évenements là pour que ça se fasse automatiquement à chaque appel et pas avoir besoin d'appeller explicitement la fonction. Sauf qu'apparement d'après ce que l'on voit dans le code de la vcl Delphi, l'évenement se produit une seul fois même si tu appelle plusieurs showmodal à la suite. Je ne sais pas pourquoi ils ont fait cela, c'est dommage.

    Par contre pour ton idée il va falloir gérer ou sont chacunes des fenêtres je veut dire ne position les unes sur les autres (Je ne sais pas si je suis clair). car en fait là on s'embête pas on dessinent la form grisé en avant plan avec BringToFront. Mais il ne faudra pas le faire sur toutes les fenêtres. Mais j'ai peut être une autre idée, je vais y travailler.

  19. #39
    Membre expert
    Avatar de aityahia
    Homme Profil pro
    CIEPTAL CARS SPA
    Inscrit en
    Mars 2006
    Messages
    1 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : Algérie

    Informations professionnelles :
    Activité : CIEPTAL CARS SPA
    Secteur : Transports

    Informations forums :
    Inscription : Mars 2006
    Messages : 1 938
    Points : 3 329
    Points
    3 329
    Par défaut
    pour les fentre Mdichild et la fentere Mere c' est bon avec se code sa marche a merveille reste juste a traite le cas des fenetre normal et stayOntop

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    {*------------------------------------------------------------------------------
     Unité permettant de griser une form lorsqu'elle appelle un showmodal pour
     en afficher une autre
     
     @Author    tiki06 (Avec l'aide de Sub0)
     @Version   02-août-2006 Version initiale
    -------------------------------------------------------------------------------}
    Unit UGriserForm;
     
    Interface
     
    Uses Windows, Forms, Types, Graphics;
     
     
    const
      PIXELCOUNTMAX = 32768;
      WS_EX_LAYERED = $80000;
     
     
    type
      pRGBArray  = ^TRGBArray;
      TRGBArray   = ARRAY[0..PIXELCOUNTMAX-1] OF TRGBTriple;
     
     
     
    Procedure FusionerImage(FusionForm: TForm; BmpGrise: TBitmap);
    Function  CustomShowModal(Fenetre: TForm):integer;
     
     
    implementation
     
     
    {*------------------------------------------------------------------------------
      Fonction pour fusioner la form et l'image grisé
     
      @param    FusionForm       Form a fusioner
      @param    BmpGrise         Bitmap de l'image grisé
    -------------------------------------------------------------------------------}
    Procedure FusionerImage(FusionForm: TForm; BmpGrise: TBitmap);
    Var
      Size                : PSIZE;
      TopLeft, BmpTopLeft : TPoint;
      Blend               : TBlendFunction;
    Begin
      With FusionForm Do
      Begin
        SetWindowLong(Handle, GWL_EXSTYLE,
          GetWindowLong(Handle, GWL_EXSTYLE) Or WS_EX_LAYERED);
        New(Size);
        Size.cx := Width;
        Size.cy := Height;
        TopLeft := BoundsRect.TopLeft;
        BmpTopLeft := Point(0, 0);
        With Blend Do Begin
          BlendOp := 0;
          BlendFlags := 0;
          SourceConstantAlpha := 255;
          AlphaFormat := 0;
        End;
        BmpGrise.PixelFormat := pf32bit;
        UpdateLayeredWindow(Handle, GetDC(0), @TopLeft, Size,
          BmpGrise.Canvas.handle, @BmpTopLeft, 0, @Blend, 2);
      End;
    End;
     
    {*----------------------------------------------------------------------------
      Fonction pour afficher une fenêtre en showmodal et griser celle qui est
      active pendant l'appel du showmodal
     
      @param    Fenetre        Form a afficher en Showmodal
    -----------------------------------------------------------------------------}
     
    Function CustomShowModal(Fenetre: TForm):integer;
    var
      WindowHandle          : THandle;
      deviceContext         : HDC;
      BitmapForm            : Tbitmap;
      icolor                : integer;
      r,g,b                 : byte;
      iheight,iwidth        : integer;
      RowOriginal           : pRGBArray;
      FormGrise             : TForm;
      PosLeft,PosTop,Delta  : Integer;
      i :Integer;
    begin
    //----------------------------------------------
     
      WindowHandle:= Application.MainForm.Handle;
      deviceContext:= GetWindowDC(WindowHandle);
      try
        BitmapForm             := Tbitmap.Create;
        BitmapForm.PixelFormat := pf24bit;
        BitmapForm.Width       := Application.MainForm.Width;
        BitmapForm.Height      := Application.MainForm.Height;
     
        BitBlt(BitmapForm.Canvas.Handle, 0, 0, BitmapForm.Width, BitmapForm.Height,
          deviceContext, 0, 0, SRCCOPY);
     
          screen.FormCount
     
      finally
        ReleaseDC(WindowHandle, deviceContext);
      end;
     
      for iHeight := 0 to BitmapForm.height-1 do
      begin
        RowOriginal  := pRGBArray(BitmapForm.Scanline[iHeight]);
        for iWidth := 0 to BitmapForm.width-1 do
        begin
          r:=RowOriginal[iWidth].rgbtRed;
          g:=RowOriginal[iWidth].rgbtGreen;
          b:=RowOriginal[iWidth].rgbtBlue;
          icolor:=(r+g+b) div 3;
          RowOriginal[iWidth].rgbtRed   := icolor;
          RowOriginal[iWidth].rgbtGreen := icolor;
          RowOriginal[iWidth].rgbtBlue  := icolor;
        end;
      end;
     
      FormGrise                := Tform.Create(Application.MainForm);
      FormGrise.Name           := 'GrayscaleFormMAin';
      FormGrise.Caption        := Application.MainForm.Caption;
     
      if Application.MainForm.FormStyle = FsMdiChild then
      begin
        PosTop                 := Application.MainForm.ClientOrigin.Y-(Application.MainForm.Height-Application.MainForm.ClientHeight);
        PosLeft                := Application.MainForm.ClientOrigin.X-(Application.MainForm.Width-Application.MainForm.ClientWidth);
        Delta                  := round((Application.mainform.Width-Application.MainForm.ClientWidth)/2)+ Application.MainForm.BorderWidth;
        if Application.MainForm.BorderStyle in [bsSingle,bsToolWindow] then
          Dec(Delta);
        FormGrise.Top          := PosTop+Delta;
        FormGrise.left         := PosLeft+Delta;
      end
      else
      Begin
        FormGrise.Top          := Application.MainForm.Top;
        FormGrise.Left         := Application.MainForm.Left;
      end;
      FormGrise.Width          := Application.MainForm.Width;
      FormGrise.Height         := Application.MainForm.Height;
      FormGrise.DoubleBuffered := True;
      FormGrise.BorderIcons    := Application.MainForm.BorderIcons;
      FormGrise.BorderStyle    := Application.MainForm.BorderStyle;
     
      FusionerImage(FormGrise,BitmapForm);
      FormGrise.Show;
      FormGrise.BringToFront;
     
      BitmapForm.Free;
      Result:=Fenetre.ShowModal;
      if FormGrise<>nil then FormGrise.Release;
     end;
     
    End.

    j'ai juste changer 'activeform par Application.MainForm

  20. #40
    Membre émérite Avatar de edam
    Homme Profil pro
    Développeur Delphi/c++/Omnis
    Inscrit en
    Décembre 2003
    Messages
    1 894
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Développeur Delphi/c++/Omnis
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2003
    Messages : 1 894
    Points : 2 771
    Points
    2 771
    Par défaut
    Citation Envoyé par kurkaine
    ne pas surcharger mon application avec des fenêtres superposé.
    , la vérité j'ai pas compris ce que tu dire ????? sa me casse la tete
    PAS DE DESTIN, C'EST CE QUE NOUS FAISONS

Discussions similaires

  1. Capturer l'image d'une fenêtre en arrière plan
    Par Etanne dans le forum Général Dotnet
    Réponses: 3
    Dernier message: 09/06/2013, 01h29
  2. Bouger la souris sur une fenêtre en arrière plan
    Par youtpout978 dans le forum C#
    Réponses: 4
    Dernier message: 26/06/2011, 13h13
  3. comment lancer une fenètre en arrièr plan
    Par moon93 dans le forum wxPython
    Réponses: 2
    Dernier message: 16/07/2007, 09h25
  4. Griser une fenêtre en arrière plan
    Par kurkaine dans le forum C++Builder
    Réponses: 8
    Dernier message: 04/08/2006, 14h28

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo