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
Aide pour Variable lié à une image bitmap [ par Minmrst ]
Bonjours, Il s'agit de mon premier post[^^happy13] Je suis étudiant en BTS IG en première année, et pour apprendre les algorithmes et la programmatio
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
|
Derniers Blogs
CSS CONTENT STATE SELECTORS (PERSONNAL DRAFT)CSS CONTENT STATE SELECTORS (PERSONNAL DRAFT) par FREMYCOMPANY
Bonjour à tous, Je viens de publier une proposition comprenant 5 pseudo-classes pour le CSS Working Group ayant trait à l'état de chargement d'un élément (ex: IMG,VIDEO,AUDIO,OBJECT pour l'HTML.). Si le c½ur vous en dit, vous pouvez retrouver cette p...
Cliquez pour lire la suite de l'article par FREMYCOMPANY MBA : POURQUOI FAIRE ET COMMENT LE CHOISIR ?MBA : POURQUOI FAIRE ET COMMENT LE CHOISIR ? par ROMELARD Fabrice
Formation initiale Durant la formation, le découpage classique est le suivant (je donnerai les équivalences Suisse lorsque je les connaîtrais) : Ecole primaire jusqu'au Collège : Formation générale permettant d'obtenir les méthodes...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice Y'A DES ERREURS QUI PEUVENT RENDRE LE DéVELOPPEUR VIOLENTY'A DES ERREURS QUI PEUVENT RENDRE LE DéVELOPPEUR VIOLENT par Aleks
Quand on a ce genre d'erreur sans log :
Et bas on a juste envie de choper le gas de Microsoft qu'a développé ça et lui foutre des baffes de Coboye ! ...
Cliquez pour lire la suite de l'article par Aleks [HYPER-V 3] PRéSENTATION DES COMMANDLETS POWERSHELL[HYPER-V 3] PRéSENTATION DES COMMANDLETS POWERSHELL par Pierrick CATRO-BROUILLET
Avec la sortie prochaine de la Beta Consumer Preview de Windows 8, j'avais envie de revenir sur une des fonctionnalités que j'attends le plus et que, en bon geek que je suis, j'utilise déjà : Hyper-V 3 ainsi son module PowerShell.
Il y a déjà pléthor...
Cliquez pour lire la suite de l'article par Pierrick CATRO-BROUILLET IIS7 - COMPRESSION GZIPIIS7 - COMPRESSION GZIP par cyril
La compression GZIP permet d'améliorer les performances de navigation en compressant ce qu'envoie le serveur à un client. Pour comprendre comment cela fonctionne, regardons ce qu'il se passe au niveau HTTP lorsqu'un client tente d'accéder à une ress...
Cliquez pour lire la suite de l'article par cyril
Logiciels
Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning Academy System (17.1.3.0)ACADEMY SYSTEM (17.1.3.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System COLLECTOR PLUS (3.00B)COLLECTOR PLUS (3.00B)COLLECTOR PLUS version 3.00B est un logiciel utilisant une base de données alimentée par :
- L... Cliquez pour télécharger COLLECTOR PLUS PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO LettresFaciles 2011 (8.0.0.1)LETTRESFACILES 2011 (8.0.0.1)LettresFaciles est un logiciel facilitant la création et la rédaction de lettres types.
Son inte... Cliquez pour télécharger LettresFaciles 2011
|