vb6 help

Discussion in 'AutoCAD' started by mark, Feb 4, 2004.

  1. mark

    mark Guest

    Sub Main()
    If App.PrevInstance Then
    MsgBox " My Application is Already Running ", _
    vbApplicationModal & vbOKOnly & vbExclamation, "Error"
    AppActivate "My Application"
    Exit Sub
    End If
    Form1.Show
    End Sub


    in my vb application, i have the code above
    to prevent the system to launch multiple instances
    of the application, it works fine if the app is in its
    normal size, but when it is minimized, it will not
    bring it to the front.
    also, how to make the mesage box modal to
    my application, the constant vbApplicationModal
    does not seem to do the job

    any help will be greatly appreciated.

    TIA
    mark
     
    mark, Feb 4, 2004
    #1
  2. A bit of a guess here, but does your App have a .WindowState property
    available?
    If so, try setting it to Normal after you AppActivate.

    James
     
    James Belshan, Feb 6, 2004
    #2
  3. mark

    mark Guest

    how to create a windowstate property,
    App does not have one...
    would realy like to see a sample

    thanks
    mark
     
    mark, Feb 10, 2004
    #3
  4. Do you get any different behavior if you use
    vbApplicationModal + vbOKOnly + vbExclamation
    to combine the MsgBox flags?

    The "&" seems to give the same result as "+" for me, but since the flags are
    numeric, I'm more accustomed to using + instead of &. Just a thought,
    probably not the answer.

    James
     
    James Belshan, Feb 10, 2004
    #4
  5. WindowState is a property that programs like Excel and AutoCAD have.
    Unfortunately the code for those properties is hidden, I was just hoping
    that VB was kind enough to give you a similar property. Otherwise, it looks
    like you may have to use the API functions. In this case, I'd check to see
    if VB gives you the HWND of your app. If not, you'll have to use the
    FindWindow API function with your window's title (either .Caption or
    ..WindowTitle property, I think) to find your HWND (window handle -- it's
    just how API functions identify each program's or form's window).

    here's some links to help you get some API examples:
    http://www.google.com/search?q=vb+setwindowplacement
    http://www.google.com/search?q=vb+api+bring+window+to+front
    http://groups.google.com/groups?q=window+api+group:autodesk.autocad.customization.vba

    Good luck,

    James
     
    James Belshan, Feb 10, 2004
    #5
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.