• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

[SDK] 15 - SkinBox

Started by Patrice Terrier, February 11, 2008, 10:46:37 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Patrice Terrier

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

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

Patrice Terrier

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

Petr Schreiber

#2
Hi Patrice,

the clock looks really nice!

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

psch.thinbasic.com

Patrice Terrier

#3
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.

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

Petr Schreiber

#4
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
AMD Sempron 3400+ | 1GB RAM @ 533MHz | GeForce 6200 / GeForce 9500GT | 32bit Windows XP SP3

psch.thinbasic.com

Kent Sarikaya

Looks so nice, thanks Patrice another beautiful project!

Eros Olmi

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

Patrice Terrier

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 :

'+--------------------------------------------------------------------------+
'|                                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

Patrice Terrier

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

Bob Mechler

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

Patrice Terrier

Bob

QuoteIf 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

Jules Marchildon

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 :)

Patrice Terrier

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

Jules Marchildon

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

Patrice Terrier

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