<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic 回复： trackview opacity in 3ds Max Programming Forum</title>
    <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/trackview-opacity/m-p/10552806#M5064</link>
    <description>&lt;LI-CODE lang="general"&gt;fn CreateUser32AssistAssembly =
(
	source = "using System;\n"
	source += "using System.Runtime.InteropServices;\n"
	source += "class Wind32Assists\n"
	source += "{\n"
	source += "		[DllImport(\"user32.dll\", EntryPoint=\"UpdateWindow\")]\n"
	source += "		public static extern bool UpdateWindow(IntPtr hWnd);\n"
	source += "		[DllImport(\"user32.dll\", EntryPoint=\"GetWindowLong\")]\n"
	source += "		public static extern Int32 GetWindowLong(IntPtr hWnd, Int32 index);\n"
	source += "		[DllImport(\"user32.dll\", EntryPoint=\"SetWindowLong\")]\n"
	source += "		public static extern Int32 SetWindowLong(IntPtr hWnd, Int32 index, Int32 newVal);\n"
	source += "		[DllImport(\"user32.dll\")]\n"
	source += "		public static extern bool SetLayeredWindowAttributes(IntPtr hwnd, uint crKey, byte bAlpha, uint dwFlags);\n"
	source += "}\n"

	csharpProvider = dotnetobject "Microsoft.CSharp.CSharpCodeProvider"
	compilerParams = dotnetobject "System.CodeDom.Compiler.CompilerParameters"

	compilerParams.GenerateInMemory = on
	compilerResults = csharpProvider.CompileAssemblyFromSource compilerParams #(source)
	
	assembly = compilerResults.CompiledAssembly
	assembly.CreateInstance "Wind32Assists"
)

global Wind32Ass = CreateUser32AssistAssembly()

fn setWindowSemitransparent hwnd alpha = 
(
	WS_EX_LAYERED           = 0x00080000
	GWL_EXSTYLE         	= (-20)
	LWA_ALPHA               = 0x00000002
	
	style = Wind32Ass.GetWindowLong hwnd GWL_EXSTYLE
	Wind32Ass.SetWindowLong hwnd GWL_EXSTYLE (bit.or style WS_EX_LAYERED)
	Wind32Ass.SetLayeredWindowAttributes hwnd 0 (alpha*255) LWA_ALPHA
)
fn setWindowOpaque hwnd = 
(
	WS_EX_LAYERED           = 0x00080000
	GWL_EXSTYLE         	= (-20)
	LWA_ALPHA               = 0x00000002
	
	Wind32Ass.SetLayeredWindowAttributes hwnd 0 255 LWA_ALPHA
	
	style = Wind32Ass.GetWindowLong hwnd GWL_EXSTYLE
	Wind32Ass.SetWindowLong hwnd GWL_EXSTYLE (bit.and style (bit.not WS_EX_LAYERED))
	Wind32Ass.UpdateWindow hwnd
)


fn findTrackViewHwnd pattern:"*" = 
(
	hwnd = for k=1 to trackView.numTrackViews() do
	(
		name = trackView.getTrackViewName k
		if matchpattern name pattern:pattern do
		(
			hwnd = (trackviews.getTrackView k).ui.hwnd
			exit with hwnd
		)
	)
	if hwnd == OK then 0 else hwnd
)

------- USING ----------------&amp;gt;

my_trackview_name = "Track View*" -- name or wildcard
hwnd = findTrackViewHwnd pattern:my_trackview_name

setWindowSemitransparent hwnd 0.5 	-- set half-transparent (aplha == 0.5)
setWindowOpaque hwnd 				-- set opaque (aplha == 1)&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 17 Aug 2021 18:19:48 GMT</pubDate>
    <dc:creator>denisT.MaxDoctor</dc:creator>
    <dc:date>2021-08-17T18:19:48Z</dc:date>
    <item>
      <title>trackview opacity</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/trackview-opacity/m-p/10544958#M5062</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Snipaste_2021-08-14_15-12-00.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/952693iF6FC31BDE8C7353C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Snipaste_2021-08-14_15-12-00.png" alt="Snipaste_2021-08-14_15-12-00.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Is there any way to make the trackview transparent like when we try to dock it?&lt;/P&gt;</description>
      <pubDate>Sat, 14 Aug 2021 07:32:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/trackview-opacity/m-p/10544958#M5062</guid>
      <dc:creator>yun7928903</dc:creator>
      <dc:date>2021-08-14T07:32:47Z</dc:date>
    </item>
    <item>
      <title>回复： trackview opacity</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/trackview-opacity/m-p/10551248#M5063</link>
      <description>&lt;P&gt;in the lower version of max, I can use:&lt;/P&gt;&lt;P&gt;HiddenDOSCommand ("python G:\\trackviewAlpha.py") donotwait:true startpath:"c:\\"&lt;/P&gt;&lt;P&gt;to run a py:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;import win32gui&lt;BR /&gt;import win32con&lt;BR /&gt;import winxpgui&lt;BR /&gt;import win32api&lt;BR /&gt;import subprocess&lt;BR /&gt;import time&lt;/P&gt;&lt;P&gt;hwnd = win32gui.FindWindow(None, "cometTrackview") ## name&lt;BR /&gt;win32gui.SetWindowLong (hwnd, win32con.GWL_EXSTYLE, win32gui.GetWindowLong (hwnd, win32con.GWL_EXSTYLE ) | win32con.WS_EX_LAYERED )&lt;BR /&gt;winxpgui.SetLayeredWindowAttributes(hwnd, win32api.RGB(0,0,0), 180, win32con.LWA_ALPHA)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;to get the transparent track view. But in 2018 there seems to have been a callback. will make the track view not transparent again..ORZ&lt;BR /&gt;if I write another callback against the system callback seems too silly...&amp;nbsp;&lt;/P&gt;&lt;P&gt;and it's very slow (=′ー`)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Aug 2021 09:04:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/trackview-opacity/m-p/10551248#M5063</guid>
      <dc:creator>yun7928903</dc:creator>
      <dc:date>2021-08-17T09:04:42Z</dc:date>
    </item>
    <item>
      <title>回复： trackview opacity</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/trackview-opacity/m-p/10552806#M5064</link>
      <description>&lt;LI-CODE lang="general"&gt;fn CreateUser32AssistAssembly =
(
	source = "using System;\n"
	source += "using System.Runtime.InteropServices;\n"
	source += "class Wind32Assists\n"
	source += "{\n"
	source += "		[DllImport(\"user32.dll\", EntryPoint=\"UpdateWindow\")]\n"
	source += "		public static extern bool UpdateWindow(IntPtr hWnd);\n"
	source += "		[DllImport(\"user32.dll\", EntryPoint=\"GetWindowLong\")]\n"
	source += "		public static extern Int32 GetWindowLong(IntPtr hWnd, Int32 index);\n"
	source += "		[DllImport(\"user32.dll\", EntryPoint=\"SetWindowLong\")]\n"
	source += "		public static extern Int32 SetWindowLong(IntPtr hWnd, Int32 index, Int32 newVal);\n"
	source += "		[DllImport(\"user32.dll\")]\n"
	source += "		public static extern bool SetLayeredWindowAttributes(IntPtr hwnd, uint crKey, byte bAlpha, uint dwFlags);\n"
	source += "}\n"

	csharpProvider = dotnetobject "Microsoft.CSharp.CSharpCodeProvider"
	compilerParams = dotnetobject "System.CodeDom.Compiler.CompilerParameters"

	compilerParams.GenerateInMemory = on
	compilerResults = csharpProvider.CompileAssemblyFromSource compilerParams #(source)
	
	assembly = compilerResults.CompiledAssembly
	assembly.CreateInstance "Wind32Assists"
)

global Wind32Ass = CreateUser32AssistAssembly()

fn setWindowSemitransparent hwnd alpha = 
(
	WS_EX_LAYERED           = 0x00080000
	GWL_EXSTYLE         	= (-20)
	LWA_ALPHA               = 0x00000002
	
	style = Wind32Ass.GetWindowLong hwnd GWL_EXSTYLE
	Wind32Ass.SetWindowLong hwnd GWL_EXSTYLE (bit.or style WS_EX_LAYERED)
	Wind32Ass.SetLayeredWindowAttributes hwnd 0 (alpha*255) LWA_ALPHA
)
fn setWindowOpaque hwnd = 
(
	WS_EX_LAYERED           = 0x00080000
	GWL_EXSTYLE         	= (-20)
	LWA_ALPHA               = 0x00000002
	
	Wind32Ass.SetLayeredWindowAttributes hwnd 0 255 LWA_ALPHA
	
	style = Wind32Ass.GetWindowLong hwnd GWL_EXSTYLE
	Wind32Ass.SetWindowLong hwnd GWL_EXSTYLE (bit.and style (bit.not WS_EX_LAYERED))
	Wind32Ass.UpdateWindow hwnd
)


fn findTrackViewHwnd pattern:"*" = 
(
	hwnd = for k=1 to trackView.numTrackViews() do
	(
		name = trackView.getTrackViewName k
		if matchpattern name pattern:pattern do
		(
			hwnd = (trackviews.getTrackView k).ui.hwnd
			exit with hwnd
		)
	)
	if hwnd == OK then 0 else hwnd
)

------- USING ----------------&amp;gt;

my_trackview_name = "Track View*" -- name or wildcard
hwnd = findTrackViewHwnd pattern:my_trackview_name

setWindowSemitransparent hwnd 0.5 	-- set half-transparent (aplha == 0.5)
setWindowOpaque hwnd 				-- set opaque (aplha == 1)&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 17 Aug 2021 18:19:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/trackview-opacity/m-p/10552806#M5064</guid>
      <dc:creator>denisT.MaxDoctor</dc:creator>
      <dc:date>2021-08-17T18:19:48Z</dc:date>
    </item>
    <item>
      <title>回复： trackview opacity</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/trackview-opacity/m-p/10553521#M5065</link>
      <description>&lt;P&gt;wow~nice.it's much faster when work with the callback.TKS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-- 实时透明化&lt;BR /&gt;fn trackviewAlpha_yun =&lt;BR /&gt;( setWindowSemitransparent hwnd 0.5 )&lt;BR /&gt;try(unRegisterRedrawViewsCallback trackviewAlpha_yun)catch()&lt;BR /&gt;registerRedrawViewsCallback trackviewAlpha_yun&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Aug 2021 01:08:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/trackview-opacity/m-p/10553521#M5065</guid>
      <dc:creator>yun7928903</dc:creator>
      <dc:date>2021-08-18T01:08:42Z</dc:date>
    </item>
  </channel>
</rss>

