473,385 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

EnumChildWindows (Win32 error 127) (c#)

Hello,

I am having the oddest error with the EnumChildWindows function. Below are
the imports, and the methods.

[DllImport("user32.dll", SetLastError=true)]

public static extern int EnumChildWindows(IntPtr hWndParent, EnumChildProc
callback, int lParam);

public delegate int EnumChildProc(IntPtr hwnd, long lParam);

public void M_initChildWindows()

{

if(WindowObject_Basic_GDI_Handle != IntPtr.Zero)

{

try

{

User32.EnumChildWindows(WindowObject_Basic_GDI_Han dle, new
User32.EnumChildProc(M_addChildWindows), 0);

}

catch(Exception e)

{

System.Diagnostics.Debug.WriteLine("Child Window failure: " +
e.Message);

}

}
}

private int M_addChildWindows(IntPtr Window, long Data)

{
if(Window != IntPtr.Zero)

{

ChildWindowObject_Basic c_WindowObject_Basic = new
ChildWindowObject_Basic(Window);

c_WindowObject_Basic_Array.Add(c_WindowObject_Basi c);

}


return 1;

}

I keep getting a 127 error, even though it appears to enumerate the windows.
I placed it within a try statement to continue working other things, but
it's coming back to bite me in the ass.

Anyone have any ideas?

Thanks,

Ryan
Nov 17 '05 #1
1 9201
Ryan,

Your declaration of the callback delegate and function is incorrect. It
should be:

[DllImport("user32.dll", SetLastError=true)]
public static extern int EnumChildWindows(IntPtr hWndParent, EnumChildProc
callback, IntPtr lParam);

public delegate int EnumChildProc(IntPtr hwnd, IntPtr lParam);

LPARAM translates to an IntPtr.

Also, as an aside, you might want to check your publicly exposed method
names. They violate the public naming convention (M_initChildWindows, for
example).

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Ryan Ross" <ry***@nni.com> wrote in message
news:5O********************@nni.com...
Hello,

I am having the oddest error with the EnumChildWindows function. Below are
the imports, and the methods.

[DllImport("user32.dll", SetLastError=true)]

public static extern int EnumChildWindows(IntPtr hWndParent, EnumChildProc
callback, int lParam);

public delegate int EnumChildProc(IntPtr hwnd, long lParam);

public void M_initChildWindows()

{

if(WindowObject_Basic_GDI_Handle != IntPtr.Zero)

{

try

{

User32.EnumChildWindows(WindowObject_Basic_GDI_Han dle, new
User32.EnumChildProc(M_addChildWindows), 0);

}

catch(Exception e)

{

System.Diagnostics.Debug.WriteLine("Child Window failure: " +
e.Message);

}

}
}

private int M_addChildWindows(IntPtr Window, long Data)

{
if(Window != IntPtr.Zero)

{

ChildWindowObject_Basic c_WindowObject_Basic = new
ChildWindowObject_Basic(Window);

c_WindowObject_Basic_Array.Add(c_WindowObject_Basi c);

}


return 1;

}

I keep getting a 127 error, even though it appears to enumerate the
windows. I placed it within a try statement to continue working other
things, but it's coming back to bite me in the ass.

Anyone have any ideas?

Thanks,

Ryan

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Holly | last post by:
Hello List, My windows laptop configured as: XP, Python 1.5.2, MySQL 4.0.9 and Appache 1.3.17 A form ("Post" has been used) has a product list with about 400 products. The user checks each...
0
by: kinryuu | last post by:
I'm trying to write a program that captures selected text from the active window. I have everything setup as far as getting the foreground window (with GetForegroundWindow()) and I'm using...
0
by: Alex | last post by:
Hello, I am after one week trying to make working IIS with ASP Net. I am really dissapointed about this situation. I tried every advice, article and so on... . It is not working......
11
by: Tomas Kepic | last post by:
Hi, i'm trying to create my first ASP.NET project ( HelloASPWorld project) but an error occured when I put OK button in NewProject. ERROR: "The Web server reported the following error when...
4
by: Secrétariat | last post by:
Hello ! The RC2 is great but : I use an other filesystem for the data. So I have C:\Program file\PostgreSQL... and I have F:\PostgreSQL\8.0.0-beta4\data. In the file C:\Program...
3
by: John F | last post by:
I have a question about EnumChildWindows(). Currently I'm using this API function to iterate through all the controls in another application. In my call back function I call SendMessage() and...
1
by: pigeonrandle | last post by:
Hi, This could also be read as 'Does the EnumChildWindows callback block the rest of my application until the enumeration has finished?'. Basically i want to create a treeview similar to...
1
by: prithvis.mohanty | last post by:
using System; using System.Drawing; using System.ComponentModel; using System.Windows.Forms; using System.Runtime.InteropServices; using System.Text; using System.Collections; using...
0
by: Emilio | last post by:
Good morning to everyone, I've tested this "format" od this code to enumerate some controls in a window and it works fine. Private Delegate Function EnumChildProcDelegate _ (ByVal hWnd As...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.