Solved

Refresh other apps window api?

Posted on 2002-03-20
3
301 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 52

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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…

751 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