Author Topic: XP AERO, i get it to work!  (Read 6520 times)

0 Members and 1 Guest are viewing this topic.

Offline Patrice Terrier

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2022
    • www.zapsolution.com
XP AERO, i get it to work!
« on: September 30, 2008, 09:06:01 PM »
I have challenged myself to enable the drawing of child controls hover a layered window, something normaly impossible, but as we say here "the word impossible is not french"  ;D

This is draft code, but it works not only on VISTA (where it flys) but also on XP !!!

I though first to create a hook trampolin on the BeginPaint EndPaint API, when it comes to my mind that WM_PRINT could do it just fine, because the wParam is able to use a private memory DC, and ... that does the trick.

I have attached the source code to this post, again it is not polished, but i wanted to let you try it on XP, because i know most of you are reluctant to move ahead to VISTA.

 8)

Added:

Code: [Select]
'   // I get it to work
    lParam& = %PRF_CLIENT OR %PRF_CHILDREN OR %PRF_NONCLIENT OR %PRF_ERASEBKGND
    CALL SendMessage(hWnd, %WM_PRINT, hMemDC, lParam&)


« Last Edit: August 10, 2011, 02:48:19 PM by Patrice Terrier »
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Offline Petr Schreiber

  • Sr. Member
  • ****
  • Posts: 254
Re: XP AERO, i get it to work!
« Reply #1 on: October 01, 2008, 05:37:24 PM »
Hi Patrice,

thanks for this new sample, looks good as usual :)
I tested it on Windows XP SP2 and all worked fine, CPU usage about 40% on single core processor.


Petr

AMD Sempron 3400+ | 1GB RAM @ 533MHz | GeForce 6200 / GeForce 9500GT | 32bit Windows XP SP3

psch.thinbasic.com

Offline Patrice Terrier

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2022
    • www.zapsolution.com
Re: XP AERO, i get it to work!
« Reply #2 on: October 01, 2008, 06:53:03 PM »
Petr

If interrested i could post the code to take over the BeginPaint EndPaint and let the child controls to be drawn to the memory DC instead of the classic window DC, and this without using the WM_PRINT message.

But this would require the use of a DLL because of the "detour hook" technic being used.
And it would make possible to suppress the timer, freeing up CPU resources.

Note-1: with WM_PRINT if you remove the timer then you won't see anymore the child controls.

Note-2: You can reduce drasticaly the CPU usage if you use a TIMER value of 100 instead of 50 and remove the flare animation (and or suppress zooming)

Try first to remove the zooming like this:
Code: [Select]
       '// Draw layer 4 with respect of the z-order
       IF ImageArray(4) = 0 THEN ImageArray(4) = zLoadImageFromFile((EXE.Path$ + "LensFlare.png"), imgW, imgH, 0)
       Img = ImageArray(4)
       IF Img THEN
          CALL GetImageSize(Img, imgW, imgH)
          IF FlipMove3 = 0 THEN
             xMove3 = xMove3 + 2
             IF xMove3 > 260 THEN FlipMove3 = -1
          ELSE
             xMove3 = xMove3 - 2
             IF xMove3 < 0 THEN FlipMove3 = 0
          END IF
'          CALL GdipDrawImageRectRectI(graphics, Img, 103 + xMove3, 50 + (xMove3 \ 2), imgW - (xMove3\4), imgH - (xMove3\4), 0, 0, imgW, imgH, 2, ImgAttr)
          CALL GdipDrawImageRectRectI(graphics, Img, 103 + xMove3, 50 + (xMove3 \ 2), imgW, imgH, 0, 0, imgW, imgH, 2, ImgAttr)
       END IF
and you will see that the CPU usage would be only 3%

Try also to play with the timer delay in the range 0-100 to adjust the smooth moving of the flare.

...
« Last Edit: October 01, 2008, 06:55:20 PM by Patrice Terrier »
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Offline Patrice Terrier

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2022
    • www.zapsolution.com
Re: XP AERO, i get it to work!
« Reply #3 on: October 01, 2008, 07:03:26 PM »
I forget to say that when using a layered window with the alpha channel (using variable opacity), you don't need to manage the region yourself, everything is done by the OS.  :)

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Offline Patrice Terrier

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2022
    • www.zapsolution.com
Re: XP AERO, i get it to work!
« Reply #4 on: August 10, 2011, 06:21:52 PM »
The first post of this thread has been updated, to fix the ZIP file corruption caused by the "Server Collapse".

...
« Last Edit: August 10, 2011, 06:24:17 PM by Patrice Terrier »
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com