久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <i id='jIywT'><tr id='jIywT'><dt id='jIywT'><q id='jIywT'><span id='jIywT'><b id='jIywT'><form id='jIywT'><ins id='jIywT'></ins><ul id='jIywT'></ul><sub id='jIywT'></sub></form><legend id='jIywT'></legend><bdo id='jIywT'><pre id='jIywT'><center id='jIywT'></center></pre></bdo></b><th id='jIywT'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='jIywT'><tfoot id='jIywT'></tfoot><dl id='jIywT'><fieldset id='jIywT'></fieldset></dl></div>
      <bdo id='jIywT'></bdo><ul id='jIywT'></ul>
    1. <legend id='jIywT'><style id='jIywT'><dir id='jIywT'><q id='jIywT'></q></dir></style></legend>

    2. <tfoot id='jIywT'></tfoot>

      <small id='jIywT'></small><noframes id='jIywT'>

    3. 在 C++ Win32 中創建透明窗口

      Creating a transparent window in C++ Win32(在 C++ Win32 中創建透明窗口)
    4. <tfoot id='myrRe'></tfoot>

              <tbody id='myrRe'></tbody>
            1. <small id='myrRe'></small><noframes id='myrRe'>

              <i id='myrRe'><tr id='myrRe'><dt id='myrRe'><q id='myrRe'><span id='myrRe'><b id='myrRe'><form id='myrRe'><ins id='myrRe'></ins><ul id='myrRe'></ul><sub id='myrRe'></sub></form><legend id='myrRe'></legend><bdo id='myrRe'><pre id='myrRe'><center id='myrRe'></center></pre></bdo></b><th id='myrRe'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='myrRe'><tfoot id='myrRe'></tfoot><dl id='myrRe'><fieldset id='myrRe'></fieldset></dl></div>
                <bdo id='myrRe'></bdo><ul id='myrRe'></ul>
                <legend id='myrRe'><style id='myrRe'><dir id='myrRe'><q id='myrRe'></q></dir></style></legend>

                本文介紹了在 C++ Win32 中創建透明窗口的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我正在創建一個非常簡單的 Win32 C++ 應用程序,其唯一目的是僅顯示半透明的 PNG.窗口不應有任何鍍鉻,并且所有不透明度都應在 PNG 本身中控制.

                I'm creating what should be a very simple Win32 C++ app whose sole purpose it to ONLY display a semi-transparent PNG. The window shouldn't have any chrome, and all the opacity should be controlled in the PNG itself.

                我的問題是當窗口下的內容發生變化時窗口不會重新繪制,因此 PNG 的透明區域卡住"了應用程序最初啟動時窗口下的內容.

                My problem is that the window doesn't repaint when the content under the window changes, so the transparent areas of the PNG are "stuck" with what was under the window when the application was initially started.

                這是我設置新窗口的行:

                Here's the line where I setup the new window:

                hWnd = CreateWindowEx(WS_EX_TOPMOST, szWindowClass, szTitle, WS_POPUP, 0, height/2 - 20, 40, 102, NULL, NULL, hInstance, 0);
                

                對于 RegisterClassEx 的調用,我為后臺設置了這個:

                For the call to RegisterClassEx, I have this set for the background:

                wcex.hbrBackground = (HBRUSH)0;
                

                這是我的 WM_PAINT 消息處理程序:

                Here is my handler for WM_PAINT message:

                 case WM_PAINT:
                 {
                   hdc = BeginPaint(hWnd, &ps);
                   Gdiplus::Graphics graphics(hdc);
                   graphics.DrawImage(*m_pBitmap, 0, 0);
                   EndPaint(hWnd, &ps);
                   break;
                 }
                

                需要注意的一點是,應用程序始終停靠在屏幕左側并且不會移動.但是,應用程序下方的內容可能會隨著用戶打開、關閉或移動其下方的窗口而發生變化.

                One thing to note is that the application is always docked to the left of the screen and doesn't move. But, what's underneath the application may change as the user opens, closes or moves windows under it.

                當應用程序第一次啟動時,它看起來很完美.PNG 的透明(和半透明)部分完美地顯示出來.但是,當應用程序下面的背景發生變化時,背景不會更新,它只是與應用程序剛啟動時保持不變.實際上,WM_PAINT(或 WM_ERASEBKGND 在背景變化時不會被調用).

                When the application first starts, it looks perfect. The transparent (and simi-transparent) parts of the PNG show through perfectly. BUT, when the background underneath the application changes, the background DOESN'T update, it just stays the same from when the application first started. In fact, WM_PAINT (or WM_ERASEBKGND does not get called when the background changes).

                我已經玩了很長一段時間,并且已經接近 100% 正確,但還沒有完全正確.例如,我嘗試將背景設置為 (HBRUSH) NULL_BRUSH,并且嘗試處理 WM_ERASEBKGND.

                I've been playing with this for quite a while and have gotten close to getting 100% right, but not quite there. For instance, I've tried setting the background to (HBRUSH) NULL_BRUSH and I've tried handling WM_ERASEBKGND.

                當窗口下的內容發生變化時,如何讓窗口重新繪制?

                What can be done to get the window to repaint when the contents under it changes?

                推薦答案

                通過使用本系列第 1 部分和第 2 部分中的代碼,我能夠完全按照自己的意愿行事:

                I was able to do exactly what I wanted by using the code from Part 1 and Part 2 of this series:

                使用 C++ 顯示啟動畫面

                • 第 1 部分: 創建 HBITMAP 存檔
                • 第 2 部分: 顯示窗口 存檔

                那些博客文章談論的是在 Win32 C++ 中顯示啟動畫面,但這與我需要做的幾乎相同.我相信我缺少的部分是,我需要使用 UpdateLayeredWindow 函數和正確的 BLENDFUNCTION 參數.我將粘貼下面的 SetSplashImage 方法,該方法可以在上面鏈接的第 2 部分中找到:

                Those blog posts are talking about displaying a splash screen in Win32 C++, but it was almost identical to what I needed to do. I believe the part that I was missing was that instead of just painting the PNG to the window using GDI+, I needed to use the UpdateLayeredWindow function with the proper BLENDFUNCTION parameter. I'll paste the SetSplashImage method below, which can be found in Part 2 in the link above:

                void SetSplashImage(HWND hwndSplash, HBITMAP hbmpSplash)
                {
                  // get the size of the bitmap
                  BITMAP bm;
                  GetObject(hbmpSplash, sizeof(bm), &bm);
                  SIZE sizeSplash = { bm.bmWidth, bm.bmHeight };
                
                  // get the primary monitor's info
                  POINT ptZero = { 0 };
                  HMONITOR hmonPrimary = MonitorFromPoint(ptZero, MONITOR_DEFAULTTOPRIMARY);
                  MONITORINFO monitorinfo = { 0 };
                  monitorinfo.cbSize = sizeof(monitorinfo);
                  GetMonitorInfo(hmonPrimary, &monitorinfo);
                
                  // center the splash screen in the middle of the primary work area
                  const RECT & rcWork = monitorinfo.rcWork;
                  POINT ptOrigin;
                  ptOrigin.x = 0;
                  ptOrigin.y = rcWork.top + (rcWork.bottom - rcWork.top - sizeSplash.cy) / 2;
                
                  // create a memory DC holding the splash bitmap
                  HDC hdcScreen = GetDC(NULL);
                  HDC hdcMem = CreateCompatibleDC(hdcScreen);
                  HBITMAP hbmpOld = (HBITMAP) SelectObject(hdcMem, hbmpSplash);
                
                  // use the source image's alpha channel for blending
                  BLENDFUNCTION blend = { 0 };
                  blend.BlendOp = AC_SRC_OVER;
                  blend.SourceConstantAlpha = 255;
                  blend.AlphaFormat = AC_SRC_ALPHA;
                
                  // paint the window (in the right location) with the alpha-blended bitmap
                  UpdateLayeredWindow(hwndSplash, hdcScreen, &ptOrigin, &sizeSplash,
                      hdcMem, &ptZero, RGB(0, 0, 0), &blend, ULW_ALPHA);
                
                  // delete temporary objects
                  SelectObject(hdcMem, hbmpOld);
                  DeleteDC(hdcMem);
                  ReleaseDC(NULL, hdcScreen);
                }
                

                這篇關于在 C++ Win32 中創建透明窗口的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                In what ways do C++ exceptions slow down code when there are no exceptions thown?(當沒有異常時,C++ 異常會以何種方式減慢代碼速度?)
                Why catch an exception as reference-to-const?(為什么要捕獲異常作為對 const 的引用?)
                When and how should I use exception handling?(我應該何時以及如何使用異常處理?)
                Scope of exception object in C++(C++中異常對象的范圍)
                Catching exceptions from a constructor#39;s initializer list(從構造函數的初始化列表中捕獲異常)
                Difference between C++03 throw() specifier C++11 noexcept(C++03 throw() 說明符 C++11 noexcept 之間的區別)
                  <bdo id='Ye27z'></bdo><ul id='Ye27z'></ul>

                    <small id='Ye27z'></small><noframes id='Ye27z'>

                    <tfoot id='Ye27z'></tfoot>
                  1. <legend id='Ye27z'><style id='Ye27z'><dir id='Ye27z'><q id='Ye27z'></q></dir></style></legend>

                      <i id='Ye27z'><tr id='Ye27z'><dt id='Ye27z'><q id='Ye27z'><span id='Ye27z'><b id='Ye27z'><form id='Ye27z'><ins id='Ye27z'></ins><ul id='Ye27z'></ul><sub id='Ye27z'></sub></form><legend id='Ye27z'></legend><bdo id='Ye27z'><pre id='Ye27z'><center id='Ye27z'></center></pre></bdo></b><th id='Ye27z'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Ye27z'><tfoot id='Ye27z'></tfoot><dl id='Ye27z'><fieldset id='Ye27z'></fieldset></dl></div>
                        <tbody id='Ye27z'></tbody>

                        • 主站蜘蛛池模板: 91av免费 | 精品一区二区三区在线观看 | 51调教丨国产调教视频 | 91av免费在线观看 | 午夜视频网 | 国产精品一区二区在线免费观看 | 国产精品久久久国产盗摄 | 日韩av综合网 | 日韩欧美网站 | 日韩在线小视频 | 一级黄色免费看 | a毛片在线观看 | 久热在线 | 久久久天堂国产精品女人 | 欧美日韩亚洲视频 | 性巴克成人免费网站 | 欧美综合网 | 97色综合 | 在线视频成人 | 黄色大片在线播放 | 亚洲国产成人av | 三级视频在线观看 | 天天干在线观看 | 九月丁香婷婷 | 日韩欧美亚洲国产 | 免费观看一区二区 | 国产精品一区一区三区 | 一级黄色小视频 | 国产欧美日韩在线 | 操操操操操操 | 一区二区小视频 | 欧美日韩在线一区 | 亚洲天天看 | 91免费福利视频 | 一级特黄妇女高潮 | 久久精品99国产国产精 | 综合一区二区三区 | 久插视频 | 性爱免费视频 | 91亚洲国产成人精品性色 | 国产成人精品一区二区三区视频 |