Solved

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

Posted on 1999-01-28
6
175 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
Technology Partners: 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!

 
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

Technology Partners: 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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

713 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