另外,希望能解决使用其他输出文本函数,如DrawText or DrawTextEx

解决方案 »

  1.   

    呵呵:Declare Function DrawState Lib "user32" Alias "DrawStateA" _
        (ByVal hdc As Long, _
        ByVal hBrush As Long, _
        ByVal lpDrawStateProc As Long, _
        ByVal lParam As Long, _
        ByVal wParam As Long, _
        ByVal x As Long, _
        ByVal y As Long, _
        ByVal cx As Long, _
        ByVal cy As Long, _
        ByVal fuFlags As Long) As Long
      

  2.   

    Public Const DST_TEXT = &H1&
    Public Const DSS_DISABLED = &H20&DrawState hdc, 0, 0, hIcon, 0, xPixels, yPixels, m_lIconSizeX, m_lIconSizeY, DST_TEXT Or DSS_DISABLED
      

  3.   

    一个 GrayString使用的范例:
    http://www.codeguru.com/vb/articles/1834.shtml
      

  4.   

    对不起,问题没有解决。
    TO: enmity(灵感之源) 
    我希望变Disabled的是字体而不是图标或者图像,这个问题我已经解决
    TO: technofantasy(www.applevb.com)
    那里去看过了,一时半会儿看不懂,并且我也找到了一个代码例子,但是运行结果
    仍然不理想,我想得到的效果是:将Command控件的Enabled设为Disabled之后,
    显示的Caption变灰不可用,我希望可以使用作图方式画出来。Private Declare Function GrayString Lib "user32" Alias "GrayStringA" (ByVal hDC As Long, ByVal hBrush As Long, ByVal lpOutputFunc As Long, ByVal lpData As String, ByVal nCount As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
    Private Sub Form_Paint()
        'KPD-Team 2000
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        Const mStr = "Hello ... This is a Grayed String"
        'set the form's backcolor to White
        Me.BackColor = vbWhite
        'API uses pixels
        Me.ScaleMode = vbPixels
        'Call the function
        GrayString Me.hDC, ByVal 0&, ByVal 0&, mStr, Len(mStr), 0, 0, Me.TextWidth(mStr), Me.TextHeight(mStr)
    End Sub
      

  5.   

    to:printer(打印机) 对,这就是针对文本的,请看其参数DST_TEXT Or DSS_DISABLED,这说明是对文本灰化。你尝试过了吗?
      

  6.   

    enmity(灵感之源) 
    hIcon,是什么?看起来好像是图标的句柄,那么,换成字符串的首地址么?
    ByVal lParam As Long
    ByVal wParam As Long都是什么意思,我的字符串MyStr放到哪里?
      

  7.   

    to:printer(打印机) 
    那是对象句柄,如你用DrawText等API的第一个参数一样。
      

  8.   

    While Drawtext is declared like this,It seems not like at all 
    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