Accueil > > > MÉMORISE SIMPLEMENT LA POSITION ET LA TAILLE DE VOS FENÊTRES
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
GetWindowPlacement
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
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
Evènement onDrawCell d'un StringGrid [ par madcap ]
Bonjour tous le monde, J'ai créé un panel qui contient différents éléments, StringGrid, boutons, label, etc... Ce panel je le crée à l'exécution, il
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
|
Derniers Blogs
[DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE[DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE par orion
Comme de nombreux geek, je suis un grand amateur de série TV et je rate régulièrement des épisodes de mes séries préférés. Une solution s'offre à vous avec ce merveilleux site : Tv Gorge - www.tvgorge.com Moteur de recherche à l'appui, vous pouvez ...
Cliquez pour lire la suite de l'article par orion TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Vincent Bellet et Baptiste Giraudier La BI dans SharePoint 2010, Les nouveaux services d'application dans SP2010 et SQL Server Reporting services 2008 R2. La BI dans SharePoint est généralisée pour tous afin de permettre à tous les coll...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2010 : PLAN DE MIGRATION VERS SHAREPOINT 2010TECHDAYS PARIS 2010 : PLAN DE MIGRATION VERS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Arnault Nouvel et Antoine Dongois Le processus à prendre : Apprendre (découvrir la plateforme) Préparer (documenter l'historique et choisir la méthode de MAJ) Test (Test de MAJ) Implémenter (Effectuer la MAJ) Valid...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2010 : LA PLEINIèRE DU SECOND JOURTECHDAYS PARIS 2010 : LA PLEINIèRE DU SECOND JOUR par ROMELARD Fabrice
Après un retour sur l'histoire des TechDays de Paris et le fait que ce soit le plus gros event MS au monde (du fait de sa gratuité), le président de MS France (Eric Boustoullier) a fait une présentation de la vision Microsoft pour les années à venir...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Logiciels
DB-MAIN (9.1.0)DB-MAIN (9.1.0)DB-MAIN is a data-modeling and data-architecture tool. It is designed to help developers and anal... Cliquez pour télécharger DB-MAIN Xilisoft DPG Convertisseur (5.1.37.0120)XILISOFT DPG CONVERTISSEUR (5.1.37.0120)Xilisoft DPG Convertisseur offre aux fans de Nintendo DS une bonne solution leur permettant de dé... Cliquez pour télécharger Xilisoft DPG Convertisseur GraphicsGale (2.01.01)GRAPHICSGALE (2.01.01)GraphicsGale est un logiciel de PixelArt avec de nombreuse fonctionnalités permettant de réalisé ... Cliquez pour télécharger GraphicsGale Architecte 3D (Platinum 2010)ARCHITECTE 3D (PLATINUM 2010)Architecte 3D Platinium vous permet de concevoir facilement les plans votre future maison, de l'é... Cliquez pour télécharger Architecte 3D TeamViewer 5 (TeamViewer 5)TEAMVIEWER 5 (TEAMVIEWER 5)Dépanner un ami,expliquer une manipulation devient un jeu d'enfant.
Prise en main d'un autre ord... Cliquez pour télécharger TeamViewer 5
|