Sign in to follow this  
Followers 0
MyEarth

SOLVED - Help with a script ( maybe GDI+ )

24 posts in this topic

#1 ·  Posted (edited)

Hi,

I know there are many example on the forum about analog clock, the most with GDI+, but they are all complex with many feature. I'm search something simple with lower CPU usage to start, like this image ( i have do it with paint :D )

Posted Image

The only thing i'd like is to make it "resizable" but not with the mouse, example if i make:

$GUI = GUICreate("Form1", 300, 300, -1, -1)

Or

$GUI = GUICreate("Form1", 1000, 1000, -1, -1)

The three lines are always based on the size of the $GUI.

Thanks for any kind of help

Edited by MyEarth

Share this post


Link to post
Share on other sites



You should create the ratio of the size of the GUI to the size of the needles. Thereafter use _Winapi_GetWindowHeight/Width and calculate the size of the needles.

For Dynamic Resize monitor WM_SIZE message

Hope this helps :)


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

Thanks for the answer

I don't need a dynamic resize ( in real temp ), just make the three lines based on the size on the GUI, once is start i'll not change it.

If someone can make an example of a stupid simple clock :D i'll appreciate it

Share this post


Link to post
Share on other sites

What you have so far ?


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

I have tested i think all of the analog clock of this forum, but as i say before the do so many thing ( without any comment ) that is hard to understand how it work, at least for me.

For this reason i'd like to check the basic functionality of a clock just with three line and nothing else, use it as a "base" and work on that

Thanks for your interest

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

For this reason i'd like to check the basic functionality of a clock just with three line and nothing else, use it as a "base" and work on that

Basic functionality would be complex because it would involve calculation regarding Hour Min Sec hand with the distance they move in each second and clearing the drawn part and again redrawing it.

If you need something really simple, I can code a single (second) needle. Otherwise may be someone expert would sound more helpful

Regards :)

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

For this reason i'd like to check the basic functionality of a clock just with three line and nothing else, use it as a "base" and work on that

Basic functionality would be complex because it would involve calculation regarding Hour Min Sec hand with the distance they move in each second and clearing the drawn part and again redrawing it.

If you need something really simple, I can code a single (second) needle. Otherwise may be someone expert would sound more helpful


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

A clock with only the seconds it's not a clock :D

Don't worry because i know there are many calculation, draw and redraw and if you don't have time i'll wait another expert, this forum is full of competent people like you.

Thanks anyway ;)

Edited by MyEarth

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

#include <GUIConstantsEx.au3>

Global $PI = 3.1415926535897932384626433832795
Global $Sec = @SEC, $Min = @MIN, $Hour = @HOUR
Global $Radius = 170, $Radius_Element_Sec[$Radius], $Radius_Element_Min[$Radius], $Radius_Element_Hour[$Radius]
Global $Color_Sec = 0xFF0000, $Color_Min = 0x0000FF, $Color_Hour = 0x00000
Global $width = 400, $height = 400

GUICreate("Johnmcloud Test Version", $width, $height, -1, -1)
GUISetBkColor(0xFFFFFF)
;~ GUICtrlCreatePic("Test.bmp", 0, 0, $width, $height)
;~ GUICtrlSetState(-1, $GUI_DISABLE)
_onstart()
GUISetState(@SW_SHOW)

While 1
 $nMsg = GUIGetMsg()
 Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
 EndSwitch
 _Clock()
WEnd

Func _Clock()
 If $Sec <> @SEC Then
  $Sec = @SEC
  For $i = 0 To $Radius - 1
   $curX = $width / 2 + Cos($PI / 2 - ($Radius * $Sec / 60 * $PI / ($Radius / 2))) * $i
   $curY = $width / 2 - Sin($PI / 2 - ($Radius * $Sec / 60 * $PI / ($Radius / 2))) * $i
   GUICtrlSetPos($Radius_Element_Sec[$i], $curX, $curY)
  Next
 EndIf
 If $Min <> @MIN Then
  $Min = @MIN
  For $i = 0 To $Radius - 1
   $curX = $width / 2 + Cos($PI / 2 - ($Radius * ($Min + $Sec / 60) / 60 * $PI / ($Radius / 2))) * $i
   $curY = $width / 2 - Sin($PI / 2 - ($Radius * ($Min + $Sec / 60) / 60 * $PI / ($Radius / 2))) * $i
   GUICtrlSetPos($Radius_Element_Min[$i], $curX, $curY)
  Next
 EndIf
 If $Hour <> @HOUR Then
  $Hour = @HOUR
  For $i = 0 To $Radius - 1
   $curX = $width / 2 + Cos($PI / 2 - ($Radius * ($Hour + $Min / 60) / 12 * $PI / ($Radius / 2))) * $i
   $curY = $width / 2 - Sin($PI / 2 - ($Radius * ($Hour + $Min / 60) / 12 * $PI / ($Radius / 2))) * $i
   GUICtrlSetPos($Radius_Element_Hour[$i], $curX, $curY)
  Next
 EndIf
 Sleep(10)
EndFunc   ;==>_Clock

Func _onstart()
 For $i = 0 To $Radius - 1
  $Sec = @SEC
  $curX = $width / 2 + Cos($PI / 2 - ($Radius * $Sec / 60 * $PI / ($Radius / 2))) * $i
  $curY = $width / 2 - Sin($PI / 2 - ($Radius * $Sec / 60 * $PI / ($Radius / 2))) * $i
  $Radius_Element_Sec[$i] = GUICtrlCreateLabel("", $curX, $curY, 1, 1)
  GUICtrlSetBkColor(-1, $Color_Sec)
  $Min = @MIN
  $curX = $width / 2 + Cos($PI / 2 - ($Radius * ($Min + $Sec / 60) / 60 * $PI / ($Radius / 2))) * $i
  $curY = $width / 2 - Sin($PI / 2 - ($Radius * ($Min + $Sec / 60) / 60 * $PI / ($Radius / 2))) * $i
  $Radius_Element_Min[$i] = GUICtrlCreateLabel("", $curX, $curY, 4, 4)
  GUICtrlSetBkColor(-1, $Color_Min)
  $Hour = @HOUR
  $curX = $width / 2 + Cos($PI / 2 - ($Radius * ($Hour + $Min / 60) / 12 * $PI / ($Radius / 2))) * $i
  $curY = $width / 2 - Sin($PI / 2 - ($Radius * ($Hour + $Min / 60) / 12 * $PI / ($Radius / 2))) * $i
  $Radius_Element_Hour[$i] = GUICtrlCreateLabel("", $curX, $curY, 5, 5)
  GUICtrlSetBkColor(-1, $Color_Hour)
 Next
 Sleep(10)
EndFunc   ;==>_Start

First, i don't know GDI+ but this is the best i can do, i'm not a good coder

Second, don't ask me about the resize method based on the GUI size, i don't have idea how to do it but Phoneix i think can help you

Third, There is a little bug, the second needle is under the hour/minute and not over it, i don't know why

Edited by johnmcloud
1 person likes this

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Here what I did so far using the GUICtrlSetGraphic() stuff:

;coded by UEZ 2013-04-05
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>

Global Const    $iW = 256, $iH = $iW, $iCenterX = $iW / 2, $iCenterY = $iH / 2, $fD2R = ACos(-1) / 180, _
                $iRadiusH = Int($iW * 0.2), $iRadiusM = Int($iW * 0.3), $iRadiusS = Int($iW * 0.4), $iPenSize = 2, _
                $iBGColor = 0x585858, $iSecColor = 0x0080FF, $iMinColor = 0xFF00FF, $iHrColor = 0x00FF00

Global $hGUI = GUICreate("Puristic Clock by UEZ", $iW, $iH, -1, -1, -1, $WS_EX_COMPOSITED)
GUISetBkColor($iBGColor)
Global $iGraphic = GUICtrlCreateGraphic(0, 0, $iW, $iH)
GUISetState()

DrawClock()
AdlibRegister("DrawClock", 500)

Do
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            AdlibUnRegister("DrawClock")
            GUIDelete()
            Exit
    EndSwitch
Until False

Func DrawClock()
    ;erase background
    GUICtrlSetGraphic($iGraphic, $GUI_GR_PENSIZE, $iW)
    GUICtrlSetGraphic($iGraphic, $GUI_GR_COLOR, $iBGColor)
    GUICtrlSetGraphic($iGraphic, $GUI_GR_MOVE, $iCenterX, $iCenterY)
    GUICtrlSetGraphic($iGraphic, $GUI_GR_LINE, $iCenterX + Cos((-90 + 6 * (@SEC - 1)) * $fD2R) * $iRadiusS, $iCenterY + Sin((-90 + 6 * (@SEC - 1)) * $fD2R) * $iRadiusS)

    ;draw hour
    GUICtrlSetGraphic($iGraphic, $GUI_GR_PENSIZE, $iPenSize)
    GUICtrlSetGraphic($iGraphic, $GUI_GR_MOVE, $iCenterX, $iCenterY)
    GUICtrlSetGraphic($iGraphic, $GUI_GR_COLOR, $iHrColor)
    GUICtrlSetGraphic($iGraphic, $GUI_GR_LINE, $iCenterX + Cos((-90 + 30 * Mod(@HOUR, 12) + @MIN / 2) * $fD2R) * $iRadiusH, $iCenterY + Sin((-90 + 30 * Mod(@HOUR, 12) + @MIN / 2) * $fD2R) * $iRadiusH)

    ;draw minute
    GUICtrlSetGraphic($iGraphic, $GUI_GR_MOVE, $iCenterX, $iCenterY)
    GUICtrlSetGraphic($iGraphic, $GUI_GR_COLOR, $iMinColor)
    GUICtrlSetGraphic($iGraphic, $GUI_GR_LINE, $iCenterX + Cos((-90 + 6 * @MIN) * $fD2R) * $iRadiusM, $iCenterY + Sin((-90 + 6 * @MIN) * $fD2R) * $iRadiusM)

    ;draw seconds
    GUICtrlSetGraphic($iGraphic, $GUI_GR_MOVE, $iCenterX, $iCenterY)
    GUICtrlSetGraphic($iGraphic, $GUI_GR_COLOR, $iSecColor)
    GUICtrlSetGraphic($iGraphic, $GUI_GR_LINE, $iCenterX + Cos((-90 + 6 * @SEC) * $fD2R) * $iRadiusS, $iCenterY + Sin((-90 + 6 * @SEC) * $fD2R) * $iRadiusS)

    GUICtrlSetGraphic($iGraphic, $GUI_GR_REFRESH)
EndFunc

 

Not fully tested...

Br,

UEZ

Edited by UEZ
1 person likes this

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

@UEZ

Good, but i see a track using your version

Sometime flickering, and the second come back and appears twice

P.S What is the vaule for length of the lines?

Posted Image

@johnmcloud

I like it, you have forgot the hour needle must to be is smaller than the others ;)

Edited by OliverA

I'M QUIT FROM THIS FORUM!

It was fun until it lasted, hope on my future way i can't find people that offend without any reason ( i was called lazy and parasitic, and everyone agreed...United we stand, divided we fall ) just for fun because don't have anything to do in the life, without knowing anything about the person who write, noone forced to post, noone forced to help.

From the top of the from their very great superiority they not go down to my level, that people can not spread the knowledge but you have to learn by yourself.

In what way? It's easy...just search on google

For that people, wish you the best way,

Oliver Astone

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

@OliverA: I didn't test it using WinXP. Just use GUISetBkColor($iBGColor) to get this problem solved!

Not centered? Sure?

The length (radius) of the lines is defined at the top of the script.

Btw, I don't like to use the GUICtrlSetGraphic() stuff - it's shitty.

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Using background resolve the track ( and if i need to set an image? ), but i have problems with seconds, check the video:

http://www.yourfilelink.com/get.php?fid=835412

Maybe is AdlibRegister("DrawClock", 500)? I don't have that problem with the label version of johnmcloud

Edited by OliverA

I'M QUIT FROM THIS FORUM!

It was fun until it lasted, hope on my future way i can't find people that offend without any reason ( i was called lazy and parasitic, and everyone agreed...United we stand, divided we fall ) just for fun because don't have anything to do in the life, without knowing anything about the person who write, noone forced to post, noone forced to help.

From the top of the from their very great superiority they not go down to my level, that people can not spread the knowledge but you have to learn by yourself.

In what way? It's easy...just search on google

For that people, wish you the best way,

Oliver Astone

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Using background resolve the track ( and if i need to set an image? ), but i have problems with seconds, check the video:

http://www.yourfilelink.com/get.php?fid=835412

Maybe is AdlibRegister("DrawClock", 500)? I don't have that problem with the label version of johnmcloud

The OP asked for a simple clock not using GDI+ or any other extras. That's why I used the shitty GUICtrlSetGraphic() stuff. I tested it in my WinXP VM and I cannot see any flickering problems and also on my Win7 X64 to Aero notebook.

Btw, I updated the code a little bit.

My personal preference is to use GDI+ which is much more flexible and powerful.

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

I don't have say "please not use GDI+", i don't know how to code in gdi+ and i see many complex example using it

I have ask for three line :D, maybe i'll add a backgroud image or a color, that's all

If you want to show and example in gdi+ it's not a problem, but please do simplest as you can

P.S. If your GUICtrlSetGraphic() example, it's possible to add a GUICtrlCreatePic()? If i add it i can't see nothing except the image, i have disable the image btw. Really thanks

EDIT: For what i have read is impossible to set in image over the GUICtrlSetGraphic(), bad -.-

Edited by OliverA

I'M QUIT FROM THIS FORUM!

It was fun until it lasted, hope on my future way i can't find people that offend without any reason ( i was called lazy and parasitic, and everyone agreed...United we stand, divided we fall ) just for fun because don't have anything to do in the life, without knowing anything about the person who write, noone forced to post, noone forced to help.

From the top of the from their very great superiority they not go down to my level, that people can not spread the knowledge but you have to learn by yourself.

In what way? It's easy...just search on google

For that people, wish you the best way,

Oliver Astone

Share this post


Link to post
Share on other sites

I don't have say "please not use GDI+", i don't know how to code in gdi+ and i see many complex example using it

I have ask for three line :D, maybe i'll add a backgroud image or a color, that's all

If you want to show and example in gdi+ it's not a problem, but please do simplest as you can

P.S. If your GUICtrlSetGraphic() example, it's possible to add a GUICtrlCreatePic()? If i add it i can't see nothing except the image, i have disable the image btw. Really thanks

EDIT: For what i have read is impossible to set in image over the GUICtrlSetGraphic(), bad -.-

Hi,

I know there are many example on the forum about analog clock, the most with GDI+, but they are all complex with many feature. I'm search something simple with lower CPU usage to start, like this image ( i have do it with paint :D )

That's why I used GUICtrlSetGraphic().

Here a GDI+ version:

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

Ops, i don't have read want the OP want, i have think you was talked with me about gdi+, sorry ;) ( my motherlangueges isn't english )

Thanks for the link, i'll check it out

Edited by OliverA

I'M QUIT FROM THIS FORUM!

It was fun until it lasted, hope on my future way i can't find people that offend without any reason ( i was called lazy and parasitic, and everyone agreed...United we stand, divided we fall ) just for fun because don't have anything to do in the life, without knowing anything about the person who write, noone forced to post, noone forced to help.

From the top of the from their very great superiority they not go down to my level, that people can not spread the knowledge but you have to learn by yourself.

In what way? It's easy...just search on google

For that people, wish you the best way,

Oliver Astone

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

Thanks to all for support and also OliverA for testing the script

UEZ, that GDI+ example is really nice, congrats, but you can remove everything except the second/minute/hour basic function (like "custom" line func, remove dynamic resize in real temp, remove speacking clock, remove move, etc. all thing unecessay to the basic function of the code )?

I want study on it and improve my knowledge ;)

Edited by MyEarth

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

Here the reduce GDI+ code:

;coded by UEZ 2011 build 2011-04-11
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("MustDeclareVars", 1)
Opt("GUIOnEventMode", 1)

Global $hGUI, $hGraphics, $hBackbuffer, $hBitmap, $hBitmapBG, $hPen1, $hPen2, $hPen3, $hPen4
Global $iW = 300, $iH = $iW
Global Const $p2_hm = $iW / 35
Global Const $p3_hm = $iW / 35
Global Const $p4_hm = $iW / 100
Global Const $cX = $iW /2, $cY = $iH / 2
Global Const $deg = ACos(-1) / 180
Global Const $radius = $iW * 0.85, $cR = $radius * 0.50
Global Const $cR1 = $cR * 0.90, $cR2 = $cR * 0.20
Global Const $cR3 = $cR * 0.80, $cR4 = $cR * 0.15
Global Const $cR5 = $cR * 0.50, $cR6 = $cR * 0.10
Global $sek = @SEC * 6 - 90
Global $min = @MIN * 6 + (@SEC / 10) - 90
Global $std = @HOUR * 30 + (@MIN / 2) - 90
Global $x1, $y1, $x2, $y2, $x3, $y3, $x4, $y4, $x5, $x6, $y5, $y6
; Initialize GDI+
_GDIPlus_Startup()

Global $title = "GDI+ Simple Clock by UEZ 2011"
$hGUI = GUICreate($title, $iW, $iH)
If @OSBuild < 7600 Then WinSetTrans($hGui,"", 0xFF)
GUISetState()

$hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphics)
$hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
$hBitmapBG = _GDIPlus_BitmapCreateFromFile("c:\Program Files (x86)\AutoIt3\Examples\GUI\torus.png")

; Using antialiasing
_GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2)
DllCall($ghGDIPDll, "uint", "GdipSetTextRenderingHint", "handle", $hBackbuffer, "int", 3)

; Create a Pen object
$hPen1 = _GDIPlus_PenCreate(0xFF800010, 4)
$hPen2 = _GDIPlus_PenCreate(0xA01010F0,  $p2_hm)
$hPen3 = _GDIPlus_PenCreate(0xA01010F0,  $p3_hm)
$hPen4 = _GDIPlus_PenCreate(0x9010D040,  $p4_hm)

GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

GUIRegisterMsg($WM_ERASEBKGND, "WM_ERASEBKGND")

Global $timer = 500

Draw()
GUIRegisterMsg($WM_TIMER, "Draw") ;$WM_TIMER = 0x0113
DllCall("User32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $timer, "int", 0)

While Sleep(100000000)
WEnd

Func Draw()
    $sek = @SEC * 6 - 90
    $min = @MIN * 6 + (@SEC * 0.10) - 90
    $std = @HOUR * 30 + (@MIN * 0.50) - 90
    _GDIPlus_GraphicsClear($hBackbuffer, 0xFFFFFFFF) ;needed for transparent images
    _GDIPlus_GraphicsDrawImageRect($hBackbuffer, $hBitmapBG, 0, 0, $iW, $iH) ;this will stretch any image it $iW and $iH isn't the same

    _GDIPlus_GraphicsDrawLine($hBackbuffer, $cX - $cR, $cY, $cX - $cR + 35, $cY, $hPen1)
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $cX + $cR, $cY, $cX + $cR - 35, $cY, $hPen1)
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $cX, $cY - $cR, $cX, $cY - $cR + 35, $hPen1)
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $cX, $cY + $cR, $cX, $cY + $cR - 35, $hPen1)

    $x5 = $cX + Cos($std * $deg) * $cR5
    $y5 = $cY + Sin($std * $deg) * $cR5
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $x5, $y5, $cX, $cY, $hPen2) ;hours

    $x3 = $cX + Cos($min * $deg) * $cR3
    $y3 = $cY + Sin($min * $deg) * $cR3
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $x3, $y3, $cX, $cY, $hPen3) ;minutes

    $x1 = $cX + Cos($sek * $deg) * $cR1
    $y1 = $cY + Sin($sek * $deg) * $cR1
    $x2 = $cX + Cos(($sek + 180) * $deg) * $cR2
    $y2 = $cY + Sin(($sek + 180) * $deg) * $cR2
    _GDIPlus_GraphicsDrawLine($hBackbuffer, Floor($x1), Floor($y1), Floor($x2), Floor($y2), $hPen4) ;seconds

    _GDIPlus_GraphicsDrawEllipse($hBackbuffer, $cX - 3, $cY - 3, 6, 6, $hPen1)

_WinAPI_RedrawWindow($hGUI)
EndFunc

Func WM_ERASEBKGND($hWnd, $Msg, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $iW, $iH)
    Return True
EndFunc   ;==>_WM_ERASEBKGND

Func _Exit()
    GUIRegisterMsg($WM_TIMER, "")
    GUIRegisterMsg($WM_ERASEBKGND, "")

    ; Clean up GDI+ resources
    _GDIPlus_PenDispose($hPen1)
    _GDIPlus_PenDispose($hPen2)
    _GDIPlus_PenDispose($hPen3)
    _GDIPlus_PenDispose($hPen4)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_BitmapDispose($hBitmapBG)
    _GDIPlus_GraphicsDispose($hBackbuffer)
    _GDIPlus_GraphicsDispose($hGraphics)

    ; Uninitialize GDI+
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
    Exit
EndFunc

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

Many thanks, I'm playing with your code, two things i don't have undestand

- Where is the bk color? I have try to change this:

_GDIPlus_GraphicsClear($hBackbuffer, 0xFFFFFFFF)

But i see strange behavor

- How gdi+ load images ( bmp, jpg etc. )

Reading the help I have try in this way:

$hImage = _GDIPlus_ImageLoadFromFile("myimage.bmp")
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, 0, 0, $iW, $iH)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_ImageDispose($hImage)

But it think is not correct, can you can enlighten me? Then i can put this thread to solved

Thanks again

Edited by MyEarth

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0