Solved

Refresh other apps window api?

Posted on 2002-03-20
3
297 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
ID: 6882107
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
ID: 6882134
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
ID: 6902032
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

867 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

20 Experts available now in Live!

Get 1:1 Help Now