{"id":1329,"date":"2024-08-07T08:00:00","date_gmt":"2024-08-07T00:00:00","guid":{"rendered":"http:\/\/www.wyrcad.com\/?p=1329"},"modified":"2024-08-08T08:10:27","modified_gmt":"2024-08-08T00:10:27","slug":"%e8%ae%be%e7%bd%ae%e6%9f%90%e7%aa%97%e4%bd%93%e9%80%8f%e6%98%8e","status":"publish","type":"post","link":"https:\/\/www.wyrcad.com\/?p=1329","title":{"rendered":"\u8bbe\u7f6e\u7a97\u4f53\u900f\u660e"},"content":{"rendered":"\n<p>&#8216;\u5982\u4e0b\u4e24\u4e2a\u7a97\u4f53\u5747\u4e3a\u900f\u660e\uff0c\u5373\uff0c\u53ef\u4ee5\u770b\u5230\u5176\u540e\u7684\u5c4f\u5e55\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"963\" height=\"775\" src=\"https:\/\/www.wyrcad.com\/wp-content\/uploads\/2024\/07\/Transparent.jpg\" alt=\"\" class=\"wp-image-1330\" srcset=\"https:\/\/www.wyrcad.com\/wp-content\/uploads\/2024\/07\/Transparent.jpg 963w, https:\/\/www.wyrcad.com\/wp-content\/uploads\/2024\/07\/Transparent-300x241.jpg 300w, https:\/\/www.wyrcad.com\/wp-content\/uploads\/2024\/07\/Transparent-768x618.jpg 768w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n\n\n\n<p>Option Explicit<\/p>\n\n\n\n<p>\u2018Example<br>\u2018Call Translucent(Me.hwnd)\u2019\u8bbe\u7f6e\u5f53\u524d\u7a97\u4f53\u534a\u900f\u660e<br>\u2018Translucent oAutoCAD.hwnd\u2019\u8bbe\u7f6e\u5df2\u7ed1\u5b9a\u7684 AutoCAD \u534a\u900f\u660e<\/p>\n\n\n\n<p>Private Declare Function GetWindowLong Lib \u201cuser32.dll\u201d Alias \u201cGetWindowLongA\u201d (ByVal hwnd As Long, ByVal nIndex As Long) As Long<br>Private Declare Function SetWindowLong Lib \u201cuser32\u201d Alias \u201cSetWindowLongA\u201d (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long<br>Private Declare Function SetLayeredWindowAttributes Lib \u201cuser32\u201d (ByVal hwnd As Long, ByVal CrKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long<\/p>\n\n\n\n<p>Private Const WS_EX_LAYERED = &amp;H80000<br>Private Const GWL_EXSTYLE As Long = -20<br>Private Const LWA_ALPHA = &amp;H2<br>Private Const LWA_COLORKEY = &amp;H1<\/p>\n\n\n\n<p>\u2018hWnd\u662f\u900f\u660e\u7a97\u4f53\u7684\u53e5\u67c4<br>\u2018crKey\u4e3a\u63a9\u7801\u7684\u989c\u8272,\u53ef\u4ee5\u7528RGB(r,g,b)\u6765\u6307\u5b9a<br>\u2018bAlpha\u662f\u4e0d\u900f\u660e\u5ea6,\u53d6\u503c\u8303\u56f4\u662f\uff080,255\uff09,\u5176\u4e2d0\u4ee3\u8868\u5168\u900f\u660e,255\u4ee3\u8868\u4e0d\u900f\u660e<br>\u2018dwFlags\u662f\u900f\u660e\u65b9\u5f0f,\u4e09\u79cd\u53d6\u503c\u65b9\u5f0f:<br>\u2018LWA_ALPHA\u65f6,crKey\u53c2\u6570\u65e0\u6548,bAlpha\u53c2\u6570\u6709\u6548<br>\u2018LWA_COLORKEY\u65f6,\u989c\u8272\u4e3acrKey\u7684\u5730\u65b9\u53d8\u4e3a\u900f\u660e,bAlpha\u53c2\u6570\u65e0\u6548<br>\u2018LWA_ALPHA Or LWA_COLORKEY\u65f6,crKey\u7684\u5730\u65b9\u5c06\u53d8\u4e3a\u5168\u900f\u660e,\u5176\u5b83\u5730\u65b9\u6839\u636ebAlpha\u53c2\u6570\u786e\u5b9a\u900f\u660e\u5ea6<br>Public Sub Translucent(ByVal hwnd As Long)<br>On Error Resume Next<br>SetWindowLong hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) Or WS_EX_LAYERED<br>SetLayeredWindowAttributes hwnd, RGB(255, 255, 255), 128, LWA_ALPHA<br>On Error GoTo 0<br>End Sub<\/p>\n\n\n\n<p>Public Sub NoTranslucent(ByVal hwnd As Long)<br>On Error Resume Next<br>SetWindowLong hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) Or WS_EX_LAYERED<br>SetLayeredWindowAttributes hwnd, RGB(255, 255, 255), 255, LWA_ALPHA<br>On Error GoTo 0<br>End Sub<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8216;\u5982\u4e0b\u4e24\u4e2a\u7a97\u4f53\u5747\u4e3a\u900f\u660e\uff0c\u5373\uff0c\u53ef\u4ee5\u770b\u5230\u5176\u540e\u7684\u5c4f\u5e55\u3002 Option Explicit \u2018Example &hellip; <a href=\"https:\/\/www.wyrcad.com\/?p=1329\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201c\u8bbe\u7f6e\u7a97\u4f53\u900f\u660e\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[24,17],"class_list":["post-1329","post","type-post","status-publish","format-standard","hentry","category-bianchengyuandi","tag-vb","tag-biancheng"],"_links":{"self":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts\/1329","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1329"}],"version-history":[{"count":4,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts\/1329\/revisions"}],"predecessor-version":[{"id":1507,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts\/1329\/revisions\/1507"}],"wp:attachment":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1329"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1329"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1329"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}