[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 235
  • Last Modified:

A Window in a VB form?

I would like my VB to take control of another window APP whcih is a stand along. The other app has it's gui. I would like to show it's graphics but do not want to user to be able to interact with it.  What I am thinking is to shell start the app, abd shows only part of the other App's GUI. SO idealy would be have a hole or a window in my VB form, so  the user does not see the menu, the title bar, and some of the command buttons...

Anyone have a way of disable the controling part of another App?

I can give more points for a real working solution.  Any comments that helped in find a solution would also get some credit.
0
DBDN1011
Asked:
DBDN1011
  • 5
  • 4
  • 4
  • +1
1 Solution
 
watyCommented:
I have just found code to do domething like that a few minutes ago.

I have downloaded it, but not yet tested. If you want I can send it to you by e-mail.

Here is the url :
   http://ourworld.compuserve.com/homepages/raymer/kidnap.htm
0
 
DalinCommented:
DBDN1011,

It was a interesting project waty posted.  Good job, waty!

I have a code to make a form transparent, but I have not worked it out for a portion of the form. I post it here and you may experiemtnwith it to see if it works for you.

Regards
Dalin


'Declare:

Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRECT As RECT) As Long

Declare Function GetClientRect Lib "user32" (ByVal hWnd As Long, lpRECT As RECT) As Long

Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long

Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long

Declare Function ScreenToClient Lib "user32" (ByVal hWnd As Long, lpPoint As POINTAPI) As Long

Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
       Public Const RGN_AND = 1
       Public Const RGN_COPY = 5
       Public Const RGN_DIFF = 4
       Public Const RGN_OR = 2
       Public Const RGN_XOR = 3

Type POINTAPI
       x As Long
       Y As Long
End Type


Type RECT
       Left As Long
       Top As Long
       Right As Long
       Bottom As Long
End Type



Public Sub MakeTransparent(frm As Form)

       '     'This code was takin from a AOL Visual Basic
       '     'Message Board. It was submited by: SOOPRcow
       Dim rctClient As RECT, rctFrame As RECT
       Dim hClient As Long, hFrame As Long
       '     '// Grab client area and frame area
       GetWindowRect frm.hWnd, rctFrame
       GetClientRect frm.hWnd, rctClient
       '     '// Convert client coordinates to screen coordinates
       Dim lpTL As POINTAPI, lpBR As POINTAPI
       lpTL.x = rctFrame.Left
       lpTL.Y = rctFrame.Top
       lpBR.x = rctFrame.Right
       lpBR.Y = rctFrame.Bottom
       ScreenToClient frm.hWnd, lpTL
       ScreenToClient frm.hWnd, lpBR
       rctFrame.Left = lpTL.x
       rctFrame.Top = lpTL.Y
       rctFrame.Right = lpBR.x
       rctFrame.Bottom = lpBR.Y
       rctClient.Left = Abs(rctFrame.Left)
       rctClient.Top = Abs(rctFrame.Top)
       rctClient.Right = rctClient.Right + Abs(rctFrame.Left)
       rctClient.Bottom = rctClient.Bottom + Abs(rctFrame.Top)
       rctFrame.Right = rctFrame.Right + Abs(rctFrame.Left)
       rctFrame.Bottom = rctFrame.Bottom + Abs(rctFrame.Top)
       rctFrame.Top = 0
       rctFrame.Left = 0
       '     '// Convert RECT structures to region handles
       hClient = CreateRectRgn(rctClient.Left, rctClient.Top, rctClient.Right, rctClient.Bottom)
       hFrame = CreateRectRgn(rctFrame.Left, rctFrame.Top, rctFrame.Right, rctFrame.Bottom)
       '     '// Create the new "Transparent" region
       CombineRgn hFrame, hClient, hFrame, RGN_XOR
       '     '// Now lock the window's area to this created region
       SetWindowRgn frm.hWnd, hFrame, True
End Sub
0
 
DalinCommented:
DBDN1011,
I was trying to do it with a picture box, and was hoping to make the pixture box area transparent and thus you can have the other app under it...I can make the picture box transperent in the form, but the form's backgrounfd is still there...

You can add a toolbar and menus in the form, put your controling stuff in menu and tool bar, and make the form transperent. Hopefully, your form's tilte bar, toolbar and menu can cover the other app's.

Regards

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
DBDN1011Author Commented:
waty,
Thank you for the posting.  I downloaded the prokect and it was pretty cool.
However, It does not really suit my need.  I do not want the other app's control. This one will replace my nemu with the other apps. it is basally like I shell start the other one, and minimize my self. Beside, I have other MDI child which causes problem.
I think this code still need some debugging, since my three tries end up with illegal function and shutdown.

I am still trying Dalin's. It's more like what I am look for. But I was not able to dig a hole in the form

Thanks for the help so far, gentlemen.

0
 
DalinCommented:
DBDN1011,
I spend a little more time on the problem. Unforturnately, I was not able to dig a hole in the form yet. But I think what you can do is to prepare a couple of tileless forms, and shows around the 3rd party app to cover the things you want. make those form to be Always on top. Since it does not have title bar, it will not move..
I will let you know if I get a better idea.
Regards
0
 
DBDN1011Author Commented:
Dalin,
I think I am getting an good results from your solution. Let me know if you have more thoughts.
The problem is more difficult than I thought. I will increase the points.

waty, Thank you for the posting, Although it did not work in my case, I am grateful for your answer. While I would like to credit this to Dalin, I am award you some points too.

Thanks to all.
0
 
AllenC_JrCommented:
Here is Some Code I Wrote To Do This
------------------------------------------
Private Declare Function SetParent& Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long)

Private Declare Function SetWindowText Lib "user32" _
    Alias "SetWindowTextA" (ByVal hwnd As Long, _
    ByVal lpString As String) As Long

Private Declare Function FindWindow& Lib "user32" Alias "FindWindowA" (ByVal lpClassName$, ByVal lpWindowName$)

Private Sub EnslaveWindow(ObjCage As Object, WindowCaption$, Optional WindowClass As String = "", Optional NewWindowCaption$)
Dim m_lngCagedWindow&
m_lngCagedWindow = FindWindow(ByVal vbNullString, ByVal WindowCaption) 'The Caption isn't Case Sensitive
If m_lngCagedWindow = 0 Then Exit Sub
SetParent m_lngCagedWindow, ObjCage.hwnd
If Not NewWindowCaption = "" Then
SetWindowText m_lngCagedWindow, NewWindowCaption
End If
ObjCage.Enabled = False
End Sub

Private Sub Form_Activate()
EnslaveWindow P1, "Form2", "", "Rex"
End Sub

Private Sub Form_Load()
Form2.Show
DoEvents
End Sub
Private Sub Form_Unload(Cancel As Integer)
Unload Form2
End Sub

0
 
AllenC_JrCommented:
I Almost Forgot, I Need to Point Out that P1 Is A Picture Box, A Way you can Get Only A Portion of the Object is to do this

You could Create 2 Picture Boxes
 The First One Being the Area that you want to view on the form.
  The Second the Form PlaceHolder(object that holds the form)

You Could Place the Second Picture Box Inside the First and Move it until you get the area of the form that you want to view.
0
 
AllenC_JrCommented:
Oh yeah I Almost forgot that you'll need o use the SetWindowPos API Call to set the form's Left And Top To 0
Here it is.
Private Declare Function SetWindowPos Lib "User32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal CX As Long, ByVal CY As Long, ByVal wFlags As Long) As Long

You Might have to find out how to use this API Call with this method(i can't get it to work for some stupid reason)
0
 
AllenC_JrCommented:
Hey I Also (after reading all the Postings) realized that you could Capture the Form you want to control's hWnd with the FindWindow API Call(captures the hwnd) Which would allow you to create parts of that form transparent(all parts except the area you want) then create a hold on your form the same size then use the setwindowpos api call that would allow you to move it under that hole.
0
 
DBDN1011Author Commented:
Sorry,
I was on vocation. I will check this out.
As I mentioned I would award this points to Dalin. If yours work, I will post a question for  you.
Thanks for your help.
0
 
DalinCommented:
Thank you.  I realy don't care that much about points any more.
0
 
DBDN1011Author Commented:
Thanks for all the help
0
 
DalinCommented:
You don't need to give me so many points.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

  • 5
  • 4
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now