CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VB >  基础类

在form上指定位置写字???在线等待,来者有分,信誉之上!

楼主happydou(豆豆)2003-09-04 16:49:28 在 VB / 基础类 提问

1、如何在form上指定位置写字?例如在坐标为(100,100)的位置显示hello  
  2、当form画的线段变化后,原来的线段更新掉,显示当前的图画  
  不清楚的地方,我在线回答 问题点数:50、回复次数:5Top

1 楼cuizm(射天狼 http://www.j2soft.cn/)回复于 2003-09-04 16:59:43 得分 20

1.  
  form1.Currentx   =   100  
  form1.Currenty   =   100  
  form1.print   "hello"  
   
  2.  
  form1.cls(不知是不是这样,没太明白)  
  Top

2 楼LeoUltraman(King)回复于 2003-09-04 17:01:12 得分 20

(1)form.CurrentX=100  
  form.CurrentY=100  
  form.Print   "hello"  
  (2)form.cls  
        call   DrawLine()Top

3 楼LeoUltraman(King)回复于 2003-09-04 17:03:59 得分 5

所谓英雄所见略同  
  呵呵  
  可以散分了楼主Top

4 楼Gelim(Gelim)回复于 2003-09-04 17:14:51 得分 5

使用drawtext或textout  
   
   
  Top

5 楼Gelim(Gelim)回复于 2003-09-04 17:17:38 得分 0

放在moduel:  
   
  Option   Explicit  
   
  Public   Const   DT_BOTTOM   =   &H8  
  Public   Const   DT_CALCRECT   =   &H400  
  Public   Const   DT_CENTER   =   &H1  
  Public   Const   DT_EXPANDTABS   =   &H40  
  Public   Const   DT_EXTERNALLEADING   =   &H200  
  Public   Const   DT_LEFT   =   &H0  
  Public   Const   DT_NOCLIP   =   &H100  
  Public   Const   DT_NOPREFIX   =   &H800  
  Public   Const   DT_RIGHT   =   &H2  
  Public   Const   DT_SINGLELINE   =   &H20  
  Public   Const   DT_TABSTOP   =   &H80  
  Public   Const   DT_TOP   =   &H0  
  Public   Const   DT_VCENTER   =   &H4  
  Public   Const   DT_WORDBREAK   =   &H10  
   
  Type   RECT  
                  Left   As   Long  
                  Top   As   Long  
                  Right   As   Long  
                  Bottom   As   Long  
  End   Type  
   
  Type   SIZE  
                  cx   As   Long  
                  cy   As   Long  
  End   Type  
   
  Declare   Function   TextOut   Lib   "gdi32"   Alias   "TextOutA"   (ByVal   hDC   As   Long,   ByVal   X   As   Long,   ByVal   Y   As   Long,   ByVal   lpString   As   String,   ByVal   nCount   As   Long)   As   Long  
  Declare   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   Long  
  Declare   Function   GetTextExtentPoint32   Lib   "gdi32"   Alias   "GetTextExtentPoint32A"   (ByVal   hDC   As   Long,   ByVal   lpsz   As   String,   ByVal   cbString   As   Long,   lpSize   As   SIZE)   As   Long  
   
   
  放在form:  
  Option   Explicit  
   
  Const   LongStr   =   "Determines   the   width   and   height   of   the   rectangle.   If   there   are   multiple   lines   of   text,   DrawText   uses   the   width   of   the   rectangle   pointed   to   by   the   lpRect   parameter   and   extends   the   base   of   the   rectangle   to   bound   the   last   line   of   text.   If   there   is   only   one   line   of   text,   DrawText   modifies   the   right   side   of   the   rectangle   so   that   it   bounds   the   last   character   in   the   line.   In   either   case,   DrawText   returns   the   height   of   the   formatted   text   but   does   not   draw   the   text."  
   
  Private   Sub   Command1_Click()  
          Dim   r   As   RECT,   s   As   SIZE  
           
          r.Left   =   50:   r.Top   =   20  
          DrawText   Me.hDC,   "Draw   Text   Test",   14,   r,   DT_CALCRECT  
          Line   (r.Left,   r.Top)-(r.Right,   r.Bottom),   RGB(255,   255,   0),   BF  
          DrawText   Me.hDC,   "Draw   Text   Test",   14,   r,   0  
           
          r.Left   =   50:   r.Top   =   50:   r.Right   =   300  
          DrawText   Me.hDC,   LongStr,   Len(LongStr),   r,   DT_CALCRECT   Or   DT_WORDBREAK  
          Line   (r.Left,   r.Top)-(r.Right,   r.Bottom),   RGB(255,   255,   0),   BF  
          DrawText   Me.hDC,   LongStr,   Len(LongStr),   r,   DT_WORDBREAK  
  End   Sub  
   
  Top

相关问题

  • 怎样在窗体或者picturebox的指定坐标写字符
  • 如何在窗口内指定某一位置写字?
  • 请教: 如何使用指定的程序(如写字板)打开一个文件
  • 请问:如何在VC里打开写字板程序并显示指定目录下的文本?
  • 请问能否直接在FORM上画图写字呢?
  • 一段关于在form 窗口中写字 的代码,为什么不行??
  • 为什么写字时,老写字母!
  • 写字的问题
  • 在Canvas上写字
  • PictureBox 中如何写字?

关键词

  • 位置
  • publicconst dt
  • form
  • hello
  • as long

得分解答快速导航

  • 帖主:happydou
  • cuizm
  • LeoUltraman
  • LeoUltraman
  • Gelim

相关链接

  • Visual Basic类图书
  • Visual Basic类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo