gmaker吧 关注:11贴子:127
  • 6回复贴,共1

Excel用户窗体自定义

只看楼主收藏回复

之前做excel窗户,因为定制需要,需要把边框及标题去掉。及时活用三个函数基本就可以改写窗体。
FindWindow()
GetWindowLong()
SetWindowLong()
具体转换在vba中需要声明


IP属地:海南1楼2014-07-27 16:46回复
    在用户窗体初始话前声明
    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long


    IP属地:海南2楼2014-07-27 16:48
    回复
      再在
      Private Sub UserForm_Initialize()
      Dim IStyle As Long, hWnd As Long
      hWnd = FindWindow("ThunderDFrame", Me.Caption)
      IStyle = GetWindowLong(hWnd, GWL_STYLE)
      IStyle = IStyle And Not WS_CAPTION
      SetWindowLong hWnd, GWL_STYLE, IStyle
      DrawMenuBar hWnd
      IStyle = WS_EX_LEFT Or WS_EX_LTRREADING Or WS_EX_RIGHTSCROLLBAR
      IStyle = GetWindowLong(hWnd, GWL_EXSTYLE) And Not IStyle
      SetWindowLong hWnd, GWL_EXSTYLE, IStyle
      End sub


      IP属地:海南3楼2014-07-27 16:50
      回复
        注意像WS_EX_LEFT 需要在函数前定义常量值


        IP属地:海南4楼2014-07-27 16:51
        回复
          虽然看不懂,但还是支持


          来自iPhone客户端5楼2014-07-28 00:06
          收起回复
            不明觉厉。。


            6楼2014-08-13 18:13
            回复