WS_EX_LAYERED Causing system Caton

Ask for help, how to use AHK_H, etc.
arcticir
Posts: 694
Joined: 17 Nov 2013, 11:32

WS_EX_LAYERED Causing system Caton

07 Sep 2017, 06:12

A large number of create LAYERED window, will cause the system Caton.
This kind of Caton seems to be due to DWM.EXE, although even at peak, it occupies the CPU at about 15%, but it seems to cause a huge burden on the system.
Window, mouse and keyboard, are lost response.
Not only when creating a cardon, when the LAYERED window closes / loses focus and other events occur, it will also be the Caton system.

Is there any way to avoid this problem?



In this example, my computer, in less than a second time to create the window and show it.
Then for 30 seconds for Caton, and show the contents of the window.
If you try to close it, it will disappear after 1 minute in Caton.

Code: Select all

gui:=GuiCreate()
h:=5
idx:=2000
loop idx
text(gui.hwnd,2,A_Index*h,50,h-3)

gui.show("w155 h" 500)
return

text(hwnd,x,y,w,h){
	static bit:="DWORD biSize;LONG biWidth;LONG biHeight;WORD biPlanes;WORD biBitCount;DWORD biCompression;DWORD biSizeImage;LONG biXPelsPerMeter;LONG biYPelsPerMeter;DWORD biClrUsed;DWORD biClrImportant;"
	,dc:=GetDC(),pt:=Struct("x,y")

	hwnd:=CreateWindowEx(0x80000, "static","",0X40000000|0x10000000,0,0,0,0,hwnd,0,0,0)
	bi:=Struct(bit,{biSize:sizeof(bit),biWidth:w,biHeight:h,biPlanes:1,biBitCount:32})
	hbm := CreateDIBSection(dc,bi[]),ReleaseDC(0,hdc)
	hdc := CreateCompatibleDC(),obm := SelectObject(hdc, hbm)
	GdipCreateFromHDC(hdc,getvar(G:=0))
	GdipSetInterpolationMode(G,7)
	GdipGraphicsClear(g,0xffdd00dd)
	pt.x:=x,pt.y:=y
	UpdateLayeredWindow(hwnd,0,pt[],getvar(temp1:=w|h<<32),hdc, getvar(temp2:=0),0,getvar(temp3:=255<<16|1<<24),2)
	SelectObject(hdc, obm),DeleteObject(hbm),DeleteDC(hdc),GdipDeleteGraphics(G)
}
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: WS_EX_LAYERED Causing system Caton

07 Sep 2017, 18:57

Can you test it on non AHK_H, do you get the same problem?
arcticir
Posts: 694
Joined: 17 Nov 2013, 11:32

Re: WS_EX_LAYERED Causing system Caton

08 Sep 2017, 09:41

Yes, using LU32, the same problem exists.

Code: Select all

gui,+hwndhwnd
Gdip_Startup()
h:=5
idx:=20

loop % idx
test(hwnd,2,A_Index*h,50,h-3)

gui,show,w155 h500
return

test(hwnd,x,y,w,h){
	hwnd:=DllCall( "CreateWindowEx", UInt,0x80000, Str,"Static", Int,0
	,UInt,0X40000000|0x10000000,  Int,0, Int,0, UInt,0, UInt,0, UInt,hWnd, Int,0, Int,0, Int,0 )
	hbm :=CreateDIBSection(w,h)
	hdc := CreateCompatibleDC(0)
	obm := SelectObject(hdc, hbm)
	G:=Gdip_GraphicsFromHDC(hdc)
	Gdip_SetInterpolationMode(G,7)
	Gdip_GraphicsClear(g,0xffdd00dd)

	UpdateLayeredWindow(hwnd,hdc,x,y,w,h)
	SelectObject(hdc, obm),DeleteObject(hbm),DeleteDC(hdc),Gdip_DeleteGraphics(G)
}

Return to “Ask for Help”

Who is online

Users browsing this forum: No registered users and 23 guests