Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Refresh other apps window api?

Posted on 2002-03-20
3
Medium Priority
?
309 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 54

Accepted Solution

by:
Ryan Chong earned 300 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

916 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