Form on top with setparent

Discussion in 'AutoCAD' started by Ad Brouwer, Nov 9, 2004.

  1. Ad Brouwer

    Ad Brouwer Guest

    Hello,

    In VB I use setparent to get a form on top of the acad-window ( Call
    SetParent(Me.hwnd, FindWindow(vbNullString, oAcad.caption))

    This works perfectly for a Standard exe-program, but when the form is part
    of a DLL and you try to move the form, the Acad-screen doesn't get
    refreshed. Does somebody have a solution for this?

    thanks,

    Ad Brouwer
     
    Ad Brouwer, Nov 9, 2004
    #1
  2. Ad Brouwer

    bcoward Guest

    Ad,

    Logically; it seems like you may be seeing the result of an in process and out of process WM_Paint message from the operating system.

    Test this thinking...

    If I use setparent in an exe or ActiveX exe the last operating system message (WM_Paint) is cast to the thread that is running in process with AutoCAD when the form is moved. If the code is wrapped up in a dll then it is running out of AutoCAD process so when you move your form the last message cast (WM_Paint) is on a thread that is only refreshing your form screen matrix.

    To test you could put a redraw or repaint in your dll for each window running with your solution. Or, I would change the type VB project to a standard exe or activex exe knowing that running the activex exe will push a new GUID registry. If by changing only th VB type project and it is fixed then this logic might be correct.

    That's the way I'd look at debugging this but might be way off.

    Regards,

    Bob Coward
    CADS, Inc

    800-366-0946
     
    bcoward, Nov 9, 2004
    #2
  3. Have you tried this function ??


    Public Const SWP_NOMOVE = 2
    Public Const SWP_NOSIZE = 1
    Public Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
    Public Const HWND_TOPMOST = -1
    Public Const HWND_NOTOPMOST = -2

    Declare Function SetWindowPos Lib "user32" _
    (ByVal hwnd As Long, _
    ByVal hWndInsertAfter As Long, _
    ByVal x As Long, _
    ByVal y As Long, _
    ByVal cx As Long, _
    ByVal cy As Long, _
    ByVal wFlags As Long) As Long


    Public Function SetTopMostWindow(hwnd As Long, Topmost As Boolean) As Long

    If Topmost = True Then
    'Make the window topmost
    SetTopMostWindow = SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0,
    FLAGS)
    Else
    SetTopMostWindow = SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0,
    0, FLAGS)
    SetTopMostWindow = False
    End If
    End Function
     
    Jorge Jimenez, Nov 10, 2004
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.