SetWindowLong挂(SetWindowLong Hanging)
为什么* SetWindowLong(myForm.hWnd,GWL_HWNDPARENT,parentHwnd)*挂起?
我可以通过这三个步骤不断重现这个问题。
- 创建.NET表单
- 初始化WaitWindow COM对象,在传递.NET Forms Handle时调用COM对象上的ShowWindow
- 在VB6中调用SetWindowLong方法
C#Windows应用程序(挂起)
private static void Main(string[] args) { Form form = new Form(); form.Show(); Interop.WaitWindow waitWindow = new Interop.WaitWindow(); waitWindow.ShowWindow(form.Handle.ToInt32(), Language.RISEnglish); }
C#控制台应用程序(不挂起)
private static void Main(string[] args) { IntPtr handle = Process.GetCurrentProcess().MainWindowHandle; Interop.WaitWindow waitWindow = new Interop.WaitWindow(); waitWindow.ShowWindow(handle.ToInt32(), Language.RISEnglish); }
VB6代码片段
Public Sub ShowWindow(ByVal parentHwnd As Long, ByVal language As Language) SetWindowLong(myForm.hWnd, GWL_HWNDPARENT, parentHwnd) 'Hangs Here CenterWindow (parentHwnd) myForm.ShowRetrieving (language) myForm.Show (vbModal) End Sub
非常感谢你的帮助:)
编辑
我知道不应该调用SetWIndowLong来更改父级,但我试图理解为什么它只在使用.NET表单句柄时挂起。
EDIT2
我现在相信这个问题与SetWindowLong无关,而是实际的句柄本身。 我还在调查,但似乎当我从.NET调用VB6代码时,它会创建一个RPC线程。 我还不确定,但我觉得它与跨线程问题有关。
Why does
SetWindowLong(myForm.hWnd, GWL_HWNDPARENT, parentHwnd)
hang?I can recreate this problem consistently doing these three steps.
- Create the .NET Form
- Initalize the WaitWindow COM object, call ShowWindow on the COM object while passing the .NET Forms Handle
- In VB6 invoke the SetWindowLong method
C# Windows Application (Hangs)
private static void Main(string[] args) { Form form = new Form(); form.Show(); Interop.WaitWindow waitWindow = new Interop.WaitWindow(); waitWindow.ShowWindow(form.Handle.ToInt32(), Language.RISEnglish); }
C# Console Application (Doesn't Hang)
private static void Main(string[] args) { IntPtr handle = Process.GetCurrentProcess().MainWindowHandle; Interop.WaitWindow waitWindow = new Interop.WaitWindow(); waitWindow.ShowWindow(handle.ToInt32(), Language.RISEnglish); }
VB6 Code Snippet
Public Sub ShowWindow(ByVal parentHwnd As Long, ByVal language As Language) SetWindowLong(myForm.hWnd, GWL_HWNDPARENT, parentHwnd) 'Hangs Here CenterWindow (parentHwnd) myForm.ShowRetrieving (language) myForm.Show (vbModal) End Sub
Really would appreciate your help :)
EDIT
I do understand that SetWIndowLong shouldn't be called to change the parent but I'm trying to understand why it hangs only when a .NET form handle is used.
EDIT2
I now believe the issue is not related to SetWindowLong but the actual handle itself. I'm still investigating but it appears that when I call the VB6 code from .NET it creates an RPC thread. I'm not sure yet but I have a feeling it has something to do with a cross-threading issue.
原文:https://stackoverflow.com/questions/10216414
最满意答案
我建议阅读由O'Reilly出版的Colin Moock的“Essential ActionScript 3.0”,以熟悉该语言。 要么,要么是Adobe的“Programming ActionScript 3.0”,它随Flash或Flex IDE一起提供。
除此之外,我还推荐使用ActionScript 3.0语言参考 。 只要保持这种方便,你最终会记住最常见的API。
I'd recommend reading over Colin Moock's "Essential ActionScript 3.0," published by O'Reilly, to get familiar with the language. Either that, or Adobe's "Programming ActionScript 3.0," which is provided with the Flash or Flex IDE.
Beyond those, I'd recommend the ActionScript 3.0 Language Reference. Just keep that handy and you'll eventually memorize the most common APIs.
相关问答
更多-
Actionscript 3.0和MVC(Actionscript 3.0 and MVC)[2022-04-19]
我使用自己的设置实现MVC实践/体系结构,但不是框架。 在我看来,MVC是一种组织代码(和功能)的方式。 可用的MVC框架功能可简化和自动化交互。 对于我的许多项目,不需要增加MVC框架的功能,最终只会施加一些限制。 如果这些功能很重要或者您正在与团队合作,那么mvc框架有许多好处。 但对于个人项目,我发现自己设置的简单性可以完成这项工作。 I use my own setup that implements MVC practices/architecture, but is not a framewor ... -
ActionScript2如何?> ActionScript3的学习曲线?(How's the ActionScript2 -> ActionScript3 learning curve?)[2023-07-24]
您可能已经看到了as2 - > as3迁移文档 ? 当然,一些语法已经改变了,但是如果你知道as2,那么写as3根本不会成为问题。 一开始可能会出现一些奇怪的事情,但这只是检查文档以找到新的方式。 如果你通过as1&as2攻击你自己,as3可能会导致一些头痛,因为它更严格(不允许你做任何你不应该做的事情);) 在不到一周的时间内你可能会对as3很好。 You've probably already seen the as2 -> as3 migration doc? Sure, some syntax ha ... -
ActionScript 3.0交换(Actionscript 3.0 swap)[2024-03-10]
不幸的是,你不能以这种方式实现交换,因为ActionScript 3,Java和许多其他语言按值传递基元和对象引用 。 该链接会给你细节,但基本上这意味着函数内的引用与函数外部的引用不同(即使它们确实引用同一对象)。 因此,在函数外部摆弄函数中的参数引用不起作用。 你被迫做内联交换。 如果你真的需要在函数中做一些交换行为,你必须将参数包装在另一个对象中,然后你可以改变内部参考: public static function Swap(var a, var b) { var c = a.value; ... -
制作简单按钮的ActionScript 3.0代码是什么?(What is the ActionScript 3.0 Code to Make a Simple Button?)[2022-05-21]
ActionScript 3使用基于事件的系统,因此要在用户单击DisplayObject时收到通知,您需要侦听单击MouseEvent 。 myDisplayObject.addEventListener(MouseEvent.CLICK, clickHandler); function clickHandler(event:MouseEvent):void { event.target.gotoAndStop(2); } ActionScript 3 uses an event based sys ... -
学习ActionScript 3.0作为专业程序员的资源(Resources for Learning ActionScript 3.0 as a Professional Programmer)[2023-12-22]
我建议阅读由O'Reilly出版的Colin Moock的“Essential ActionScript 3.0”,以熟悉该语言。 要么,要么是Adobe的“Programming ActionScript 3.0”,它随Flash或Flex IDE一起提供。 除此之外,我还推荐使用ActionScript 3.0语言参考 。 只要保持这种方便,你最终会记住最常见的API。 I'd recommend reading over Colin Moock's "Essential ActionScript 3. ... -
在flash actionscript 3.0中播放目录中的视频(playing video from directory in flash actionscript 3.0)[2024-04-12]
您需要使用Video对象来执行此操作。 请参阅文档 。 如果您需要从URL加载, Adobe有一个非常好的教程 。 您可以应用完全相同的原则从文件加载,因为URL和文件路径的处理方式类似。 这个问题的代码应该可以游戏地从文件中加载。 我希望有所帮助! You will need to use the Video object to do this. See the documentation. If you're needing to load from a URL, Adobe has a very go ... -
有基于Eclipse , Flash Develop或IntelliJ 构建的Flash Builder 。 可以使用Flex SDK中的MXMLC编译器构建应用程序或库,可以将其作为插件安装到Eclipse。 还有一些项目,如HaXe ,可以编译到Flash运行时。 There's Flash Builder built on Eclipse, FlashDevelop, or IntelliJ. Apps or libraries can be built with the MXMLC compiler ...
-
ActionScript 3.0中的Screendump是可能的还是?(Screendump from within Actionscript 3.0 is it possible or?)[2022-06-22]
创建一个BitmapData并使用相应的DisplayObject调用其draw() 方法 var bmpData:BitmapData = new BitmapData(sprite.width, sprite.height, true); bmpData.draw(sprite); 如果要缩小缩略图,请创建一个Matrix并使用所需的缩放参数调用其createBox方法,并将其传递给draw方法。 var bmpData:BitmapData = new BitmapData(thumbW, thum ... -
尝试这个: addEventListener(Event.ADDED_TO_STAGE, this.ready); function ready(e:Event) { removeEventListener(Event.ADDED_TO_STAGE, ready); addEventListener(Event.ENTER_FRAME, initiateApp); } function initiateApp(e:Event){ MovieClip(root).goto ...
-
完全是编程新手,想学习ActionScript 3.0(Completely new to Programming, want to learn ActionScript 3.0)[2022-07-10]
我强烈建议下载Flash Develop (需要windows)进行开发,它是免费的,也是IMO最好的AS3编辑器。 它会让你开始运行。 如果您使用的是mac,则可能需要从Adobe代码编辑器的免费试用开始。 对于资源和教程,网络上有很多免费的东西可以帮助您入门。 一对夫妇是8bitrocket & gamedev.stackexchange首先要做的就是选择一个简单的游戏(也许是一个真/假琐事游戏)并且只需构建它。 有关常规AS3编程的入门,请查看各种文档和教程。 祝好运并玩得开心点! I highly ...