// リンクっぽいボタンを作るモジュール // 月影とも 2006. 2.08 // HSP3b3 バグ対策済み 2006. 5.23 #ifndef a_textlink /* #include "boxmes.hsp" */ // 横幅を指定して自動改行するmesモジュール // 月影とも 2006.02.08 #ifndef boxmes #module #deffunc boxmes str _string, int _maxX #uselib "user32.dll" #func DrawText "DrawTextA" int,int,int,int,int _str = _string mref bmscr, 67 pos_startx = ginfo_cx redrawSw = wpeek(bmscr, 78) redraw 0 rect = ginfo_cx,ginfo_cy,$7FFFFFF,$7FFFFFF if _maxX:rect.2 = _maxX+pos_startx DrawText hdc,varptr(_str),-1,varptr(rect), $10:h=stat;DT_WORDBREAK pos pos_startx,ginfo_cy+h redraw redrawSw return h #global #endif #ifndef cRGB #define ctype cRGB(%1,%2,%3) ((%1)&0xFF)|((%2)&0xFF)<<8|((%3)&0xFF)<<16 #endif #module a_textlink mRect,mcl,mbid,mwid,mhfont,mstr,mstat #uselib "gdi32.dll" #func SetBkMode "SetBkMode" int,int #func SetTextColor "SetTextColor" int,int #func SelectObject "SelectObject" int,int #func CreateFontIndirect "CreateFontIndirectA" int #func DeleteObject "DeleteObject" int #uselib "user32.dll" #func DrawText "DrawTextA" int,int,int,int,int #func SetCursor "SetCursor" int #func PostMessage "PostMessageA" int,int,int,int #modfunc _textlink_draw curgsel = ginfo_sel gsel mwid SetBkMode hdc, 1 : oldbkmode=stat ;TRANSPARENT SetTextColor hdc, mcl.mstat : oldtxcolor = stat SelectObject hdc, mhfont : oldhfont = stat DrawText hdc,varptr(mstr),-1,varptr(mRect), $210;DT_WORDBREAK SetBkMode hdc, oldbkmode SetTextColor hdc,oldtxcolor SelectObject hdc, oldhfont mref bmscr,67 redraw wpeek(bmscr, 78) gsel curgsel return h #modfunc _textlink_getwid return mwid #modfunc _textlink_mousemove int _wid, int _x, int _y if _wid!mwid : return if (mRect.0<=_x & mRect.2>=_x & mRect.1<=_y & mRect.3>=_y) { if mstat ! 1 { mstat = 1 _textlink_draw thismod SetCursor hHandCursor@a_textlink_host } } else { if mstat ! 0 { mstat = 0 _textlink_draw thismod SetCursor hDefaultCursor@a_textlink_host } } return #modfunc _textlink_mouseclick int _wid, int _x, int _y if _wid!mwid : return if (mRect.0<=_x & mRect.2>=_x & mRect.1<=_y & mRect.3>=_y) { curginfo = ginfo_sel gsel _wid PostMessage hwnd,$111,16384+mbid,0 gsel curginfo } return #modinit str _string,int _w,int _txcolor, int _hovcolor, int _btnid mRect = ginfo_cx, ginfo_cy, $FFFFFF, 0 if _w : mRect.2 = ginfo_cx+_w mcl = _txcolor,_hovcolor mbid = _btnid mwid = ginfo_sel mstat = -1 mref bmscr,67 CreateFontIndirect varptr(bmscr.49) mhfont = stat mstr = _string DrawText hdc,varptr(mstr),-1,varptr(mRect), $610;DT_WORDBREAK|DT_CALCRECT pos ,ginfo_cy+(mRect.3-mRect.1) _textlink_mousemove thismod, mwid, -1,-1 return #modterm DeleteObject mhfont return #global #module a_textlink_host #uselib "user32.dll" #func ShowWindow "ShowWindow" int,int #func SetClassLong "SetClassLongA" int,int,int #func LoadCursor "LoadCursorA" int,int // 文字列、ラベル、横幅、通常色、ホバー色 #define global textlink(%1,%2,%3=0,%4=$FF0000,%5=$FF) \ xy@a_textlink_host = ginfo_cx,ginfo_cy :\ button gosub %1, %2 : btnid@a_textlink = stat :\ pos xy@a_textlink_host ,xy@a_textlink_host.1 :\ _textlink %1,%3,%4,%5,btnid@a_textlink #deffunc _textlink str _string, int _w, int _txcolor, int _hovcolor, int _btnid ShowWindow objinfo_hwnd(_btnid),0 newmod mod_textlink, a_textlink, _string, _w, _txcolor, _hovcolor, _btnid return _btnid #deffunc textlink_cls foreach mod_textlink _textlink_getwid mod_textlink.cnt if stat = ginfo_sel : delmod mod_textlink.cnt loop return #deffunc _textlink_mousemoveall int _wid, int _x, int _y foreach mod_textlink _textlink_mousemove mod_textlink.cnt,_wid,_x,_y loop return #deffunc _textlink_mouseclickall int _wid, int _x, int _y foreach mod_textlink _textlink_mouseclick mod_textlink.cnt,_wid,_x,_y loop return #deffunc textlink_screen SetClassLong hwnd,-12,0 oncmd gosub *onMouseMove,$200 oncmd gosub *onLButtonUp,$202 ;// return #deffunc _textlink_init LoadCursor 0,$7F89;IDC_HAND hHandCursor = stat textlink "",*dmy : clrobj stat: textlink_cls SetClassLong hwnd,-12,0 : hDefaultCursor = stat textlink_screen *dmy return *onMouseMove _textlink_mousemoveall ginfo_intid, lparam<<16>>16, lparam>>16 return *onLButtonUp _textlink_mouseclickall ginfo_intid, lparam<<16>>16, lparam>>16 return #global _textlink_init ;///////////////////////////////////////////////////// //* pos 30,30 textlink "リンク 0", *sub,320, cRGB($cc,$cc,$ff), cRGB($00,$00,$FF) pos ,ginfo_cy+4 textlink "リンク 1", *sub,320, cRGB($33,$99,$66), cRGB($FF,$00,$FF) pos ,ginfo_cy+4 textlink "リンク 2", *sub,320 pos ,ginfo_cy+4 textlink "リンク 3", *sub,320 stop *sub dialog stat return //*/