Author Topic: [SDK] 15 - SkinBox  (Read 18833 times)

0 Members and 1 Guest are viewing this topic.

Offline Patrice Terrier

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2022
    • www.zapsolution.com
[SDK] 15 - SkinBox
« on: February 11, 2008, 10:46:37 AM »
This new SkinBox project uses the latest skin engine: zSkin.inc.

Bonus: I have added a new Clock control using the VISTA look (zClockCtrl).
The clock itself is available in 2-size: smallclock.png and largeclock.png in the Resource folder




See attached zip file: SkinBox.zip

...
« Last Edit: August 10, 2011, 04:18:06 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: [SDK] 15 - SkinBox
« Reply #1 on: February 11, 2008, 01:57:56 PM »
To have a clock even more realistic, you can add drop shadow under the hands like this:

               '// Draw the hour hand
               IF nHH > 12 THEN nHH = nHH - 12
               nAngle = (nHH * 30 - 90) + 30 * nMM \ 60 
               X = CenterX + (COS(nAngle * Pi180) * (CenterX - (imgW \ 4)))
               Y = CenterY + (SIN(nAngle * Pi180) * (CenterY - (imgW \ 4)))
CALL DrawLine(graphics, CenterX+2, CenterY+2, X+2, Y+2, &H40000000, (imgW \ 40))
               CALL DrawLine(graphics, CenterX, CenterY, X, Y, ARGB1, (imgW \ 40))
               
               '// Draw the minute hand
               nAngle = (nMM * 6 - 90) + 6 * nSS \ 60
               X = CenterX + (COS(nAngle * Pi180) * (CenterX - (imgW \ 5)))
               Y = CenterY + (SIN(nAngle * Pi180) * (CenterY - (imgW \ 5)))
CALL DrawLine(graphics, CenterX+2, CenterY+2, X+2, Y+2, &H40000000, (imgW \ 40))
               CALL DrawLine(graphics, CenterX, CenterY, X, Y, ARGB1, (imgW \ 40))
               
               '// Draw the second hand
               nAngle = (nSS * 6 - 90)
               X = CenterX + (COS(nAngle * Pi180) * (CenterX - (imgW \ 6)))
               Y = CenterY + (SIN(nAngle * Pi180) * (CenterY - (imgW \ 6)))
CALL DrawLine(graphics, CenterX+2, CenterY+2, X+2, Y+2, &H40000000, (imgW \ 50))
               CALL DrawLine(graphics, CenterX, CenterY, X, Y, ARGB2, (imgW \ 50))
               nAngle = (nSS * 6 - 270)
               X = CenterX + (COS(nAngle * Pi180) * (imgW \ 8 ))
               Y = CenterY + (SIN(nAngle * Pi180) * (imgW \ 8 ))
CALL DrawLine(graphics, CenterX+2, CenterY+2, X+2, Y+2, &H40000000, (imgW \ 50))
               CALL DrawLine(graphics, CenterX, CenterY, X, Y, ARGB2, (imgW \ 50))

               '// Draw the center of the clock
CALL DrawEllipseFilled(graphics, CenterX - 1, CenterY - 1, 6, 6, &H40000000)
               CALL DrawEllipseFilled(graphics, CenterX - 3, CenterY - 3, 6, 6, &HFFFF0000)


try it also with the "LargeClock.png".

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

Offline Petr Schreiber

  • Sr. Member
  • ****
  • Posts: 254
Re: [SDK] 15 - SkinBox
« Reply #2 on: February 11, 2008, 03:38:49 PM »
Hi Patrice,

the clock looks really nice!

Thanks,
Petr
« Last Edit: August 10, 2011, 04:19:03 PM by Patrice Terrier »
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: [SDK] 15 - SkinBox
« Reply #3 on: February 11, 2008, 04:56:49 PM »
He he,  ;)
it was to check if you (and others) learned well from my previous SDK examples.

On XP, to mimic the VISTA AERO GLASS, mode you must use:
the COMPOSITED mode!

In the WinMain section, change dwExStyle = 0 to this:


     ' Window Extended Style
       IF Vista() THEN
          dwExStyle = 0
       ELSE
          dwExStyle = %WS_EX_LAYERED
          IF zOsVersion > 500 THEN dwExStyle = dwExStyle OR %WS_EX_COMPOSITED
       END IF

     ' Windows Style, avoid using %WS_CLIPSIBLINGS OR %WS_CLIPCHILDREN with the Skin Engine
       dwStyle = %WS_POPUP ' OR %WS_CLIPCHILDREN OR %WS_CLIPSIBLINGS


I have updated the ZIP file, to switch to composited mode on XP, and added the drop shadow to clock's hand.

Note: VISTA always works in composited mode when using DWM.

...
 
« Last Edit: February 11, 2008, 06:32:15 PM by Patrice Terrier »
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Offline Petr Schreiber

  • Sr. Member
  • ****
  • Posts: 254
Re: [SDK] 15 - SkinBox
« Reply #4 on: February 11, 2008, 06:50:53 PM »
Oh no,

I failed in the test :D

Thanks Patrice, now it works perfectly.
I am bad SDK student, still attracted by the dark side ( DDT ), but it is getting better! ( I open Petzolds book in free time more often to learn what I should learn years ago ) :)

I will have to print your codes out and study them in detail.


Thanks,
Petr
« Last Edit: February 11, 2008, 06:53:34 PM by Petr Schreiber »
AMD Sempron 3400+ | 1GB RAM @ 533MHz | GeForce 6200 / GeForce 9500GT | 32bit Windows XP SP3

psch.thinbasic.com

Offline Kent Sarikaya

  • Full Member
  • ***
  • Posts: 201
Re: [SDK] 15 - SkinBox
« Reply #5 on: February 12, 2008, 12:30:09 AM »
Looks so nice, thanks Patrice another beautiful project!

Offline Eros Olmi

  • Sr. Member
  • ****
  • Posts: 268
    • thinBasic
Re: [SDK] 15 - SkinBox
« Reply #6 on: February 12, 2008, 07:53:31 AM »
Works perfectly here.
Great job, as usual.
thinBasic Script Interpreter - www.thinbasic.com | www.thinbasic.com/community
Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Offline Patrice Terrier

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2022
    • www.zapsolution.com
Re: [SDK] 15 - SkinBox
« Reply #7 on: March 19, 2008, 09:50:57 AM »
Quote
(how much of the code can I use for my applications? is it ok just to name you in the credits? )

This code is under my copyright, as written in the source code there :
Code: [Select]
'+--------------------------------------------------------------------------+
'|                                SkinBox                                   |
'|                                                                          |
'|                      Skin Engine for VISTA and XP                        |
'|           with full crystal and blur effect in composited mode           |
'|                                                                          |
'|                Example of what is going on behind the hood.              |
'|                                                                          |
'+--------------------------------------------------------------------------+
'|                                                                          |
'|                         Author Patrice TERRIER                           |
'|                            copyright(c) 2007                             |
'|                           www.zapsolution.com                            |
'|                         support@zapsolution.com                          |
'|                                                                          |
'+--------------------------------------------------------------------------+
'|                  Project started on : 08-04-2007 (MM-DD-YYYY)            |
'|                        Last revised : 02-11-2008 (MM-DD-YYYY)            |
'+--------------------------------------------------------------------------+

What you could do to express your grateful, is to post there some contributions of your own ;)

The Blur mode on VISTA is hardware accelerated through the use of DWM.

    IF zDwmIsCompositionEnabled() THEN

       IF SK_USEVISTABLUR() THEN
          CALL zSetBlurBehindMode(zMainWindow(0), %TRUE, 0)
          CALL zPaintBrushBitmap(hDCdest, 0, 0, xWidth, yHeight, zColorARGB(0, 0))
          EXIT SUB
       END IF

       IF SK_USEVISTACRYSTAL() THEN
          CALL zSetCrystalBehindMode(zMainWindow(0), %TRUE)
          CALL zPaintBrushBitmap(hDCdest, 0, 0, xWidth, yHeight, zColorARGB(0, 0))
          EXIT SUB
       END IF

    END IF



On XP i am doing it that way:

    hDeskTop = GetDesktopWindow(): hDCSrce = GetWindowDC(hDeskTop)

    nDiv = SK_AEROBLURLEVEL()
    IF nDiv THEN
       nDiv = nDiv + 1
       xDiv = xWidth \ nDiv
       yDiv = yHeight \ nDiv

       hDC1 = CreateCompatibleDC(hDCdest)
       hBM1 = zCreateDIBSection(hDCdest, xWidth, yHeight, 32)
       CALL SelectObject(hDC1, hBM1)
'      // Copy from DC source
       CALL BitBlt(hDC1, 0, 0, xWidth, yHeight, hDCSrce, xSrce, ySrce, %SRCCOPY)

       hDC2 = CreateCompatibleDC(hDCdest)
       hBM2 = zCreateDIBSection(hDCdest, xDiv, yDiV, 32)
       CALL SelectObject(hDC2, hBM2)

'      // Perform reduction
       IF GdipCreateFromHDC(hDC2, graphics) = 0 THEN
          CALL GdipCreateBitmapFromHBITMAP(hBM1, BYVAL %NULL, Img)
          CALL GdipSetInterpolationMode(graphics, 2)
          CALL GdipDrawImageRectRectI(graphics, Img, 0, 0, xDiv, yDiv, 0, 0, xWidth, yHeight, %UnitPixel, ImgAttr)
          CALL GdipDeleteGraphics(graphics)
          CALL GdipDisposeImage(Img)
       END IF
       CALL zDeleteObject(hBM1)
       CALL DeleteDC(hDC1)

'      // Blur from reduction
       IF GdipCreateFromHDC(hDCdest, graphics) = 0 THEN
          CALL GdipCreateBitmapFromHBITMAP(hBM2, BYVAL %NULL, Img)
          CALL GdipSetInterpolationMode(graphics, 2)
          CALL GdipDrawImageRectRectI(graphics, Img, xDest, yDest, xWidth, yHeight, 0, 0, xDiv, yDiv, %UnitPixel, ImgAttr)
          CALL GdipDeleteGraphics(graphics)
          CALL GdipDisposeImage(Img)
       END IF
       CALL zDeleteObject(hBM2)
       CALL DeleteDC(hDC2)
    ELSE
       CALL BitBlt(hDCdest, xDest, yDest, xWidth, yHeight, hDCSrce, xSrce, ySrce, %SRCCOPY)
    END IF

    CALL ReleaseDC(hDeskTop, hDCSrce)


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

Offline Patrice Terrier

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2022
    • www.zapsolution.com
Re: [SDK] 15 - SkinBox
« Reply #8 on: October 24, 2008, 04:54:54 PM »
Everything is provided within the ZIP file, see zSkin.inc.


Note: if you don't have a good knowledge of low level SDK API programming, then you will have a hard time with my code.
Good luck anyway.

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

Offline Bob Mechler

  • Newbie
  • *
  • Posts: 4
Re: [SDK] 15 - SkinBox
« Reply #9 on: December 05, 2008, 12:13:49 AM »
Just downloaded SkinBox. If I switch to SDK style can I subclass or superclass and get these effects.

I'm only wanting to subclass so I can control textbox to textbox navigation, provide a duplicate previous value for a field, give a way to call a lookup dialog etc.

I've used gradient code on dialogs and ownerdrawn buttons that I've gleaned from Poffs and a couple of PB forum questions.

Thanks,

Bob Mechler

Offline Patrice Terrier

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2022
    • www.zapsolution.com
Re: [SDK] 15 - SkinBox
« Reply #10 on: December 05, 2008, 12:58:49 PM »
Bob

Quote
If I switch to SDK style can I subclass or superclass and get these effects

Please studdy all the tutorial(s) there.
They are all based on pure SDK, because it is the best way to take full control of your window.

None of the examples provided on the PB forum will lead you to a full skinned window, because ownerdrawn controls are very different than skinning the non-client area of a window.

Subclassing and Superclassing are two distinct concepts. When you superclass a control you inherit of the original control properties while you can add extra features of your own. When subclassing you can only change the behavior of the existing features.

...

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

Offline Jules Marchildon

  • Newbie
  • *
  • Posts: 9
Re: [SDK] 15 - SkinBox
« Reply #11 on: March 05, 2011, 04:55:47 PM »
Patrice,

Thank you for all your hard work and sharing with us!!! 

From time to time, because I have no time, I must go back in time to re-look "how was that done?" and your hard work is timeless pieces of art!

And thanks to Jose for this wonderful site, I can't be without, it's a great resource of time saving code!

...did I mention I'm out of time?

Best Regards,
Jules :)

Offline Patrice Terrier

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2022
    • www.zapsolution.com
Re: [SDK] 15 - SkinBox
« Reply #12 on: March 06, 2011, 08:53:48 AM »
Jules--

After more than 120 download of this project, you are one of the few, taking the time of posting a feedback.

Thank you!  ;)

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

Offline Jules Marchildon

  • Newbie
  • *
  • Posts: 9
Re: [SDK] 15 - SkinBox
« Reply #13 on: March 06, 2011, 04:32:37 PM »
You are very very welcome Patrice!!!

Not just for this, but for everything you have done, past, present and future!

There are so many things, so many routines, so many tips you supply, it's unbelievable you would not receive more praise. I for one, know from our past how dedicated and creative you are. It could be possible others don't spend the time to research your code to understand what they have in their hands!  They may download it, run it and say wow!, ...but they maybe missing what's under the hood, and that's too bad.

I myself no longer have the same time available since 2003 to dedicate myself to programming, I often go stretches without coding and my memory fails me most of the time, and when I do code, my time is spent trying to get up to speed to where I left off last time, so I may be just as guilty.

Again,  to Patrice , Jose, and many many others who contribute their expertise - you deserve it!... if not a million dollars, at least a humble thank you!

Best Regards,
Jules

Offline Patrice Terrier

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2022
    • www.zapsolution.com
Re: [SDK] 15 - SkinBox
« Reply #14 on: August 10, 2011, 04:21:36 PM »
The first post of this thread has been updated, to fix the ZIP file corruption caused by the "Server Collapse".

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