Accueil > > > FORM TOP MOST (CHANGE LORS DU RUNTIME)
FORM TOP MOST (CHANGE LORS DU RUNTIME)
Information sur la source
Description
Form avec un "system menu" supplémentaire: "Most On Top". Lorsque actif: la forme a un bouton dans la bar des tâches (taskbar) et reste au dessus des autres applications. Lorsque inactif: retourne dans son état précédent: pas de bouton dans la bar des tâches et ancien form style.
Source
- unit odaMostOnTopForm;
-
- // author : Loda
- // date : 20070524
- // Descr : Form with a system menu item "most on top". can change at runtime.
-
- interface
-
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls;
-
- type
- TfrmMostOnTop = class(TForm)
- private
- fMostOnTop : Boolean;
- fOldParent : TWinControl;
- fOldFormStyle : TFormStyle;
- FmiMostOnTopCaption: string;
- procedure SetMostOnTop(const Value: Boolean);
- procedure SetmiMostOnTopCaption(const Value: string);
- procedure CreateMostOnTopSysMenu;
-
- procedure WMSysCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND;
-
- protected
- procedure CreateParams(var Params: TCreateParams); override;
-
- public
- // Operation System Most on Top (with task bar button)
- // side effect : change (and restore) form style
- property MostOnTop : Boolean read fMostOnTop write SetMostOnTop;
- // caption of system menu item. (check when MostOnTop = true)
- property miMostOnTopCaption : string read FmiMostOnTopCaption write SetmiMostOnTopCaption;
-
- constructor CreateMostOnTop(AOwner: TComponent; aMostOnTop : Boolean = true);
- constructor Create(AOwner: TComponent);override;
- end;
-
-
- const
- SC_invMostOnTop = WM_USER + 5;
-
- // example of use:
- // (create a form and display it.)
- var
- frmMostOnTop : TfrmMostOnTop;
-
- implementation
-
- {$R *.dfm}
-
- { TfrmMostOnTop }
-
- constructor TfrmMostOnTop.CreateMostOnTop(AOwner: TComponent ; aMostOnTop : Boolean);
- begin
- fMostOnTop := aMostOnTop; // will be apply in CreateParam
- Create(AOwner);
- end;
-
- constructor TfrmMostOnTop.Create(AOwner: TComponent);
- begin
- inherited Create(AOwner);
- fOldFormStyle := FormStyle;
- FmiMostOnTopCaption := 'Most on Top';
- CreateMostOnTopSysMenu;
- end;
-
- procedure TfrmMostOnTop.CreateParams(var Params: TCreateParams);
- begin
- inherited;
- {DOC:
- for a OS Most on Top form:
- Form style MUST be fsStayOnTop
- ParentWindows MUST be Desktop
- ExStyle MUST be TOPMost}
- if fMostOnTop then begin
- Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW or WS_EX_TOPMOST;
- Params.WndParent := GetDesktopWindow;
- end;
- end;
-
- procedure TfrmMostOnTop.WMSysCommand(var Msg: TWMSysCommand);
- begin
- if Msg.CmdType = SC_invMostOnTop then begin
- MostOnTop := not fMostOnTop;
- end else
- inherited;
- end;
- procedure TfrmMostOnTop.CreateMostOnTopSysMenu;
- var
- SysMenu : HMenu;
- begin
-
- // reset it (prevent multiple add (when change caption))
- SysMenu := GetSystemMenu(Handle, true) ;
- // Get system menu
- SysMenu := GetSystemMenu(Handle, false) ;
-
- {add our menu}
- if fMostOnTop then
- InsertMenu(SysMenu,SC_CLOSE,MF_STRING or MF_Checked or MF_BYCOMMAND,SC_invMostOnTop,pchar(FmiMostOnTopCaption))
- else
- InsertMenu(SysMenu,SC_CLOSE,MF_STRING or MF_BYCOMMAND,SC_invMostOnTop,pchar(FmiMostOnTopCaption));
-
- {Add a seperator bar}
- InsertMenu(SysMenu,SC_CLOSE,MF_SEPARATOR or MF_BYCOMMAND,0,'');
-
- // see SetMenuItemBitmaps to change check mark
- end;
-
- procedure TfrmMostOnTop.SetMostOnTop(const Value: Boolean);
- begin
- if value = fMostOnTop then exit;
-
- fMostOnTop := Value;
-
- if value then begin
-
- fOldParent := Parent;
- Parent := nil;
-
- fOldFormStyle := FormStyle;
- FormStyle := fsStayOnTop;
-
- end else begin
-
- Parent := fOldParent;
-
- formStyle := fOldFormStyle;
-
- end;
-
- DestroyHandle;
- HandleNeeded; // Apply the Most On Top (call CreateParam)
-
- UpdateControlState; //refresh the form
-
- // recreate the system menu, cause destryhandle&friends reset it.
- CreateMostOnTopSysMenu;
-
- end;
-
- procedure TfrmMostOnTop.SetmiMostOnTopCaption(const Value: string);
- begin
- if value = FmiMostOnTopCaption then exit;
- FmiMostOnTopCaption := Value;
- CreateMostOnTopSysMenu;
- end;
-
- end.
unit odaMostOnTopForm;
// author : Loda
// date : 20070524
// Descr : Form with a system menu item "most on top". can change at runtime.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TfrmMostOnTop = class(TForm)
private
fMostOnTop : Boolean;
fOldParent : TWinControl;
fOldFormStyle : TFormStyle;
FmiMostOnTopCaption: string;
procedure SetMostOnTop(const Value: Boolean);
procedure SetmiMostOnTopCaption(const Value: string);
procedure CreateMostOnTopSysMenu;
procedure WMSysCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND;
protected
procedure CreateParams(var Params: TCreateParams); override;
public
// Operation System Most on Top (with task bar button)
// side effect : change (and restore) form style
property MostOnTop : Boolean read fMostOnTop write SetMostOnTop;
// caption of system menu item. (check when MostOnTop = true)
property miMostOnTopCaption : string read FmiMostOnTopCaption write SetmiMostOnTopCaption;
constructor CreateMostOnTop(AOwner: TComponent; aMostOnTop : Boolean = true);
constructor Create(AOwner: TComponent);override;
end;
const
SC_invMostOnTop = WM_USER + 5;
// example of use:
// (create a form and display it.)
var
frmMostOnTop : TfrmMostOnTop;
implementation
{$R *.dfm}
{ TfrmMostOnTop }
constructor TfrmMostOnTop.CreateMostOnTop(AOwner: TComponent ; aMostOnTop : Boolean);
begin
fMostOnTop := aMostOnTop; // will be apply in CreateParam
Create(AOwner);
end;
constructor TfrmMostOnTop.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
fOldFormStyle := FormStyle;
FmiMostOnTopCaption := 'Most on Top';
CreateMostOnTopSysMenu;
end;
procedure TfrmMostOnTop.CreateParams(var Params: TCreateParams);
begin
inherited;
{DOC:
for a OS Most on Top form:
Form style MUST be fsStayOnTop
ParentWindows MUST be Desktop
ExStyle MUST be TOPMost}
if fMostOnTop then begin
Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW or WS_EX_TOPMOST;
Params.WndParent := GetDesktopWindow;
end;
end;
procedure TfrmMostOnTop.WMSysCommand(var Msg: TWMSysCommand);
begin
if Msg.CmdType = SC_invMostOnTop then begin
MostOnTop := not fMostOnTop;
end else
inherited;
end;
procedure TfrmMostOnTop.CreateMostOnTopSysMenu;
var
SysMenu : HMenu;
begin
// reset it (prevent multiple add (when change caption))
SysMenu := GetSystemMenu(Handle, true) ;
// Get system menu
SysMenu := GetSystemMenu(Handle, false) ;
{add our menu}
if fMostOnTop then
InsertMenu(SysMenu,SC_CLOSE,MF_STRING or MF_Checked or MF_BYCOMMAND,SC_invMostOnTop,pchar(FmiMostOnTopCaption))
else
InsertMenu(SysMenu,SC_CLOSE,MF_STRING or MF_BYCOMMAND,SC_invMostOnTop,pchar(FmiMostOnTopCaption));
{Add a seperator bar}
InsertMenu(SysMenu,SC_CLOSE,MF_SEPARATOR or MF_BYCOMMAND,0,'');
// see SetMenuItemBitmaps to change check mark
end;
procedure TfrmMostOnTop.SetMostOnTop(const Value: Boolean);
begin
if value = fMostOnTop then exit;
fMostOnTop := Value;
if value then begin
fOldParent := Parent;
Parent := nil;
fOldFormStyle := FormStyle;
FormStyle := fsStayOnTop;
end else begin
Parent := fOldParent;
formStyle := fOldFormStyle;
end;
DestroyHandle;
HandleNeeded; // Apply the Most On Top (call CreateParam)
UpdateControlState; //refresh the form
// recreate the system menu, cause destryhandle&friends reset it.
CreateMostOnTopSysMenu;
end;
procedure TfrmMostOnTop.SetmiMostOnTopCaption(const Value: string);
begin
if value = FmiMostOnTopCaption then exit;
FmiMostOnTopCaption := Value;
CreateMostOnTopSysMenu;
end;
end.
Conclusion
j'ai crée cette source parceque je n'arrivais pas à changer, lors du RunTime, le WS_EX_TOPMOST sans avoir des effets secondaires.
le système utiliser pour la caption peut (devrait) être changé pour qqch de meilleur (une const ? ). à voir selon vos besoins.
notez que le "vrai" nom de ce genre de système est "top-most". (merci F0xi pour la précision). Je laisse MostOnTop plus par (mauvaises) habitude qu'autre choses.
Pour un exemple: crée une instance de la form et afficher là. Regardez dans le menu de la fenêtre (system menu).
Historique
- 25 mai 2007 09:26:54 :
- ajoute le zip. ajoute la var.
Sources du même auteur
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
Icone dans un TStatus bar ! [ par MAsterC ]
Je ne comprend pas !!!!Et sa ne marche pas !!tu peux tu me faire un exemple s'te plaît !merciMAsterC
progress bar [ par snakefinger ]
salut comment faire pour k1 progress bar suit un scan de fichiers.merci d'avance et.A+.
CS-Bar [ par koko ]
Bon d'abord je ne sais pas ou je dois mettre ceci...alors, je n'arrive pas à installé la CS-Bar... il me dit que certain de mes fichiers sont perimés
tps restant ds une progress bar [ par lnicos ]
ba voilà le titre est clair ;-p, yep je cherche un truc afin de prévenir les utilisateurs du temps restants dans la copie de fichier. Pour le moment j
Smtp + Progress Bar + Bytes Total + Bytes Sent. [ par DeZNiUS ]
J'ai un problème : quand j'envoi des gros fichiers avec mon programme que je fait avec le composant NMSMTP, mon programme affiche dans la status bar '
progressBar + TWebBrowser [ par Fredelphi ]
Bonjour,Est-il possible de faire un progress bar avec un TWebBrowser ?En fait, je charge une page avec get(url), mais parfois c'est assez long...donc
Images dans une gauge ou progress bar [ par magicvinni ]
Bonjour, Je cherche à mettre une image sur une gauge ou une progress bar (je ne vois pas trop la différence entre les 2). Je suis allé voir chez to
IE Bar et CS ... [ par zehunter ]
quelqu'un c'est-il en quel langage la CS IEBAR 2.1 a ete code? et si il existe un semblant de source ou de doc du comment fait ton pareil?ca serais co
Comment colorée cette bar du menu [ par skiso ]
Comment colorée cette bar du menu (s'elle qui support le menu) avec XPmenugéneralement : en xp elle en blank en 2000, 98 elle en
agir sur la scroll bar d'un webbrowser [ par popiggy ]
Bonjour,Je voudrais savoir comment on fait pour controler la navigation (haut-bas) sur un webbrowser, car par défaut il place un ascenseur à droite ma
|
Derniers Blogs
UNE JOLIE-HORLOGE ET PAS QU'UN PEU !UNE JOLIE-HORLOGE ET PAS QU'UN PEU ! par neodante
Pour les possesseurs d'iPhone, ça y est Bijin Tokei - qui se traduit littéralement en Français par " Jolie Horloge " - est arrivé et GRATUITEMENT s'il vous plaît ! Après la version Tokyo, Hokkaido, night club, racing, Gal, "pour les mademoiselles'", . voi...
Cliquez pour lire la suite de l'article par neodante TECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICESTECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICES par ROMELARD Fabrice
Animé par: Gaetan Bouveret et Julien Chomarat Business Connectivity Services (BCS) est dans SharePoint 2010 la version 2 de Business Data Catalog (BDC dans SharePoint 2007). Il s'agit de la solution permettant de visualiser des données provenan...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice [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
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
|