First commit 25/10/1998
This commit is contained in:
165
traymain.cpp
Normal file
165
traymain.cpp
Normal file
@ -0,0 +1,165 @@
|
||||
//----------------------------------------------------------------------------
|
||||
//Borland C++Builder
|
||||
//Copyright (c) 1987, 1998 Borland International Inc. All Rights Reserved.
|
||||
//----------------------------------------------------------------------------
|
||||
//---------------------------------------------------------------------------
|
||||
#include <vcl.h>
|
||||
#include <shellapi.h>
|
||||
#include <registry.hpp>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "traymain.h"
|
||||
#include "TPropiedades.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma resource "*.dfm"
|
||||
TTrayMainForm *TrayMainForm;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TTrayMainForm::TTrayMainForm(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
Running = true;
|
||||
TrayMessage(NIM_ADD);
|
||||
TrayMessage(NIM_MODIFY);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TTrayMainForm::DrawItem(TMessage& Msg)
|
||||
{
|
||||
IconDrawItem((LPDRAWITEMSTRUCT)Msg.LParam);
|
||||
TForm::Dispatch(&Msg);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TTrayMainForm::MyNotify(TMessage& Msg)
|
||||
{
|
||||
POINT MousePos;
|
||||
|
||||
switch(Msg.LParam)
|
||||
{
|
||||
case WM_RBUTTONUP:
|
||||
if ( GetCursorPos(&MousePos) )
|
||||
{
|
||||
PopupMenu1->PopupComponent = Propiedades;
|
||||
SetForegroundWindow(Handle);
|
||||
PopupMenu1->Popup(MousePos.x, MousePos.y);
|
||||
PopupMenu1->PopupComponent = 0;
|
||||
}
|
||||
else
|
||||
Show();
|
||||
break;
|
||||
case WM_LBUTTONDBLCLK:
|
||||
Properties1Click(0);
|
||||
break;
|
||||
/*
|
||||
case WM_LBUTTONUP:
|
||||
Properties1Click(0);
|
||||
break;
|
||||
*/
|
||||
default:
|
||||
break;
|
||||
}
|
||||
TForm::Dispatch(&Msg);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TTrayMainForm::FormDestroy(TObject *Sender)
|
||||
{
|
||||
TrayMessage(NIM_DELETE);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
bool __fastcall TTrayMainForm::TrayMessage(DWORD dwMessage)
|
||||
{
|
||||
NOTIFYICONDATA tnd;
|
||||
PSTR pszTip;
|
||||
|
||||
pszTip = TipText();
|
||||
|
||||
tnd.cbSize = sizeof(NOTIFYICONDATA);
|
||||
tnd.hWnd = Handle;
|
||||
tnd.uID = IDC_MYICON;
|
||||
tnd.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
|
||||
tnd.uCallbackMessage = MYWM_NOTIFY;
|
||||
|
||||
if (dwMessage == NIM_MODIFY)
|
||||
{
|
||||
tnd.hIcon = IconHandle();
|
||||
if (pszTip)
|
||||
lstrcpyn(tnd.szTip, pszTip, sizeof(tnd.szTip));
|
||||
else
|
||||
tnd.szTip[0] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
tnd.hIcon = NULL;
|
||||
tnd.szTip[0] = '\0';
|
||||
}
|
||||
|
||||
return (Shell_NotifyIcon(dwMessage, &tnd));
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
HANDLE __fastcall TTrayMainForm::IconHandle(void)
|
||||
{
|
||||
if (Running)
|
||||
return imagenOn -> Picture->Icon->Handle;
|
||||
else
|
||||
return imagenOFF -> Picture->Icon->Handle;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TTrayMainForm::ToggleState(void)
|
||||
{
|
||||
Running = !Running;
|
||||
TrayMessage(NIM_MODIFY);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
PSTR __fastcall TTrayMainForm::TipText(void)
|
||||
{
|
||||
if (Running)
|
||||
return ("Lanzador de RAS's esta Activado.");
|
||||
else
|
||||
return ("-- DESACTIVADO --");
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
LRESULT IconDrawItem(LPDRAWITEMSTRUCT lpdi)
|
||||
{
|
||||
HICON hIcon;
|
||||
|
||||
hIcon = (HICON)LoadImage(g_hinst, MAKEINTRESOURCE(lpdi->CtlID), IMAGE_ICON,
|
||||
16, 16, 0);
|
||||
if (!hIcon)
|
||||
return(FALSE);
|
||||
|
||||
DrawIconEx(lpdi->hDC, lpdi->rcItem.left, lpdi->rcItem.top, hIcon,
|
||||
16, 16, 0, NULL, DI_NORMAL);
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TTrayMainForm::Properties1Click(TObject *Sender)
|
||||
{
|
||||
// Show();
|
||||
Propiedades -> Visible = !(Propiedades->Visible);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TTrayMainForm::ToggleState1Click(TObject *Sender)
|
||||
{
|
||||
ToggleState();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TTrayMainForm::Shutdown1Click(TObject *Sender)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
||||
void __fastcall TTrayMainForm::BSalirClick(TObject *Sender)
|
||||
{
|
||||
Visible = false;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
||||
void __fastcall TTrayMainForm::FormCreate(TObject *Sender)
|
||||
{
|
||||
Visible = false;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
Reference in New Issue
Block a user