utiles_v2017/_app.cpp

100 lines
1.7 KiB
C++

#include "StdAfx.h"
#include "_app.h"
C_app *C_app::p_app=NULL;
//****************************************************
C_app::C_app(void)
{
pirate=FALSE;
nth=0;
C_app::p_app=this;
}
//****************************************************
C_app::~C_app(void)
{
}
//****************************************************
BOOL C_app::inicio()
{
archi.rellena_dirs_ejecucion();
if (!on_inicia())
{
CWnd *Msg = new CWnd;
Msg->MessageBox(er.msg,er.modulo);
if (log.path[0])
{
log.loguea(&er);
}
delete Msg;
return FALSE;
}
return TRUE;
}
// ****************************************************
int C_app::fin()
{
pirate=true;
if (!on_cierra())
{
CWnd *Msg = new CWnd;
Msg->MessageBox(er.msg,er.modulo);
delete Msg;
return FALSE;
}
while (nth>0)
Sleep(50);
return TRUE;
}
//****************************************************
void C_app::cierra()
{
//this->PostMessage(WM_CLOSE,0,0);
delete this;
}
//****************************************************
BOOL C_app::on_inicia()
{
return TRUE;
}
//****************************************************
BOOL C_app::on_cierra()
{
return TRUE;
}
//****************************************************
void C_app::suma_th()
{
long aux;
do
{
aux=nth;
if(aux==InterlockedExchange(&nth,aux+1))
break;
Sleep(1);
} while (TRUE);
}
//****************************************************
void C_app::resta_th()
{
long aux;
do
{
aux=nth;
if(aux==InterlockedExchange(&nth,aux-1))
break;
Sleep(1);
} while (TRUE);
}
//****************************************************
C_app* C_app::GetApp()
{
if(!C_app::p_app)
C_app::p_app = new C_app();
return C_app::p_app;
}
//****************************************************