我有一个问题,黄色对象在我的应用程序中的多个vb6表单上“点击”: 我可以想到的唯一可能影响它的是以下(从VBForums开始,我用来使青色元素透明,就像你在图像中看到的那样,但是这对
我可以想到的唯一可能影响它的是以下(从VBForums开始,我用来使青色元素透明,就像你在图像中看到的那样,但是这对vbYellow没有任何影响.
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 SetLayeredWindowAttributes Lib "user32" ( _ ByVal hwnd As Long, _ ByVal crKey As Long, _ ByVal bAlpha As Byte, _ ByVal dwFlags As Long) As Long Private Const GWL_STYLE = (-16) Private Const GWL_EXSTYLE = (-20) Private Const WS_EX_LAYERED = &H80000 Private Const LWA_COLORKEY = &H1 Private Const LWA_ALPHA = &H2 Private Sub Form_Load() Me.BackColor = vbCyan SetWindowLong Me.hwnd, GWL_EXSTYLE, GetWindowLong(Me.hwnd, GWL_EXSTYLE) Or WS_EX_LAYERED SetLayeredWindowAttributes Me.hwnd, vbCyan, 0&, LWA_COLORKEY End Sub
我试图用相同颜色的图像替换vbYellow形状.这也有点击功能,但最终会得到相同的结果,甚至不会触发任何设置的点击功能.
我认为问题在于VB6 / Win32有时会使用不同的颜色代码.有时只需从#RRGGBB(RGB)切换到#BBGGRR(BGR).选择黄色的好颜色是洋红色,#FF00FF,因为无论是否切换红色和蓝色成分,此颜色都会起作用.
然后可以直接使用vbMagenta而不会出现问题.