9/27/2023 0 Comments Win32 transparent rectangleMessageBox(hWnd, _T("Hatch brush background is TRANSPARENT"), _T("Information"), MB_OK) Draw the inner rectangle using a hatch brush transparent background. End application-specific layout section. Just print the greeting string in the top left corner. Start application-specific layout section. TCHAR greeting = _T("Select your brush background.") LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) WM_DESTROY - post a quit message and return PURPOSE: Processes messages for the main window. FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM) Draw a rectangle with the specified hatch brush. Associate the hatch brush with the current device context. This displays the inner rectangle yellow background. Make the hatch brush background opaque. This displays the outer rectangle blue background. Make the hatch brush background transparent. Select the hatch brush background transparency based on user's input. HBrush = CreateHatchBrush(HatchStyleHorizontal, RGB(255, 0, 0)) Create a hatch brush that draws horizontal red lines. ![]() Draw a rectangle with blue background. Associate the brush with the display device context. HBrush = CreateSolidBrush (RGB(0, 0, 255)) VOID SetHatchBrushBackground(HDC hdc, bool transparent) transparent, the hatch brush background user's value true if transparent, false if opaque. * It makes the background of the inner rectangle transparent or opaque in function of the user's input. An inner rectangle using a hatch brush with red horizontal lines and yellow background. An outer rectangle using a solid brush with blue background. * This function creates the following rectangles: nCmdShow: the fourth parameter from WinMain hWnd: the value returned from CreateWindow hInstance: the first parameter from WinMainĬreateWindowEx(NULL, L"BUTTON", L"Transparent", WS_VISIBLE | WS_CHILD,ģ5, 35, 120, 20, hWnd, (HMENU)BTN_MYBUTTON_ID_1, NULL, NULL) ĬreateWindowEx(NULL, L"BUTTON", L"Opaque", WS_VISIBLE | WS_CHILD,ģ5, 65, 120, 20, hWnd, (HMENU)BTN_MYBUTTON_ID_2, NULL, NULL) NULL: this application does not have a menu bar 500, 100: initial size (width, length) CW_USEDEFAULT, CW_USEDEFAULT: initial position (x, y) WS_OVERLAPPEDWINDOW: the type of window to create szTitle: the text that appears in the title bar szWindowClass: the name of the application HInst = hInstance // Store instance handle in our global variable Wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION)) Wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1) Wcex.hCursor = LoadCursor(NULL, IDC_ARROW) Wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPLICATION)) LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM) Forward declarations of functions included in this code module: Static TCHAR szTitle = _T("Win32 Application Hatch Brush") The string that appears in the application's title bar. Static TCHAR szWindowClass = _T("win32app") Reference to the GDI+ static library). You can also set a hatch brush background to transparent or to opaque. The following example creates a logical brush that has the specified hatch pattern and color. However, color management is performed when the brush is selected into an ICM-enabled device context. ICM: No color is defined at brush creation. When you no longer need the brush, call the DeleteObject function to delete it. Your application can retrieve the current brush origin by calling the GetBrushOrgEx function. ![]() You can do this by calling the SetBrushOrgEx function. If an application uses a hatch brush to fill the backgrounds of both a parent and a child window with matching color, you must set the brush origin before painting the background of the child window. It can also call SetBkMode to affect the rendering of the brush. RemarksĪ brush is a bitmap that the system uses to paint the interiors of filled shapes.Īfter an application creates a brush by calling CreateHatchBrush, it can select that brush into any device context by calling the SelectObject function. If the function fails, the return value is NULL. If the function succeeds, the return value identifies a logical brush. To create a COLORREF color value, use the RGB macro. The foreground color of the brush that is used for the hatches. This parameter can be one of the following values. The CreateHatchBrush function creates a logical brush that has the specified hatch pattern and color.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |