Solved

Refresh other apps window api?

Posted on 2002-03-20
3
294 Views
Last Modified: 2012-06-21
I have the window handle of a textbox in Sage (a completely different application which I do not have source for). I can place my own vb apps picturebox into Sage's textbox, but the problem is that my picturebox does not seem to be repainting when other windows are dragged over the top, or if Sage is minimized then maximized. The autoredraw properties of my picturebox and its form are true. I can make this slightly better by refreshing my form and its picturebox on a timer event, but it is still not very good.

Any thoughts?
0
Comment
Question by:PeteD
  • 2
3 Comments
 
LVL 2

Author Comment

by:PeteD
Comment Utility
I should perhaps have mentioned that I put my apps picturebox into Sage's textbox using the SetParent api
0
 
LVL 49

Accepted Solution

by:
Ryan Chong earned 75 total points
Comment Utility
Hi PeteD,

Try this:

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

Private Const SW_HIDE = 0
Private Const SW_SHOW = 5
Private Const SW_MAXIMIZE = 3
Private Const SW_MINIMIZE = 6
Private Const SW_NORMAL = 1

Private Sub cmdDisplay_Click()
    Dim retval As Long, retval1 As Long
    Dim s As String
    List1.Clear
    s = Space(255)
    retval = FindWindow(vbNullString, Text1.Text)
    retval1 = GetClassName(retval, s, 255)
    List1.AddItem "Window name:  " & Text1.Text
    List1.AddItem "Window Hwnd:  " & retval
    List1.AddItem "Classname:  " & s
    List1.AddItem "Characters:  " & retval1
End Sub

Private Sub Form_Load()
    Text1.Text = Me.Caption
    Dim retval As Long
    retval = ShowWindow(Me.hwnd, SW_MAXIMIZE)
End Sub

Private Sub Option1_Click(Index As Integer)
    Dim retval As Long, retval1 As Long, retval2 As Long
    s = Space(255)
    retval = FindWindow(vbNullString, Text1.Text)
    retval1 = GetClassName(retval, s, 255)
    If Option1.Item(0) Then
    retval2 = ShowWindow(retval, SW_SHOW)
    End If
    If Option1.Item(1) Then
    retval2 = ShowWindow(retval, SW_MINIMIZE)
    End If
    If Option1.Item(2) Then
    retval2 = ShowWindow(retval, SW_HIDE)
    End If
    If Option1.Item(3) Then
    retval2 = ShowWindow(retval, SW_MAXIMIZE)
    End If
    If Option1.Item(4) Then
    retval2 = ShowWindow(retval, SW_NORMAL)
    End If
End Sub

Use: retval2 = ShowWindow(retval, SW_NORMAL)
0
 
LVL 2

Author Comment

by:PeteD
Comment Utility
ryancys,

Hi, This didnt work! I had been trying stuff like this. The only way I have managed to solve the problem is wen the window in question is visible, constantly run a loop with a doevents every 20000 loops. This is a horrible solution, but so far is the only working one. Your the only one who answered so you get the points. Thanks for your suggestion!

Pete
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now