|
Trouver une ressource
Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !
MÉMORISE SIMPLEMENT LA POSITION ET LA TAILLE DE VOS FENÊTRES
Information sur la source
Description
Utilisation simple : - mettre ParametreFenetre.pas dans votre projet Dans le Show de la form procedure TForm3.formCreate(Sender: TObject); begin LirePositionFenetre(Self, 'Setting'); end; Dans le Close de la form procedure TForm3.FormClose(Sender: TObject; var Action: TCloseAction); begin EcrirePositionFenetre(Self, 'Setting'); end;
Source
- unit ParametreFenetre;
- (*************************************************
- Author: BuzzLeclaire, France.
-
- E-mail:
- rainconnu@free.fr
-
- Testé avec 7.
-
- Cet unit peut librement être utilisé ou distribué.
-
- 25.08.2008
-
- ***************************************************)
-
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls, ExtCtrls, IniFiles;
-
- Procedure LirePositionFenetre(Fenetre: TForm; NomFichier: String);
- Procedure EcrirePositionFenetre(Fenetre: TForm; NomFichier: String);
-
- implementation
-
- {$R *.DFM}
- Uses UPath;
-
- // sur une idée de Cirec Patch par CSIDL
- Const CSIDL_TEMPLATES = $15; // pour ne pas déclarer uses ShlObj
-
- Procedure LirePositionFenetre(Fenetre: TForm; NomFichier: String);
- Var
- Fichier_Ini: TIniFile;
-
- Begin
- // Path[CISDL_TEMPLATES donne le chemin MesDoc de l'utilisateur courant
- // On créer ou on lit le fichier
- Fichier_Ini := TIniFile.Create(Path[CSIDL_TEMPLATES] + NomFichier + '.ini');
- Try
- if Fichier_Ini.SectionExists(Fenetre.Name) then
- begin
- // On récupère les données si il y en à
- Fenetre.Left := Fichier_Ini.ReadInteger(Fenetre.Name, 'Left', 0);
- Fenetre.Top := Fichier_Ini.ReadInteger(Fenetre.Name, 'Top', 0);
-
- // si la fenêtre n'ai pas taillable Height, Width reste inchangé (sauf si on touche directement le ini
- Fenetre.Height := Fichier_Ini.ReadInteger(Fenetre.Name, 'Height', 0);
- Fenetre.Width := Fichier_Ini.ReadInteger(Fenetre.Name, 'Width', 0);
- end;
- Finally
- Fichier_Ini.Free;
- end;
- end;
-
- Procedure EcrirePositionFenetre(Fenetre: TForm; NomFichier: String);
- Var
- Fichier_Ini: TIniFile;
- WindowPlacement : TWindowPlacement;
- Begin
- WindowPlacement.length:=SizeOf(WindowPlacement);
- WindowPlacement.flags := 0;
- WindowPlacement.showCmd := 1;
- // récupération de l'emplacement ou se situe la fiche lorsque WindowState est en wsNormal
- GetWindowPlacement(Fenetre.Handle,@WindowPlacement);
- With Fichier_ini do
- Begin
- // Path[CISDL_TEMPLATES donne le chemin MesDoc de l'utilisateur courant
- // On créer ou on lit le fichier
- Fichier_Ini := TIniFile.Create(Path[CSIDL_TEMPLATES] + NomFichier + '.ini');
- Try
- // On alimente la section
- WriteInteger(Fenetre.Name, 'Left', WindowPlacement.rcNormalPosition.Left);
- WriteInteger(Fenetre.Name, 'Top', WindowPlacement.rcNormalPosition.Top);
- WriteInteger(Fenetre.Name, 'Height', WindowPlacement.rcNormalPosition.Bottom - WindowPlacement.rcNormalPosition.Top);
- WriteInteger(Fenetre.Name, 'Width', WindowPlacement.rcNormalPosition.Right - WindowPlacement.rcNormalPosition.Left);
- Finally
- Fichier_Ini.Free;
- end;
- end;
-
- end;
-
- end.
unit ParametreFenetre;
(*************************************************
Author: BuzzLeclaire, France.
E-mail:
rainconnu@free.fr
Testé avec 7.
Cet unit peut librement être utilisé ou distribué.
25.08.2008
***************************************************)
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, IniFiles;
Procedure LirePositionFenetre(Fenetre: TForm; NomFichier: String);
Procedure EcrirePositionFenetre(Fenetre: TForm; NomFichier: String);
implementation
{$R *.DFM}
Uses UPath;
// sur une idée de Cirec Patch par CSIDL
Const CSIDL_TEMPLATES = $15; // pour ne pas déclarer uses ShlObj
Procedure LirePositionFenetre(Fenetre: TForm; NomFichier: String);
Var
Fichier_Ini: TIniFile;
Begin
// Path[CISDL_TEMPLATES donne le chemin MesDoc de l'utilisateur courant
// On créer ou on lit le fichier
Fichier_Ini := TIniFile.Create(Path[CSIDL_TEMPLATES] + NomFichier + '.ini');
Try
if Fichier_Ini.SectionExists(Fenetre.Name) then
begin
// On récupère les données si il y en à
Fenetre.Left := Fichier_Ini.ReadInteger(Fenetre.Name, 'Left', 0);
Fenetre.Top := Fichier_Ini.ReadInteger(Fenetre.Name, 'Top', 0);
// si la fenêtre n'ai pas taillable Height, Width reste inchangé (sauf si on touche directement le ini
Fenetre.Height := Fichier_Ini.ReadInteger(Fenetre.Name, 'Height', 0);
Fenetre.Width := Fichier_Ini.ReadInteger(Fenetre.Name, 'Width', 0);
end;
Finally
Fichier_Ini.Free;
end;
end;
Procedure EcrirePositionFenetre(Fenetre: TForm; NomFichier: String);
Var
Fichier_Ini: TIniFile;
WindowPlacement : TWindowPlacement;
Begin
WindowPlacement.length:=SizeOf(WindowPlacement);
WindowPlacement.flags := 0;
WindowPlacement.showCmd := 1;
// récupération de l'emplacement ou se situe la fiche lorsque WindowState est en wsNormal
GetWindowPlacement(Fenetre.Handle,@WindowPlacement);
With Fichier_ini do
Begin
// Path[CISDL_TEMPLATES donne le chemin MesDoc de l'utilisateur courant
// On créer ou on lit le fichier
Fichier_Ini := TIniFile.Create(Path[CSIDL_TEMPLATES] + NomFichier + '.ini');
Try
// On alimente la section
WriteInteger(Fenetre.Name, 'Left', WindowPlacement.rcNormalPosition.Left);
WriteInteger(Fenetre.Name, 'Top', WindowPlacement.rcNormalPosition.Top);
WriteInteger(Fenetre.Name, 'Height', WindowPlacement.rcNormalPosition.Bottom - WindowPlacement.rcNormalPosition.Top);
WriteInteger(Fenetre.Name, 'Width', WindowPlacement.rcNormalPosition.Right - WindowPlacement.rcNormalPosition.Left);
Finally
Fichier_Ini.Free;
end;
end;
end;
end.
Conclusion
Historique
- 25 août 2008 16:22:05 :
- J'ai changer l'appel de Form2 à Self
J'ai ajouter des Try, finally
J'ai ajouté des with do begin
- 25 août 2008 16:23:28 :
- - J'ai changé les appel
LirePositionFenetre(Form3, 'Setting');
en
LirePositionFenetre(Self, 'Setting');
- J'ai ajouté With Do begin
- J'ai ajouté des clause Try, Finally
- 25 août 2008 16:51:49 :
- J'ai modifier tout le projet pour avoir des .pas cohérente et plus parlante.
- 25 août 2008 17:12:06 :
- Correction Try trop Haut
- 25 août 2008 18:11:57 :
- Alors pour mieux coller :
- Il apparaissaient un probleme si on maximizais les fenetres maximizable.
Alors j'ai pris le GetWindowPlacement.
- 26 août 2008 16:52:07 :
- J'ai donc ajouter l'acces par le systeme de Cirec
Fichier_Ini := TIniFile.Create(Path[CSIDL_TEMPLATES] + NomFichier + '.ini');
Ce qui sur mon poste envoir mon fichier setting à
C:\Documents and Settings\RURUInc\Modèles
Sources de la même categorie
Sources en rapport avec celle ci
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
Pour que la form ne se cache pas sous barre de tache [ par cocowz ]
Bonsoir,J'ai un truc c'est que quand je lance le projet... puis dans la form je peux choisir la position de ma form (en bas a gauche ou droite ou en h
Roulette sur Timage [ par rivaud_renee ]
J'ai posé un Timage sur un panel. Je déplace l"image sans problèmes ( voir code ci-après ); mais je souhaiterai également y faire un zoom ( plus et mo
Position Left maximum ? [ par jnmchl ]
Bonsoir,Je place dynamiquement des boutons dans un scrollbox très très large ...Le problème c'est que à partir du moment ou le X càd le button.left dé
probleme sur serpent [ par seb33000 ]
salut, j ai un souci sur la progr de mon serpent, mon prof n a pas su m aider. j ai un message de violation a l execution. le serpent est un peu basic
Position d'une fenêtre [ par catmldrd ]
Bonjour, J'aimerais savoir la position de laform car je doit afficher une autre form dans la form principale;Si on déplace la forme principale alors
MDI - Probléme de positionnement Left et Right [ par Spawnrider ]
Bonjour, Je développe une application utilisant des Forms MDI en Delphi 6. Je possede une MDI Mére (Form Principale) et je souhaite cr
Delphifr & Firefox.... [ par ELCouz ]
Bonjour,Je ne sais pas si je suis le seul mais quand je copy/paste du code dune source jobtien plein de # ######## ...example (taken from http://www.d
probleme avec dblookupcombobox? [ par abdousoft ]
Salut j'ai une form contient un dblookupcombobox et qui contient une liste des codes des employers et une autre form avec un qrband de type </st
Delphi vers C++ [ par Roulio52 ]
Salut à tous !Je suis un petit débutant en C++,et je commence à créer un petit paint sous borland.J'ai un code DELPHI qui pourrait m'être super utile
Form déroulante. [ par hackeur13 ]
Bonsoir,alors voila mon probleme,je voudrais savoir comment faire pour avoir une Fiche transparent ou deroulant mais je ne sais pas comment faire??Car
|
Téléchargements
Logiciels à télécharger sur le même thème :
Comparez les prix Nouvelle version

LG KP501
Entre 9€ et 159€
|