下面则用javascript实现的非常实用的滚动,你可以修改滚动的方向
<DIV
id=scrollbody>
<DIV
id=scrolltext>
your
contnet
</di>
</di>
<SCRIPT
type=text/javascript>
<!--
try{
var
marqueesHeight
=
150;
var
stopscroll
=
false;
var
scrollElem
=
documentgetElementById("scrollbody");
with(scrollElem){
stylewidth
=
275;
styleheight
=
marqueesHeight;
styleoverflow
=
'hidden';
noWrap
=
true;
}
scrollElemonmouseover
=
new
Function('stopscroll
=
true');
scrollElemonmouseout
=
new
Function('stopscroll
=
false');
var
preTop
=
0;
var
currentTop
=
0;
var
stoptime
=
0;
var
leftElem
=
documentgetElementById("scrolltext");
scrollElemappendChild(leftElemcloneNode(true));
init_srolltext();
}catch(e){}
function
init_srolltext(){
scrollElemscrollTop
=
0;
setInterval('scrollUp()',
15);
}
function
scrollUp(){
if(stopscroll)
return;
currentTop
+=
1;
if(currentTop
==
30){
stoptime
+=
1;
currentTop
-=
1;
if(stoptime
==
180){
currentTop
=
0;
stoptime
=
0;
}
}else{
preTop
=
scrollElemscrollTop;
scrollElemscrollTop
+=
1;
if(preTop
==
scrollElemscrollTop){
scrollElemscrollTop
=
0;
scrollElemscrollTop
+=
1;
}
}
}
//-->
</SCRIPT>
<!--
phpstatsportscn
-->
<SCRIPT
language=JavaScript
type=text/javascript>
var
_PCSWebSite="10000008";
var
_PCSText="num1";
</SCRIPT>
程序员的表白代码
第一条语言:Java代码翻译:直到死之前,每天爱你多一点代码:while(lifeend){love++;}
第二条语言:C语言代码翻译:IcannotsayHellototheWorldwithoutu代码:#incldestdiohintmain(){printf(HelloWorldn);retrn0;}//IcannotsayHellototheWorldwithoutu
第三条语言:python代码翻译:山无陵,江水为竭,冬雷震震,夏雨雪,天地合,乃敢与君绝!代码:if(mountainarris==None):if(riverwater==None):if(winterthunder==True):if(summersnow==True):if(skyheight==groundheight):iwithyou=Falseelse:iwithyou=True
第四条语言:Erlang代码代码翻译:深圳相遇,至死不渝代码:-module(you_and_me)-export([start/1])-record(person,{name,address,status})start(Name)-one_world(Name)one_world(Name)keep_to_love_you(Person)say_goodbye(Person)-io:format(~p:seeyounextworld!~n,[Person#personname])see_you_next_world(Name)-one_world(Name)
第五条语言:Java语言代码翻译:爱你到天荒地老代码:while(!worlddestroy){Systemoutprintln(iloveyou);}
在软件启动时,为了加深软件在用户头脑中的印象,可以在软件封面上由下而上循环滚动显示一些包含软件名称、功能、版本、用户名、研制单位等文字信息,在用户按下任意键或点击鼠标键后,立即结束演示进入程序主界面。本文通过向工程中添加Splash screen组件,然后在CsplashWnd类中添加DrawText成员方便地实现了具有滚动文字效果的软件封面,其中文字的位置、对齐方式、字体、字号、颜色都由程序来控制。
---- 详细设计步骤如下:
---- 1创建一个名为test的SDI或MDI工程;
---- 2向工程中添加Splash screen组件,即添加一个CWnd类的派生类CsplashWnd;
---- 3编辑或导入软件封面的位图资源,标识号为IDB_SPLASH;
---- 4向CsplashWnd类中添加一个公有成员函数DrawText,此函数用来在软件封面中显示文字,的实现代码如下:(其中参数含义分别为:内存dc,文字位置,对齐方式,字体,字号,颜色,正文文字)
void CSplashWnd::DrawText(CDC pDC,
int x, int y, int nAlign,
CString sFontName, int nFONTSIZE0,
COLORREF crTextColor, CString sText)
{
LOGFONT lf;//字体
lflfStrikeOut=0;//删除线
lflfCharSet = DEFAULT_CHARSET ;//字符集
lflfEscapement =0;//角度
lflfItalic = 0 ;//倾斜
lflfUnderline = 0 ;//下划线
lflfHeight = nFONTSIZE0 ;//字号
strcpy(lflfFaceName,sFaceName
GetBuffer(sFontNameGetLength()));
CFont font ;
fontCreateFontIndirect(&lf);
CFont pOldFont = (CFont )
pDC->SelectObject(&font);
UINT oldAlign,uAlign ;
switch(nAlign)
{
case 0: uAlign = TA_LEFT | TA_TOP ; break;
case 1: uAlign = TA_CENTER | TA_TOP; break;
case 2: uAlign = TA_RIGHT | TA_TOP ; break;
default: uAlign = TA_LEFT | TA_TOP ; break;
}
oldAlign = pDC->SetTextAlign(uAlign);
int oldMode = pDC->SetBkMode(TRANSPARENT);
int oldColor = pDC->SetTextColor(crTextColor) ;
pDC->TextOut(x,y,sText);
pDC->SetTextColor(oldColor) ;
pDC->SetTextAlign(oldAlign);
pDC->SetBkMode(oldMode);
pDC->SelectObject(pOldFont);
fontDeleteObject();
}
---- 5 给CsplashWnd类中添加如下公有成员变量,并初始化变量;
class CSplashWnd : public CWnd
{
public:
CDC m_dcText,m_dcImage;//显示dc的兼容内存dc
CBitmap m_pBitmap;//位图对象
CBitmap m_pOldBitmapText,
m_pOldBitmap;//跟踪内存dc中的原位图
CRgn m_rgn;//用于生成矩形区域
CRect m_TextRect ;//显示文字的矩形区域
int m_nCurPos ;//文字当前位置
}
CSplashWnd::CSplashWnd()
{
m_nCurPos = 50 ;
}
---- 6在SPLASHCPP中加入以下预定义命令:
#define TITLECOLOR RGB(0,0,255)//默认标题颜色
#define CONTENTCOLOR RGB(0,255,255)//默认说明文字颜色
#define FONTSIZE0 15 //默认字号
---- 7 在CsplashWnd类Create中拷贝矩形区域到m_TextRect ;
BOOL CSplashWnd::Create
(CWnd pParentWnd /= NULL/)
{
m_TextRectCopyRect
(&CRect(50,100,500,300));
}
---- 8 在CsplashWnd类的成员OnPaint中添加代码,响应显示窗口时发送的WM_PAINT消息。
void CSplashWnd::OnPaint()
{
CPaintDC dc(this);
BITMAP bm;
m_bitmapGetBitmap(&bm);
static BOOL bFirst = TRUE;//
指示是否第一次绘制窗口
if(bFirst)
{
if (!m_dcImageCreateCompatibleDC(&dc)) return;
m_pOldBitmap = m_dcImageSelectObject(&m_bitmap);
if (!m_dcTextCreateCompatibleDC(&dc)) return;
m_pBitmap = new CBitmap ;
int nBitCount = m_dcTextGetDeviceCaps(BITSPIXEL);
m_pBitmap->CreateBitmap
(bmbmWidth,bmbmHeight,1,nBitCount,NULL);
m_pOldBitmapText = m_dcTextSelectObject(m_pBitmap);
m_rgnCreateRectRgn(m_TextRectleft,m_TextRecttop,
m_TextRectright,m_TextRectbottom);
bFirst = FALSE;
}
m_dcTextSelectClipRgn(NULL);
m_dcTextBitBlt(0, 0, bmbmWidth,
bmbmHeight,&m_dcImage, 0, 0, SRCCOPY);
m_dcTextSelectClipRgn(&m_rgn);
int nBasex = m_TextRectleft ;
int nBasey = m_TextRectbottom-m_nCurPos;
int nMidx = m_TextRectleft + m_TextRectWidth()/2 ;
DrawText(&m_dcText,nMidx,nBasey, 1,
"楷体_GB2312", FONTSIZE0+5,TITLECOLOR,"研制单位");
DrawText(&m_dcText,nMidx,nBasey+30, 1,
"楷体_GB2312", FONTSIZE0,CONTENTCOLOR,
"武警指挥学院模拟中心");
DrawText(&m_dcText,nMidx,nBasey+50, 1,
"楷体_GB2312", FONTSIZE0,TITLECOLOR,"邮政编码");
DrawText(&m_dcText,nMidx,nBasey+70, 1,
"楷体_GB2312", FONTSIZE0,CONTENTCOLOR,"300350");
dcBitBlt(0, 0, bmbmWidth,
bmbmHeight,&m_dcText, 0,0, SRCCOPY);
}
欢迎分享,转载请注明来源:表白网
评论列表(0条)