Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 282
  • Last Modified:

Activating the source application window after a DDE LinkExecute

Environment information: W98, VB5
I've created a simple form that starts a source application (ArcView) and is able to perform oeration on the source's data as well as to query the source to obtain some data back. The problem is that I'm unable to make the source get the focus: I'd like the source's window to become active and get on top of the other windows after the request, but it never happens.
0
svbeev
Asked:
svbeev
1 Solution
 
BelfryCommented:
API: SetForeGroundWindow, BringWindowToTop
0
 
svbeevAuthor Commented:
Sorry, but I'm a COBOLsaur and have no idea how to use your suggestion. In particular, how to load (?) and call  API.

Please be more specific - I won't feel humiliated if you include the code.

Thank you.
0
 
marconovaroCommented:

Belfry's comment is right: use this code:

' In the declaration section:
Private Declare Function SetForegroundWindow Lib "user32" ( _
      ByVal hwnd As Long) As Long

' Use it like this:
SetForegroundWindow( YourForm.hwnd )

This should bring the window on top.
Hope this helps
M
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
svbeevAuthor Commented:
My problem is not to bring my VB form on top, but to bring the linked application window on top. I know the linked application name (because I started it with a "shell" command), but I don't know how to refer the corresponding window in the SetForegroundWindow API.
0
 
marconovaroCommented:

If you know the window caption, you can use this API to get the related HWND:

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
      ByVal lpClassName As String, _
      ByVal lpWindowName As String) As Long


Use it like this:

dim hwnd as Long

hwnd = FindWindow( 0, "My caption" )


HTH
M


0
 
svbeevAuthor Commented:
OK, this is the code I use:

Sub cboDocType_Click()
    Dim hwnd As Long
    cmd = "av.GetProject.AddDoc(" & cboDocType & ".make) av.GetActiveDoc.GetWin.Open"
    txtDDE.LinkExecute cmd
    hwnd = FindWindow(0, "ArcView GIS Demo Edition")
    SetForegroundWindow (hwnd)
End Sub

This subroutine runs when I select one line in the listbox. Maybe it's the last instruction that's wrong (I guessed that hwnd had to be used instead of YourForm.hwnd you specified in your first comment); maybe the window caption should be written in a different way (but "ArcView GIS Demo Edition" is what I see in the window...); anyway, so as it is it doesn't work...
0
 
svbeevAuthor Commented:
Hello everybody,
it happens that I found a solution by myself! the instruction AppActivate followed by the window title works just fine, so there's no need for an API to be called.

Thank you, Belfry and marconovaro, for the time you dedicated to my question, but I hope you'll agree if I simply close this topic not awarding these points to anybody.

Bye.
0
 
NetminderCommented:
User resolved; points refunded and question closed.

Netminder
EE Admin
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now