Manuel H.C. Lt JG


Registrado: 20 Ago 2002Mensajes: 61Ubicación: Madrid (España)
|
Publicado: Lun 28 Oct, 2002 11:36 am Asunto: Scroll de texto |
|
|
Saludos a tpd@s,estoy intentando transformar un codigo q creo se compila con borlan,el codigo lo q hace es un scroll de un texto sobre una imagen en bmp viendose correr el texto y el fondo la imagen,pero me he atrancado en un componente q no se cual poner en builder,el codigo es este..
#include "Comun.h"
#include "SobreCri.h"
DEFINE_RESPONSE_TABLE1(TSobre, TDialog)
EV_WM_TIMER,
EV_WM_LBUTTONDOWN,
EV_WM_PAINT,
END_RESPONSE_TABLE;
TSobre::TSobre(TWindow *p, bool pr) : TDialog(p, DlgSobre)
{
presentacion = pr;
Bmp = new TBitmap(*GetModule(), TResId(LOGOSPC));
}
TSobre::~TSobre()
{
DeleteObject(hFont1);
delete Bmp;
}
bool TSobre::EvInitDialog(HWND)
{
TDialog::SetupWindow();
GetWindowRect(Re);
Re.left = (Re.left + Re.right - Bmp->Width())/2;
Re.top = (Re.top + Re.bottom - Bmp->Height())/2;
Re.right = Re.left + Bmp->Width()+4;
Re.bottom = Re.top + Bmp->Height()+2;
MoveWindow(Re, TRUE);
nLineas = 28;
TLineas = atoi(GetApplication()->LoadString(STR_SOBRE-1).c_str());
linea1 = TLineas-10;
paso = 0;
ancho = Re.Width();
aLinea = Re.Height()/(nLineas-3);
velocidad = 90U;
hFont1 = CreateFont(aLinea, 0, 0, 0, 600, 0, 0, 0, 0, 0, 0, 0, 0,
"Comic Sans MS"/*"Times New Roman"*/);
Invalidate();
SetTimer(1, velocidad, NULL);
return false;
}
void TSobre::EvTimer(uint)
{
// TPoint pos;
// int inc;
KillTimer(1);
// Tomar posición del raton
// GetCursorPos(pos);
// inc = (10*(pos.Y() - Re.top-Re.Height()/2)) / Re.Height();
// if(pos.Y() > Re.top+Re.Height()/2)
// {
// paso += inc;
paso++;
if(paso >= aLinea)
{
linea1++;
paso = 0;
if(linea1 == TLineas) linea1 = 0;
}
/* }
else
{
paso += inc;
if(paso <= 0)
{
linea1--;
paso = aLinea;
if(linea1 < 0) linea1 = TLineas-1;
}
}*/
Invalidate(false);//Rect(Re, false);
if(presentacion && linea1 == TLineas-25) Destroy(IDOK);
else SetTimer(1, velocidad, NULL);
}
void TSobre::EvPaint()
{
char Linea[100];
int j, i;
TPaintDC dc(*this);
TSize s;
TMemoryDC memDC(dc);
delete Bmp;
Bmp = new TBitmap(*GetModule(), TResId(LOGOSPC));
memDC.SelectObject(*Bmp);
memDC.SetBkMode(TRANSPARENT);
memDC.SelectObject(hFont1);
i = linea1;
j = 0;
while(j < nLineas)
{
strcpy(Linea, GetApplication()->LoadString(STR_SOBRE+i).c_str());
switch(Linea[0])
{
case 'a': memDC.SetTextColor(RGB(0, 0, 60)); break; // Azul
case 'A': memDC.SetTextColor(RGB(100, 100, 250)); break; // Azul claro
case 'R': memDC.SetTextColor(RGB(250, 60, 60)); break; // Rojo
case 'M': memDC.SetTextColor(RGB(250, 250, 60)); break; // Amarillo
case 'V': memDC.SetTextColor(RGB(27, 109, 22)); break; // Verde
}
s = memDC.GetTextExtent(&Linea[1], strlen(&Linea[1]));
memDC.TextOut((ancho-s.cx)/2, j*aLinea-paso, &Linea[1]);
i++;
j++;
if(i >= TLineas) i = 0;
}
dc.BitBlt(0, 0, Bmp->Width(), Bmp->Height(), memDC, 0, 0, SRCCOPY);
}
void TSobre::EvLButtonDown(uint, TPoint&)
{
KillTimer(1);
Destroy(IDOK);
}
En el componnte q me he quedado es el dc q no se cual poner...un saludo a ver si me podeis hechar una mano.... |
|