The MASM Forum

General => The Campus => Topic started by: mabdelouahab on October 24, 2013, 12:16:15 PM

Title: Help Plz
Post by: mabdelouahab on October 24, 2013, 12:16:15 PM
Hi;
I want to draw a shape transparent
I created the following procedure

CreateDraw proc hwnd:DWORD, x:DWORD, y:DWORD
LOCAL xySize:sxySIZE
LOCAL cxA:DWORD
LOCAL cyA:DWORD
LOCAL ghWndMain:HWND
LOCAL hdc:DWORD
LOCAL bitmap:DWORD
LOCAL memDC:DWORD
LOCAL aV:DWORD
LOCAL nV:DWORD
LOCAL graph:PVOID
LOCAL pen2:PVOID         
LOCAL blend:BLENDFUNCTION         
   

mov eax, x
mov cxA, eax
mov xySize.dWidth, eax

mov eax, y
mov cyA, eax
mov xySize.dHeight, eax

mov eax, hwnd
mov ghWndMain, eax


   invoke   GetWindowLong,ghWndMain,GWL_EXSTYLE
      or   eax,WS_EX_LAYERED
   invoke   SetWindowLong,ghWndMain,GWL_EXSTYLE,eax

   invoke GetDC,ghWndMain
   mov hdc,eax   

   invoke CreateCompatibleBitmap,hdc, cxA, cyA
   mov bitmap,eax   

   invoke CreateCompatibleDC,hdc
   mov memDC,eax   
   
   invoke SelectObject,memDC, bitmap;,hdc
   invoke ReleaseDC,ghWndMain, hdc;,hdc

   invoke GdipCreateFromHDC,memDC,ADDR graph
   invoke GdipGraphicsClear,graph,0

   For_ nV=0 To cyA
      invoke division,nV,cyA
      invoke Multipl,eax,255
       invoke GdipCreatePen1,ARGB1(100,0,0,0),FP4(0.1), UnitWorld, ADDR pen2
      invoke GdipDrawLineI,graph, pen2, 0, nV, cxA, nV
   Next


   mov blend.BlendOp,AC_SRC_OVER;
        mov blend.BlendFlags , 0;
        mov blend.AlphaFormat,AC_SRC_ALPHA;
        mov blend.SourceConstantAlpha, 190;

      invoke UpdateLayeredWindow,ghWndMain, hdc, NULL,addr xySize, memDC,addr ptZero, 0,addr blend, ULW_ALPHA;


CreateDraw endp

...............

WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
   LOCAL wc:WNDCLASSEX
   LOCAL msg:MSG
   LOCAL hwnd:HWND
LOCAL gsi:GdiplusStartupInput
LOCAL gtkn:PULONG

   mov gsi.GdiplusVersion,1
   mov gsi.DebugEventCallback,0
   mov gsi.SuppressBackgroundThread,0
   mov gsi.SuppressExternalCodecs,0
   invoke GdiplusStartup,ADDR gtkn,ADDR gsi,0
   
   mov   wc.cbSize,SIZEOF WNDCLASSEX
   mov   wc.style, CS_HREDRAW or CS_VREDRAW   ; or CS_BYTEALIGNWINDOW
   mov   wc.lpfnWndProc, OFFSET WndProc
   mov   wc.cbClsExtra,NULL
   mov   wc.cbWndExtra,SIZEOF WND_DATA
   push  hInstance
   pop   wc.hInstance
   mov   wc.hbrBackground,COLOR_BTNFACE+1
   mov   wc.lpszMenuName,NULL
   mov   wc.lpszClassName,OFFSET ClassName
   invoke LoadIcon,NULL,IDI_APPLICATION
   mov   wc.hIcon,eax
   mov   wc.hIconSm,eax
   invoke LoadCursor,NULL,IDC_ARROW
   mov   wc.hCursor,eax
   
   invoke RegisterClassEx, addr wc; or  or

   INVOKE CreateWindowEx,WS_EX_LAYERED,\
         ADDR ClassName,ADDR AppName,\
               NULL,CW_USEDEFAULT,\
              CW_USEDEFAULT ,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,\
              hInst,NULL

   mov   hwnd,eax


   invoke ShowWindow, hwnd,SW_SHOWNORMAL
   invoke UpdateWindow, hwnd
   
   .WHILE TRUE
      invoke GetMessage, ADDR msg,NULL,0,0
      .BREAK .IF (!eax)
      invoke TranslateMessage, ADDR msg
      invoke DispatchMessage, ADDR msg
   .ENDW
   
   mov     eax,msg.wParam
   ret
WinMain endp
......


   .ELSEIF uMsg==WM_CREATE
               invoke CreateDraw,hWnd,100,100
......

I got the error contained in Attachments
result...Error

Thank you for your help...
Title: Re: Help Plz
Post by: dedndave on October 24, 2013, 12:28:26 PM
i can't read French   :P
you should be able to use Ctrl-C to copy the text (the messagebox must have focus)
then paste it to the forum reply window

use "code" tags around code - see the # icon above the reply window
also - the Campus sub-forum is a better place to post this kind of question

that's a lot of code to draw a box (or whatever it makes)
and - shouldn't need to use GDI+, normal GDI MoveToEx and LineTo functions should work
there are also Rect and other functions to draw different shapes with a selected pen

as for being transparent - i take it you mean that the background is untouched ?
or - do you mean alpha blend (opacity)

if you draw a line - the surrounding background is not affected
maybe you can google a picture that is similar to what you want to do
Title: Re: Help Plz
Post by: jj2007 on October 24, 2013, 04:30:11 PM
Quote from: dedndave on October 24, 2013, 12:28:26 PM
i can't read French   :P

"The memory could not be read" - he got an exception...

mabdelouahab,

First things first: Welcome to the Forum :icon14:

You should zip your code, including specific rc and inc files, and post it here. The bug should be easy to find with Olly, but without the code it's not possible.
Title: Re: Help Plz
Post by: Farabi on October 24, 2013, 08:36:25 PM
I used to be get used to Graphics, but for GDI+ Im not good with it. Telling him about the formula to make a transparent pixel would be an overkill for a newbie. I guess I remain silent.  :icon_mrgreen:
Title: Re: Help Plz
Post by: mabdelouahab on October 24, 2013, 08:40:08 PM
Thank you  for all

I'm not the best English Language, Sorry

I've modified the code
The procedure is called after the button is pressed
I have added other action but I have two problems:
1. Transparency does not extend behind then Main Form background, is applicable only in background, I want her to come out to the Desktop
2. I could not hide the Caption and Border of the Form

https://drive.google.com/file/d/0B5q3H3sB5u6QZXA3OXZEWFBtYnc/edit?usp=sharing

The program Zip in Attachment
Thank you for your help
Title: Re: Help Plz
Post by: avcaballero on October 24, 2013, 09:03:10 PM
Hello, I did something like that here (http://www.abreojosensamblador.net/Productos/AOWG/html/Pags_en/Chap02.html#Transparencias), just in TinyC for the moment you'd better to download the source code and try to compile it...  :P
Title: Re: Help Plz
Post by: jj2007 on October 24, 2013, 09:13:14 PM
This will avoid the crash:

      invoke UpdateLayeredWindow,ghWndMain, hdc, NULL,addr xySize, memDC,addr ptZero, 0,addr blend, ULW_ALPHA
   ret

CreateDraw endp


You can shorten the top of your code a bit:

include \masm32\MasmBasic\MasmBasic.inc
uselib gdiplus

CreateDraw                         PROTO   :DWORD,:DWORD,:DWORD
...


All the .model etc stuff is already done in MasmBasic.inc, except the gdiplus library. The Masm32 uselib macro takes care of that.

Nice work :t
Title: Re: Help Plz
Post by: mabdelouahab on October 24, 2013, 10:03:51 PM
Thank  :biggrin: avcaballero ...
Not what I'm looking for
I'm looking for transparency with the desktop
https://drive.google.com/file/d/0B5q3H3sB5u6QbC0xc1Exa1VCZzA/edit?usp=sharing
Title: Re: Help Plz
Post by: mabdelouahab on October 24, 2013, 10:15:22 PM
Thank jj2007  :t
I corrected the error message  :biggrin:
But I can not find the result that search for it  :(
I'm looking for transparency with the desktop

https://drive.google.com/file/d/0B5q3H3sB5u6QNEVxb25KaUxMNnM/edit?usp=sharing

Upon checking I find that transparency is only available with a black background molds

I also want to hide the Border and then Caption bar of the form
Title: Re: Help Plz
Post by: GoneFishing on October 24, 2013, 10:28:11 PM
Quote from: mabdelouahab on October 24, 2013, 10:15:22 PM
I also want to hide the Border and then Caption bar of the form

Maybe  this example (http://masm32.com/board/index.php?topic=2399.msg24943#msg24943) (see screenshot)
will show you the way. It was included in the previous MASM32 package.

Also see the splashscreen example in \MASM32\examples\exampl01\splash folder
Title: Re: Help Plz
Post by: Gunther on October 25, 2013, 05:12:43 AM
Hi mabdelouahab,

welcome to the forum. Good work.

Gunther
Title: Re: Help Plz
Post by: qWord on October 25, 2013, 10:29:43 AM
If per-pixel alpha values are needed, only the function UpdateLayeredWindow() must be called and WM_PAINT is gone out of use (if the window content or it's size has changed, the function must be called again). Unfortunately it seems that such windows can't have controls. Furthermore invisible pixels (alpha=0) are mouse-hit-transparent. The window region could be changed using SetWindowReg()**, if wished (the example use WS_EX_TOOLWINDOW to get a rectangular window region).
In the attachment a small example based on the above code, which shows a red point that can be drag with the mouse (close = right mouse button).
include \masm32\include\masm32rt.inc
include gdiplus.inc
includelib gdiplus.lib
.686
.mmx
.xmm

CreateDraw PROTO    :HWND
WinMain proto :DWORD,:DWORD,:DWORD,:DWORD


ARGB1 MACRO alpha, red, green, blue
  EXITM % (alpha SHL 24) OR (red SHL 16) OR (green SHL 8) OR blue
ENDM

.data
    ClassName db "MainWinClass",0
    AppName  db "Main Window",0
.data?
    g_hInstance HINSTANCE ?
    ptZero POINT <>
.code
main proc
LOCAL CommandLine:LPSTR

    invoke GetModuleHandle, NULL
    mov    g_hInstance,eax
    invoke GetCommandLine
    mov    CommandLine,eax
    invoke WinMain, g_hInstance,NULL,CommandLine, SW_SHOWDEFAULT
    invoke ExitProcess,eax
   
main endp

CreateDraw proc hwnd:DWORD
LOCAL hdc:HDC,memDC:HDC
LOCAL bitmap:PVOID
LOCAL hBmp:HBITMAP
LOCAL graphics:PVOID,path:PVOID,brush:PVOID
LOCAL blend:BLENDFUNCTION
LOCAL rect:RECT
LOCAL color:DWORD,count:DWORD

    mov hdc,rv(GetDC,0)   

    invoke GetWindowRect,hwnd,ADDR rect
    mov edx,rect.right
    mov ecx,rect.bottom
    sub edx,rect.left
    sub ecx,rect.top
    add edx,1
    add ecx,1
    mov rect.right,edx
    mov rect.bottom,ecx
   
    invoke GdipCreateBitmapFromScan0,rect.right,rect.bottom,0,PixelFormat32bppPARGB,0,ADDR bitmap
    invoke GdipGetImageGraphicsContext,bitmap,ADDR graphics
    invoke GdipGraphicsClear,graphics,ARGB1(0,0,0,0)
   
   
    invoke GdipCreatePath,FillModeAlternate,ADDR path
    invoke GdipAddPathEllipseI,path,0,0,rect.right,rect.bottom
    invoke GdipCreatePathGradientFromPath,path,ADDR brush
    invoke GdipSetPathGradientCenterColor,brush,ARGB1(210,255,0,0)
    mov count,1
    mov color,ARGB1(0,255,0,0)
    invoke GdipSetPathGradientSurroundColorsWithCount,brush,ADDR color,ADDR count
    invoke GdipFillEllipseI,graphics,brush,0,0,rect.right,rect.bottom
    invoke GdipDeleteBrush,brush
    invoke GdipDeletePath,path
   
    mov blend.BlendOp,AC_SRC_OVER
    mov blend.BlendFlags , 0
    mov blend.AlphaFormat,AC_SRC_ALPHA
    mov blend.SourceConstantAlpha, 255
   
    mov memDC,rv(CreateCompatibleDC,hdc)
    invoke GdipCreateHBITMAPFromBitmap,bitmap,ADDR hBmp,0
    mov hBmp,rv(SelectObject,memDC,hBmp)

    invoke UpdateLayeredWindow,hwnd,0,ADDR rect,ADDR rect.right, memDC,addr ptZero, 0,addr blend, ULW_ALPHA
    invoke DeleteObject,rv(SelectObject,memDC,hBmp)
    invoke DeleteDC,memDC
   
    invoke GdipDisposeImage,bitmap
   
    ret

CreateDraw endp

WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
LOCAL gsi:GdiplusStartupInput
LOCAL gtkn:PULONG

    mov gsi.GdiplusVersion,1
    mov gsi.DebugEventCallback,0
    mov gsi.SuppressBackgroundThread,0
    mov gsi.SuppressExternalCodecs,0
    invoke GdiplusStartup,ADDR gtkn,ADDR gsi,0
   
    mov   wc.cbSize,SIZEOF WNDCLASSEX
    mov   wc.style, CS_HREDRAW or CS_VREDRAW
    mov   wc.lpfnWndProc, OFFSET WndProc
    mov   wc.cbClsExtra,NULL
    mov   wc.cbWndExtra,0 ;SIZEOF WND_DATA
    push  g_hInstance
    pop   wc.hInstance
    mov   wc.hbrBackground,0
    mov   wc.lpszMenuName,NULL
    mov   wc.lpszClassName,OFFSET ClassName
    invoke LoadIcon,NULL,IDI_APPLICATION
    mov   wc.hIcon,eax
    mov   wc.hIconSm,eax
    invoke LoadCursor,NULL,IDC_ARROW
    mov   wc.hCursor,eax
   
    invoke RegisterClassEx, addr wc; or  or

    INVOKE CreateWindowEx,WS_EX_LAYERED or WS_EX_TOOLWINDOW or WS_EX_TOPMOST,\
            ADDR ClassName,ADDR AppName,\
             WS_VISIBLE,100,\
            100 ,200,200,NULL,NULL,\
            hInst,NULL
   
    .WHILE TRUE
        invoke GetMessage, ADDR msg,NULL,0,0
        .BREAK .IF (!eax)
        invoke TranslateMessage, ADDR msg
        invoke DispatchMessage, ADDR msg
    .ENDW
   
    mov     eax,msg.wParam
    ret
WinMain endp

WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
       
    .IF uMsg==WM_DESTROY
        invoke PostQuitMessage,NULL
    .ELSEIF uMsg==WM_CREATE
        invoke CreateDraw,hWnd
        ;fn CreateWindowEx,0,"button","Show",WS_CHILD or WS_VISIBLE,10,10,50,20,hWnd,0,g_hInstance,0
    .ELSEIF uMsg==WM_LBUTTONDOWN
        invoke  SendMessage,hWnd,WM_NCLBUTTONDOWN,HTCAPTION,lParam
    .ELSEIF uMsg==WM_RBUTTONUP
        invoke PostMessage,hWnd,WM_CLOSE,0,0
    .ELSE
        invoke DefWindowProc,hWnd,uMsg,wParam,lParam       
        ret
    .ENDIF
    xor eax,eax
    ret
WndProc endp

end main


EDIT: ** WS_POPUP may be an alternative
Title: Re: Help Plz
Post by: jj2007 on October 25, 2013, 06:00:42 PM
qWord, what have you done??
Title: Re: Help Plz
Post by: avcaballero on October 25, 2013, 06:44:00 PM
Interesting, qWord :t
Title: Re: Help Plz
Post by: GoneFishing on October 25, 2013, 08:03:29 PM
very nice example, qWord  :t
the window looks like a breakpoint in VS  ;)
what if to add some (color / transparency / shape) animation  to it ?
Title: Re: Help Plz
Post by: dedndave on October 25, 2013, 10:07:09 PM
very cool, qWord   :t

i suppose that could be done with an icon or cursor, as well
Title: Re: Help Plz
Post by: mabdelouahab on October 25, 2013, 10:08:19 PM
Thank qWord  ;Gunther;jj2007;avcaballero;vertograd;Farabi;dedndave;all..
very nice example, qWord  ,Thank ... :eusa_clap:
I will complete my project
After that I will respond
Title: Re: Help Plz
Post by: Gunther on October 25, 2013, 11:14:11 PM
qWord,

rock solid.  :t

Gunther
Title: Re: Help Plz
Post by: qWord on October 26, 2013, 03:06:20 PM
Quote from: vertograd on October 25, 2013, 08:03:29 PMwhat if to add some (color / transparency / shape) animation  to it ?
as said, recall UpdateLayeredWindow() if you wish to change the window's content. The Shape depends on the window region and what you draw with GDI+.
In the attachment the modified example with an animated "red point"  :biggrin:
include \masm32\include\masm32rt.inc
include \masm32\include\gdiplus.inc
includelib \masm32\lib\gdiplus.lib
.686
.mmx
.xmm

TIMER_INTERVAL      EQU 40 ; ms
TIMER_ID            EQU 100
INTERPOLATION_STEPS EQU 100
ANIMATION_COLOR     EQU 0ff0000h

ARGB1 MACRO alpha, red, green, blue
  EXITM % (alpha SHL 24) OR (red SHL 16) OR (green SHL 8) OR blue
ENDM

WAVE_2D struct
    n               DWORD ? ; number of interpolation steps
    lambda          REAL4 ? ; wavelength in pixels
    alpha_offset    REAl4 ? ;
    alpha_range     REAL4 ? ;
    rcp_c           REAl4 ? ; 1/c
    rcp_n           REAl4 ? ; 1/n
    omega           REAl4 ? ; 2*pi*f = 2*pi*(c/lambda)
WAVE_2D ends

.data?
    g_hInstance HINSTANCE ?
    g_ptZero    POINT <>
    g_wave      WAVE_2D <>
    g_t         DWORD ?
   
.const
    align 4
    ;/* play with the following 4 values ;-) */
    ss_lambda   REAl4 40.0  ; wavelength in pixels
    ss_c        REAL4 20.0  ; phase velocity in pixels/s
   
    ss_range    REAl4 90.0  ; linear gradient for alpha values (from center to border):
    ss_offset   REAl4 120.0 ; alpha(r,t) = ss_offset + ss_range * wave_function(r,t)
   
    ss_1        REAl4 1.0
    ss_2pi      REAl4 6.2831853071796
    ss_1Em3     REAl4 1.0E-3
   
    ClassName   db "foo xyz",0
    AppName     db "layered window, per-pixel alpha",0
.code
main proc
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
LOCAL gsi:GdiplusStartupInput
LOCAL gtkn:PULONG

    mov gsi.GdiplusVersion,1
    mov gsi.DebugEventCallback,0
    mov gsi.SuppressBackgroundThread,0
    mov gsi.SuppressExternalCodecs,0
    invoke GdiplusStartup,ADDR gtkn,ADDR gsi,0

    mov wc.hInstance,rvx(g_hInstance=GetModuleHandle,0)
    mov wc.cbSize,WNDCLASSEX
    mov wc.style,CS_HREDRAW or CS_VREDRAW
    mov wc.lpfnWndProc,WndProc
    mov wc.cbClsExtra,0
    mov wc.cbWndExtra,0
    mov wc.hbrBackground,0
    mov wc.lpszMenuName,0
    mov wc.lpszClassName,OFFSET ClassName
    mov wc.hIconSm,rvx(wc.hIcon=LoadIcon,0,IDI_APPLICATION)
    mov wc.hCursor,rv(LoadCursor,0,IDC_ARROW)
    fn RegisterClassEx,&wc
    fn CreateWindowEx,WS_EX_LAYERED or WS_EX_TOPMOST,&ClassName,&AppName,WS_VISIBLE OR WS_POPUP,100,100,200,200,0,0,wc.hInstance,0

    .while TRUE
        .break .if !rv(GetMessage,&msg,0,0,0)
        fn TranslateMessage,&msg
        fn DispatchMessage,&msg
    .endw
    invoke GdiplusShutdown,gtkn
    invoke ExitProcess,msg.wParam

main endp

update_layer proc uses ebx esi edi hWnd:HWND,t:REAL4,pWave:ptr WAVE_2D
LOCAL hdc:HDC,memDC:HDC
LOCAL bitmap:PVOID
LOCAL hBmp:HBITMAP
LOCAL graphics:PVOID,path:PVOID,brush:PVOID
LOCAL blend:BLENDFUNCTION
LOCAL rect:RECT
LOCAL nx:DWORD,nxh:DWORD

    mov ebx,pWave
   
    invoke GetWindowRect,hWnd,ADDR rect
    mov edx,rect.right
    mov ecx,rect.bottom
    sub edx,rect.left
    sub ecx,rect.top
    mov rect.right,edx
    mov rect.bottom,ecx

    invoke GdipCreateBitmapFromScan0,ecx,edx,0,PixelFormat32bppPARGB,0,ADDR bitmap
    invoke GdipGetImageGraphicsContext,bitmap,ADDR graphics
    invoke GdipGraphicsClear,graphics,ARGB1(0,0,0,0)
   
    invoke GdipCreatePath,FillModeAlternate,ADDR path
    mov eax,rect.right
    .if eax > rect.bottom
        mov eax,rect.bottom
    .endif
    mov nx,eax
    shr eax,1
    mov nxh,eax
    invoke GdipAddPathEllipseI,path,0,0,nx,nx
    invoke GdipCreatePathGradientFromPath,path,ADDR brush

    mov eax,[ebx].WAVE_2D.n
    lea edi,[eax*DWORD+DWORD]
    mov esi,alloc(edi)
    mov edi,alloc(edi)

    ;/**
    ; * calculate interpolation points (alpha+color, position)
    ; * used formular:
    ; *    alpha(x,t) = A*sin(omega*(x/c+t)) + offset
    ; *             A = x/(nx/2)
    ; *         omega = 2*pi*f = 2*pi*c/lambda
    ; * [x] = pixel
    ; * [t] = s
    ; * [c] = pixel/s
    ; * [lambda] = pixel
    ; */
    cvtsi2ss xmm6,nxh
    movss xmm7,ss_1
    divss xmm7,xmm6
    mulss xmm6,[ebx].WAVE_2D.rcp_n
    xorps xmm0,xmm0
    xor ecx,ecx
    .while ecx <= [ebx].WAVE_2D.n
        movss xmm1,xmm0
        mulss xmm1,xmm7
        .if ecx == [ebx].WAVE_2D.n
            mrm REAl4 ptr [esi+ecx*REAL4],ss_1 ; ensures that the last position is 1.0
        .else
            movss REAl4 ptr [esi+ecx*REAL4],xmm1
        .endif
        movss xmm1,xmm0
        mulss xmm1,[ebx].WAVE_2D.rcp_c
        movss xmm2,xmm7
        mulss xmm2,xmm0
        addss xmm1,t
        mulss xmm1,[ebx].WAVE_2D.omega
        movss REAl4 ptr [esp-REAl4],xmm1
        fld REAl4 ptr [esp-REAL4]
        fsin
        fstp REAl4 ptr [esp-REAL4]
        movss xmm1,REAl4 ptr [esp-REAL4]
        mulss xmm1,[ebx].WAVE_2D.alpha_range
        addss xmm1,[ebx].WAVE_2D.alpha_offset
        mulss xmm1,xmm2
        cvtss2si eax,xmm1
        shl eax,24
        or eax,ANIMATION_COLOR
        mov DWORD ptr [edi+ecx*DWORD],eax
        addss xmm0,xmm6; x = x + step
        add ecx,1
    .endw

    mov eax,[ebx].WAVE_2D.n
    add eax,1
    invoke GdipSetPathGradientPresetBlend,brush,edi,esi,eax
   
    invoke GdipFillEllipseI,graphics,brush,0,0,nx,nx
    invoke GdipDeleteGraphics,graphics
    invoke GdipDeleteBrush,brush
    invoke GdipDeletePath,path
   
    free edi
    free esi
   
    mov blend.BlendOp,AC_SRC_OVER
    mov blend.BlendFlags , 0
    mov blend.AlphaFormat,AC_SRC_ALPHA
    mov blend.SourceConstantAlpha, 255
   
    fnx memDC = CreateCompatibleDC,rvx(hdc=GetDC,rv(GetDesktopWindow))
    invoke ReleaseDC,rv(GetDesktopWindow),hdc
    invoke GdipCreateHBITMAPFromBitmap,bitmap,ADDR hBmp,0
    fnx hBmp = SelectObject,memDC,hBmp

    invoke UpdateLayeredWindow,hWnd,0,ADDR rect,ADDR rect.right, memDC,addr g_ptZero, 0,addr blend, ULW_ALPHA
    invoke DeleteObject,rv(SelectObject,memDC,hBmp)
    invoke DeleteDC,memDC
    invoke GdipDisposeImage,bitmap
   
    ret
   
update_layer endp

WndProc proc hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
LOCAL t:REAL4

    .if uMsg == WM_DESTROY
        invoke PostQuitMessage,NULL
    .elseif uMsg == WM_CREATE
       
        ;/* fill WAVE_2D structure (could be done before assembling) */
        mov g_wave.n,INTERPOLATION_STEPS
        mrm g_wave.lambda,ss_lambda
        mrm g_wave.alpha_offset,ss_offset
        mrm g_wave.alpha_range,ss_range
        movss xmm0,ss_c
        divss xmm0,ss_lambda
        mulss xmm0,ss_2pi
        movss g_wave.omega,xmm0
        movss xmm1,ss_1
        divss xmm1,ss_c
        movss g_wave.rcp_c,xmm1
        movss xmm0,ss_1
        cvtsi2ss xmm1,g_wave.n
        divss xmm0,xmm1
        movss g_wave.rcp_n,xmm0
       
        ;/* set layer (t=0) */
        fn update_layer,hWnd,0,&g_wave
       
        ;/* start timer */
        invoke SetTimer,hWnd,TIMER_ID,TIMER_INTERVAL,0
        mov g_t,rv(GetTickCount)
   
    .elseif uMsg == WM_TIMER && wParam == TIMER_ID
       
        ;/* update */
        invoke GetTickCount
        sub eax,g_t
        cvtsi2ss xmm0,eax
        mulss xmm0,ss_1Em3
        movss t,xmm0
        fn update_layer,hWnd,t,&g_wave

    .elseif uMsg == WM_LBUTTONDOWN
        invoke  SendMessage,hWnd,WM_NCLBUTTONDOWN,HTCAPTION,lParam
    .elseif uMsg == WM_RBUTTONUP
        invoke PostMessage,hWnd,WM_CLOSE,0,0
    .else
        invoke DefWindowProc,hWnd,uMsg,wParam,lParam       
        ret
    .endif
    xor eax,eax
    ret
WndProc endp
end main
Title: Re: Help Plz
Post by: GoneFishing on October 26, 2013, 10:27:31 PM
qWord
Thank you for providing new , animated example  :t
you're very experienced in coding the  layered windows  ...
Interestingly that they (i.e. LWs) are invisible for ALT-TAB / toolbar   
May I use your source code for further experiments ?
Title: Re: Help Plz
Post by: Force on October 27, 2013, 01:20:10 AM
That's Great qWord,

:t

Force
Title: Re: Help Plz
Post by: qWord on October 27, 2013, 01:53:11 AM
Quote from: vertograd on October 26, 2013, 10:27:31 PMInterestingly that they (i.e. LWs) are invisible for ALT-TAB / toolbar
for Win7 the program appears in the task bar. However, this depends on the windows styles and if the window has an owner- or parent window.
Quote from: vertograd on October 26, 2013, 10:27:31 PMMay I use your source code for further experiments ?
yes, of course.
Title: Re: Help Plz
Post by: GoneFishing on October 27, 2013, 02:44:09 AM
Thanks,
I just checked out LW.EXE and it appeared in the task bar ( sorry , I made the  mistake  in my previous post  )
while GTdi01.EXE DID NOT  (Win8)
Title: extended example
Post by: qWord on October 29, 2013, 10:28:53 AM
I somehow loved that example and therefore extend it a bit: now the window size, wave parameters, number of interpolation points and the color can be changed while runtime.
Be warned, at some configurations the animation will get a bit "psychedelic"  :biggrin:
Quote from: usageusage:
                     mouse wheel -> change size of window
   CONTROL         + mouse wheel -> change phase velocity
   SHIFT           + mouse wheel -> change wavelength
   CONTROL + SHIFT + mouse wheel -> change number of interpolation points (GDI+ path gradient)
   C               + mouse wheel -> change color
   SPACE                         -> show parameters
A right mouse click close the application.
Title: Re: Help Plz
Post by: dedndave on October 29, 2013, 10:48:45 AM
 :biggrin:
hypnotic, even
subliminal messages "send money to qWord - send money to qWord"   :P
Title: Re: Help Plz
Post by: GoneFishing on October 29, 2013, 06:04:02 PM
...
Title: Re: Help Plz
Post by: avcaballero on October 29, 2013, 08:59:27 PM
Quote from: dedndave on October 29, 2013, 10:48:45 AM
hypnotic, even
subliminal messages "send money to qWord - send money to qWord"
Ha ha ha. Plz, wait a moment Dave, don't send all your money yet to qWord, that I will code another hypnotic spiral...  :greensml:
Title: Re: Help Plz
Post by: dedndave on October 29, 2013, 10:29:18 PM
better hurry - i have him on auto-pay, now   :biggrin:
Title: Re: Help Plz
Post by: GoneFishing on October 29, 2013, 11:06:38 PM
Quote from: avcaballero on October 29, 2013, 08:59:27 PM
Quote from: dedndave on October 29, 2013, 10:48:45 AM
hypnotic, even
subliminal messages "send money to qWord - send money to qWord"
Ha ha ha. Plz, wait a moment Dave, don't send all your money yet to qWord, that I will code another hypnotic spiral...  :greensml:

I suppose , sadly you'll have to include the complete source code to strengthen the psychic magnetism of the demo  ;)

qWord:

unfortunately I currently don't have all required knowledge and skills to code it myself (quickly enough)

so here're all my ideas about how to enhance this simple demo  :

First LW tutorial
-Launch 2 instances of LW
-move the later one a few pixels to the left / right   , up / down
-enjoy 
Title: Re: Help Plz
Post by: Gunther on October 30, 2013, 01:16:45 AM
Very cool, qWord.  :t

Gunther
Title: Re: Help Plz
Post by: Farabi on October 30, 2013, 02:51:42 PM
My, that is impressive qWord.  :t
Title: Re: Help Plz
Post by: qWord on October 31, 2013, 02:42:23 AM
Farabi, remove your damn googel tracking image from the signature.
Title: Re: Help Plz
Post by: jj2007 on October 31, 2013, 02:46:36 AM
Must be a MSIE problem (where I see a vertical scrollbar to the right but no image) - can't see anything in Firefox, just an empty area with no links...
Title: Re: Help Plz
Post by: GoneFishing on October 31, 2013, 02:47:24 AM
The same for IE
Title: Re: Help Plz
Post by: dedndave on October 31, 2013, 03:19:36 AM
in FF, i sometimes see the outline of the box when the page first loads

i save the HTML page - it is named MyAds.gif
Hutch probably disabled animated signatures
Title: Re: Help Plz
Post by: GoneFishing on October 31, 2013, 06:53:47 AM
Quote from: avcaballero on October 29, 2013, 08:59:27 PM
Quote from: dedndave on October 29, 2013, 10:48:45 AM
hypnotic, even
subliminal messages "send money to qWord - send money to qWord"
Ha ha ha. Plz, wait a moment Dave, don't send all your money yet to qWord, that I will code another hypnotic spiral...  :greensml:

Something like this (http://www.youtube.com/watch?v=CQPNj38WscM), please  ;)
Title: Re: Help Plz
Post by: Gunther on October 31, 2013, 06:59:15 AM
Hi vertograd,

Quote from: vertograd on October 31, 2013, 06:53:47 AM
Something like this (http://www.youtube.com/watch?v=CQPNj38WscM), please  ;)

it looks a bit psychedelic.  :dazzled:

Gunther
Title: Re: Help Plz
Post by: GoneFishing on October 31, 2013, 07:08:42 AM
Hi Gunther,

Yes, indeed !!!  :t