Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 如何使窗口不透明?_C_Windows_Windows Ce - Fatal编程技术网

C 如何使窗口不透明?

C 如何使窗口不透明?,c,windows,windows-ce,C,Windows,Windows Ce,我想使父窗口为非透明,RGB值为(99,99,99)?以前我的窗口是透明的,但现在我需要将窗口设置为非透明 下面提到的是与我的父窗口相关的功能: ATOM MyRegisterClass(HINSTANCE hInstance) { LogEntry(L"Entered in myRegisterClass Function"); WNDCLASS CLASS_NAME_ONE_SEG_APP; CLASS_NAME_ONE_SEG_APP.cbClsExtra = 0

我想使父窗口为非透明,RGB值为(99,99,99)?以前我的窗口是透明的,但现在我需要将窗口设置为非透明

下面提到的是与我的父窗口相关的功能:

ATOM MyRegisterClass(HINSTANCE hInstance)
{
    LogEntry(L"Entered in myRegisterClass Function");

    WNDCLASS CLASS_NAME_ONE_SEG_APP;
    CLASS_NAME_ONE_SEG_APP.cbClsExtra = 0;
    CLASS_NAME_ONE_SEG_APP.cbWndExtra = 0;
    CLASS_NAME_ONE_SEG_APP.hbrBackground = 0;
    CLASS_NAME_ONE_SEG_APP.hCursor = 0;
    CLASS_NAME_ONE_SEG_APP.hIcon = 0;
    CLASS_NAME_ONE_SEG_APP.hInstance = hInstance;
    CLASS_NAME_ONE_SEG_APP.lpfnWndProc =  (WNDPROC) WndProc;
    CLASS_NAME_ONE_SEG_APP.lpszClassName = className;
    CLASS_NAME_ONE_SEG_APP.lpszMenuName = 0;
    CLASS_NAME_ONE_SEG_APP.style = 0;

    LogEntry(L"Exiting from myRegisterClass Function");

    return RegisterClass(&CLASS_NAME_ONE_SEG_APP); 
}
下面提到的是一个InitInstance函数,我在其中创建父窗口

handles.parent是我的父窗口。

bool WINAPI InitInstance(HINSTANCE hInstance, int nCmdShow)
{
    LogEntry(L"Entered in InitInstance Function");
    handles.parent = CreateWindowEx(0,
                                    className,
                                    windowName, 
                                    WS_VISIBLE | WS_POPUP,
                                    0, 0, 
                                    coordinates.width, coordinates.height,
                                    NULL, 
                                    NULL, 
                                    hInstance, 
                                    NULL);

    if(handles.parent == NULL)
    {
        LogValue(L"Cannot Create Parent Window"
            L"\nInitInstance Function terminated abnormally");
        return false;
    }
    else
    {
        UpdateWindow(handles.parent);
        ShowWindow(handles.parent, nCmdShow);
        LogEntry(L"Exiting from InitInstance Function");
        return true;
    }
}
下面提到的是WM_PAINT的一个功能:

case WM_PAINT:
        LogEntry(L"Entred in WM_PAINT");
        PaintWindow(); 
        SetFocus(handles.parent);
        LogEntry(L"Exited from WM_PAINT");
        break;
此油漆窗口执行以下操作

void PaintWindow()
{
    LogEntry(L"Entered in PaintWindow Function");
    HWND *handle = &handles.volUp;

    //Paint Buttons on the window
    for(register char i =  MIN_BUTTON; i <= MAX_BUTTON; i++)
    {
        PaintButton( (INITIAL_BUTTON + i) , *handle, btns, i);
        handle++;
    }

    //Paint the AXIS_VOL_ON_OFF Button According to its Status
    if(volumeStatus.status == VOLUME_ON)
        PaintButton(IDB_BTN_VOL_OFF, handles.volOnOff, btns, AXIS_VOL_ON_OFF);
    else if(volumeStatus.status = VOLUME_MUTE)
        PaintButton(IDB_BTN_VOL_ON, handles.volOnOff, btns, AXIS_VOL_ON_OFF);

    //Paint Images on the window
    if(handles.screenMode == SCREEN_MODE_OPERATION)
        InsertImages();

    LogEntry(L"Exited from PaintWindow Function");
}
void PaintWindow()
{
日志输入(L“在油漆窗口功能中输入”);
HWND*handle=&handles.volUp;
//在窗户上画按钮

对于(register char i=MIN_BUTTON;i你需要给你的类一个非空的背景笔刷

  CLASS_NAME_ONE_SEG_APP.hbrBackground = CreateSolidBrush(RGB((99,99,99));
在WindowProc中,您需要确保将WM_ERASEBKGND消息传递给DefWindowProc(这部分可能已经发生)

后来 好的,你的WM_PAINT代码做了一些错误的事情。当你处理WM_PAINT消息时,调用和
EndPaint
是很重要的,并且你必须使用从绘制开始时获得的HDC

case WM_PAINT:
    {
    LogEntry(L"Entred in WM_PAINT");

    PAINTSTRUCT ps;
    HDC hdc = BeginPaint(&ps);
    PaintWindow(hdc); 
    EndPaint(hwnd, &ps);

    LogEntry(L"Exited from WM_PAINT");
    }  
    break;
您的窗口是透明的,因为您从不在WM_PAINT处理程序中调用BeginPaint,所以您永远不会在屏幕上绘制任何东西


有关更完整的示例,请参见。

您需要为类提供一个非空的背景笔刷

  CLASS_NAME_ONE_SEG_APP.hbrBackground = CreateSolidBrush(RGB((99,99,99));
在WindowProc中,您需要确保将WM_ERASEBKGND消息传递给DefWindowProc(这部分可能已经发生)

后来 好的,你的WM_PAINT代码做了一些错误的事情。当你处理WM_PAINT消息时,调用和
EndPaint
是很重要的,并且你必须使用从绘制开始时获得的HDC

case WM_PAINT:
    {
    LogEntry(L"Entred in WM_PAINT");

    PAINTSTRUCT ps;
    HDC hdc = BeginPaint(&ps);
    PaintWindow(hdc); 
    EndPaint(hwnd, &ps);

    LogEntry(L"Exited from WM_PAINT");
    }  
    break;
您的窗口是透明的,因为您从不在WM_PAINT处理程序中调用BeginPaint,所以您永远不会在屏幕上绘制任何东西


请参阅以获取更完整的示例。

我尝试过使用CreateSolidBrush,但仍然得到了透明窗口。问题在于您的WndProc代码中,请向我们展示您用于WM_PAINT的代码,WM_橡皮擦BKGNDI添加了WM_PAINT详细信息。我没有使用WM_橡皮擦BKGNDI尝试过使用CreateSolidBrush,但我仍然得到transpa出租窗口。问题在于你的WndProc代码,那么,给我们看看你用于WM_PAINT和WM_ERASEBKGNDI的代码,它添加了WM_PAINT的详细信息。我没有使用WM_ERASEBKGNDUpdateWindow(),它在这里没有任何用处。Charles Petzold教大家这样做,但这完全没有必要。UpdateWindow()查尔斯·佩佐尔德教过每个人这样做,但这完全没有必要。