怎样使窗口没有标题栏,但能在任务栏显示标题字.

蒋宏伟 2003-03-08 04:17:48
搞定马上结帐.先谢谢了.要源码
...全文
114 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
蒋宏伟 2003-03-13
  • 打赏
  • 举报
回复
真是不好意思,这个问题我自己翻API大全找到了
Private Const GWL_STYLE = (-16)
Private Const WS_SYSMENU = &H80000
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 Sub Form_Load()
Dim lStyle As Long

lStyle = GetWindowLong(hwnd, GWL_STYLE) Or WS_SYSMENU
SetWindowLong hwnd, GWL_STYLE, lStyle
end sub
图标文字一任具全
Sean918 2003-03-09
  • 打赏
  • 举报
回复
mark

收藏
northwolves 2003-03-08
  • 打赏
  • 举报
回复
呵呵,这样可以:

'This sample show you how to cut the caption title exactly with the icon not dispear.
'add a new form ,do nothing but copy this codes for it.
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 cmd2_Click() '*******************
Me.ScaleMode = 2
Dim area As Long
area = CreateRectRgn(0, 0, Me.Width, Me.Height) '画含标题栏的矩形框
area = SetWindowRgn(Me.hWnd, area, True) '恢复标题栏
End Sub
Private Sub Form_Load()
Me.Icon = LoadPicture("C:\Program Files\Microsoft Visual Studio\Common\Graphics\Icons\Misc\misc03.ico")
Me.WindowState = 0
Dim capheight As Long, area As Long
Me.ScaleMode = 2
Me.ForeColor = vbRed
Me.Line (1, 0)-(Me.Width, 0) '紧贴标题栏画线做标记
capheight = GetSystemMetrics(33) + GetSystemMetrics(4) ' 边框宽度+标题栏高度
area = CreateRectRgn(0, capheight, Me.Width, Me.Height) '画无标题栏的矩形框
area = SetWindowRgn(Me.hWnd, area, True) '裁剪标题栏
End Sub
Sean918 2003-03-08
  • 打赏
  • 举报
回复
搞不定啊

这是我的代码,但是还是没有用:

Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function DefWindowProc Lib "user32" Alias "DefWindowProcA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Private Const WM_SETICON = &H80
Private Const ICON_SMALL = 0
Private Const ICON_BIG = 1

Private Declare Function OpenFile Lib "kernel32" (ByVal lpFileName As String, lpReOpenBuff As OFSTRUCT, ByVal wStyle As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Const OFS_MAXPATHNAME = 128
Const OF_READ = &H0

Private Type OFSTRUCT
cBytes As Byte
fFixedDisk As Byte
nErrCode As Integer
Reserved1 As Integer
Reserved2 As Integer
szPathName(OFS_MAXPATHNAME) As Byte
End Type


Private Sub Form_Load()
Set Me.Icon = LoadPicture("C:\Program Files\Microsoft Visual Studio\Common\Graphics\Icons\Misc\FACE02.ICO")
SetWindowText Me.hwnd, "要显示的标题"


hDecomp = DefWindowProc(Me.hwnd, WM_SETICON, ICON_BIG, 0)
SendMessage Me.hwnd, WM_SETICON, ICON_BIG, hDecomp

End Sub
hengxin54 2003-03-08
  • 打赏
  • 举报
回复
图标还是显示不了,只有标题,帮你UP
Sean918 2003-03-08
  • 打赏
  • 举报
回复
Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long

Private Sub Form_Load()
Me.ShowInTaskbar = True
SetWindowText Me.hwnd, "要显示的标题"
Set Me.Icon = LoadPicture("D:\Microsoft Visual Studio\Common\Graphics\Icons\Misc\FACE02.ICO")

End Sub
蒋宏伟 2003-03-08
  • 打赏
  • 举报
回复
可是没有图标呀,怎么加图标呀
baitianhai 2003-03-08
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/topic/1268/1268991.xml?temp=.7164575

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧