您的位置:程序门 -> vb -> 基础类



在线等,高手请进.怎样将label控件逆时针转90度啊.急......


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


在线等,高手请进.怎样将label控件逆时针转90度啊.急......
发表于:2007-02-05 17:03:54 楼主
在线等,高手请进.怎样将label控件逆时针转90度啊.急......
发表于:2007-02-05 17:14:241楼 得分:0
private   sub   form_load()
label1.font   =   "@宋体 "
label1.caption   =   "@宋体 "
end   sub
发表于:2007-02-05 17:17:472楼 得分:0
不是这样的.我要的是将label控件旋转逆时针90度,而不是里面的字.
发表于:2007-02-05 18:16:303楼 得分:0
设计时将label控件的属性height改大及width改小重作设置.
或用鼠标左键点中窗体上该控件,会出现6个深色方块,将鼠标移动至控件的右下角,出现斜向双箭头点住鼠标左键网左下方移动,label控件由横向长方形变为竖向长方形即可.
发表于:2007-02-05 18:24:034楼 得分:0
补充,其实窗体任何可见控件大小都是这样调整的.
发表于:2007-02-05 18:31:065楼 得分:0
不行的.假如label控件里面内容为:chinese,开始是横着的.现在是要将此控件竖着(逆时针旋转90度)显示,里面的字也是跟着label控件一起逆时针旋转90度,急.......
发表于:2007-02-05 18:49:396楼 得分:0
控件旋转不太知道,但是用ide画图的话可以做到图形的旋转
发表于:2007-02-05 18:53:417楼 得分:0
谢谢,用api函数可以吗?
发表于:2007-02-05 19:12:338楼 得分:0
给你找到一个旋转字体的代码,自己复制运行试试(我没调试过):


首先建立一个工程文件,然后加入一个新的类文件,并将这个类的name属性改变为apifont,然后在类的代码窗口中加入以下的代码:

  option   explicit
  
  private   declare   function   selectcliprgn   lib   “gdi32”(byval   hdc   as   long,   byval   hrgn   as   long)   as   long
  private   declare   function   createrectrgn   lib   “gdi32”(byval   x1   as   long,   byval   y1   as   long,   byval   x2   as   long,   byval   y2   as   long)   as   long
  private   declare   function   settextcolor   lib   “gdi32”(byval   hdc   as   long,   byval   crcolor   as   long)   as   long
  private   declare   function   deleteobject   lib   “gdi32”(byval   hobject   as   long)   as   long
  private   declare   function   createfontindirect   lib   “gdi32”   alias   “createfontindirecta”   (lplogfont   as   logfont)   as   long
  private   declare   function   selectobject   lib   “gdi32”(byval   hdc   as   long,   byval   hobject   as   long)   as   long
  private   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
  private   declare   function   settextalign   lib   “gdi32”(byval   hdc   as   long,   byval   wflags   as   long)   as   long
  
  private   type   rect
     left   as   long
     top   as   long
     right   as   long
     bottom   as   long
  end   type
  
  private   const   ta_left   =   0
  private   const   ta_right   =   2
  private   const   ta_center   =   6
  private   const   ta_top   =   0
  private   const   ta_bottom   =   8
  private   const   ta_baseline   =   24
  
  private   type   logfont
     lfheight   as   long
     lfwidth   as   long
     lfescapement   as   long
     lforientation   as   long
     lfweight   as   long
     lfitalic   as   byte
     lfunderline   as   byte
     lfstrikeout   as   byte
     lfcharset   as   byte
     lfoutprecision   as   byte
     lfclipprecision   as   byte
     lfquality   as   byte
     lfpitchandfamily   as   byte
     lffacename   as   string   *   50
  end   type
  
  private   m_lf   as   logfont
  private   newfont   as   long
  private   orgfont   as   long
  public   sub   charplace(o   as   object,   txt$,   x,   y)
     dim   throw   as   long
     dim   hregion   as   long
     dim   r   as   rect
  
     r.left   =   x
     r.right   =   x   +   o.textwidth(txt$)   *   2
     r.top   =   y
     r.bottom   =   y   +   o.textheight(txt$)   *   2
  
     hregion   =   createrectrgn(r.left,   r.top,   r.right,   r.bottom)
     throw   =   selectcliprgn(o.hdc,   hregion)
     throw   =   textout(o.hdc,   x,   y,   txt$,   len(txt$))
     deleteobject   (hregion)
  end   sub
  public   sub   setalign(o   as   object,   top,   baseline,   bottom,   left,   center,   right)
     dim   vert   as   long
     dim   horz   as   long
  
     if   top   =   true   then   vert   =   ta_top
     if   baseline   =   true   then   vert   =   ta_baseline
     if   bottom   =   true   then   vert   =   ta_bottom
     if   left   =   true   then   horz   =   ta_left
     if   center   =   true   then   horz   =   ta_center
     if   right   =   true   then   horz   =   ta_right
     settextalign   o.hdc,   vert   or   horz
  end   sub
  public   sub   setcolor(o   as   object,   cvalue   as   long)
     dim   throw   as   long
  
     throw   =   settextcolor(o.hdc,   cvalue)
  end   sub
  public   sub   selectorg(o   as   object)
     dim   throw   as   long
  
     newfont   =   selectobject(o.hdc,   orgfont)
     throw   =   deleteobject(newfont)
  end   sub
  public   sub   selectfont(o   as   object)
     newfont   =   createfontindirect(m_lf)
     orgfont   =   selectobject(o.hdc,   newfont)
  end   sub
  public   sub   fontout(text$,   o   as   control,   xx,   yy)
     dim   throw   as   long
  
     throw   =   textout(o.hdc,   xx,   yy,   text$,   len(text$))
  end   sub
  
  public   property   get   width()   as   long
     width   =   m_lf.lfwidth
  end   property
  
  public   property   let   width(byval   w   as   long)
     m_lf.lfwidth   =   w
  end   property
  
  public   property   get   height()   as   long
     height   =   m_lf.lfheight
  end   property
  
  public   property   let   height(byval   vnewvalue   as   long)
     m_lf.lfheight   =   vnewvalue
  end   property
  
  public   property   get   escapement()   as   long
     escapement   =   m_lf.lfescapement
  end   property
  
  public   property   let   escapement(byval   vnewvalue   as   long)
     m_lf.lfescapement   =   vnewvalue
  end   property
  
  public   property   get   weight()   as   long
     weight   =   m_lf.lfweight
  end   property
  
  public   property   let   weight(byval   vnewvalue   as   long)
     m_lf.lfweight   =   vnewvalue
  end   property
  
  public   property   get   italic()   as   byte
     italic   =   m_lf.lfitalic
  end   property
  
  public   property   let   italic(byval   vnewvalue   as   byte)
     m_lf.lfitalic   =   vnewvalue
  end   property
  
  public   property   get   underline()   as   byte
     underline   =   m_lf.lfunderline
  end   property
  
  public   property   let   underline(byval   vnewvalue   as   byte)
     m_lf.lfunderline   =   vnewvalue
  end   property
  
  public   property   get   strikeout()   as   byte
     strikeout   =   m_lf.lfstrikeout
  end   property
  
  public   property   let   strikeout(byval   vnewvalue   as   byte)
     m_lf.lfstrikeout   =   vnewvalue
  end   property
  
  public   property   get   facename()   as   string
     facename   =   m_lf.lffacename
  end   property
  
  public   property   let   facename(byval   vnewvalue   as   string)
     m_lf.lffacename   =   vnewvalue
  end   property
  
  private   sub   class_initialize()
     m_lf.lfheight   =   30
     m_lf.lfwidth   =   10
     m_lf.lfescapement   =   0
     m_lf.lfweight   =   400
     m_lf.lfitalic   =   0
     m_lf.lfunderline   =   0
     m_lf.lfstrikeout   =   0
     m_lf.lfoutprecision   =   0
     m_lf.lfclipprecision   =   0
     m_lf.lfquality   =   0
     m_lf.lfpitchandfamily   =   0
     m_lf.lfcharset   =   0
     m_lf.lffacename   =   "arial "   +   chr(0)
  end   sub  

  在工程文件的form1中加入一个picturebox和一个commandbutton控件,然后在form1的代码窗口中加入以下的代码:

  option   explicit
  
  dim   af   as   apifont
  dim   x,   y   as   integer
  
  private   sub   command1_click()
     dim   i   as   integer
  
     set   af   =   nothing
     set   af   =   new   apifont
     picture2.cls
     for   i   =   0   to   3600   step   360
     af.escapement   =   i
     af.selectfont   picture2
     x   =   picture2.scalewidth   /   2
     y   =   picture2.scaleheight   /   2  


     af.fontout   “旋转字体测试   ”,   picture2,   x,   y
     af.selectorg   picture2
     next   i
  end   sub
  
  private   sub   form_load()
     picture2.scalemode   =   3
  end   sub    

  运行程序,点击form上的command1按钮,在窗口的图片框就会出现旋转的文本显示。


快速检索

最新资讯
热门点击