• Welcome to Valhalla Legends Archive.
 

How to load an application in a window in vb6

Started by CrAz3D, January 03, 2005, 05:44 PM

Previous topic - Next topic

CrAz3D

I am trying to load multiple instances of my bot into a single window, creating somewhat of a bot that has profile loading capabilites, but through a plugin.

My main bot has all of the connections, I would just like to be able to create an ActiveX DLL that will hold the multiple bots all together nicely.

Any ideas of how to go about this would be apreciated, thanks very much.
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

MyndFyre

I don't know offhand (because I don't have the VB6 environment in front of me) what is available in VB6, but you could create an ActiveX control that manages all of the necessary information for a connection.  I did something similar -- the chat window/user lists/send box was all put together in a custom control, and each control was bound to a tab page.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

CrAz3D

#2
I thought about doing something like tabbed pages, but then I would have to edit my main bot, I'm trying to stay away from that as much as possible.  Maybe I could create bot as an ActiveX EXE?...anyone know if that might work?

EDIT:
I've never used SphtBot extensively, but I just looked @ ProfileLauncher & it seems that that is what I'll end up doing.  Quite a dandy idea Spht has there.  Hope he doesn't mind me borrowing his awesomeness.
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

MyndFyre

Quote from: CrAz3D on January 03, 2005, 06:22 PM
I thought about doing something like tabbed pages, but then I would have to edit my main bot, I'm trying to stay away from that as much as possible.  Maybe I could create bot as an ActiveX EXE?...anyone know if that might work?

I don't believe that an EXE would be the way to go.  COM is intended to provide multilanguage interoperability through libraries -- while an EXE is also a library, you're somewhat defeating the purpose.  I don't know if VB6 allows you to export COM objects through an EXE, so maybe it won't make a difference.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

UserLoser.

Could use a MDI dialog with MDI child dialogs for each profile, that's how I do it.

CrAz3D

That's what I'd like to do, but the what I want to be the child is in a totally different project & is already compiled functioning without the MDI form.  The MDI form would be the plugin.
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

Stealth

You could do it by using SetParent on a bunch of newly-executed instances of the part you have compiled and working, perhaps passing the children command line arguments telling them what profile file or folder they should be reading out of?

Or I misinterpreted what you said.
- Stealth
Author of StealthBot

CrAz3D

Well, that sounds like what I'm looking for...just not so sure about setting a regular form as the parent of my compiled form/program.

Currently what I have is my main bot compiled & running, then I load the plugin which has a basic class module & a Form.  The form loads on startup & I try to set the child/parent relationship bye this:
SetParent PlugY(NameToIndex("Form1")).hWnd, Form1.hWnd
PlugY(NameToIndex("Form1")) is the bot's Form1 hosted in the plugin (I think).

When I run the code, I recieve:

RunTime 438
Object Doesn't Support this method or property.


My problem is retrieving the hWnd from the bot's Form1, I'm quite sure that is where my problem is at.



Thanks all for the help!
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

CrAz3D

#8
Ok, figured out for the most part...just a little more playing around to do & it should work.

With a combination of FindWindow, MoveWindow, & SetParent I have been able to put my bot into the plugin form, however I'm about to try to use find window without the entire/correct window name PRAYING that I can stil find the window.

Dim Form1hWnd As Long, OldhWnd As Long
Dim BotPath As String
BotPath = Left(App.Path, Len(App.Path) - 8)

Shell BotPath & "Xenogenic.exe"

Form1hWnd = FindWindow(vbNullString, "Xenogenic")
OldhWnd = SetParent(Form1hWnd, Form1.hwnd)
MoveWindow Form1hWnd, 0, -20, 400, 300, 1


Thanks SO much



EDIT: A new problem has arisen from my awesome w/eness.
The bot opens, but then I guess it takes too long to open the SetParent() code tries to find the new bot before it actually opens.  So I end up with the bot openning into the taskbar again...I'd like it to go straight to the Parent form.  Any ideas on what I can do to slow down the Parent form?  (It works when I try the SetParent after the bot is already sitting in the taskbar)
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

CrAz3D

*bump*

*points to new problem in above post that I editted instead of posted*

;)  ::)
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

Stealth

Is your main form an MDI form? In the test app I wrote a long time ago (I was experimenting with interprocess communication) the main form was just an empty MDI form and all the children were separate individual forms.
- Stealth
Author of StealthBot

CrAz3D

My main form is a regular single form.  I can get the bot to go in to the new parent when I run the find/setparent code after I physically see that the bot has loaded, but if I run it right after i "shell" the bot it won't find the bot's window.
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

Stealth

I dug up the experimental interprocess communication code I had written. Interesting stuff.

First off, it uses a function apparently from vb-helper.com to shell and retrieve the hWnd of children:

' Return the window handle for an instance handle.
Public Function InstanceToWnd(ByVal target_pid As Long) As Long
    Dim test_hwnd As Long
    Dim test_pid As Long
    Dim test_thread_id As Long

    ' Get the first window handle.
    test_hwnd = FindWindow(ByVal 0&, ByVal 0&)

    ' Loop until we find the target or we run out
    ' of windows.
    Do While test_hwnd <> 0
        ' See if this window has a parent. If not,
        ' it is a top-level window.
        If GetParent(test_hwnd) = 0 Then
            ' This is a top-level window. See if
            ' it has the target instance handle.
            test_thread_id = GetWindowThreadProcessId(test_hwnd, test_pid)

            If test_pid = target_pid Then
                ' This is the target.
                InstanceToWnd = test_hwnd
                Exit Do
            End If
        End If

        ' Examine the next window.
        test_hwnd = GetWindow(test_hwnd, GW_HWNDNEXT)
    Loop
End Function


I then store, in an array of user-defined types, the old parent and hwnd of each form that's loaded. (I return the child forms to their old parent before telling them to close via IPC.) For testing purposes, the array was fixed-size, but it could easily be made scalable or converted to a collection of class objects.

Public Sub NewInstance(Optional ByVal Path As String)
    Dim pid As Long

    pid = Shell(IIf(LenB(Path) > 0, Path, "C:\Visual Studio\E2\MEx.exe"), vbNormalFocus)
   
    If pid = 0 Then
        Debug.Print "Error starting instance at " & Path & "."
        Exit Sub
    End If

    Children(0).hWnd = InstanceToWnd(pid)
    Children(0).oldParent = SetParent(Children(0).hWnd, frmMain.hWnd)
End Sub


Seems to hook in the new window without any problem. HTH
- Stealth
Author of StealthBot

CrAz3D

Thanks very much Stealth, I'll look through that & see what I can't do about it.
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

NetNX

Well i think i understand what you are trying todo... If you are trying to have multiple bots you might want to create a control that could be used the way CSB is but just include it with your program and dont compile it too DLL so people dont just steal ur dll and use it as their own... and then have it set to do something like


on error goto err:
Public function LoadNewBot(CNFG as string) as boolean
Dim FrmNewBot as New FrmBot '// frmbot is a blank bot from or mdi from
FrmNewBot.load CNFG '// load selected part of the config to load...
FrmNewBot.show
FrmNewBot.addchat vbwhite, CNFG, vbyellow, " configuration loaded on new window"
LoadNewBot = true
err:
End Fuction