Solved

A Window in a VB form?

Posted on 1998-09-11
14
218 Views
Last Modified: 2010-04-30
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
Comment
Question by:DBDN1011
  • 5
  • 4
  • 4
  • +1
14 Comments
 
LVL 14

Expert Comment

by:waty
ID: 1434281
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
 
LVL 9

Expert Comment

by:Dalin
ID: 1434282
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
 
LVL 9

Expert Comment

by:Dalin
ID: 1434283
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
 

Author Comment

by:DBDN1011
ID: 1434284
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
 
LVL 9

Expert Comment

by:Dalin
ID: 1434285
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
 

Author Comment

by:DBDN1011
ID: 1434286
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
 
LVL 2

Expert Comment

by:AllenC_Jr
ID: 1434287
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
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.

 
LVL 2

Expert Comment

by:AllenC_Jr
ID: 1434288
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
 
LVL 2

Expert Comment

by:AllenC_Jr
ID: 1434289
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
 
LVL 2

Expert Comment

by:AllenC_Jr
ID: 1434290
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
 

Author Comment

by:DBDN1011
ID: 1434291
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
 
LVL 9

Accepted Solution

by:
Dalin earned 1000 total points
ID: 1434292
Thank you.  I realy don't care that much about points any more.
0
 

Author Comment

by:DBDN1011
ID: 1434293
Thanks for all the help
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1434294
You don't need to give me so many points.
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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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…

930 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

14 Experts available now in Live!

Get 1:1 Help Now