का उपयोग कर सक्रिय प्रदर्शन का सही नीचे कोने में संदेश विंडो प्रदर्शित करने के इन दिनों आप सॉफ्टवेयर का एक बहुत कुछ सेकंड के लिए या एक करीबी तक सक्रिय स्क्रीन का सही नीचे कोने में संदेश खिड़कियों प्रदर्शित होते देख बटन क्लिक किया गया है (एफ नॉर्टन इसे डाउनलोड करने के बाद करता है)।कैसे डेल्फी
मैं डेल्फी 7 का उपयोग कर ऐसा करने के लिए करना चाहते हैं (और यदि संभव हो डेल्फी 2010, के बाद से मैं धीरे धीरे नवीनतम संस्करण के लिए मेरी कोड पलायन कर रहा हूँ)।
मुझे फोकस प्राप्त न करने वाले फ़ॉर्मों के बारे में SO पर कुछ पोस्ट मिलीं, लेकिन यह समस्या का केवल एक हिस्सा है। मैं पहले से कैसे (इस संदेश खिड़की की सही स्थिति यह है कि इंटरनेट एक उपयोगकर्ता स्क्रीन के दाईं ओर उसकी टास्कबार डाल दिया है हो सकता है जानते हुए भी निर्धारित करने के लिए पर भी सोच रहा हूँ।
Thx।
अद्यतन 26 जनवरी , 10:drorhan
के कोड से शुरू मैं निम्नलिखित प्रपत्र बनाया जो काम करता है टास्कबार नीचे, दाएं, बाएं या schreen के शीर्ष पर दिखाई दे या नहीं (डेल्फी 7 में)
fPopupMessage.dpr:
object frmPopupMessage: TfrmPopupMessage
Left = 537
Top = 233
AlphaBlend = True
AlphaBlendValue = 200
BorderStyle = bsToolWindow
Caption = 'frmPopupMessage'
ClientHeight = 48
ClientWidth = 342
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnClose = FormClose
OnCreate = FormCreate
DesignSize = (
342
48)
PixelsPerInch = 96
TextHeight = 13
object img: TImage
Left = 0
Top = 0
Width = 64
Height = 48
Align = alLeft
Center = True
Transparent = True
end
object lblMessage: TLabel
Left = 72
Top = 8
Width = 265
Height = 34
Alignment = taCenter
Anchors = [akLeft, akTop, akRight, akBottom]
AutoSize = False
Caption = '...'
Font.Charset = DEFAULT_CHARSET
Font.Color = clNavy
Font.Height = -11
Font.Name = 'Verdana'
Font.Style = [fsBold]
ParentFont = False
Transparent = True
WordWrap = True
end
object tmr: TTimer
Enabled = False
Interval = 3000
OnTimer = tmrTimer
Left = 16
Top = 16
end
end
। और
fPopupMessage.pas
unit fPopupMessage;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, ImgList;
type
TfrmPopupMessage = class(TForm)
tmr: TTimer;
img: TImage;
lblMessage: TLabel;
procedure FormCreate(Sender: TObject);
procedure tmrTimer(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
bBeingDisplayed : boolean;
function GetPopupMessage: string;
procedure SetPopupMessage(const Value: string);
function GetPopupCaption: string;
procedure SetPopupCaption(const Value: string);
function TaskBarHeight: integer;
function TaskBarWidth: integer;
procedure ToHiddenPosition;
procedure ToVisiblePosition;
public
{ Public declarations }
procedure StartAnimationToHide;
procedure StartAnimationToShow;
property PopupCaption: string read GetPopupCaption write SetPopupCaption;
property PopupMessage: string read GetPopupMessage write SetPopupMessage;
end;
var
frmPopupMessage: TfrmPopupMessage;
procedure DisplayPopup(sMessage:string; sCaption:string = '');
implementation
{$R *.dfm}
const
DFT_TIME_SLEEP = 5; // the speed you want to show/hide.Increase/descrease this to make it faster or slower
DFT_TIME_VISIBLE = 3000; // number of mili-seconds the form is visible before starting to disappear
GAP = 2; // pixels between form and right and bottom edge of the screen
procedure DisplayPopup(sMessage:string; sCaption:string = '');
begin
// we could create the form here if necessary ...
if not Assigned(frmPopupMessage) then Exit;
frmPopupMessage.PopupCaption := sCaption;
frmPopupMessage.PopupMessage := sMessage;
if not frmPopupMessage.bBeingDisplayed
then begin
ShowWindow(frmPopupMessage.Handle, SW_SHOWNOACTIVATE);
frmPopupMessage.Visible := True;
end;
frmPopupMessage.StartAnimationToShow;
end;
procedure TfrmPopupMessage.FormCreate(Sender: TObject);
begin
img.Picture.Assign(Application.Icon);
Caption := '';
lblMessage.Caption := '';
bBeingDisplayed := False;
ToHiddenPosition();
end;
procedure TfrmPopupMessage.FormClose(Sender: TObject; var Action: TCloseAction);
begin
tmr.Enabled := False;
Action := caHide;
bBeingDisplayed := False;
end;
function TfrmPopupMessage.TaskBarHeight: integer; // this is just to get the taskbar height to put
// my form in the correct position
var
hTB: HWND;
TBRect: TRect;
begin
hTB := FindWindow('Shell_TrayWnd', '');
if hTB = 0 then
Result := 0
else
begin
GetWindowRect(hTB, TBRect);
if TBRect.Top = 0 // tray bar is positioned to the left or to the right
then
Result := 1
else
Result := TBRect.Bottom - TBRect.Top;
end;
end;
function TfrmPopupMessage.TaskBarWidth: integer; // this is just to get the taskbar height to put
// my form in the correct position
var
hTB: HWND;
TBRect: TRect;
begin
hTB := FindWindow('Shell_TrayWnd', '');
if hTB = 0 then
Result := 0
else
begin
GetWindowRect(hTB, TBRect);
if TBRect.Left = 0 // tray bar is positioned to the left or to the right
then
Result := 1
else
Result := TBRect.Right - TBRect.Left
end;
end;
procedure TfrmPopupMessage.ToHiddenPosition;
begin
Self.Left := Screen.Width - TaskbarWidth - Self.Width - GAP;
Self.Top := Screen.Height - TaskBarHeight;
end;
procedure TfrmPopupMessage.ToVisiblePosition;
begin
Self.Left := Screen.Width - TaskBarWidth - Self.Width - GAP;
Self.Top := Screen.Height - Self.Height - TaskBarHeight - GAP;
end;
procedure TfrmPopupMessage.StartAnimationToShow;
var
i: integer;
begin
if bBeingDisplayed
then
ToVisiblePosition()
else begin
ToHiddenPosition();
for i := 1 to Self.Height+GAP do
begin
Self.Top := Self.Top-1;
Application.ProcessMessages;
Sleep(DFT_TIME_SLEEP);
end;
end;
tmr.Interval := DFT_TIME_VISIBLE;
tmr.Enabled := True;
bBeingDisplayed := True;
end;
procedure TfrmPopupMessage.StartAnimationToHide;
var
i: integer;
begin
if not bBeingDisplayed then Exit;
for i := 1 to Self.Height+GAP do
begin
Self.Top := Self.Top+1;
Application.ProcessMessages;
Sleep(DFT_TIME_SLEEP);
end;
bBeingDisplayed := False;
Visible := False;
end;
procedure TfrmPopupMessage.tmrTimer(Sender: TObject);
begin
tmr.Enabled := False;
StartAnimationToHide();
end;
function TfrmPopupMessage.GetPopupMessage: string;
begin
Result := lblMessage.Caption;
end;
procedure TfrmPopupMessage.SetPopupMessage(const Value: string);
begin
lblMessage.Caption := Value;
end;
function TfrmPopupMessage.GetPopupCaption: string;
begin
Result := frmPopupMessage.Caption;
end;
procedure TfrmPopupMessage.SetPopupCaption(const Value: string);
begin
frmPopupMessage.Caption := Value;
end;
end.
दो बटन के साथ अपने परीक्षण के रूप में के रूप में इस्तेमाल करने के लिए किया जा:
procedure TfrmMain.button1Click(Sender: TObject);
begin
DisplayPopup('Message displayed at ' + FormatDateTime('ddd mmm yy zzz', Now),'My Program');
beep;
end;
procedure TfrmMain.button2Click(Sender: TObject);
begin
DisplayPopup('Another message displayed at ' + FormatDateTime('hh:nn zzz', Now),'My Program');
end;
संदेश प्रपत्र आवेदन आइकन प्रदर्शित होगा, लेकिन मैं शायद एक TImageList जोड़ देगा और एक छवि अनुक्रमणिका पास करने के लिए एक संपत्ति जोड़ें ताकि मैं अलग-अलग आइकन प्रदर्शित कर सकूं। मैं Dev.Express घटकों से TcxLabel का भी उपयोग करूंगा क्योंकि यह लंबवत पोजिशनिंग प्रदान करेगा, लेकिन उपर्युक्त इकाई का उपयोग इस प्रकार किया जा सकता है।
मैंने डेल्फी 7 और विंडोज एक्सपी के साथ इसका परीक्षण किया। अगर कोई इस इकाई का उपयोग डेल्फी और/या विंडोज विस्टा या विंडोज 7 के किसी अन्य संस्करण के साथ करता है, तो कृपया मुझे बताएं कि यह इकाई वहां भी काम करेगी या नहीं।
मैं Bolloon टिप्स सोचा सिस्टम ट्रे में हमेशा एसवाई में एक आइकन से जुड़े हैं स्टेम ट्रे हालांकि गलत हो सकता है। मैं सक्रिय स्क्रीन के निचले दाएं भाग पर स्थित होने के लिए और फोकस प्राप्त किए बिना इसे प्रदर्शित करने के लिए किसी भी डेल्फी फॉर्म (जिसे मैं उस पर रखना चाहता हूं, टेक्स्ट, इमेज और इतने पर ...) रखना चाहता हूं। – Edelcom