Re: Using IWin32Window to SetParent

From: Dan (qqqqq)
Date: 03/15/04


Date: Mon, 15 Mar 2004 17:24:29 -0600

Ed -
Thanks for the response. The same code, today, is working. It's the oddest
thing.

Incidentally, the error was an overflow that was happening on Handle.ToInt32
when I called SetParent to restore the "original" parent. It was in the Hide
method below:

Private Declare Auto Function SetParent Lib "user32.dll" (ByVal Child As
Int32, ByVal Parent As Int32) As Int32
...
Private mlOldParent as Int32
...
Friend Overloads Sub Show(ByVal oOwner As IWin32Window)
    Try
        mlOldParent = SetParent(Handle.ToInt32, oOwner.Handle.ToInt32)
    Catch ex As Exception
        mlOldParent = -1
    End Try

    MyBase.Show()
End Sub
Friend Shadows Sub Hide()
    Try
        If mlOldParent > 0 Then
            Call SetParent(Handle.ToInt32, mlOldParent)
        End If
    Catch
    End Try
End Sub

Dan

""Ed Dore [MSFT]"" <eddo@online.microsoft.com> wrote in message
news:jchiJyrCEHA.1672@cpmsftngxa06.phx.gbl...
> Hi Dan,
>
> Something obviously changed if it was previously working. Probably the
best
> thing to do would be to debug the overflow exception. Can you track down
> and post the section of code that's throwing the exception?
>
> For what it's worth, a better solution might be to create a toolwindow in
a
> VS .Net addin. There are some ToolWindow samples available with the VS
> Automation samples out on:
>
>
>
http://www.microsoft.com/downloads/details.aspx?familyid=3ff9c915-30e5-430e-
> 95b3-621dccd25150&displaylang=en
>
> Sincerely,
> Ed Dore [MSFT]
>
> This post is 'AS IS' with no warranties, and confers no rights.
>



Relevant Pages

  • Re: 2147483647 + 2147483647 = -2?
    ... The Int32 value type represents signed integers with values ranging from ... By default the int operations are not checked by overflow, ... it will throw an exception in that case. ... "Jack Wasserstein" wrote in ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Balloon-Tooltips (CreateWindow fails)
    ... Public cbSize As Int32 ... Public szInfo As String ... Public Enum BalloonMessageType ... Shared Sub NotifyBalloon(ByRef ntfyIcon As NotifyIcon, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: VB, sending messages to another app using SendMessage / PostMessage.
    ... > Public Sub New ... The following procedure is required by the Windows Form ... > Declare Function SetFocus Lib "user32" As Long ... As Int32 ...
    (microsoft.public.vb.winapi)
  • Re: VB, sending messages to another app using SendMessage / PostMessage.
    ... | Public Sub New ... | Declare Function SetFocus Lib "user32" As Long ... | (ByVal lpClassName As String, ByVal lpWindowName As String) As Int32 ...
    (microsoft.public.vb.winapi)
  • Re: User Control Resize
    ... Public Class UserControl1 ... Private Const WM_WINDOWPOSCHANGING As Int32 = &H46 ... Public Sub New ... 'This call is required by the Windows Form Designer. ...
    (microsoft.public.dotnet.languages.vb)