首页 \ 问答 \ SetWindowLong挂(SetWindowLong Hanging)

SetWindowLong挂(SetWindowLong Hanging)

为什么* SetWindowLong(myForm.hWnd,GWL_HWNDPARENT,parentHwnd)*挂起?

我可以通过这三个步骤不断重现这个问题。

  1. 创建.NET表单
  2. 初始化WaitWindow COM对象,在传递.NET Forms Handle时调用COM对象上的ShowWindow
  3. 在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.

  1. Create the .NET Form
  2. Initalize the WaitWindow COM object, call ShowWindow on the COM object while passing the .NET Forms Handle
  3. 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
更新时间:2022-11-02 17:11

最满意答案

我建议阅读由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.

相关问答

更多
  • 我使用自己的设置实现MVC实践/体系结构,但不是框架。 在我看来,MVC是一种组织代码(和功能)的方式。 可用的MVC框架功能可简化和自动化交互。 对于我的许多项目,不需要增加MVC框架的功能,最终只会施加一些限制。 如果这些功能很重要或者您正在与团队合作,那么mvc框架有许多好处。 但对于个人项目,我发现自己设置的简单性可以完成这项工作。 I use my own setup that implements MVC practices/architecture, but is not a framewor ...
  • 您可能已经看到了as2 - > as3迁移文档 ? 当然,一些语法已经改变了,但是如果你知道as2,那么写as3根本不会成为问题。 一开始可能会出现一些奇怪的事情,但这只是检查文档以找到新的方式。 如果你通过as1&as2攻击你自己,as3可能会导致一些头痛,因为它更严格(不允许你做任何你不应该做的事情);) 在不到一周的时间内你可能会对as3很好。 You've probably already seen the as2 -> as3 migration doc? Sure, some syntax ha ...
  • 不幸的是,你不能以这种方式实现交换,因为ActionScript 3,Java和许多其他语言按值传递基元和对象引用 。 该链接会给你细节,但基本上这意味着函数内的引用与函数外部的引用不同(即使它们确实引用同一对象)。 因此,在函数外部摆弄函数中的参数引用不起作用。 你被迫做内联交换。 如果你真的需要在函数中做一些交换行为,你必须将参数包装在另一个对象中,然后你可以改变内部参考: public static function Swap(var a, var b) { var c = a.value; ...
  • 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 ...
  • 我建议阅读由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. ...
  • 您需要使用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 ...
  • 创建一个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 ...
  • 我强烈建议下载Flash Develop (需要windows)进行开发,它是免费的,也是IMO最好的AS3编辑器。 它会让你开始运行。 如果您使用的是mac,则可能需要从Adobe代码编辑器的免费试用开始。 对于资源和教程,网络上有很多免费的东西可以帮助您入门。 一对夫妇是8bitrocket & gamedev.stackexchange首先要做的就是选择一个简单的游戏(也许是一个真/假琐事游戏)并且只需构建它。 有关常规AS3编程的入门,请查看各种文档和教程。 祝好运并玩得开心点! I highly ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。