大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 技术开发 -> 其他相关 -> 设定StatusBar的文字成不同的颜色

设定StatusBar的文字成不同的颜色

时间: 2021-07-31 作者:daque

设定statusbar上的笔墨,该笔墨以statusbar地方form的字型设定于准,并以form的forecolor为字的脸色,笔墨过长时,机动会截除这个程式的本质意旨不太大,由于当笔墨被盖掉後需自行从新再呼唤这个sub本领再将笔墨表露出来,只有咱们再运用subclassing的办法,於statusbar接受到wm_paint时,去呼唤这个subroutine,这程式提防於font的领会

''below is within formprivate sub command1_click()call showpaneltext(statusbar1, 1, "这是一个风趣的程式hahahaha")end sub

''第一个叁数字传送入statusbar''第二个叁数表白笔墨要在第几个panel上 表露,由1算起''第三个叁数是待表露的字串private sub showpaneltext(statusbar1 as statusbar, pno as long, byval paneltextas string)dim bkcolor as longdim color as longdim res as longdim arect as rect, rect5 as rectdim hfont as longdim hdc2 as longdim textheight as longdim tx as textmetricdim oscalet as long, oscalel as long, oscaleh as long, oscalew as longdim oscalem as long

oscalem = me.scalemodeoscalet = me.scaletoposcalel = me.scaleleftoscaleh = me.scaleheightoscalew = me.scalewidthme.scalemode = 3

hdc2 = getdc(statusbar1.hwnd)call gettextmetrics(me.hdc, tx) ''博得form 字型资源讯息hfont = createfont(tx.tmheight, tx.tmavecharwidth, 0, 0, _tx.tmweight, 0, 0, 0, tx.tmcharset, 0, 0, 0, _tx.tmpitchandfamily, me.font.name) ''依form的字型爆发另一个font''由于不知怎样博得font的handle只好,运用createfont的办法来博得 hfontcall selectobject(hdc2, hfont) ''设字型res = settextcolor(hdc2, me.forecolor) ''设字的脸色bkcolor = getsyscolor(color_btnface)setbkcolor hdc2, bkcolor ''设字的背局面settextalign hdc2, ta_toptextheight = me.textheight(paneltext)arect.top = (statusbar1.height - textheight) \ 2if statusbar1.style = 0 thenarect.left = statusbar1.panels(pno).left + 2arect.right = arect.left + statusbar1.panels(pno).width - 6elsearect.left = statusbar1.left + 2arect.right = statusbar1.width - 6end ifarect.bottom = statusbar1.heightinvalidaterect statusbar1.hwnd, arect, 1 ''颁布处事区失效,用来重画statusbarupdatewindow statusbar1.hwnddrawtext hdc2, paneltext, lenb(strconv(paneltext, vbfromunicode)), arect, 0releasedc statusbar1.hwnd, hdc2deleteobject (hfont)me.scalemode = oscalemme.scaleheight = oscalehme.scaletop = oscaletme.scaleleft = oscalelme.scalewidth = oscalewend sub''below is within .bas moduleoption explicittype rectleft as longtop as longright as longbottom as longend typetype textmetrictmheight as longtmascent as longtmdescent as longtminternalleading as longtmexternalleading as longtmavecharwidth as longtmmaxcharwidth as longtmweight as longtmoverhang as longtmdigitizedaspectx as longtmdigitizedaspecty as longtmfirstchar as bytetmlastchar as bytetmdefaultchar as bytetmbreakchar as bytetmitalic as bytetmunderlined as bytetmstruckout as bytetmpitchandfamily as bytetmcharset as byteend typedeclare function createfont lib "gdi32" alias "createfonta" _(byval h as long, byval w as long, byval e as long, byval o as long, _byval w as long, byval i as long, byval u as long, byval s as long, _byval c as long, byval op as long, byval cp as long, _byval q as long, byval paf as long, byval f as string) as longdeclare function gettextmetrics lib "gdi32" alias "gettextmetricsa" _(byval hdc as long, lpmetrics as textmetric) as longdeclare function getbkcolor lib "gdi32" (byval hdc as long) as longdeclare function settextcolor lib "gdi32" (byval hdc as long, _byval crcolor as long) as longdeclare function getdc lib "user32" (byval hwnd as long) as longdeclare function releasedc lib "user32" (byval hwnd as long, _byval hdc as long) as longdeclare function setbkcolor lib "gdi32" (byval hdc as long, _byval crcolor as long) as longdeclare function settextalign lib "gdi32" (byval hdc as long, _byval wflags as long) as longdeclare function selectobject lib "gdi32" (byval hdc as long, _byval hobject as long) as longdeclare function drawtext lib "user32" alias "drawtexta" _(byval hdc as long, byval lpstr as string, byval ncount as long, _lprect as rect, byval wformat as long) as longdeclare function invalidaterect lib "user32" (byval hwnd as long, _lprect as rect, byval berase as long) as long

declare function updatewindow lib "user32" (byval hwnd as long) as longdeclare function getsyscolor lib "user32" (byval nindex as long) as longdeclare function deleteobject lib "gdi32" (byval hobject as long) as long

public const color_btnface = 15public const ta_top = 0

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.