Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

nietod, or anyone... ugh, still confused! help!

Posted on 1999-01-28
6
Medium Priority
?
191 Views
Last Modified: 2010-04-16
OkAy...

Now that I know which functions to use, I still don't know exactly HOW to use them.

How would EnumChildWindows() find an edit box? Does it find the resource ID?

Can I get some code for this?
D
0
Comment
Question by:SuperMario
  • 4
6 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 1185426
Once you have the parent window you call EnumChildWindows() specifing the parent window's handle and a pointer to a callback procedure you've written.  windows will call your callback function for each child window that the specified window has.  for each window, check to see if it is the edit box window, if so, you've found it, do whatever you want with it and then return FALSE, to stop enumeration.   If it is not the target window, return TRUE to continue enumeration.

You can test if a window is an edit box by looking at its class name.  You obtain that with GetClassName().
0
 
LVL 3

Author Comment

by:SuperMario
ID: 1185427
Okay...
I tried EnumWindows, but.. I honestly have no clue how to implement this into code. I'm sorry I'm being so dense about it. I need just... code. I'm a visual learner.
D
0
 
LVL 3

Author Comment

by:SuperMario
ID: 1185428
oo0o0o0....

Using Spy ++, I found the handle, class, style and rect of the edit box. So now, how would I put text into this window w/ the given info?

Thanks so much,
D
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 3

Author Comment

by:SuperMario
ID: 1185429
Now that I found this, I tried just changing its caption. It sucks though, because no matter what I try I get a "This program has performed an illegal operation" because of an unhandled exception in MFC42D.DLL.\

This is getting mighty confusing.
D
0
 
LVL 8

Accepted Solution

by:
Answers2000 earned 0 total points
ID: 1185430
I missed any previous question, but here's how to use the functions you mention

1. Code

// the enumeration call-back
BOOL CALLBACK EnumChildProc( HWND hWndChild, LPARAM lParam )
{
char szClassName[256] ;
GetClassName( hWndChild, szClassName, sizeof szClassName )

if ( 0 == _strcmpi( szClassName, "edit" ) )
{
 // hWndChild is the child edit control, do whatever you need here
}

return TRUE ;
}


// in your main code
EnumChildWindows( hWndParent, (WNDENUMPROC)EnumChildProc, 0 ) ;

2. If the call-back function is a member of class make sure it's a static member, e.g.

class CSomeClass
{
static BOOL CALLBACK CSomeClass::EnumChildProc( HWND hWndChild, LPARAM lParam )
} ;

BOOL CALLBACK CSomeClass::EnumChildProc( HWND hWndChild, LPARAM lParam )
{
// etc
}


3. Note - when you call EnumChildWindows the last parameter get's passed into the LPARAM of the EnumChildProc function.  You can use this to pass any data type you want.  As a pointer will fit into LPARAM simply cast a pointer to whatever data structure the call back function might need.
0
 
LVL 3

Author Comment

by:SuperMario
ID: 1185431
That should do it! Thanks a ton.
0

Featured Post

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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

971 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