这句(SetWindowLong myform, -16, mystyle And Not WS_CAPTION)中的WS_CAPTION属性在MSDN中是这样解释的:
WS_CAPTION Creates a window that has a title bar (implies the WS_BORDER style). Cannot be used with the WS_DLGFRAME style
它是不是和别的Window Style属性有关,你试试把相关的属性也改一下,看看问题是不是出在这里。
'This sample show you how to cut the caption title exactly and create controls with code.
'add form1,form2 ,do nothing but copy this codes for it,then run form1
Option Explicit
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 SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Private WithEvents cmd1 As CommandButton
Private WithEvents cmd2 As CommandButton
Private Sub cmd1_Click() '******************
Dim capheight As Long, area As Long
Form2.ScaleMode = 2
Form2.ForeColor = vbRed
Form2.Line (1, 0)-(Form2.Width, 0) '紧贴标题栏画线做标记
capheight = GetSystemMetrics(33) + GetSystemMetrics(4) ' 边框宽度+标题栏高度
area = CreateRectRgn(0, capheight, Form2.Width, Form2.Height) '画无标题栏的矩形框
area = SetWindowRgn(Form2.hWnd, area, True) '裁剪标题栏
End Sub
Private Sub cmd2_Click() '*******************
Form2.ScaleMode = 2
Dim area As Long
area = CreateRectRgn(0, 0, Form2.Width, Form2.Height) '画含标题栏的矩形框
area = SetWindowRgn(Form2.hWnd, area, True) '恢复标题栏
End Sub
Private Sub Form_Load()
Me.WindowState = 0
Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2, 8000, 5000 '居中及设置窗体大小
Set cmd1 = Controls.Add("VB.CommandButton", "cmd1", Me) '添加cmd1按纽
Set cmd2 = Controls.Add("VB.CommandButton", "cmd2", Me) '添加cmd2按纽
cmd1.Move 1000, 1000, 1500, 500
cmd2.Move 3000, 1000, 1500, 500
cmd1.Caption = "裁剪标题栏"
cmd2.Caption = "恢复标题栏"
cmd1.Visible = True
cmd2.Visible = True
Form2.Show
End Sub