2010-01-25 7 views
5

का उपयोग कर सक्रिय प्रदर्शन का सही नीचे कोने में संदेश विंडो प्रदर्शित करने के इन दिनों आप सॉफ्टवेयर का एक बहुत कुछ सेकंड के लिए या एक करीबी तक सक्रिय स्क्रीन का सही नीचे कोने में संदेश खिड़कियों प्रदर्शित होते देख बटन क्लिक किया गया है (एफ नॉर्टन इसे डाउनलोड करने के बाद करता है)।कैसे डेल्फी

मैं डेल्फी 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 के किसी अन्य संस्करण के साथ करता है, तो कृपया मुझे बताएं कि यह इकाई वहां भी काम करेगी या नहीं।

उत्तर

3
unit Unit1; 

interface 

uses 
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
    Dialogs, StdCtrls; 

type 
    TForm1 = class(TForm) 
    Button1: TButton; 
    procedure FormCreate(Sender: TObject); 
    procedure Button1Click(Sender: TObject); 
    private 
    { Private declarations } 
    public 
    { Public declarations } 
    end; 

var 
    Form1: TForm1; 

implementation 

{$R *.dfm} 

procedure TForm1.FormCreate(Sender: TObject); 
    function 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); 
     Result := TBRect.Bottom - TBRect.Top; 
    end; 
    end; 

begin 
    Self.Left := Screen.Width - Self.Width; 
    Self.Top := Screen.Height-Self.Height-TaskBarHeight; 
end; 

procedure TForm1.Button1Click(Sender: TObject); 
var 
    i: integer; 
    TimeSleep: integer; 
begin 
    TimeSleep := 5; // the speed you want to show/hide.Increase/descrease this to make it faster or slower 
    for i := 1 to Self.Height do 
    begin 
    Self.Top := Self.Top+1; 
    Sleep(TimeSleep); 
    end; 
    // now let's show it again(use this as code as the show code) 
    for i := 1 to Self.Height do 
    begin 
    Self.Top := Self.Top-1; 
    Sleep(TimeSleep); 
    end; 
end; 

end. 

के माध्यम से http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_25043483.html

2

जो आप खोज रहे हैं वह सिस्टम ट्रे में बुलून टिप्स हैं। सामान्य WinAPI के लिए यहां nice tutorial है, आपको डेल्फी में अनुवाद करने में समस्या नहीं होनी चाहिए।

आप डेल्फी here में गुब्बारे युक्तियों के लिए कोड का उपयोग करने के लिए कुछ तैयार कर सकते हैं।

एक अच्छा कार्यान्वयन available here है।

+1

मैं Bolloon टिप्स सोचा सिस्टम ट्रे में हमेशा एसवाई में एक आइकन से जुड़े हैं स्टेम ट्रे हालांकि गलत हो सकता है। मैं सक्रिय स्क्रीन के निचले दाएं भाग पर स्थित होने के लिए और फोकस प्राप्त किए बिना इसे प्रदर्शित करने के लिए किसी भी डेल्फी फॉर्म (जिसे मैं उस पर रखना चाहता हूं, टेक्स्ट, इमेज और इतने पर ...) रखना चाहता हूं। – Edelcom

1

आप देख सकते हैं जहां टास्कबार है:

uses ShellAPI; 
//... 
Var AppBar: TAppbarData; 
//... 
begin 
    FillChar(AppBar, sizeof(AppBar), 0); 
    AppBar.cbSize := Sizeof(AppBar); 

    if ShAppBarMessage(ABM_GETTASKBARPOS, AppBar) <> 0 then 
    begin 
    //AppBar.rc is TRect 
    end; 
end; 

और फिर अपने रूप को दिखाने के ...

1

आप Growl for Windows इस्तेमाल कर सकते हैं - मुझे नहीं लगता कि इसके लिए एक डेल्फी पुस्तकालय अभी तक नहीं है, लेकिन आप इसे यूडीपी संदेशों के माध्यम से नियंत्रित कर सकते हैं, इसलिए किसी भी नेटवर्क लाइब्रेरी को करना चाहिए।

+0

अद्यतन: http://growl.matf.de पर Growl को नियंत्रित करने के लिए कुछ कोड प्रतीत होता है। टिप के लिए – mghie

+0

Thx, लेकिन मैं संदेशों को नियंत्रित करना चाहता हूं और उपयोगकर्ताओं को अतिरिक्त सॉफ़्टवेयर इंस्टॉल करने के बिना स्वयं को देखना चाहता हूं। लिंक के लिए – Edelcom

1

चेक बाहर गिरह, विंडोज के लिए गुर्राने के समान है, लेकिन मैं बेहतर हो पाया है। आसानी से इंटरफ़ेस करने के लिए एक पास फ़ाइल है, और जिस तरह से यह काम करता है वह बहुत ही सरल है, केवल विंडोज संदेशों को भेजना।

http://fullphat.net/

यह भी अंत उपयोगकर्ता नियंत्रण की कुछ राशि जिनमें से संदेश देखने के लिए, fading से पहले अवधि आदि

+0

Thx, लेकिन मैं अंतिम उपयोगकर्ता को अतिरिक्त सॉफ़्टवेयर स्थापित करने के लिए मजबूर नहीं करना चाहता हूं। हालांकि स्नारल के पीछे विचार एक अच्छा है (बस मैं इस समय के लिए क्या देख रहा हूं)। उत्तर के लिए – Edelcom

4

का उपयोग कर TJvDesktopAlert घटक जो JVCL में शामिल है की कोशिश करो, तो आप पा सकते हैं अनुमति देता है jvcl \ उदाहरण \ JvDesktopAlert \ JvDesktopAlertDemo.dpr में एक उदाहरण

alt text http://www.agnisoft.com/deepak/blog/DesktopAlert.jpg

+0

Thx। दुर्भाग्यवश, मैं जेवीसीएल घटकों का उपयोग नहीं करता, althought मैंने इसे एक बार स्थापित किया। मैं यह देखने के लिए कोड देखूंगा कि वे इसे कैसे करते हैं, लेकिन उन्होंने उन्हें अपने स्वयं के TJVExForm कक्षा से विरासत में मिला है। मैं इसके लिए बहुत सारे कोड या कक्षाओं में खींचना नहीं चाहता हूं। – Edelcom