私は真ん中の長方形で半透明の形を想像して、半透明であるが、そうより透明(または完全に透明、すなわち「見えない」)半透明で完全に透明なWindowsフォームを使用できますか?
というセクションを持つフォームをしたいのですがそれは完全に透明です(ちょっとドーナッツのような)
私は真ん中の長方形で半透明の形を想像して、半透明であるが、そうより透明(または完全に透明、すなわち「見えない」)半透明で完全に透明なWindowsフォームを使用できますか?
というセクションを持つフォームをしたいのですがそれは完全に透明です(ちょっとドーナッツのような)
VB6の場合は、this thread from VBForumsをご覧ください。
は、便宜上、私はここにコードを貼り付けています
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 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 Declare Function DeleteObject Lib "gdi32" (ByVal hObject 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 = CreateRectRgn(_
wid * 0.25, hgt * 0.25, _
wid * 0.75, hgt * 0.75)
' 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
DeleteObject combined_rgn
DeleteObject inner_rgn
DeleteObject outer_rgn
End Sub
参考:このコードには、バグがあります:border_width =(wid - ScaleWidth)/ 2 title_height = hgt - border_width - ScaleHeight。スケーラビリティと*高さをピクセルに変換する必要があります。 –
border_width =(wid - frm.ScaleX(frm.ScaleWidth、vbTwips、vbPixels))/ 2 title_height = hgt - border_width - frm.ScaleY(frm.ScaleHeight、vbTwips、vbPixels) –
VB6が持っている「サンダーフォームを。」 "Windowsフォーム"は.Net GUIウィジェットフレームワークです。ここでVB6や.Netについて聞いていますか? – Bob77