Только что вот нашёл и запустил свой старый скрипт, где в цикле используется BitBlt для перерисовки окна. Вроде мельканий никаких нет:
If !pToken := Gdip_Startup()
{
MsgBox, 48, Ошибка GDI+, Убедитесь в наличии gdiplus.dll в вашей системе!
ExitApp
}
OnExit, Exit
SetBatchLines, -1
SetWinDelay, 0
k1 = 52 ; коэффициент частоты
k2 = 80 ; коэффициент амплитуды
Width = 492
Height = 250 ; размеры картинки
SleepDuration = 6 ; пауза в цикле
Frame = 3 ; рамка
H2 := Height//2
X := (A_ScreenWidth-Width)//2
Y := (A_ScreenHeight-Height)//2
DllCall("Winmm\timeBeginPeriod", UInt, 3)
hbm := CreateDIBSection(Width, Height)
hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)
Gdip_SetSmoothingMode(G, 4)
pFrameBrush := Gdip_BrushCreateSolid(0xffC4C0B8) ; кисть для рамки
pFillBrush := Gdip_BrushCreateSolid(0xffffffff) ; кисть для заливки
pGrayPen := Gdip_CreatePen(0xff808080, 1) ; карандаш для оси
pBluePen := Gdip_CreatePen(0xff0000ff, 1) ; карандаш для графика
Gdip_FillRectangle(G, pFrameBrush, -1, -1, Width+2, Height+2) ; с запасом
Gdip_FillRectangle(G, pFillBrush, Frame, Frame, Width-Frame*2-1, Height-Frame*2-1)
Gdip_DeleteBrush(pFrameBrush)
Gdip_DrawLine(G, pGrayPen, Frame, H2, Width-Frame-1, H2)
Gui, Color, 0xECE9D8
Gui, Add, Pic, x20 y20 w%Width% h%Height% hwndhPic
Gui, Add, Button, % "x" (Width - 40)//2 " y" 35 + Height " w80 h23 gPause vButton", Start
Gui, Show, % "w" Width+40 " h" Height + 75
hPicDC := GetDC(hPic) ; получаем контекст контрола, чтобы переносить в него изображение
BitBlt(hPicDC, 0, 0, Width, Height, hdc, 0, 0) ; переносим рисунок в контекст контрола
OnMessage(0xF, "WM_PAINT") ; поддержка изображения при перерисовке окна
Loop
{
i := !i
x1 := Frame+1
y1 := Round((-Sin((x1 - Frame - 1)*k1/1000))*k2 + H2)
While x1 < Width-Frame-2
{
DllCall("Sleep", UInt, SleepDuration)
if !p
Continue
x2 := x1 + 1
y2 := Round((-Sin((x2 - Frame - 1)*k1/1000))*k2 + H2)
if i
Gdip_DrawLine(G, pBluePen, x1, y1, x2, y2)
Else
{
end := x2 = Width-Frame-2
Gdip_FillRectangle(G, pFillBrush, x1-1, Frame+1, end ? 3 : 2, Height-Frame*2-2)
Gdip_DrawLine(G, pGrayPen, x1-1, H2, end ? x2+1 : x2, H2)
}
x1 := x2, y1 := y2
BitBlt(hPicDC, 0, 0, Width, Height, hdc, 0, 0)
}
}
Pause:
GuiControl,, Button, % (p := !p) ? "Stop" : "Start"
Return
GuiClose:
GuiEscape:
ExitApp
Exit:
Gdip_DeletePen(pGrayPen), Gdip_DeletePen(pBluePen), Gdip_DeleteBrush(pFillBrush)
ReleaseDC(hPicDC, hPic)
SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc), Gdip_DeleteGraphics(G)
Gdip_Shutdown(pToken)
DllCall("Winmm\timeEndPeriod", UInt, 3)
ExitApp
WM_PAINT() ; поддержка изображения при перерисовке окна
{
global
SetTimer, Timer, -10
Return
Timer:
BitBlt(hPicDC, 0, 0, Width, Height, hdc, 0, 0)
Return
}