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

  1. <small id='2xZ4M'></small><noframes id='2xZ4M'>

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

    1. <legend id='2xZ4M'><style id='2xZ4M'><dir id='2xZ4M'><q id='2xZ4M'></q></dir></style></legend>

    2. <tfoot id='2xZ4M'></tfoot>
        <bdo id='2xZ4M'></bdo><ul id='2xZ4M'></ul>
    3. 使用 C++ 靜態控制背景顏色

      Static Control Background Color with C++(使用 C++ 靜態控制背景顏色)

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

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

            <legend id='MD0dC'><style id='MD0dC'><dir id='MD0dC'><q id='MD0dC'></q></dir></style></legend>

              <bdo id='MD0dC'></bdo><ul id='MD0dC'></ul>
              • <tfoot id='MD0dC'></tfoot>
              • 本文介紹了使用 C++ 靜態控制背景顏色的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我正在使用 Windows API 創建一個基本的 GUI,但我遇到了一個問題.它從一個主窗口開始,該窗口以我設置的自定義背景顏色打開 (RGB(230,230,230)).然后用靜態控件在左上角顯示文本.

                I am creating a basic GUI with the Windows API and I have run into an issue. It starts with a main window that opens with a custom background color I set (RGB(230,230,230)). It then displays text in the upper left corner with the static control.

                settingstext = CreateWindow("STATIC",
                                             "SETTINGS",
                                             SS_LEFT | WS_CHILD,
                                             12,
                                             20,
                                             100,
                                             20,
                                             hwnd,
                                             NULL,
                                             proginstance,
                                             NULL);
                ShowWindow(settingstext, 1);
                

                這是可行的,但是當顯示文本時,我需要一種方法來更改它的背景以匹配主窗口,否則它看起來就像沒有融合在一起.

                This works, but when the text is displayed I need a way to change the background of it to match the main window or else it just looks like it doesn't blend in.

                我的問題是,我該怎么做?我目前使用下面的方法并且它有效,但我想知道,有沒有辦法在靜態控件的 CreateWindow 函數之后以某種方式永久設置背景顏色,而無需更改系統顏色,以及只需將它應用于那個控件,而不是任何發送 WM_CTLCOLORSTATIC 消息的控件.我已經嘗試在消息循環之外使用 GetDC 函數和 SetBkColor 函數,但沒有任何效果.

                My question is, how do I do this? I currently use the method below and it works, but I wanted to know, is there a way to permanently set the background color somehow, right after the CreateWindow function for the static control without changing system colors, and just have it apply to that one control and not anything that sends the WM_CTLCOLORSTATIC message. I have experimented around with using the GetDC function and SetBkColor function outside of the message loop but nothing works.

                    case WM_CTLCOLORSTATIC:
                    {
                    HDC hdcStatic = (HDC) wParam;
                    SetTextColor(hdcStatic, RGB(0,0,0));
                    SetBkColor(hdcStatic, RGB(230,230,230));
                    return (INT_PTR)CreateSolidBrush(RGB(230,230,230));
                    }
                

                我想這樣做是因為...

                I want to do this because...

                • 我不想用每次窗口重繪時都需要調用的函數填滿我的消息循環.
                • 讓更改僅應用于此靜態控件.

                我將非常感謝可以提供的任何幫助,至少為我指明正確的方向,謝謝.

                I would be very thankful for any help that could be provided, at least pointing me in the right direction, thanks.

                推薦答案

                對于靜態文本控件,沒有永久的方法來設置文本顏色或其背景.即使您想將更改應用于單個靜態控件;您仍然需要在即將繪制控件時在父 dlgproc 中處理 WM_CTLCOLORSTATIC 通知消息.

                For static text controls there's no permanent way to set the text color or their background. Even if you want to apply the changes to a single static control; you would still have to handle WM_CTLCOLORSTATIC notification message in parent dlgproc just when the control is about to be drawn.

                這是由于 DefWindowProc 每次處理 WM_CTLCOLORSTATIC 時都會覆蓋您對設備上下文的更改,如 MSDN:

                This is due to the DefWindowProc overwriting your changes to the device context each time it handles WM_CTLCOLORSTATIC as stated in the MSDN:

                默認情況下,DefWindowProc 函數為靜態控件選擇默認系統顏色.

                By default, the DefWindowProc function selects the default system colors for the static control.

                static HBRUSH hBrush = CreateSolidBrush(RGB(230,230,230));
                
                case WM_CTLCOLORSTATIC:
                {
                    if (settingstext == (HWND)lParam)
                
                              //OR if the handle is unavailable to you, get ctrl ID
                
                    DWORD CtrlID = GetDlgCtrlID((HWND)lParam); //Window Control ID
                    if (CtrlID == IDC_STATIC1) //If desired control
                    {
                       HDC hdcStatic = (HDC) wParam;
                       SetTextColor(hdcStatic, RGB(0,0,0));
                       SetBkColor(hdcStatic, RGB(230,230,230));
                       return (INT_PTR)hBrush;
                    }
                }
                

                如果您想讓控件的背景在父對話框上透明,您可以使用 SetBkMode(hdcStatic, TRANSPARENT).

                If you're looking to make the control's background transparent over a parent dialog you could use SetBkMode(hdcStatic, TRANSPARENT).

                這篇關于使用 C++ 靜態控制背景顏色的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 之間的區別)
                1. <small id='JxjTl'></small><noframes id='JxjTl'>

                    <tbody id='JxjTl'></tbody>

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

                        1. 主站蜘蛛池模板: 国产精品大全 | 91超碰在线 | 久久夜视频 | 久久久国产一区 | 久久国产精品网 | 国产精品99久久久久久久久久久久 | 欧美久久久久久久久 | 国产精品无码永久免费888 | 日韩视频一级 | 国产精品视频久久久久 | 午夜免费观看体验区 | 久久国产欧美日韩精品 | 一区二区免费在线观看 | 91精品久久久久久久99 | 成人中文字幕在线观看 | 久久久精彩视频 | 黄色片av | 91n成人 | 欧美高清视频 | 国产乱码精品1区2区3区 | 成人免费在线播放视频 | 精品久久1 | 国产露脸国语对白在线 | 久久aⅴ乱码一区二区三区 91综合网 | 97精品超碰一区二区三区 | 男女那个视频 | 国产精品久久久久久久久久妞妞 | 色999视频 | 欧美日韩亚洲国产 | 精品一二三区视频 | 成人免费黄视频 | 激情五月综合 | 日韩欧美二区 | 成人免费观看网站 | 一区二区视频在线 | 久久久久久久久久久久久九 | 在线观看国产网站 | 久久久久国产一区二区三区四区 | 伊人成人免费视频 | 亚洲免费一区 | 久久久久国产一区二区三区四区 |