Solved

Refresh other apps window api?

Posted on 2002-03-20
3
299 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 51

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

830 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