First commit 25/10/1998

This commit is contained in:
José David Guillén 2021-09-12 22:21:22 +02:00
commit ce9a6b7473
22 changed files with 1236 additions and 0 deletions

13
DialUp/DIALUPT.DPR Normal file

@ -0,0 +1,13 @@
program DialUpT;
uses
Forms,
Main_F in 'Main_F.pas' {Form1};
{$R *.RES}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

BIN
DialUp/DIALUPT.RES Normal file

Binary file not shown.

BIN
DialUp/Main_f.dcu Normal file

Binary file not shown.

BIN
DialUp/Main_f.dfm Normal file

Binary file not shown.

85
DialUp/Main_f.hpp Normal file

@ -0,0 +1,85 @@
// Borland C++ Builder
// Copyright (c) 1995, 1998 by Borland International
// All rights reserved
// (DO NOT EDIT: machine generated header) 'Main_F.pas' rev: 3.00
#ifndef Main_FHPP
#define Main_FHPP
#include <DialUp.hpp>
#include <StdCtrls.hpp>
#include <Dialogs.hpp>
#include <Forms.hpp>
#include <Controls.hpp>
#include <Graphics.hpp>
#include <Classes.hpp>
#include <SysUtils.hpp>
#include <Messages.hpp>
#include <Windows.hpp>
#include <SysInit.hpp>
#include <System.hpp>
//-- user supplied -----------------------------------------------------------
namespace Main_f
{
//-- type declarations -------------------------------------------------------
class DELPHICLASS TForm1;
class PASCALIMPLEMENTATION TForm1 : public Forms::TForm
{
typedef Forms::TForm inherited;
__published:
Dialup::TDialUp* DialUp;
Stdctrls::TListBox* ListBox1;
Stdctrls::TButton* Button1;
Stdctrls::TButton* Button2;
Stdctrls::TButton* Button3;
Stdctrls::TButton* Button4;
Stdctrls::TRadioButton* RadioButton1;
Stdctrls::TRadioButton* RadioButton2;
Stdctrls::TLabel* Label1;
Stdctrls::TLabel* Status;
Stdctrls::TLabel* Status2;
Stdctrls::TCheckBox* CheckBox1;
void __fastcall Button1Click(System::TObject* Sender);
void __fastcall Button2Click(System::TObject* Sender);
void __fastcall DialUpEntryGet(System::TObject* Sender, const char * EntryName, const int EntryName_Size
);
void __fastcall Button3Click(System::TObject* Sender);
void __fastcall DialUpConnect(System::TObject* Sender);
void __fastcall DialUpError(System::TObject* Sender, int ErrorCode, System::AnsiString ErrorMessage
);
void __fastcall DialUpDialing(System::TObject* Sender);
void __fastcall DialUpNotConnected(System::TObject* Sender, int ErrorCode, System::AnsiString ErrorMessage
);
void __fastcall DialUpAsyncEvent(System::TObject* Sender, int State, int Error, System::AnsiString
MessageText);
void __fastcall Button4Click(System::TObject* Sender);
void __fastcall DialUpActiveConnection(System::TObject* Sender, int Handle, const Dialup::TRasConnStatusA
&Status, System::AnsiString StatusString, const char * EntryName, const int EntryName_Size, const
char * DeviceType, const int DeviceType_Size, const char * DeviceName, const int DeviceName_Size);
void __fastcall Button5Click(System::TObject* Sender);
public:
/* TCustomForm.Create */ __fastcall virtual TForm1(Classes::TComponent* AOwner) : Forms::TForm(AOwner
) { }
/* TCustomForm.CreateNew */ __fastcall TForm1(Classes::TComponent* AOwner, int Dummy) : Forms::TForm(
AOwner, Dummy) { }
/* TCustomForm.Destroy */ __fastcall virtual ~TForm1(void) { }
public:
/* TWinControl.CreateParented */ __fastcall TForm1(HWND ParentWindow) : Forms::TForm(ParentWindow) { }
};
//-- var, const, procedure ---------------------------------------------------
extern PACKAGE TForm1* Form1;
} /* namespace Main_f */
#if !defined(NO_IMPLICIT_NAMESPACE_USE)
using namespace Main_f;
#endif
//-- end unit ----------------------------------------------------------------
#endif // Main_F

130
DialUp/Main_f.pas Normal file

@ -0,0 +1,130 @@
unit Main_F;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, DialUp;
type
TForm1 = class(TForm)
DialUp: TDialUp;
ListBox1: TListBox;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
Label1: TLabel;
Status: TLabel;
Status2: TLabel;
CheckBox1: TCheckBox;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure DialUpEntryGet(Sender: TObject; EntryName: array of Char);
procedure Button3Click(Sender: TObject);
procedure DialUpConnect(Sender: TObject);
procedure DialUpError(Sender: TObject; ErrorCode: Integer;
ErrorMessage: String);
procedure DialUpDialing(Sender: TObject);
procedure DialUpNotConnected(Sender: TObject; ErrorCode: Integer;
ErrorMessage: String);
procedure DialUpAsyncEvent(Sender: TObject; State, Error: Integer;
MessageText: String);
procedure Button4Click(Sender: TObject);
procedure DialUpActiveConnection(Sender: TObject; Handle: Integer;
Status: TRasConnStatusA; StatusString: String; EntryName, DeviceType,
DeviceName: array of Char);
procedure Button5Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
ListBox1.Clear; Button2.Enabled:=True;
DialUp.GetEntries;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if ListBox1.Items.Count=0 then
begin
ShowMessage('Choose entry with get entries first');
Exit;
end;
if RadioButton1.Checked then DialUp.DialMode:=dmAsync else DialUp.DialMode:=dmSync;
DialUp.Entry:=ListBox1.Items[ListBox1.ItemIndex];
DialUp.Dial;
end;
procedure TForm1.DialUpEntryGet(Sender: TObject; EntryName: array of Char);
begin
ListBox1.Items.Add(PChar(@EntryName[0]));
ListBox1.ItemIndex:=0;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
DialUp.HangUp;
end;
procedure TForm1.DialUpConnect(Sender: TObject);
begin
Status2.Caption:='Connected.';
end;
procedure TForm1.DialUpError(Sender: TObject; ErrorCode: Integer;
ErrorMessage: String);
begin
Status2.Caption:='Error';
end;
procedure TForm1.DialUpDialing(Sender: TObject);
begin
Status2.Caption:='Dialing...'; Application.ProcessMessages;
end;
procedure TForm1.DialUpNotConnected(Sender: TObject; ErrorCode: Integer;
ErrorMessage: String);
begin
Status2.Caption:='Not Connected';
end;
procedure TForm1.DialUpAsyncEvent(Sender: TObject; State, Error: Integer;
MessageText: String);
begin
Status.Caption:=MessageText;
if Error<>0 then Status2.Caption:='Error. Press Hangup button next to Dial button.';
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
ListBox1.Clear; Button2.Enabled:=False;
DialUp.GetConnections;
end;
procedure TForm1.DialUpActiveConnection(Sender: TObject; Handle: Integer;
Status: TRasConnStatusA; StatusString: String; EntryName, DeviceType,
DeviceName: array of Char);
begin
ListBox1.Items.Add(EntryName+' | '+DeviceName+' || '+StatusString);
if CheckBox1.Checked then DialUp.HangUpConn(Handle);
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
DialUp.HangUpConn(ListBox1.ItemIndex);
end;
end.

140
DialUp/README.TXT Normal file

@ -0,0 +1,140 @@
(****************************************** |******************************************
* RAR, dekompresni komponenta * |* RAR, decompression component *
* pro Delphi 3 (32b) * |* for Delphi 3 (32b) *
* (c) 1997 BEALsoft * |* (c) 1997 BEALsoft *
* v1.0 * |* v1.0 *
*________________________________________* |*________________________________________*
* !! TATO KOMPONENTA JE ZDARMA !! * |* !! THIS COMPONENT IS FREE !! *
****************************************** |******************************************)
// Kontakt na autora // Contact to author :
// aberka@usa.net, ICQ UIN 2365308, http://jakub.naf.cz/~aberka
// BEALsoft BBS, +420-5-<MOMENTALNE NENI / NONE AT THE MOMENT>, 24h
// ** Nove telefonni cislo bude umisteno na me webovske stranky **
// ** New phone number will be placen on my web pages **
// Thanx to Davide Moretti for his RAS API header (Some code in this component
// was written by him). You can reach him via e-mail: dmoretti@iper.net
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Nasledujici dokumentace je JEN v anglictine, protoze predpokladam u programatoru
znalost anglictiny.
It is recommended to read the source code, its comments.
RAS API functions are described in WIN32.HLP (Shipped with 32b Delphi)
METHODS:
=======
function Dial : Integer;
Dials <ENTRY> connection.
Non-zero result means error; OnError event also occurs.
function GetEntries : Integer;
Get available connections
Connections are stored in <ENTRIES>. OnEntryGet event occurs
function GetConnections : Integer;
Get active connection
Connections are passed thru OnActiveConnection
function HangUp : Integer;
Hangups the connection you dialed with this component
function HangUpConn(Handle : THRasConn) : Integer;
Hangups the connection identified by Handle (OnActiveConnection)
function CreateEntry : Integer;
Creates entry in phonebook and displays edit dialog
function EditEntry : Integer;
Opens edit dialog for <ENTRY>
function DeleteEntry : Integer;
Delete <ENTRY> from phonebook
function RenameEntryTo(S : String) : Integer;
Rename <ENTRY> to <S>
function SetEntryUserName(Value : String) : Integer;
Set new username (<VALUE>) to <ENTRY>
function SetEntryPassword(Value : String) : Integer;
Set new password (<VALUE>) to <ENTRY>
function RemovePassword : Integer;
Remove password from <ENTRY>
function GetEntryUserName(var Value : String) : Integer;
Get username from <ENTRY> to <VALUE>
function GetEntryPassword(var Value : String) : Integer;
Get password from <ENTRY> to <VALUE>
function StatusString(State: TRasConnState; Error: Integer): String;
Get string describing <STATE> and <ERROR>
function StatusStringCZ(State: TRasConnState; Error: Integer): String;
Get Czech string describing <STATE> and <ERROR>
PROPERTIES:
===========
property DialMode (TDialMode ... dmAsync/dmSync)
-----------------
Property describing the mode of dialing.
Async dialing means that user will be notified when anything happen
by event. See OnAsyncEvent. [onDialing,onError,onAsyncEvent]
Sync dialing means that Dial function will exit when dialing finished.
Dial function result gives neccessary information. [onDialing,onConnect,onNotConnected]
property Entry (String)
--------------
Identifies which entry will be processed by Dial,EditEntry,DeleteEntry,
GetEntryUserName,...
property Language (TLanguage ... Czech/English)
-----------------
Choose your language. Used for events with string messages.
EVENTS:
=======
OnEntryGet, procedure (Sender : TObject; EntryName : Array of Char) of Object;
----------
This event occurs when an Entry was found in phonebook by GetEntris method.
OnDialing, procedure (Sender : TObject) of object;
---------
This event occurs when Dial method is executed.
OnConnect, procedure (Sender : TObject) of object;
---------
This event occrus when connected with Dial method.
^^^^^^^^^^^
OnNotConnected, procedure (Sender : TObject; ErrorCode : Integer; ErrorMessage : String) of object;
--------------
This event is called when dialing failed.
OnAsyncEvent, procedure (Sender : TObject; State : TRasConnState; Error : Integer;
------------ MessageText : String) of object;
This event is called by RAS when dialing in Async mode. Gives information
about current process.
OnError, procedure (Sender : TObject; ErrorCode : Integer; ErrorMessage : String) of Object;
-------
This event is called when error occur in Dial method etc.
OnActiveConnection, procedure (Sender : TObject; Handle : THRasConn; Status : TRasConnStatus;
------------------ StatusString : String;
EntryName, DeviceType, DeviceName : Array of Char) of object;
This event is called when an active connection was found by GetConnections.
Gives neccessary information about found connection.

9
README.md Normal file

@ -0,0 +1,9 @@
#TrayIcon
*25/10/1998*
ToDo: wwtcf?
![screenshot](/TrayIcon.png "Screenshot")

359
TPropiedades.cpp Normal file

@ -0,0 +1,359 @@
//---------------------------------------------------------------------------
#include <registry.hpp>
#include <vcl.h>
#pragma hdrstop
#include "TPropiedades.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "DialUp"
#pragma resource "*.dfm"
TPropiedades *Propiedades;
//---------------------------------------------------------------------------
__fastcall TPropiedades::TPropiedades(TComponent* Owner)
: TForm(Owner)
{
HoraL->DateTime=0;
HoraU->DateTime=0;
HoraR->DateTime=0;
HoraS->DateTime=0;
DesconectarSalir = true;
ResetEstados();
try {
mHistorial -> Lines -> LoadFromFile("Historial.log");
}catch(...){
// do nothing
}
mHistorial -> Lines -> Add( TDateTime::CurrentDateTime().DateTimeString() + " Inicio de sesión ");
// Refrescamos las conexiones disponibles...
RefrescarConexionesClick(0);
// Obtenemos los parámetros básicos
CargaEstados();
HoraD -> Time = ( HoraU -> Time ) - ( HoraL -> Time );
// Validalidamos el temporizador
TimerDialUp -> Enabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TPropiedades::HoraLChange(TObject *Sender)
{
try {
if ( HoraL->Time > HoraU->Time ) HoraU->Time = HoraL->Time;
HoraD -> Time = ( HoraU -> Time ) - ( HoraL -> Time );
if ( HoraR->Time > (HoraU->Time - HoraL->Time) ) HoraR->Time = 0;
} catch(...) { /*do nothing*/ }
bAplicar -> Enabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TPropiedades::HoraDChange(TObject *Sender)
{
try{
HoraU -> Time = ( HoraL -> Time ) + ( HoraD -> Time );
} catch(...) { /*do nothing*/ }
}
//---------------------------------------------------------------------------
void __fastcall TPropiedades::HoraUChange(TObject *Sender)
{
try {
HoraD -> Time = ( HoraU -> Time ) - ( HoraL -> Time );
if ( HoraR->Time > (HoraU->Time - HoraL->Time) ) HoraR->Time = 0;
if ( HoraS->Time <= HoraU->Time ) HoraS->Time = HoraU->Time;
} catch(...) { /*do nothing*/ }
bAplicar -> Enabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TPropiedades::RefrescarConexionesClick(TObject *Sender)
{
// Obtenemos la lista de conexiones...
ConexionesDisponibles -> Items -> Clear();
DialUp1 -> GetEntries();
}
//---------------------------------------------------------------------------
void __fastcall TPropiedades::DialUp1EntryGet(TObject *Sender,
AnsiString EntryName)
{
ConexionesDisponibles -> Items -> Add( EntryName );
}
//---------------------------------------------------------------------------
void __fastcall TPropiedades::TimerDialUpTimer(TObject *Sender)
{
TDateTime CurrentTime, dtHoraL, dtHoraU, dtHoraR;
CurrentTime = TDateTime::CurrentTime();
dtHoraL = HoraL->Time;
dtHoraU = HoraU->Time;
dtHoraR = HoraR->Time;
TimerDialUp -> Enabled = false;
// Rango en el que deberiamos estar conectados...
if ( CurrentTime >= dtHoraL && CurrentTime < dtHoraU )
{
// Conectamos, si no lo estamos ya
if ( !connected && intentos <= NumReconexiones -> Text.ToInt() )
{
if ( intentos < 0 )
{
StatusBar1 -> Panels -> Items[0] -> Text = "Conectando...";
mHistorial -> Lines -> Add( TDateTime::CurrentDateTime().DateTimeString() + " Inicio conexión (" + DialUp1 -> Entry +")" );
DialUp1 -> Dial();
} else {
if ( Reconectar -> Checked && ( (dtHoraU - dtHoraL) > dtHoraR ) )
{
StatusBar1 -> Panels -> Items[0] -> Text = "Re-Conectando... ("+ AnsiString( intentos ) +")";
mHistorial -> Lines -> Add( TDateTime::CurrentDateTime().DateTimeString() + " Re-Conectando (" + DialUp1 -> Entry +")" );
DialUp1 -> Dial();
}
}
}
} else {
if ( connected )
{
ResetEstados();
StatusBar1 -> Panels -> Items[0] -> Text = "Desconectando...";
mHistorial -> Lines -> Add( TDateTime::CurrentDateTime().DateTimeString() + " Desconectando (" + DialUp1 -> Entry +")" );
DialUp1 -> HangUp();
StatusBar1 -> Panels -> Items[0] -> Text = "Ready";
} else {
if ( ShutDown->Checked && !connected && CurrentTime == HoraS->Time )
{
ShutDown->Checked = false;
SalvaEstados();
StatusBar1 -> Panels -> Items[0] -> Text = "Apagando equipo";
mHistorial -> Lines -> Add( TDateTime::CurrentDateTime().DateTimeString() + " APAGANDO ORDENADOR" );
//******************************
//ApagarEQUIPO();
//******************************
}
}
TimerDialUp -> Enabled = true;
}
}
//---------------------------------------------------------------------------
void __fastcall TPropiedades::ResetEstados(void)
{
intentos = -1;
connected = false;
}
//---------------------------------------------------------------------------
void __fastcall TPropiedades::HoraRChange(TObject *Sender)
{
if ( HoraR->Time > (HoraU->Time - HoraL->Time) )
HoraR->Time = 0;
bAplicar -> Enabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TPropiedades::DialUp1Error(TObject *Sender, int ErrorCode,
AnsiString ErrorMessage)
{
// Prohibimos el que se pueda volver a conectar...
if ( ErrorCode == ERROR_USER_DISCONNECTION )
intentos = 20;
connected = false;
StatusBar1 -> Panels -> Items[0] -> Text = ErrorMessage;
mHistorial -> Lines -> Add( TDateTime::CurrentDateTime().DateTimeString() + " ***************** (" + DialUp1 -> Entry +")" );
mHistorial -> Lines -> Add( TDateTime::CurrentDateTime().DateTimeString() + " ERROR: (" + ErrorMessage +")" );
mHistorial -> Lines -> Add( TDateTime::CurrentDateTime().DateTimeString() + " ***************** (" + DialUp1 -> Entry +")" );
TimerDialUp -> Enabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TPropiedades::ConexionesDisponiblesChange(TObject *Sender)
{
DialUp1 -> Entry = ConexionesDisponibles -> Text;
bAplicar -> Enabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TPropiedades::FormDestroy(TObject *Sender)
{
// Cerramos cualquier comunicación abierta
if ( connected && DesconectarSalir )
DialUp1 -> HangUp();
mHistorial -> Lines -> Add( TDateTime::CurrentDateTime().DateTimeString() + " Fin de sesión ");
}
//---------------------------------------------------------------------------
void __fastcall TPropiedades::OnExitClick(TObject *Sender)
{
DesconectarSalir = OnExit -> Checked;
bAplicar -> Enabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TPropiedades::BorrarHistorialClick(TObject *Sender)
{
mHistorial -> Lines -> Clear();
}
//---------------------------------------------------------------------------
void __fastcall TPropiedades::mHistorialChange(TObject *Sender)
{
try {
if ( Historial -> Checked )
mHistorial -> Lines -> SaveToFile("Historial.log");
} catch(...) {
// do nothing
}
}
//---------------------------------------------------------------------------
void __fastcall TPropiedades::CargaEstados(void)
{
TRegistry *Registro;
Registro = new TRegistry;
// Si es la primera vez que ejecuta el programa...
if ( ! Registro -> KeyExists("\\Software\\JDsoft\\Internet Conector") )
try {
Registro -> OpenKey( "\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", false );
Registro -> WriteString( "InternetConector", Application->ExeName );
}catch(...){ /*do nothing*/ }
try{
Registro -> OpenKey( "\\Software\\JDsoft", true );
Registro -> OpenKey( "\\Software\\JDsoft\\Internet Conector", true );
Historial->Checked = Registro -> ReadBool( "Historial" );
ConexionesDisponibles->Text = Registro -> ReadString( "Conexion" );
HoraL->Time = Registro -> ReadTime( "Inicio");
HoraU->Time = Registro -> ReadTime( "Fin" );
Reconectar->Checked = Registro -> ReadBool( "Reconectar" );
bReintentos->Position = Registro -> ReadInteger( "Reintentos" );
HoraR->Time = Registro -> ReadTime( "PreInicio" );
AutoRun->Checked = Registro -> ReadBool( "AutoRun" );
OnExit->Checked = Registro -> ReadBool( "AutoDesconexion" );
ShutDown->Checked = Registro -> ReadBool( "AutoShutDown" );
HoraS->Time = Registro -> ReadTime( "HoraShutDown" );
}catch(...){
// do nothing
}
DialUp1 -> Entry = ConexionesDisponibles -> Text;
delete Registro;
}
//---------------------------------------------------------------------------
void __fastcall TPropiedades::SalvaEstados(void)
{
if ( ! TimerDialUp -> Enabled ) return;
TRegistry *Registro;
Registro = new TRegistry;
try {
Registro -> OpenKey( "\\Software\\JDsoft", true );
Registro -> OpenKey( "\\Software\\JDsoft\\Internet Conector", true );
Registro -> WriteBool( "Historial", Historial->Checked );
Registro -> WriteString( "Conexion", ConexionesDisponibles->Text );
Registro -> WriteTime( "Inicio", HoraL->Time );
Registro -> WriteTime( "Fin", HoraU->Time );
Registro -> WriteBool( "Reconectar", Reconectar->Checked );
Registro -> WriteInteger( "Reintentos", bReintentos->Position );
Registro -> WriteTime( "PreInicio", HoraR->Time );
Registro -> WriteBool( "AutoRun", AutoRun->Checked );
Registro -> WriteBool( "AutoDesconexion", OnExit->Checked );
Registro -> WriteBool( "AutoShutDown", ShutDown->Checked );
Registro -> WriteTime( "HoraShutDown", HoraS->Time );
Registro -> OpenKey( "\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", false );
// Comprobamos el estado
if ( AutoRun -> Checked )
Registro -> WriteString( "InternetConector", Application->ExeName );
else
Registro -> DeleteValue( "InternetConector" );
}catch(...){
//do nothing
}
delete Registro;
}
//---------------------------------------------------------------------------
void __fastcall TPropiedades::ReconectarClick(TObject *Sender)
{
bAplicar -> Enabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TPropiedades::NumReconexionesChange(TObject *Sender)
{
bAplicar -> Enabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TPropiedades::HistorialClick(TObject *Sender)
{
bAplicar -> Enabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TPropiedades::bReintentosClick(TObject *Sender,
TUDBtnType Button)
{
bAplicar -> Enabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TPropiedades::AutoRunClick(TObject *Sender)
{
bAplicar -> Enabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TPropiedades::ShutDownClick(TObject *Sender)
{
bAplicar -> Enabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TPropiedades::bAceptarClick(TObject *Sender)
{
SalvaEstados();
Propiedades->Visible = false;
}
//---------------------------------------------------------------------------
void __fastcall TPropiedades::bCancelarClick(TObject *Sender)
{
CargaEstados();
Propiedades->Visible = false;
}
//---------------------------------------------------------------------------
void __fastcall TPropiedades::bAplicarClick(TObject *Sender)
{
SalvaEstados();
bAplicar -> Enabled = false;
}
//---------------------------------------------------------------------------
void __fastcall TPropiedades::DialUp1Dialing(TObject *Sender)
{
StatusBar1 -> Panels -> Items[0] -> Text = "Marcando...";
mHistorial -> Lines -> Add( TDateTime::CurrentDateTime().DateTimeString() + " Marcando... (" + DialUp1 -> Entry +")" );
}
//---------------------------------------------------------------------------
void __fastcall TPropiedades::DialUp1AsyncEvent(TObject *Sender, int State,
int Error, AnsiString MessageText)
{
if ( State == RASCS_Connected )
{
intentos++;
connected = true;
StatusBar1 -> Panels -> Items[0] -> Text = "--> Conexión ABIERTA <--";
mHistorial -> Lines -> Add( TDateTime::CurrentDateTime().DateTimeString() + " Conexión abierta (" + DialUp1 -> Entry +")" );
TimerDialUp -> Enabled = true;
} else {
StatusBar1 -> Panels -> Items[0] -> Text = MessageText;
mHistorial -> Lines -> Add( TDateTime::CurrentDateTime().DateTimeString() + MessageText + " (" + DialUp1 -> Entry +")" );
}
}
//---------------------------------------------------------------------------

BIN
TPropiedades.dfm Normal file

Binary file not shown.

98
TPropiedades.h Normal file

@ -0,0 +1,98 @@
//---------------------------------------------------------------------------
#ifndef TPropiedadesH
#define TPropiedadesH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ComCtrls.hpp>
#include <ExtCtrls.hpp>
#include <Buttons.hpp>
#include "DialUp.h"
//---------------------------------------------------------------------------
class TPropiedades : public TForm
{
__published: // IDE-managed Components
TStatusBar *StatusBar1;
TPageControl *PageControl1;
TTabSheet *TabSheet1;
TBevel *Bevel1;
TLabel *Label1;
TComboBox *ConexionesDisponibles;
TDateTimePicker *HoraL;
TDateTimePicker *HoraU;
TLabel *Label2;
TLabel *Label3;
TLabel *Label4;
TDateTimePicker *HoraD;
TBitBtn *RefrescarConexiones;
TDialUp *DialUp1;
TTimer *TimerDialUp;
TCheckBox *Reconectar;
TEdit *NumReconexiones;
TUpDown *bReintentos;
TLabel *Label5;
TDateTimePicker *HoraR;
TTabSheet *TabSheet2;
TBevel *Bevel2;
TMemo *mHistorial;
TSpeedButton *BorrarHistorial;
TCheckBox *Historial;
TTabSheet *TabSheet3;
TBevel *Bevel3;
TCheckBox *OnExit;
TCheckBox *AutoRun;
TCheckBox *ShutDown;
TDateTimePicker *HoraS;
TButton *bAceptar;
TButton *bCancelar;
TButton *bAplicar;
TBevel *Bevel4;
void __fastcall HoraLChange(TObject *Sender);
void __fastcall HoraDChange(TObject *Sender);
void __fastcall HoraUChange(TObject *Sender);
void __fastcall RefrescarConexionesClick(TObject *Sender);
void __fastcall DialUp1EntryGet(TObject *Sender, AnsiString EntryName);
void __fastcall TimerDialUpTimer(TObject *Sender);
void __fastcall HoraRChange(TObject *Sender);
void __fastcall DialUp1Error(TObject *Sender, int ErrorCode,
AnsiString ErrorMessage);
void __fastcall ConexionesDisponiblesChange(TObject *Sender);
void __fastcall FormDestroy(TObject *Sender);
void __fastcall OnExitClick(TObject *Sender);
void __fastcall BorrarHistorialClick(TObject *Sender);
void __fastcall mHistorialChange(TObject *Sender);
void __fastcall ReconectarClick(TObject *Sender);
void __fastcall NumReconexionesChange(TObject *Sender);
void __fastcall HistorialClick(TObject *Sender);
void __fastcall bReintentosClick(TObject *Sender, TUDBtnType Button);
void __fastcall AutoRunClick(TObject *Sender);
void __fastcall ShutDownClick(TObject *Sender);
void __fastcall bAceptarClick(TObject *Sender);
void __fastcall bCancelarClick(TObject *Sender);
void __fastcall bAplicarClick(TObject *Sender);
void __fastcall DialUp1Dialing(TObject *Sender);
void __fastcall DialUp1AsyncEvent(TObject *Sender, int State,
int Error, AnsiString MessageText);
private: // User declarations
void __fastcall ResetEstados(void);
void __fastcall CargaEstados(void);
void __fastcall SalvaEstados(void);
bool connected;
bool DesconectarSalir;
short int intentos;
public: // User declarations
__fastcall TPropiedades(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TPropiedades *Propiedades;
//---------------------------------------------------------------------------
#endif

BIN
TrayIcon.rar Normal file

Binary file not shown.

17
readme.txt Normal file

@ -0,0 +1,17 @@
//---------------------------------------------------------------------------
// Borland C++Builder
// Copyright (c) 1987, 1998 Borland International Inc. All Rights Reserved.
//---------------------------------------------------------------------------
TITLE:
TRAYICON
DESCRIPTION:
Places an active icon on the Explorer's tray bar.
DEMONSTRATES:
TEdit, TImage, TPopupMenu, TMenuItem, Event Handlers, Message Handler,
COMMENTS:

BIN
tmp1.ico Normal file

Binary file not shown.

After

(image error) Size: 9.9 KiB

BIN
tmp2.ico Normal file

Binary file not shown.

After

(image error) Size: 9.9 KiB

129
trayicon.bpr Normal file

@ -0,0 +1,129 @@
# ---------------------------------------------------------------------------
VERSION = BCB.03
# ---------------------------------------------------------------------------
!ifndef BCB
BCB = $(MAKEDIR)\..
!endif
# ---------------------------------------------------------------------------
PROJECT = trayicon.exe
OBJFILES = trayicon.obj traymain.obj TPropiedades.obj
RESFILES = trayicon.res
RESDEPEN = $(RESFILES) traymain.dfm TPropiedades.dfm
LIBFILES =
LIBRARIES = DCLUSR35.lib vclx35.lib VCLSMP35.lib VCL35.lib
SPARELIBS = VCL35.lib VCLSMP35.lib vclx35.lib DCLUSR35.lib
DEFFILE =
PACKAGES = VCLX35.bpi VCL35.bpi VCLDB35.bpi VCLDBX35.bpi bcbsmp35.bpi dclocx35.bpi \
QRPT35.bpi TEEUI35.bpi TEEDB35.bpi TEE35.bpi ibsmp35.bpi NMFAST35.bpi \
INETDB35.bpi INET35.bpi JDsoft.bpi
PATHASM = .;
PATHCPP = .;
PATHPAS = .;
PATHRC = .;
DEBUGLIBPATH = $(BCB)\lib\debug
RELEASELIBPATH = $(BCB)\lib\release
# ---------------------------------------------------------------------------
CFLAG1 = -Od -Hc -w -Ve -r- -k -y -v -vi- -c -b- -w-par -w-inl -Vx
CFLAG2 = -I$(BCB)\include;$(BCB)\include\vcl;"L:\Programación (-CBuilder-)\Jd Soft\" \
-H=$(BCB)\lib\vcld.csm
CFLAG3 =
PFLAGS = -U$(BCB)\lib\obj;$(BCB)\lib;$(DEBUGLIBPATH) \
-I$(BCB)\include;$(BCB)\include\vcl;"L:\Programación (-CBuilder-)\Jd Soft\" -v \
-JPHNV -M
RFLAGS = -i$(BCB)\include;$(BCB)\include\vcl;"L:\Programación (-CBuilder-)\Jd Soft\"
AFLAGS = /i$(BCB)\include /i$(BCB)\include\vcl /i"L:\Programación (-CBuilder-)\Jd Soft\" \
/mx /w0 /zd
LFLAGS = -L$(BCB)\lib\obj;$(BCB)\lib;$(DEBUGLIBPATH) -aa -Tpe -x -v
IFLAGS =
!if !$d(BCC32)
BCC32 = bcc32
!endif
!if !$d(DCC32)
DCC32 = dcc32
!endif
!if !$d(LINKER)
LINKER = ilink32
!endif
!if !$d(BRCC32)
BRCC32 = brcc32
!endif
# ---------------------------------------------------------------------------
ALLOBJ = c0w32.obj sysinit.obj $(OBJFILES)
ALLRES = $(RESFILES)
ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cp32mt.lib
# ---------------------------------------------------------------------------
.autodepend
!if $d(IDEOPTIONS)
!endif
!ifdef IDEOPTIONS
[Version Info]
IncludeVerInfo=1
AutoIncBuild=1
MajorVer=1
MinorVer=0
Release=0
Build=50
Debug=0
PreRelease=0
Special=0
Private=0
DLL=0
Locale=3082
CodePage=1252
[Version Info Keys]
FileVersion=1.0.0.50
[HistoryLists\hlIncludePath]
Count=4
Item0=$(BCB)\include;$(BCB)\include\vcl;L:\Programación (-CBuilder-)\Jd Soft\
Item1=$(BCB)\include;$(BCB)\include\vcl;L:\Programación (-CBuilder-)\Jd SoftItem1=$(BCB)\include;$(BCB)\include\vcl;L:\Programación (-CBuilder-)\Jd SoftItem1=$(BCB)\include;$(BCB)\include\vcl
Item2=
Item3=
[HistoryLists\hlLibraryPath]
Count=1
Item0=$(BCB)\lib\obj;$(BCB)\lib
[Debugging]
DebugSourceDirs=
[Parameters]
RunParams=
HostApplication=
!endif
$(PROJECT): $(OBJFILES) $(RESDEPEN) $(DEFFILE)
$(BCB)\BIN\$(LINKER) @&&!
$(LFLAGS) +
$(ALLOBJ), +
$(PROJECT),, +
$(ALLLIB), +
$(DEFFILE), +
$(ALLRES)
!
.pas.hpp:
$(BCB)\BIN\$(DCC32) $(PFLAGS) { $** }
.pas.obj:
$(BCB)\BIN\$(DCC32) $(PFLAGS) { $** }
.cpp.obj:
$(BCB)\BIN\$(BCC32) $(CFLAG1) $(CFLAG2) -o$* $*
.c.obj:
$(BCB)\BIN\$(BCC32) $(CFLAG1) $(CFLAG2) -o$* $**
.rc.res:
$(BCB)\BIN\$(BRCC32) $(RFLAGS) $<
# ---------------------------------------------------------------------------

26
trayicon.cpp Normal file

@ -0,0 +1,26 @@
//----------------------------------------------------------------------------
//Borland C++Builder
//Copyright (c) 1987, 1998 Borland International Inc. All Rights Reserved.
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
HINSTANCE g_hinst;
//---------------------------------------------------------------------------
USEFILE("readme.txt");
USEFORM("traymain.cpp", TrayMainForm);
USERES("trayicon.res");
USEFORM("TPropiedades.cpp", Propiedades);
//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE hInstance, LPSTR, int)
{
Application->Initialize();
g_hinst = hInstance;
Application->CreateForm(__classid(TTrayMainForm), &TrayMainForm);
Application->CreateForm(__classid(TPropiedades), &Propiedades);
Application->ShowMainForm = false;
Application->Run();
return 0;
}
//---------------------------------------------------------------------------

BIN
trayicon.exe Normal file

Binary file not shown.

BIN
trayicon.res Normal file

Binary file not shown.

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;
}
//---------------------------------------------------------------------------

BIN
traymain.dfm Normal file

Binary file not shown.

65
traymain.h Normal file

@ -0,0 +1,65 @@
//----------------------------------------------------------------------------
//Borland C++Builder
//Copyright (c) 1987, 1998 Borland International Inc. All Rights Reserved.
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------
#ifndef traymainH
#define traymainH
//---------------------------------------------------------------------------
#include <Forms.hpp>
#include <StdCtrls.hpp>
#include <Controls.hpp>
#include <Classes.hpp>
#include <ExtCtrls.hpp>
#include <Menus.hpp>
#include <Buttons.hpp>
#include <Graphics.hpp>
#define MYWM_NOTIFY (WM_APP+100)
#define IDC_MYICON 1006
extern HINSTANCE g_hinst;
LRESULT IconDrawItem(LPDRAWITEMSTRUCT lpdi);
//---------------------------------------------------------------------------
class TTrayMainForm : public TForm
{
__published:
TPopupMenu *PopupMenu1;
TMenuItem *Properties1;
TMenuItem *ToggleState1;
TMenuItem *Shutdown1;
TMenuItem *N1;
TMenuItem *N2;
TMenuItem *Acercade1;
TImage *imagenOn;
TImage *imagenOFF;
TSpeedButton *BSalir;
TMenuItem *Estado1;
void __fastcall FormDestroy(TObject *Sender);
void __fastcall Properties1Click(TObject *Sender);
void __fastcall ToggleState1Click(TObject *Sender);
void __fastcall Shutdown1Click(TObject *Sender);
void __fastcall BSalirClick(TObject *Sender);
void __fastcall FormCreate(TObject *Sender);
private: // private user declarations
void __fastcall DrawItem(TMessage& Msg);
void __fastcall MyNotify(TMessage& Msg);
bool __fastcall TrayMessage(DWORD dwMessage);
HANDLE __fastcall IconHandle(void);
void __fastcall ToggleState(void);
PSTR __fastcall TipText(void);
bool Running;
public: // public user declarations
virtual __fastcall TTrayMainForm(TComponent* Owner);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(WM_DRAWITEM,TMessage,DrawItem)
MESSAGE_HANDLER(MYWM_NOTIFY,TMessage,MyNotify)
END_MESSAGE_MAP(TForm)
};
//---------------------------------------------------------------------------
extern TTrayMainForm *TrayMainForm;
//---------------------------------------------------------------------------
#endif