Что нового

продолжаю рисовать график, исчезает при сворачивании окна

  • Автор темы dreamorder
  • Дата начала
D

dreamorder

Гость
Доброго времени суток гос-да.

Сделал что было задумано, рабочий пример (может кому то пригодится) :smile:

Код:
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <WinAPIEx.au3>
#include <BigNum.au3>


$Form1 = GUICreate("Form1", 800, 600, 365, 190)
GUISetBkColor(0x000000)
$Button1 = GUICtrlCreateButton("СБРОС",350, 5, 100, 19, $WS_BORDER, $WS_EX_STATICEDGE)
GUICtrlSetCursor (-1, 0)
$PolosaProcent = GUICtrlCreateLabel("   ", 38, 300, 700, 1,$WS_BORDER)
$PolosaProcent1 = GUICtrlCreateLabel("   ", 1, 300, 798, 1)
GUICtrlSetBkColor(-1, 0x990066 )
$Procent = GUICtrlCreateLabel(" 0%", 45, 293, 43, 16,BitOR($SS_CENTERIMAGE,$WS_BORDER))
GUICtrlSetColor(-1, 0x1F75FE)
GUISetState(@SW_SHOW,$Form1)

AdlibRegister('ran',Random(50,55))
AdlibRegister('Line', 55)
AdlibRegister('pPerx', 10000)

Global $iStartX
Global $iStartY = 300
Global $iEndX
Global $iEndY = 300
Global $Per = 0
Global $pPer
Global $pPerx1 = 33 
Global $pPerx2 = 37 
Global $Lpx = 300
Global $Lpxx = 293
Global $Lpyy = 45
Global $Lpy = 39
While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
        Case $Button1
			obnulen()
	EndSwitch

WEnd

Func pPerx()
	$pPerx1 += 7
	$pPerx2 += 7
	$Lpyy += 7
	$Lpy += 7
EndFunc

Func ran()
 $pPer = Random(-3, 3, 1)
EndFunc



Func obnulen()
	$Per = 0
	$iStartY = 300
	$iEndY = 300
	$Lpx = 300
	$Lpxx = 293
EndFunc


Func Line()

Select
Case $Per <-200
	$Per += 15
	$iStartY += 15
	$iEndY += 15
	$Lpx += 15
	$Lpxx += 15
Case $Per > 200
	$iStartY -= 15
	$iEndY -= 15
	$Per -= 15
	$Lpx -= 15
	$Lpxx -= 15
EndSelect

	$Per =_BigNum_Add($Per, $pPer)
	$iStartX = $pPerx1 
	$iStartY += $pPer
	$iEndX = $pPerx2   
	$iEndY += $pPer
	$Lpx += $pPer
	$Lpxx += $pPer
	Lp100()
	grss($iStartX, $iStartY, $iEndX, $iEndY)
EndFunc



Func Lp100()
	Local $PR
	$PR &= $Per
	$PR &=' %'
	GUICtrlDelete($PolosaProcent)
$PolosaProcent = GUICtrlCreateLabel("   ", $Lpy, $Lpx, 799, 1,$WS_BORDER)
 GUICtrlDelete($Procent)

$Procent = GUICtrlCreateLabel($PR, $Lpyy, $Lpxx, 43, 16,BitOR($SS_CENTERIMAGE,$WS_BORDER))
GUICtrlSetColor(-1, 0x1F75FE)
EndFunc

Func grss($iStartX, $iStartY, $iEndX, $iEndY)
_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($Form1)
$hPenBlueThin = _GDIPlus_PenCreate(0xFF33CCFF,2) ; перо для синей линии
_GDIPlus_GraphicsDrawLine($hGraphic, $iStartX, $iStartY, $iEndX, $iEndY, $hPenBlueThin) ; линия отрезка
_GDIPlus_PenDispose($hPenBlueThin) ; удаление ресурсов
_GDIPlus_GraphicsDispose($hGraphic) ; удаление ресурсов
_GDIPlus_Shutdown()
EndFunc


но есть проблема :-\, всё нарисованное исчезает при сворачивании окна,
и я не знаю как решить этот вопрос.
Пожалуйста подскажите решение :smile:

Заранее всем спасибо.
 

Redline

AutoIT Гуру
Сообщения
506
Репутация
375
Просто нужно рисовать не в окно, а в буфер и тогда все будет как надо.
Еще вынес вызов _GDIPlus, создание графики, кисти и их удаление из функции, т.к. незачем это делать каждый раз при отрисовке линии.
Код:
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <WinAPIEx.au3>
#include <BigNum.au3>

$iWidth = 800
$iHeight = 600
$Form1 = GUICreate("Form1", $iWidth, $iHeight, 365, 190)
GUISetBkColor(0x000000)
$Button1 = GUICtrlCreateButton("СБРОС",350, 5, 100, 19, $WS_BORDER, $WS_EX_STATICEDGE)
GUICtrlSetCursor (-1, 0)
$PolosaProcent = GUICtrlCreateLabel("   ", 38, 300, 700, 1,$WS_BORDER)
$PolosaProcent1 = GUICtrlCreateLabel("   ", 1, 300, 798, 1)
GUICtrlSetBkColor(-1, 0x990066 )
$Procent = GUICtrlCreateLabel(" 0%", 45, 293, 43, 16,BitOR($SS_CENTERIMAGE,$WS_BORDER))
GUICtrlSetColor(-1, 0x1F75FE)
GUISetState(@SW_SHOW,$Form1)

AdlibRegister('ran',Random(50,55))
AdlibRegister('Line', 55)
AdlibRegister('pPerx', 10000)

Global $iStartX
Global $iStartY = 300
Global $iEndX
Global $iEndY = 300
Global $Per = 0
Global $pPer
Global $pPerx1 = 33
Global $pPerx2 = 37
Global $Lpx = 300
Global $Lpxx = 293
Global $Lpyy = 45
Global $Lpy = 39

_GDIPlus_Startup()
Global $hGraphic = _GDIPlus_GraphicsCreateFromHWND($Form1)
Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphic)
Global $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
Global $hPenBlueThin = _GDIPlus_PenCreate(0xFF33CCFF,2) ; перо для синей линии
_GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2)

GUIRegisterMsg($WM_ERASEBKGND, 'WM_ERASEBKGND')

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
		Case $GUI_EVENT_CLOSE
			_GDIPlus_PenDispose($hPenBlueThin) ; удаление ресурсов
			_GDIPlus_GraphicsDispose($hGraphic) ; удаление ресурсов
			_GDIPlus_BitmapDispose($hBitmap)
			_GDIPlus_GraphicsDispose($hBackbuffer)
			_GDIPlus_Shutdown()
            Exit
        Case $Button1
            obnulen()
    EndSwitch
WEnd

Func pPerx()
    $pPerx1 += 7
    $pPerx2 += 7
    $Lpyy += 7
    $Lpy += 7
EndFunc

Func ran()
 $pPer = Random(-3, 3, 1)
EndFunc



Func obnulen()
    $Per = 0
    $iStartY = 300
    $iEndY = 300
    $Lpx = 300
    $Lpxx = 293
EndFunc


Func Line()

	Select
		Case $Per <-200
			$Per += 15
			$iStartY += 15
			$iEndY += 15
			$Lpx += 15
			$Lpxx += 15
		Case $Per > 200
			$iStartY -= 15
			$iEndY -= 15
			$Per -= 15
			$Lpx -= 15
			$Lpxx -= 15
	EndSelect
    $Per =_BigNum_Add($Per, $pPer)
    $iStartX = $pPerx1
    $iStartY += $pPer
    $iEndX = $pPerx2
    $iEndY += $pPer
    $Lpx += $pPer
    $Lpxx += $pPer
    Lp100()
    grss($iStartX, $iStartY, $iEndX, $iEndY)
EndFunc



Func Lp100()
    Local $PR
    $PR &= $Per
    $PR &=' %'
    GUICtrlDelete($PolosaProcent)
	$PolosaProcent = GUICtrlCreateLabel("   ", $Lpy, $Lpx, 799, 1,$WS_BORDER)
	 GUICtrlDelete($Procent)

	$Procent = GUICtrlCreateLabel($PR, $Lpyy, $Lpxx, 43, 16,BitOR($SS_CENTERIMAGE,$WS_BORDER))
	GUICtrlSetColor(-1, 0x1F75FE)
EndFunc

Func grss($iStartX, $iStartY, $iEndX, $iEndY)
	_GDIPlus_GraphicsDrawLine($hBackbuffer, $iStartX, $iStartY, $iEndX, $iEndY, $hPenBlueThin) ; линия отрезка
	_GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iWidth, $iHeight)
EndFunc

Func WM_ERASEBKGND()
	_GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iWidth, $iHeight)
EndFunc
 
Автор
D

dreamorder

Гость
Redline
Большое спасибо! Отлично получается :ok:


Добавлено:
Сообщение автоматически объединено:

Появилась новая проблема, вставил рисование графика в скрипт,
некоторое время работает нормально, но потом исчезают элементы окна
Код:
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <WinAPIEx.au3>
#include <EditConstants.au3>
#include <BigNum.au3>
#include <Date.au3>

Global $sButton
Global $bButton
Global $nCheck     ; часики
Global $Per = 0
Global $pPer
Global $iStartX
Global $iEndX
Global $pPerx1 = 33
Global $pPerx2 = 37
Global $Lpxx = 98
Global $Lpyy = 791
Global $iStartY = 105
Global $iEndY = 105
Global $Lpx = 105 ; полоса у
Global $Lpy = 38 ; полоса х


$Form1 = GUICreate("Form1", 839, 630, 365, 190, $WS_EX_TOOLWINDOW)
GUISetBkColor(0x808080)
$Label1 = GUICtrlCreateLabel("   ", 8, 8, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label2 = GUICtrlCreateLabel("   ", 8, 12, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label3 = GUICtrlCreateLabel("   ", 8, 16, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label4 = GUICtrlCreateLabel("   ", 8, 20, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label5 = GUICtrlCreateLabel("   ", 8, 24, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label6 = GUICtrlCreateLabel("   ", 8, 28, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label7 = GUICtrlCreateLabel("   ", 8, 32, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label8 = GUICtrlCreateLabel("   ", 8, 36, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label9 = GUICtrlCreateLabel("   ", 8, 40, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label10 = GUICtrlCreateLabel("   ", 8, 44, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label11 = GUICtrlCreateLabel("   ", 8, 48, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label12 = GUICtrlCreateLabel("   ", 8, 52, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label13 = GUICtrlCreateLabel("   ", 8, 56, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label14 = GUICtrlCreateLabel("   ", 8, 60, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label15 = GUICtrlCreateLabel("   ", 8, 64, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label16 = GUICtrlCreateLabel("   ", 8, 68, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label17 = GUICtrlCreateLabel("   ", 8, 72, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label18 = GUICtrlCreateLabel("   ", 8, 76, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label19 = GUICtrlCreateLabel("   ", 8, 80, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label20 = GUICtrlCreateLabel("   ", 8, 84, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label21 = GUICtrlCreateLabel("   ", 8, 88, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label22 = GUICtrlCreateLabel("   ", 8, 92, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label23 = GUICtrlCreateLabel("   ", 8, 96, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label24 = GUICtrlCreateLabel("   ", 8, 100, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label25 = GUICtrlCreateLabel("   ", 8, 104, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label26 = GUICtrlCreateLabel("   ", 8, 108, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label27 = GUICtrlCreateLabel("   ", 8, 112, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label28 = GUICtrlCreateLabel("   ", 8, 116, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label29 = GUICtrlCreateLabel("   ", 8, 120, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label30 = GUICtrlCreateLabel("   ", 8, 124, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label31 = GUICtrlCreateLabel("   ", 8, 128, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label32 = GUICtrlCreateLabel("   ", 8, 132, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label33 = GUICtrlCreateLabel("   ", 8, 136, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label34 = GUICtrlCreateLabel("   ", 8, 140, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label35 = GUICtrlCreateLabel("   ", 8, 144, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label36 = GUICtrlCreateLabel("   ", 8, 148, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label37 = GUICtrlCreateLabel("   ", 8, 152, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label38 = GUICtrlCreateLabel("   ", 8, 156, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label39 = GUICtrlCreateLabel("   ", 8, 160, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label40 = GUICtrlCreateLabel("   ", 8, 164, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label41 = GUICtrlCreateLabel("   ", 8, 168, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label42 = GUICtrlCreateLabel("   ", 8, 172, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label43 = GUICtrlCreateLabel("   ", 8, 176, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label44 = GUICtrlCreateLabel("   ", 8, 180, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label45 = GUICtrlCreateLabel("   ", 8, 184, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label46 = GUICtrlCreateLabel("   ", 8, 188, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label47 = GUICtrlCreateLabel("   ", 8, 192, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label48 = GUICtrlCreateLabel("   ", 8, 196, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label49 = GUICtrlCreateLabel("   ", 8, 200, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label50 = GUICtrlCreateLabel("   ", 8, 204, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Label0 = GUICtrlCreateLabel("   ", 8, 208, 21, 3) ; --- $Label0 --- Ноль ====================
GUICtrlSetBkColor(-1, 0x1F75FE)
$2Label1 = GUICtrlCreateLabel("   ", 8, 212, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label2 = GUICtrlCreateLabel("   ", 8, 216, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label3 = GUICtrlCreateLabel("   ", 8, 220, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label4 = GUICtrlCreateLabel("   ", 8, 224, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label5 = GUICtrlCreateLabel("   ", 8, 228, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label6 = GUICtrlCreateLabel("   ", 8, 232, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label7 = GUICtrlCreateLabel("   ", 8, 236, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label8 = GUICtrlCreateLabel("   ", 8, 240, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label9 = GUICtrlCreateLabel("   ", 8, 244, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label10 = GUICtrlCreateLabel("   ", 8, 248, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label11 = GUICtrlCreateLabel("   ", 8, 252, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label12 = GUICtrlCreateLabel("   ", 8, 256, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label13 = GUICtrlCreateLabel("   ", 8, 260, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label14 = GUICtrlCreateLabel("   ", 8, 264, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label15 = GUICtrlCreateLabel("   ", 8, 268, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label16 = GUICtrlCreateLabel("   ", 8, 272, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label17 = GUICtrlCreateLabel("   ", 8, 276, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label18 = GUICtrlCreateLabel("   ", 8, 280, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label19 = GUICtrlCreateLabel("   ", 8, 284, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label20 = GUICtrlCreateLabel("   ", 8, 288, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label21 = GUICtrlCreateLabel("   ", 8, 292, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label22 = GUICtrlCreateLabel("   ", 8, 296, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label23 = GUICtrlCreateLabel("   ", 8, 300, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label24 = GUICtrlCreateLabel("   ", 8, 304, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label25 = GUICtrlCreateLabel("   ", 8, 308, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label26 = GUICtrlCreateLabel("   ", 8, 312, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label27 = GUICtrlCreateLabel("   ", 8, 316, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label28 = GUICtrlCreateLabel("   ", 8, 320, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label29 = GUICtrlCreateLabel("   ", 8, 324, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label30 = GUICtrlCreateLabel("   ", 8, 328, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label31 = GUICtrlCreateLabel("   ", 8, 332, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label32 = GUICtrlCreateLabel("   ", 8, 336, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label33 = GUICtrlCreateLabel("   ", 8, 340, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label34 = GUICtrlCreateLabel("   ", 8, 344, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label35 = GUICtrlCreateLabel("   ", 8, 348, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label36 = GUICtrlCreateLabel("   ", 8, 352, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label37 = GUICtrlCreateLabel("   ", 8, 356, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label38 = GUICtrlCreateLabel("   ", 8, 360, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label39 = GUICtrlCreateLabel("   ", 8, 364, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label40 = GUICtrlCreateLabel("   ", 8, 368, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label41 = GUICtrlCreateLabel("   ", 8, 372, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label42 = GUICtrlCreateLabel("   ", 8, 376, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label43 = GUICtrlCreateLabel("   ", 8, 380, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label44 = GUICtrlCreateLabel("   ", 8, 384, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label45 = GUICtrlCreateLabel("   ", 8, 388, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label46 = GUICtrlCreateLabel("   ", 8, 392, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label47 = GUICtrlCreateLabel("   ", 8, 396, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label48 = GUICtrlCreateLabel("   ", 8, 400, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label49 = GUICtrlCreateLabel("   ", 8, 404, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$2Label50 = GUICtrlCreateLabel("   ", 8, 408, 21, 3)
GUICtrlSetBkColor(-1, 0x000000)
$Button1 = GUICtrlCreateButton("  ",37, 218, 155, 33, $WS_BORDER, $WS_EX_STATICEDGE)
GUICtrlSetCursor (-1, 0)
$Button2 = GUICtrlCreateButton("   ",37, 256, 155, 33, $WS_BORDER, $WS_EX_STATICEDGE)
GUICtrlSetCursor (-1, 0)
$hLabel = GuiCtrlCreateLabel( '', 800, 570, 31, 29)
GUICtrlSetColor(106, 0x191970)
$Grafic = GUICtrlCreateLabel("   ", 31, 3, 761, 207,$WS_BORDER,$WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x000000)
$PolosaProcent = GUICtrlCreateLabel("   ", 38, 105, 797, 1,$WS_BORDER)
$Procent = GUICtrlCreateLabel(".00%", 791, 98, 38, 16,BitOR($SS_CENTERIMAGE,$SS_RIGHT,$WS_BORDER))
GUICtrlSetBkColor(-1, 0xA0A0A4)
GUICtrlSetColor(-1, 0x191970)
$hLabel = GuiCtrlCreateLabel( '', 762, 577, 77, 18)
GUICtrlSetColor(106, 0x191970)
GUISetState(@SW_SHOW,$Form1)

AdlibRegister('ran',Random(5911,6000))
AdlibRegister('_Main', 60000)
AdlibRegister('Line', 6000)

;==============================================================================
_GDIPlus_Startup()
Global $hGraphic = _GDIPlus_GraphicsCreateFromHWND($Form1) ; Создаёт графический объект из дескриптора окна
Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics(800, 212, $hGraphic) ;Создает объект Bitmap на основе графического объекта, с указанием ширины и высоты
Global $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap) ; Возвращает графический контекст изображения
Global $hPenBlueThin = _GDIPlus_PenCreate(0xFF33CCFF,2) ; перо для синей линии
_GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 0) ; Задает качество визуализации графического объекта

GUIRegisterMsg($WM_ERASEBKGND, 'WM_ERASEBKGND')
;===============================================================================

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			 _GDIPlus_PenDispose($hPenBlueThin) ; удаление ресурсов
            _GDIPlus_GraphicsDispose($hGraphic) ; удаление ресурсов
            _GDIPlus_BitmapDispose($hBitmap)  ; удаление ресурсов
            _GDIPlus_GraphicsDispose($hBackbuffer)  ; удаление ресурсов
            _GDIPlus_Shutdown()  ; удаление ресурсов
			Exit

	EndSwitch
	time()
WEnd
;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Func _Main()

    Local  $tTime, $aTime
    ; Получение текущего системного времени
    $tTime = _Date_Time_GetSystemTime()
    $aTime = _Date_Time_SystemTimeToArray($tTime)

  Select
	Case $aTime[4] = 0
	pPerx()
    Case $aTime[4] = 12
	pPerx()
	Case $aTime[4] = 24
	pPerx()
    Case $aTime[4] = 36
	pPerx()
    Case $aTime[4] = 48
	pPerx()
	EndSelect
  EndFunc
;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
 Func ran()
    $pPer = Random(-3, 3, 1)
EndFunc
;-----------------------------------------------------------------------------------------

;---------------------------------------------------------------------------------------
Func time()
    If @SEC <> $nCheck Then
        GUICtrlSetData($hLabel, " " & @HOUR & ":" & @MIN & ":" & @SEC )
		GUICtrlSetFont(-1, 10, 600, 0, "Tahoma")
        $nCheck = @SEC
    EndIf
EndFunc
;----------------------------------------------------------------------------------------------
Func pPerx()
	$pPerx1 += 6
	$pPerx2 += 6
	$Lpy += 6
EndFunc

Func Line()

Select
Case $Per <-100
	$Per += 5
	$iStartY += 5
	$iEndY += 5
	$Lpx += 5
	$Lpxx -= 5
Case $Per > 100
	$iStartY -= 5
	$iEndY -= 5
	$Per -= 5
	$Lpx -= 5
	$Lpxx -= 5
EndSelect
	$Per =_BigNum_Add($Per, $pPer)
	$iStartX = $pPerx1
	$iStartY += $pPer
	$iEndX = $pPerx2
	$iEndY += $pPer
	$Lpx += $pPer
	$Lpxx += $pPer
	Lp00()
	grss($iStartX, $iStartY, $iEndX, $iEndY)
EndFunc
Func Lp00()
	Local $PR
	$PR &= $Per
	$PR &=' %'
GUICtrlDelete($PolosaProcent)
$PolosaProcent = GUICtrlCreateLabel("   ", $Lpy, $Lpx, 797, 1)
GUICtrlSetBkColor(-1,0x800000)
GUICtrlDelete($Procent)
$Procent = GUICtrlCreateLabel($PR, $Lpyy, $Lpxx, 38, 16,BitOR($SS_CENTERIMAGE,$WS_BORDER,$SS_RIGHT))
GUICtrlSetBkColor(-1, 0xA0A0A4)
GUICtrlSetFont(-1, 9, 570, 1, "Tahoma")
GUICtrlSetColor(-1, 0x191970)
EndFunc
;=======================================================================================================================
Func grss($iStartX, $iStartY, $iEndX, $iEndY)
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $iStartX, $iStartY, $iEndX, $iEndY, $hPenBlueThin) ; рисует линию отрезка
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, 800, 212)
EndFunc

Func WM_ERASEBKGND()
   _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, 800, 212)
EndFunc
;-------------------------------------------------------------------------------------------------------------------

на верхнем норм. вид,
на нижнем "проблема"
:blink:
 
Автор
D

dreamorder

Гость
Всем спасибо, тема решена.
Просто вставил график отдельным(дочерним) окном.
;)
 
Автор
D

dreamorder

Гость
Вот рабочий код того что смог написать (добавил не много красоты свечам) :smile:

Код:
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <WinAPIEx.au3>
#include <BigNum.au3>
#include <Date.au3>
;=====================================================================================

$Form2 = GUICreate("Form2", 955, 630, 100, 100, $WS_CLIPCHILDREN)
GUISetBkColor(0x808080)
$hLabel = GuiCtrlCreateLabel( '', 887, 587, 55, 14)
GUICtrlSetColor(106, 0x191970) ; цвет текста элемента


$iWidth = 993
$iHeight = 219
$Form1 = GUICreate("",$iWidth, $iHeight, 32, 5, BitOR($DS_SETFOREGROUND,$WS_CHILD),-1,$Form2) ; дочернее окно графика
GUISetBkColor(0x000000)
$PolosaProcent = GUICtrlCreateLabel("   ", 7, 109, 883, 1,$WS_BORDER)
$PolosaProcent1 = GUICtrlCreateLabel("   ", 8, 109, 909, 1)
GUICtrlSetBkColor(-1, 0x663333 )
$Procent = GUICtrlCreateLabel("00%", 883, 101, 33, 16,$SS_RIGHT)
GUICtrlSetColor(-1, 0x1F75FE)


GUISetState(@SW_SHOW,$Form2)
GUISetState(@SW_SHOW,$Form1)
;======================================================================================
AdlibRegister('time', 300)
AdlibRegister('ran', 1200)
AdlibRegister('Line', 1200)
AdlibRegister('_Main', 60000)

Global $sButton
Global $bButton
Global $nCheck

Global $0iStartX
Global $1iStartX
Global $2iStartX
Global $3iStartX
Global $4iStartX
Global $5iStartX
Global $iStartY = 109
Global $0iEndX
Global $1iEndX
Global $2iEndX
Global $3iEndX
Global $4iEndX
Global $5iEndX
Global $iEndY = 109
Global $Per = 0
Global $pPer
Global $centrcen = 0

Global $0pPerx1 = 2
Global $0pPerx2 = 5
Global $1pPerx1 = 1
Global $1pPerx2 = 2
Global $2pPerx1 = 2
Global $2pPerx2 = 3
Global $3pPerx1 = 3
Global $3pPerx2 = 4
Global $4pPerx1 = 4
Global $4pPerx2 = 5
Global $5pPerx1 = 5
Global $5pPerx2 = 6

Global $Lpx = 109
Global $Lpxx = 101
Global $Lpyy = 883
Global $Lpy = 8

_GDIPlus_Startup()
Global $hGraphic = _GDIPlus_GraphicsCreateFromHWND($Form1)
Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphic)
Global $hBackbuffer1 = _GDIPlus_ImageGetGraphicsContext($hBitmap)
Global $hPenBlueThin0 = _GDIPlus_PenCreate(0xFFFF0000,3) ; перо для синей линии
Global $hPenBlueThin1 = _GDIPlus_PenCreate(0xFF008000,2) ; перо для синей линии
Global $hPenBlueThin2 = _GDIPlus_PenCreate(0xFFD2691E,3) ; перо для синей линии
Global $hPenBlueThin3 = _GDIPlus_PenCreate(0xFFFFFFff,4) ; перо для синей линии
_GDIPlus_GraphicsSetSmoothingMode($hBackbuffer1, 2)


GUIRegisterMsg($WM_ERASEBKGND, 'WM_ERASEBKGND')

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
		Case $GUI_EVENT_CLOSE
			_GDIPlus_PenDispose($hPenBlueThin0) ; удаление ресурсов
            _GDIPlus_PenDispose($hPenBlueThin1) ; удаление ресурсов
			_GDIPlus_PenDispose($hPenBlueThin2) ; удаление ресурсов
			_GDIPlus_PenDispose($hPenBlueThin3) ; удаление ресурсов
            _GDIPlus_GraphicsDispose($hGraphic) ; удаление ресурсов
            _GDIPlus_BitmapDispose($hBitmap)
            _GDIPlus_GraphicsDispose($hBackbuffer1)
            _GDIPlus_Shutdown()
            Exit


    EndSwitch
WEnd

Func time()
    If @SEC <> $nCheck Then
        GUICtrlSetData($hLabel, " " & @HOUR & ":" & @MIN & ":" & @SEC )
		GUICtrlSetFont(-1, 10, 600, 0, "Tahoma")
        $nCheck = @SEC
    EndIf
EndFunc

Func _Main()

    Local  $tTime, $aTime
    ; Получение текущего системного времени
    $tTime = _Date_Time_GetSystemTime()
    $aTime = _Date_Time_SystemTimeToArray($tTime)
   ; MemoWrite("Час .........: " & $aTime[3])
  ;  MemoWrite("Минута ......: " & $aTime[4])
  ;  MemoWrite("Секунда .....: " & $aTime[5])
  ;  MemoWrite("Миллисекунда : " & $aTime[6])
  Select
	Case $aTime[4] = 0 ;усли 00 минут то начинает следующую свечу
	pPerx()
    Case $aTime[4] = 12   ;усли 12 минут то начинает следующую свечу
	pPerx()
	Case $aTime[4] = 24
	pPerx()
    Case $aTime[4] = 36
	pPerx()
    Case $aTime[4] = 48
	pPerx()
	EndSelect
EndFunc

Func pPerx()

    $centrcen = $Per + $pPer
	$0pPerx1 += 7
    $0pPerx2 += 7
    $1pPerx1 += 7
    $1pPerx2 += 7
	$2pPerx1 += 7
    $2pPerx2 += 7
	$3pPerx1 += 7
    $3pPerx2 += 7
	$4pPerx1 += 7
    $4pPerx2 += 7
	$5pPerx1 += 7
    $5pPerx2 += 7

    $Lpy += 7
EndFunc

Func ran()
 $pPer = Random(-3, 3, 1)
EndFunc

Func Line()

    Select
        Case $Per <-100
            $Per += 5
            $iStartY += 5
            $iEndY += 5
            $Lpx += 5
            $Lpxx += 5
        Case $Per > 100
            $iStartY -= 5
            $iEndY -= 5
            $Per -= 5
            $Lpx -= 5
            $Lpxx -= 5
		EndSelect
	$Per =_BigNum_Add($Per, $pPer)
	$0iStartX = $0pPerx1
	$0iEndX = $0pPerx2
    $1iStartX = $1pPerx1
	$1iEndX = $1pPerx2
	$2iStartX = $2pPerx1
	$2iEndX = $2pPerx2
	$3iStartX = $3pPerx1
	$3iEndX = $3pPerx2
	$4iStartX = $4pPerx1
	$4iEndX = $4pPerx2
	$5iStartX = $5pPerx1
	$5iEndX = $5pPerx2

    $iStartY += $pPer
	$iEndY += $pPer
    $Lpx += $pPer
    $Lpxx += $pPer
	Lp100()
	grss0($0iStartX, $iStartY, $0iEndX, $iEndY)
	grss1($1iStartX, $iStartY, $1iEndX, $iEndY)
	grss2($2iStartX, $iStartY, $2iEndX, $iEndY)
	grss3($3iStartX, $iStartY, $3iEndX, $iEndY)
	grss4($4iStartX, $iStartY, $4iEndX, $iEndY)
	grss5($5iStartX, $iStartY, $5iEndX, $iEndY)
EndFunc



Func Lp100()
    Local $PR
    $PR &= $Per
    $PR &='%'
    GUICtrlDelete($PolosaProcent)
    $PolosaProcent = GUICtrlCreateLabel("   ", $Lpy, $Lpx, 883, 1,$WS_BORDER)
     GUICtrlDelete($Procent)

    $Procent = GUICtrlCreateLabel($PR, $Lpyy, $Lpxx, 33, 16,$SS_RIGHT)
    GUICtrlSetColor(-1, 0x1F75FE)
EndFunc

Func grss1($1iStartX, $iStartY, $1iEndX, $iEndY)
	Select
Case $Per >= $centrcen
    _GDIPlus_GraphicsDrawLine($hBackbuffer1, $1iStartX, $iStartY, $1iEndX, $iEndY, $hPenBlueThin1) ; линия отрезка
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iWidth, $iHeight)
	EndSelect
EndFunc
Func grss2($2iStartX, $iStartY, $2iEndX, $iEndY)
	Select
Case $Per >= $centrcen
	 _GDIPlus_GraphicsDrawLine($hBackbuffer1, $2iStartX, $iStartY, $2iEndX, $iEndY, $hPenBlueThin2) ; линия отрезка
	 _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iWidth, $iHeight)
	 EndSelect
EndFunc
Func grss3($3iStartX, $iStartY, $3iEndX, $iEndY)
	Select
Case $Per >= $centrcen
	  _GDIPlus_GraphicsDrawLine($hBackbuffer1, $3iStartX, $iStartY, $3iEndX, $iEndY, $hPenBlueThin3) ; линия отрезка
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iWidth, $iHeight)
	EndSelect
EndFunc
Func grss4($4iStartX, $iStartY, $4iEndX, $iEndY)
	Select
Case $Per >= $centrcen
	   _GDIPlus_GraphicsDrawLine($hBackbuffer1, $4iStartX, $iStartY, $4iEndX, $iEndY, $hPenBlueThin2) ; линия отрезка
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iWidth, $iHeight)
	EndSelect
EndFunc
Func grss5($5iStartX, $iStartY, $5iEndX, $iEndY)
	Select
Case $Per >= $centrcen
	    _GDIPlus_GraphicsDrawLine($hBackbuffer1, $5iStartX, $iStartY, $5iEndX, $iEndY, $hPenBlueThin1) ; линия отрезка
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iWidth, $iHeight)
	EndSelect
EndFunc

Func grss0($0iStartX, $iStartY, $0iEndX, $iEndY)
	Select
Case $Per <= $centrcen
	  _GDIPlus_GraphicsDrawLine($hBackbuffer1, $3iStartX, $iStartY, $3iEndX, $iEndY, $hPenBlueThin0) ; линия отрезка
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iWidth, $iHeight)
	EndSelect
EndFunc


Func WM_ERASEBKGND()
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iWidth, $iHeight)
EndFunc
 
Верх