Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




A Sub That Handles The Same Event For Multiple Objects


Is there a way to do this, for example, when you have a series of text boxes, and whenever anyone of them gets focus, it runs a counter. Is there a way to write

Private sub LostFocus()
counter=counter+1

end sub

without having to write a

Private Sub Textx_LostFocus()
counter=counter+1
End sub

For every object?



thanks




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Connect Events Of Multiple Objects To One Event Handling Function?
Hi, Gurus
Please help me with this. I've been doing research for a few days but haven't got a solution. In my case, I need to create several objects of the same type. The object generates a few events need to be handled. I need to create the objects dynamically at runtime.

Now is my question. How can I connect the events with the event handing functions using WithEvents? With WithEvents, I can connect the event of a particular object with a function at design time. But I need to create the object at runtime.

I know with control array I can trap events generated by multiple objects with only one handler. (sorry, I don't know how to name the variable declared by WithEvents) But it seems to me control array only handle activex components. May I create control array at runtime? I am quite confused.

Sorry for so many questions. I was mainly working in C++ before and haven't been adjusted right for VB yet. But I have to work out the project on my own with tight schedule. If someone can help me out, I really appreciate that.

Returning Multiple Handles
I am writing an application (a) that sends messages to another application (b). The problem is that (b) can have multiple instances running, each with a different window handle.

My application (a) will send the specified message to the instance of (b) that has focus. After days of searching and hours of failed attempts, I have come here for help.

Basically, I want to be able to find all handles of application (b) running and throw them into a listbox on my application (a).

Then I want to be able to set focus to whichever handle from the above-stated listbox as if it were clicked (chosen) from the taskbar, so that my application (a) will send the message to the desired instance of (b).

Anyone have any bright ideas? I can't seem to figure out how to return multiple instances of a program. Let's just pretend that the (b) window's class will be "InstanceB:class". But it's handle will be different, of course.

Retreiving Multiple Window Handles
First post so I'd like to say "Hi" to everyone...Now that thats over, I have a question.

I am wanting to get the handles of multiple windows, all of the same class, so I figured on using FindWindow and using the classname of the windows. This only returns the handle for one of the windows.

Is there any way I can get the handles for all of the windows of the same class (type)?


Cheers All

Click Event For Web Browser Objects
I notice that the web browser doesn't have a click event. Is there any way that I can detect for a mouse click within the web browser window? I can't find an equivalent event.

Thanks

Aidan

OOP Theory Needed (event-based Objects)
What is the most commonly used / professional way to handle which screen to draw in my RPG.

Should I keep track of which screen is shown with a variable and use a DrawScreen function in my main loop which decides what screen is shown. For Example:

Code:
Public Sub DrawScreen()

Select Case Screen

Case 0 'TitleScreen
DrawTitleScreen
Text 180, 180, "New"
Text 180, 210, "Continue"
Text 180, 240, "Quit"

Case 1 'Map
DrawMap
DrawHero

Case 2 'Menu
DrawMenu
Text 10, 10, Hero.Name
Text 10, 35, "L " & Hero.Level
Text 10, 60, Hero.HpCur & "/" & Hero.HpMax

End Select

End Sub
Or is there a more efficient way to do this. I've started learning how to use Class Objects and OOP, but it's still confusing to me.

Same thing goes for Input, how would I create a Menu object that can handle its own input, seperately from say the Map.

For Example:

when the map is open, Up will move hero up.
when the menu is open, Up will move cursor up.


I hope that wasn't too confusing

Change Event On Objects Created With Controls.Add()
if i create a checkbox this way :

Code:
for i=1 to 4
Set Mycmd = Frame1.Controls.Add("Forms.Checkbox.1", "mycheckbox" & i, True)
next i

how can i know if an event _Change is occured?

thx

Single Event Handler For A Number Of Objects
Hello Mighty All,

I am facing the trouble of adding CommandBars to all Explorer/Inspector windows in MS Outlook. The issue is:

I want to use ONE subroutine to process ALL click events for the same button on all command bars. How can I do it in VB 6.0? Can I install event handler by hand (via calling smth like AddHandler)?

Thanks in advance,
Diesel21

Working On Multiple Objects
How to work on multiple objects - for example, having several textboxes, how to change their text field using one call/loop?
They are named Text1, Tex2, etc.

Wait For Multiple Objects
Hello all,

I am using waitforsingleobject(API) to wait for one application/process. But my problem comes when I my called application starts second process. At that time my application hangs. I tried with waitformultipleObjects but that is not working properly.

Thanks in advance

Multiple ADO Recordset Objects
Hi,

I have a situation where many procedures of a form are using a ADO connection declared under the General section of the form code:


Code:
Option Explicit

Dim db As New ADODB.Connection
Dim rst As New ADODB.Recordset
.................................
.................................
Now inside one of the procedures I need to define a separate recordset object,say "rst1" using the same connection object "db".

Do I need to use the 'NEW' keyword to create a new instance of the recordset object variable inside the procedure or is it not necessary to use 'NEW'?


Code:
Private Sub readdata()

Dim rst1 As New ADODB.Recordset


or,


Code:
Private Sub readdata()

Dim rst1 As ADODB.Recordset


Which of the two should I use & why?

Thanks in adavnce.

Multiple Objects Under One Roof
I have multiple objects, which form part of another object. For ease of understanding, they are

Mailing - which is the main object.

...and

AddressData - which holds company name, street details etc.
ExtdAddressData - which holds salutation, first name, surname, country etc.
MailsortData - holds details of what zone the address is going to, etc.
Baglabel - holds details of number of addresses to certain locations.

My app adds addressdata to the AddressData and /or ExtdAddressData object(s) and adds the filled object to the Address object(s) held in Mailing.

Question - Instead of having to set each object to other objects each time, how can I add a main class so that all I have to say is something like


Code:
Set AddressDetails =Mailing.AddressDetails

Multiple Objects Equals....
Can I make more than one object get the same value like:

Text1.Text, Command4.Caption = "Test"

Now I know this doesn't work, but can it be done?

Coding Multiple Objects
Hi

I have the following code:

Private Sub txtStud7_AfterUpdate()

'//To make the Jamb Width change according to:
'//Stud Width and Jamb Profile

'DEFINE VARIABLES
Dim JAMB As Integer
Dim stud As Integer

'INPUT

stud = Int(txtStud7)

'PROCESS
'If Profile is Architrave, then Jamb = Stud + 22
'If Profile is Grooved, then Jamb = Stud + 45
'If MUF Grooved, stud 70, then Jamb = Stud + 51
'If MUF Grooved, stud 90, then Jamb = Stud + 52

If stud = 0 Then
MsgBox "Please enter required Jamb size", vbExclamation, "Enter Jamb Size"
JAMB = 0
txtJamb7.SetFocus
GoTo 16

ElseIf comJMaterial = "Pine" And ComJProfile = "Flat" Then
JAMB = stud + 22
ElseIf comJMaterial = "Pine" And ComJProfile = "Grooved" Then
JAMB = stud + 45
ElseIf comJMaterial = "MUF" And ComJProfile = "Flat" Then
JAMB = stud + 22
ElseIf comJMaterial = "MUF" And ComJProfile = "Grooved" And stud = 70 Then
JAMB = stud + 51
ElseIf comJMaterial = "MUF" And ComJProfile = "Grooved" And stud = 90 Then
JAMB = stud + 52
ElseIf ComJProfile = "Flat" Then
JAMB = stud + 22

End If


'//Reminds user to change Jamb size depending on lining type
If vbNo = MsgBox(prompt:="Jamb size is based on 2 layers of 10mm Gib - Okay?", Buttons:=vbYesNo + vbQuestion, Title:="Confirm Lining") Then
MsgBox "Please alter Jamb size accordingly", vbExclamation, "Change Jamb Size"
JAMB = 0
End If

'OUTPUT
txtJamb7 = Str(JAMB)
txtJamb7.SetFocus
16
End Sub


It works how I want it to, but the problem is that I have 26 each of the txtJamb* and txtStud* boxes. Every time I make a change I have to change 26 pieces of code. The only difference between each one is the number at the end of the txtJamb* and txtStud* boxes. Is there a way to write one piece of code for all 52 boxes?

Thanks

Opening Multiple Com Objects
I have a NT service written in VB, I want this service to monitor several mail boxes and when new mail arrives call a COM DLL or EXE to deal with the incoming mail. Each mailbox may have its own Dll or Exe registered with MTS.
I am a web developer and I am quite new to VB so the following question may be somewhat trivial:

Question

Can the VB service call a COM object and let it run without having to wait for it to finish. I already have used COM objects from a mail agent but these wait till the COM object has finished executing before it can move on. The COM object will have their own error handling.

I know VB is not truly multithreaded but is it still possible to have multiple Com objects opened from the same service and executing at the same time, even if this does mean CPU sharing in VB.

Thanks,
Sean Martin

Drag And Drop Multiple Objects
I am trying to write some code that selects a number of image boxes and drags them all together to be dropped to another portion of the form. I have set drag mode to manual and tried to start the drag in the following way...

For i = 0 To UBound(selected)
Imageshadow(get_index(selected(i))).Drag vbBeginDrag
Next i

However, this seems to only initiate the drag on the last of the arrays cycled through. Does anyone know how to do this properly? Or know of a tutorial where this is done?

Problems With Textures On Multiple Objects
Hi
I have been studying the tutorials at http://www.directx4vb.com/ and I have been looking at creating keyframe animations in directx 8.1. I have tried to modify the code on lesson 10 to do multiple objects, but cannot get the textures to be applyed to any other object that my first one. Please view my amendments and tell me where I am going wrong.

Any Wat To BitBlt One Image Onto Multiple Objects?
Lets say I have four PictureBoxes. All are exactly the same. Is there a way to draw the image so that its center is in the center of the four pictureboxes? I am using the trick where you load the image into an imagelist, set the mask, then redraw it onto the target object.

Format Multiple Mshflexgrid Objects
Hello. I want to format 12 diferent mshflexgrid with the same style. Can I do that using a procedure or do I have to format each object ?
Thanks

Changing The Properties Of Multiple Objects At Once
I want to make multiple controls enabled at once, say using a loop.


VB Code:
Dim x As Integer Dim objects() As Variant objects(0) = "cmdGo"objects(1) = "cmdReset"objects(2) = "cmdClipboard"objects(3) = "txtInput"objects(4) = "cmdUnits"objects(5) = "lblOutput"objects(6) = "fraMain" For x = 0 To 5        If objects(x).Enabled = True Then    objects(x).Enabled = False    End IfNext x

I done something like that above but have had no luck. Could someone please teach me how to get it working.

Alternatively, is there a simpler way that you can make all the controls within a frame enabled at once?

Load Multiple Objects At Runtime
i know this question has been answerd alot of times, but i cant find any of those when searching, so...how do i load for example alot of commandboxes at runtime?

Applying Fonts To Multiple Objects
I have an application with like 100 different textboxes, listboxes, lables on about 5 different forms. Is there any way to change the font size, name, and etc. with the common Dialog control without having to list each individual textbox, listbox lable etc???

How To Reference Multiple Excel Objects
Hi
Had a question on how to reference multiple excel objects?

1.Open Excel file1
2.read it
3.open excel file 2
4.read it
5.close excel file2
6.now access excel file1 object
Step 6 Fails
I am using the following functions for open and close excel
(objexcel,objworkbook & objworksheet are global variables)
public sub OpenExcel(sFileName)
{
Set objExcel = CreateObject("Excel.Application")
Set objWorkBook = objExcel.Workbooks.Open (sFileName)
Set objWorksheet = objWorkBook.WorkSheets(1)
}
public sub CloseExcel(sFileName)
{
Set objWorksheet=Nothing
set objWorkBook= Nothing
'Kill the instance of excel object
objExcel.Quit
Set objExcel = Nothing
}


Selecting Multiple Objects In Code
as an output, if i want many objects to become disabled can i write the code for:

Image1 - Image78.enabled = false
Text2 - Text 6.visible = true.

Basically, i want to be able to write code for multiple objects that do the same output without having to write:

Image1.enabled = false
Image2.enabled = false
Image3.enabled = false...

etc etc etc.

Cheers

Controlling Multiple Objects With A For Loop
Is there a way to create 5 texboxes and then control how many are enabled by using a comboBox?

I.E.
Code:
Dim Counter
Dim myVariable

myVariable = comboExampleComboBox.listindex

For Counter = 1 to myVariable

txtExampleText(Counter).enabled = False

Next


This code doesn't work, but it encompasses my idea. Any help would be greatly appreciated! Thanks!

-----------------------------
looks like another bug...

Multiple WebBrowser Objects On One Form.
Well, now I seem to have another problem. Look at this code:

' Look for a certain string in an html document (searches the WHOLE doc)
Public Function LookForStringInDocument(cw As WebBrowser, lookFor As String, offset As Integer) As Boolean
    Set hel = cw.Document.body
     
    If Not (hel Is Nothing) Then
        If InStr(hel.innerHTML, lookFor) <> 0 Then
            LookForStringInDocument = True
            Set hel = Nothing
            Exit Function
        End If
    Else
        LookForStringInDocument = False
        Set hel = Nothing
        Exit Function
    End If
     
    LookForStringInDocument = False
    Set hel = Nothing
End Function

Trying to call it like this:
     If LookForStringInDocument(WB2, "You are not", 0) = true then
          MsgBox("We could not log on to our website!")
     End If

It seems that, when I pass the WB browser object (the webbrowser object doing the most work, the "primary" one on the form) to it, it works fine. But for the second web browser on my main form, it works approximately 1/10th of the time. It makes no sense as to why it would work fine sometimes, and not work the others. I have the page loaded in the second WebBrowser object (WB2), but it seems that it doesn't find the string. Yes, it is ghetto code, but it works for my purposes. I do not know why it would be working half-ass. Maybe someone can clarify for me? Thank you in advance.

- Brandon Erhart


"Inform all troops that communications are down!"

Multiple Instances Of Com Objects Hangs VB
Hi,

I am working on python and VB. I have a com server on python which is a drawing application. I create an object in VB to start the application when I click on the menu in the form. If at a time only one instance of the application is crated then it works properly. If I open multiple instances of the application without closing the previous windows then also everything works fine until I close the MDI Form. When i close the MDI Form, the MDI Form closes but VB hangs.

Private Sub mnuHi_Click()
Dim a As Object
Set a = CreateObject("Python.Dhruv")
a.make
Set a = Nothing
End Sub

How can I prevent this??

Dhruv

Problem KeyBoard Event With Added Objects Onto Form. *RESOLVED*
I move an Image arround on my Form, this works just fine,
untill I add a CommandButton, Frame or Label, etc...
then the Image just doesn't move anymore, unless i set the added objects to "Enabled = False"

How does it come that this event doesn't work when adding these objects on the Form?

This is the code I use for movement;

Code:
Option Explicit

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
     
'UP
    If Str(KeyCode) = 38 Then
       Image1.Top = Image1.Top - 120
    End If
'DOWN
    If Str(KeyCode) = 40 Then
       Image1.Top = Image1.Top + 120
    End If
'LEFT
    If Str(KeyCode) = 37 Then
       Image1.Left = Image1.Left - 120
    End If
'RIGHT
    If Str(KeyCode) = 39 Then
       Image1.Left = Image1.Left + 120
    End If

End Sub


=============================================
aka Red2048.

Edited by - T48 - [RedPlanet] on 10/7/2003 12:37:48 AM

Substitution Parameter For Creating Multiple Objects
I'm using the header fields from a csv file and a collection of User attributes from Active Directory to create a mapping form displaying the array of csv fields in one column and list boxes of the collection in the adjacent comlumn.

I want to programatically generate list boxes, each one with a suffix value that corresponds to the array index number for the csv column. So what I need to figure out is if there's a substitution parameter available in VB 6.0 that will read the counter variable in a For loop as a literal value.

Here's the concept in rather abbreviated logic
csvlist = ubound(csvfields)
For a in csvlist
Dim Listbox_"a" as Listbox 'Give index suffix so you create the temp objects
'Listbox_1,Listbox_2...
For Each ADattr in Usrattr.collection 'repeat
Listbox_"a".additem ADattr.name
Next
Next

The intention is to provide flexibility to the form, as there could be varying numbers of header fields (20 to 30), so that the corresponding column pairs:
csv_header = listbox_value can then be written to a configuration file.

Thought this would be the easiest way to map a group of fix values to anothe r (the AD User collection) that has dozens of possible selections.

Failed To Create Multiple Word Objects VB6
Hi Everyone,


I'm working on a VB6 program which will process a selected word document. Anyway, I want to allow the users to work on some other MS word documents when the process is running. Because when i run my program, the process will take about 20 mins to finish, it's illogical to have the user waited for 20 mins without working on other Word-related works. I want the user to be able to multitasking.The problem i'm having now is when the user opens a another word document from Window Explorer, I get an error, because my program is trying to perform the actions on their selection on new opened word document.


So, is there anyway to ensure a new Word instance will be created when the user open another word Document? As you can see from the Task Manager, under normal circumstance, no matter how many word documents you open, only one "WINWORD.EXE" instance is being created and shared. I believe my problem will be solved if every word document opened is accompanied by a new Word object created.


The following is a small part of my code to create the Word object



Dim wrdApp As Word.Application
Dim wrdDoc As New Word.Document
Dim tempApp As Word.Application


If TypeName(wrdApp) <> "Application" Then
Set tempApp = CreateObject("Word.Application")
Set wrdApp = CreateObject("Word.Application")
tempApp.Quit

Set tempApp = Nothing
End If


Set wrdDoc = wrdApp.Documents.Open(filePath)


Any help would be deeply appreciated. thanks..

Using Multiple Printer Objects To Print To Two Printers In VB App
I am trying to direct printer output to two different printers within the same app. In the end I need two printer files, one to a color printer and the other to a b&w one (the printing is done commercially, so we need to do this to save $$s).

Can I create a second printer object and then do something like this:

Printer1.print "text"
Printer2.print "text"

I have tried a few things to create these objects, but they don't seem to be working.

Thanks for the help.

Resolved - Multiple Objects Controlled By Same Code
If this turns out to be easy, I'm gonna shoot myself!

Here's the scenario...

I have an App (a good start?)

This app has several forms.

Virtually every one of the forms though has an object on it (a frame, but, I think irrelevant).

At various times when running the app I want to do stuff to the frame (move, colour etc) on the form with focus.

Is there ANY way I can put the code to do this (some of it is quite extensive) into a module and simply pass the form I want it to work on THIS time to the code so it works on the correct form.

I simply do not want to have 10 copies of identical code in my app.

Any thoughts??

Hope this makes sense!


Thanx in advance.


Pigmy

Sending MAIL To Multiple Receipients Using CDO Objects
Hello,

I am using CDO objects for my EMAIL application. I want to send a MAIL to multiple receipients using then ( cc - carbon copy , bcc - Bi Carbon copy ) facilities.
I have provided two text boxes where user can enter several mail account names. I had written the code but it is not performing the activity what I wanted. It is taking
all the mail accounts along with the Main Receipient ( To mail Id ) in one line and the CC and BCC are left empty.

Code which I had written is as below

Set objRecipients = ObjMsg.Recipients

' This is for the main receipient to whom the message is to be sent
Set objOneRecip = objRecipients.Add

With objOneRecip
'Fill in an appropriate alias here
.Name = Me.TxtToMail.Text
.Type = ActMsgTo
.Resolve ' get MAPI to determine complete e-mail address
End With

Can u tell me how to change the logic for both CC and BCC

Regards

Prasad

(kpra24@hotmail.com)

Multiple Check Box Event!!!!
Hi all,
I have a large number of check boxes on a form. When i uncheck any of these boxes i want a message box to display. rather than having an onclick event behind each check box is there anyway i can have catch all event that will display the message box when any of the check boxes are changed
Regards
Padraig

Trigger Multiple Event
I have an event Click on a button, which will trigger function A, I need another event such as mouse_up or mouse_down on the same button, which will trigger the same function A, how can I do that in short??

I knew VB.Net can do the tricks.

Something like


VB Code:
Private sub bttn_Click() 'Add the events here eg:Mouse_Up,Mouse_Down End Sub


How to do that in VB?

How To Set A Multiple Key Press Event?
anybody know how to set a mutiple key press event like
i wanna make the command button move right by pressing
left arrow and right arrow key. When i press both the command button will move right little bit.

[Edited by Satangel on 09-12-2000 at 09:04 PM]

Event Handler Across Multiple Forms
Let's say I have array of controls text(0)...text(n) and Msflexgrid control spread on 50 forms or more.

All the controls name are consistent, such as: msflexgrid1 or text(n) on all of the forms.

Is it possible if I want to catch an event such as: 'keypress' on text boxes control across multiple forms??

If I have to insert manually (using copy paste) such as

private sub text_keypress( index as integer, ..... )
...
....
end sub

That would be cumbersome because I have to copy paste the code in all the forms (which is more than 50).

Is it possible to trap events on control (with consistent naming on the control) across multiple forms??? Tell me!

A Click Event For Multiple Items?
Hi, I'm using VB6.

I was wondering, can you make an event for when you click anything?

Because what I'm trying to do is, if you click [a-i][1-8] (a5 g3 etc), then it does

Code:
if a1.visible = true and b2.visible = true etc then
'something
end if

Because it would be a lot easier to put it all in one if than put it in 81 different if's

And it doesn't necessarily need to be clicking on an image, clicking anything would be good enough.

Thanks,
MountainDew7

How To Capture KeyPress Event For Multiple TextBoxes
I need a way to single way to capture KeyPress event for multiple textboxes. I had a TextBox control array that referenced the KeyPress code below and that was fine but I changed my code, got rid of control array and instead dynamically create many textboxes which are referenced in an array -" DIM Pools(15,4) as Object", 15x4 TextBoxes. So now I need a way to capture KeyPress event for 60 dynamically created TextBoxes. Thanks.

This is old code for TextBox control array:

Public Sub Pool3Text_KeyPress(Index As Integer, KeyAscii As Integer)
KeyAscii = NumericCharsOnly(Pool3text(Index), KeyAscii)
If KeyAscii = 13 Then
x = CheckNumericTextBox(Pool3text, Index)
End If
End Sub

Keypress Event In Multiple Rich Text Box
I am having a problem with trapping keyevents in a Rich Textbox in different windows when I have multiple non-modal windows that contain Rich Textbox control. Here is the scenario: I opened up multiple non-modal windows that contain individual Rich Textbox. As I am typing on one of the Rich Textbox in one of the windows, an event got fired in the main app that caused the other window to be flashed using FlashWindow() function. Now my app is not getting any more Keypress events on the window that I am typing in.

My question is: How do I maintain the Keypress event on the other window while allowing the other window to flash?

Adding Multiple Records To A Table With Single Event
Hi Friends,

I am developing a payroll package using vb & access.

I have a payroll form through which I Generate the record of each employee manually one by one.

I have the master table for the Employee information( emp table) & Salary information (salary table) which i update once in a year when the revision of salary takes place.

The payroll is generated on a monthly basis.

Though the generation of payroll is same for all the employees, I have to go through the records of each employee every month & generate his payroll.

Is there any logic through which the payroll for all the employees is generated with the execution of one event ( Such as clicking a command button )

After generation of one event the records should get added to the payroll table one by one.

In other words , Is there any mechanism by which multiple records can be added to the access table with the generation of one event ?


Pls help.
with many thanks,
Dennis.

multiple records can be added to the access table with the generation of one event ? once in a year payroll for all the employees is generated with the execution of one event

Objects In Behind Other Objects Covering Up Objects Infront
I've been experimenting with direct 3d and I came across a snag. It seems that regardless of the z cordinate the objects are displayed in the order they are drawn. So if object1 is supposed to be behind object2 but is drawn after object2 object1 will actaully be drawn over object2. Is there a slick way around this problem.

Handles
I have a sort of, complicated, question.

In visual basic, I am trying to enumerate the currently open handles of all processes using the undocumented NT APIs, just for fun to learn something about them. I have been able to get EVERYTHING, PID's, Handle numbers, Attributes, everything, even object names. But i cannot get the object name of the file handles.

For example, if the type is 'Key' it will return the /Registry/path etc.. but when the type is 'File', it will return a blank. I am using this code (I am not french, so the comments I can not understand, however from the little translation I do know, it sais that 'File' types need a driver to get the name.

Edit: oops, code http://www.vbfrance.com/codes/LISTER...-NT_25915.aspx

I have seen this done in fairly easy C++, I even have an example, but i am stuck trying to convert this into Visual basic.


Code:
UCHAR lpBuffer[0x1000];
DWORD iob[2];

NtQueryInformationFile(hHandle, iob, lpBuffer, sizeof(lpBuffer), 9 );
I have something like this in VB6


Code:
lRet = NtQueryInformationFile(lDuplicateHandle, IOSTAT, WHAT GOES HERE!, 4096, 9)
Where the what goes here, I am attempting to retrieve the data the API provides, how can i do this in a long value?

If anybody has any idea on how to get the values of these filenames, please let me know. I can provide the (fairly large) c++ project if needed to see if it would be compatible with VB6. The C++ DOES use one incompatible object, that is CreateThread, but I looked at it and it looks like there might be a work-around.

How Do You Get Handles?
how do you get handles of windows? like say desktop, internet explorer, or any other running program?

2 Handles!
I was playing around with handles of windows and I have noticed that there are 2 handles per window. I can get them by taking difrent paths. One of those handles is a small number but the second handle number is large like 1000.

You can get the handel number from 1-1000 by doing something like this:
Copy and paste what is bellow. You might need to change the public declarations to privates. Create a command button, Listbox and a textbox. using the numbers that will be in the itemdata of the listbox you would be able to do anything you want with api functions to that window.


Code:
Public Declare Function GetClassName Lib "USER32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Public Declare Function GetWindowText Lib "USER32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Declare Function GetWindowTextLength Lib "USER32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long

private sub command1_click()
dim I as long
dim S as string

for i=0 to 1000

s=gclassname(i)
if trim(s)<>''" then
list1.add getwindowtitle(i)
list1.itemdata(list1.count-1)=i
end if
next i
end sub
private sub List1_click()
text1.text=list1.itemdata(list1.listindex)
end sub
Public Function GetWindowTitle(hwnd As Long)

Dim l As Long
Dim S As String

l = GetWindowTextLength(hwnd)
S = Space$(l + 1)

GetWindowText hwnd, S, l + 1
GetWindowTitle = S

End Function

Public Function GClassName(hwnd As Long) As String
Dim Size As Long
Size = 256
GClassName = Space$(Size)
Size = GetClassName(hwnd, GClassName, 256)
GClassName = Left(GClassName, Size)

End Function

If you use the findwindow api functions with the window title that would be in the listbox you would get a difrent handle number but you could still do anything to that window with that handle number.

Why are there 2 handle numbers that can be used? How can I convert the handel numbers that are usual small to the large ones by only using the handle number but not anything like class name or window title?

Thanx in advance!

Spy++ Handles
I use some api's to get windows handles, I pass em around to eachother and evrything is fine. The I use spy++ to get handles, and they have letters in them and I keep getting type mismatches, what kind of notation is spy++ using? How can I convert them to api types

Getting Handles.....
Havn't recieved some advice from some of you fine people i came up with the following code - trouble is it doesn't work.

When i get it to run notepad.exe it does, so i can't figure out what's wrong. It does run the program, just not get it's handle.


VB Code:
Public Sub Main()    BracketNo = 0    IsComment = False    IsString = False    HasLoaded = False    CAMLWnd = InstanceToWnd(Shell("C:CAMLCAMLWIN.EXE", vbNormalFocus))    ReDim CommandsEntered(0)    LoadSyntaxSet    LoadColours    'CAMLWnd = FindWindow("CAML for Windows - Terminal", vbNullString)    TerminalWnd = FindWindowEx(CAMLWnd, ByVal 0&, "Terminal", vbNullString)    HistoryWnd = FindWindowEx(CAMLWnd, ByVal 0&, "History", vbNullString)    frmCamlEditor.ShowEnd SubFunction InstanceToWnd(ByVal target_pid As Long) As Long    Dim test_hwnd As Long, test_pid As Long, test_thread_id As Long    'Find the first window    test_hwnd = FindWindow(ByVal 0&, ByVal 0&)    Do While test_hwnd <> 0        'Check if the window isn't a child        If GetParent(test_hwnd) = 0 Then            'Get the window's thread            test_thread_id = GetWindowThreadProcessId(test_hwnd, test_pid)            If test_pid = target_pid Then                InstanceToWnd = test_hwnd                Exit Do            End If        End If        'retrieve the next window        test_hwnd = GetWindow(test_hwnd, GW_HWNDNEXT)    LoopEnd Function

Handles Of A PID
How can I get the number of handles of a given Process ID?

Handles
Could someone explain or point out a good tutorial about handles?

I need to know about terms such as 'hWnd' and 'mWnd'

Thanks.

Handles ..
Short Question:

Is there a way to fetch handles of textboxes located on other windows (not yours)? I know the Handle of the Window. And when the handle is fetched, maybe you could also tell me how to determine his contents, but most important is how to find textboxes on it and a handle

Hope you can help me,


Quintonir

Copyright © 2005-08 www.BigResource.com, All rights reserved