Russian Qt Forum
Ноябрь 24, 2024, 04:54 *
Добро пожаловать, Гость. Пожалуйста, войдите или зарегистрируйтесь.
Вам не пришло письмо с кодом активации?

Войти
 
  Начало   Форум  WIKI (Вики)FAQ Помощь Поиск Войти Регистрация  

Страниц: [1]   Вниз
  Печать  
Автор Тема: Прозрачность формы  (Прочитано 9379 раз)
lilak
Гость
« : Ноябрь 14, 2004, 16:19 »

Спецы, подскажите!
 Как создать прозрачную форму, скажем, в VB6?
Спасибо!
Записан
lilak
Гость
« Ответ #1 : Ноябрь 24, 2004, 16:07 »

Впервые сталкиваюсь с ситуацией, когда в форуме не находится ни одного участника,могущего(желающего) помочь.
Неужели действительно никто не умеет создавать прозрачные формы!? :cry:
Записан
Athari
Гость
« Ответ #2 : Ноябрь 25, 2004, 18:17 »

А этот форум вообще живой?.. Что-то у меня чувство, что все вымерли... По крайней мере, в этом разделе.

Относительно прозрачности — во первых, есть гугл. Во-вторых, есть MSDN. Цитирую из последней (надеюсь, с английским проблем нет?):

Layered Windows

Using a layered window can significantly improve performance and visual effects for a window that has a complex shape, animates its shape, or wishes to use alpha blending effects. The system automatically composes and repaints layered windows and the windows of underlying applications. As a result, layered windows are rendered smoothly, without the flickering typical of complex window regions. In addition, layered windows can be partially translucent, that is, alpha-blended.

To create a layered window, specify the WS_EX_LAYERED extended window style when calling the CreateWindowEx function, or call the SetWindowLong function to set WS_EX_LAYERED after the window has been created. After the CreateWindowEx call, the layered window will not become visible until the SetLayeredWindowAttributes or UpdateLayeredWindow function has been called for this window. Note that WS_EX_LAYERED cannot be used for child windows.

To set the opacity level or the transparency color key for a given layered window, call SetLayeredWindowAttributes. After the call, the system may still ask the window to paint when the window is shown or resized. However, because the system stores the image of a layered window, the system will not ask the window to paint if parts of it are revealed as a result of relative window moves on the desktop. Legacy applications do not need to restructure their painting code if they want to add translucency or transparency effects for a window, because the system redirects the painting of windows that called SetLayeredWindowAttributes into off-screen memory and recomposes it to achieve the desired effect.

For faster and more efficient animation or if per-pixel alpha is needed, call UpdateLayeredWindow. UpdateLayeredWindow should be used primarily when the application must directly supply the shape and content of a layered window, without using the redirection mechanism the system provides through SetLayeredWindowAttributes. In addition, using UpdateLayeredWindow directly uses memory more efficiently, because the system does not need the additional memory required for storing the image of the redirected window. For maximum efficiency in animating windows, call UpdateLayeredWindow to change the position and the size of a layered window. Please note that after SetLayeredWindowAttributes has been called, subsequent UpdateLayeredWindow calls will fail until the layering style bit is cleared and set again.

Hit testing of a layered window is based on the shape and transparency of the window. This means that the areas of the window that are color-keyed or whose alpha value is zero will let the mouse messages through. However, if the layered window has the WS_EX_TRANSPARENT extended window style, the shape of the layered window will be ignored and the mouse events will be passed to other windows underneath the layered window.

SetLayeredWindowAttributes Function

--------------------------------------------------------------------------------

The SetLayeredWindowAttributes function sets the opacity and transparency color key of a layered window.

Syntax

BOOL SetLayeredWindowAttributes(          HWND hwnd,
    COLORREF crKey,
    BYTE bAlpha,
    DWORD dwFlags
);
Parameters

hwnd
[in] Handle to the layered window. A layered window is created by specifying WS_EX_LAYERED when creating the window with the CreateWindowEx function or by setting WS_EX_LAYERED via SetWindowLong after the window has been created.
crKey
[in] COLORREF structure that specifies the transparency color key to be used when composing the layered window. All pixels painted by the window in this color will be transparent. To generate a COLORREF, use the RGB macro.
bAlpha
[in] Alpha value used to describe the opacity of the layered window. Similar to the SourceConstantAlpha member of the BLENDFUNCTION structure. When bAlpha is 0, the window is completely transparent. When bAlpha is 255, the window is opaque.
dwFlags
[in] Specifies an action to take. This parameter can be one or more of the following values.
LWA_COLORKEY
Use crKey as the transparency color.
LWA_ALPHA
Use bAlpha to determine the opacity of the layered window.
Return Value

If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.




Remarks

Note that once SetLayeredWindowAttributes has been called for a layered window, subsequent UpdateLayeredWindow calls will fail until the layering style bit is cleared and set again.

For more information, see Using Layered Windows.

Function Information

Minimum DLL Version user32.dll
Header Declared in Winuser.h, include Windows.h
Import library User32.lib
Minimum operating systems Windows 2000

See Also

Windows Overview, Using Layered Windows, AlphaBlend, CreateWindowEx, SetWindowLong, TransparentBlt, UpdateLayeredWindow, COLORREF, RGB

--------------------------------------------------------------------------------

© 2004 Microsoft Corporation. All rights reserved.
_____________________________________________________

Лично я прозрачных форм не использовал, поэтому ничего практического посоветовать не могу. Разве что, если хочешь, чтобы форма была фигурной, есть еще SetWindowRgn (кажется), она работает под любой Windows, не только 2000 и выше. В общем, если ничего не помогает, читай справку.
Записан
Страниц: [1]   Вверх
  Печать  
 
Перейти в:  


Страница сгенерирована за 0.048 секунд. Запросов: 20.