Can't set transparent bg with SetLayeredWindowAttributes

agolangf · · 371 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hi coders, I am using Golang with WinApi wrappers in an attempt to make the background window of my program see-through.</p> <p>In this program I make a window with WinMain and set its background color to black at line 87. I make it always on top at line 55 and that works fine. What doesn&#39;t work is line 57 where I try to key out the black background and get the error &#34;the parameter is incorrect&#34;</p> <p>I have a pastebin here to my code <a href="https://pastebin.com/1qHVTA46" rel="nofollow">https://pastebin.com/1qHVTA46</a></p> <p>here&#39;s the output I get in my console</p> <pre><code>myHWND 16124426 SetLayered r0: 0 SetLayered r1: 0 SetLayered r2: The parameter is incorrect. Last Error: 0 </code></pre> <p>What about my parameters are incorrect? I&#39;ve been at this for a little over an hour and appreciate your consideration! I have seen the api at <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms633540(v=vs.85).aspx" rel="nofollow">https://msdn.microsoft.com/en-us/library/windows/desktop/ms633540(v=vs.85).aspx</a></p> <p>p.s. ccolorref is just a dword, which is a uint32 in golang, it can&#39;t be that causing the issue ,can it?</p> <hr/>**评论:**<br/><br/>JHunz: <pre><p>WS_EX_LAYERED is an extended style control value - it needs to be set in the first parameter of CreateWindowEx, not the fourth.</p></pre>69beards: <pre><p>wonderful! works great! bless you &lt;3 <a href="https://i.imgur.com/QC3MuK2.png" rel="nofollow">https://i.imgur.com/QC3MuK2.png</a> I&#39;m gonna go ahead and try drawing using <a href="https://github.com/gonutz/d3d9" rel="nofollow">https://github.com/gonutz/d3d9</a></p> <p>the vectors drawn shouldn&#39;t be invisible too I hope</p></pre>JHunz: <pre><p>No problem, man. I think the vectors shouldn&#39;t be invisible unless you&#39;re drawing them blue, if I&#39;m interpreting everything correctly.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

371 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传