重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
做一个窗体模板,假设是Form2
让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:空间域名、网络空间、营销软件、网站建设、获嘉网站维护、网站推广。
Dim x as New Form2
x.Show()
如果弹出窗口较多,x可以用动态数组替代
用ShowDialog()打开窗体,对话框用msgBox()或者MessageBox()都是模式的。
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 CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Long) As Long
Private Sub Form_Resize()
Const RGN_DIFF = 4
Dim outer_rgn As Long
Dim inner_rgn As Long
Dim combined_rgn As Long
Dim wid As Single
Dim hgt As Single
Dim border_width As Single
Dim title_height As Single
If WindowState = vbMinimized Then Exit Sub
' Create the regions.
wid = ScaleX(Width, vbTwips, vbPixels)
hgt = ScaleY(Height, vbTwips, vbPixels)
outer_rgn = CreateRectRgn(0, 0, wid, hgt)
border_width = (wid - ScaleWidth) / 2
title_height = hgt - border_width - ScaleHeight
inner_rgn = CreateEllipticRgn( _
border_width + ScaleWidth * 0.1, _
title_height + ScaleHeight * 0.1, _
ScaleWidth * 0.9, ScaleHeight * 0.9)
' Subtract the inner region from the outer.
combined_rgn = CreateRectRgn(0, 0, 0, 0)
CombineRgn combined_rgn, outer_rgn, _
inner_rgn, RGN_DIFF
' Restrict the window to the region.
SetWindowRgn hWnd, combined_rgn, True
End Sub
用这个函数没错。
你的hwnd没有写清楚,这样hwnd是没定义的,要指定具体窗体的hwnd,如form1.hwnd
rtn = GetWindowLong(hwnd, GWL_EXSTYLE)
SetWindowLong hwnd, GWL_EXSTYLE, rtn
SetLayeredWindowAttributes hwnd, H80C0FF, 0, LWA_COLORKEY
中的hwnd参数,全部改成 me.hwnd ,即当前窗口的hwnd
两个显示器显示有两种模式,一种是
双屏
复制,另一种是扩展。
你这个只能用第二种方式。你需要把要在另一个显示器上显示的窗体的Location设置在主显示器全屏时的右边就可以了.其实就是桌面的向右延伸。
在主显示上拖一下窗体就明白了!