November 29, 2022, 07:58:40 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Window transparency

Started by ExMember001, October 14, 2007, 01:06:11 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ExMember001

Here's a Quick example to make a window transparent and fade it in or out
Open the project file in the zip below to compile


//WindowEx functions by krypt 2007

declare import,SetLayeredWindowAttributes(Unsigned int hwnd,POINTER crKey,INT bAlpha,Unsigned INT dwFlags),INT;
import int SetWindowLongA(uint hwnd,int nIndex,uint dwNewLong);
declare import,GetWindowLong alias GetWindowLongA(Unsigned int hWnd,int nIndex),int;
declare import,RedrawWindow(Unsigned int hWnd, POINTER lprcUpdate, POINTER hrgnUpdate,Unsigned int flags),INT;

#define LWA_ALPHA               0x00000002
#define WS_EX_LAYERED           0x00080000
#define GWL_EXSTYLE             (-20)

//RedrawWindow() flags
#define RDW_INVALIDATE          0x0001
#define RDW_ERASE               0x0004
#define RDW_ALLCHILDREN         0x0080
#define RDW_FRAME               0x0400

Global sub AlphaActivate(Cwindow *mywin, int value)
{
if value = true
{
SetWindowLongA(mywin->m_hwnd, GWL_EXSTYLE,
            GetWindowLong(mywin->m_hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
}
else if value = false
{
SetWindowLongA(mywin->m_hwnd, GWL_EXSTYLE,
            GetWindowLong(mywin->m_hwnd, GWL_EXSTYLE) & ~WS_EX_LAYERED);
RedrawWindow(mywin->m_hwnd, NULL, NULL, RDW_ERASE|RDW_INVALIDATE|RDW_FRAME|RDW_ALLCHILDREN);
}
return;
}

Global sub SetAlphaValue(Cwindow *mywin, int value)
{
SetLayeredWindowAttributes(mywin->m_hwnd, 0, (255 * value) / 100, LWA_ALPHA);
return;
}