|
Hey all
My question is how to find a child window!
well, I know that I can use FindWindow("hwndclass", NULL); but how to find a child window of a program? I tried using FindWindow() but it couldn't recognize the child window... is there any way?
thanks in advance
|
|
|
|
|
EnumChildWindows()?
Artificial intelligence is no match for natural
stupidity.
|
|
|
|
|
|
After Using the FindWindow() ,For enumerating Child Window use FindWindowEx() .
if you need,I will Provide you code for Enumerting the Desktop Windows.
"I Think this Will Help"
<h5
alok gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
FindWindowEx allows you to specify a parent handle, and will search only for children of that parent window.
So you find the parent window, then call FindWindowEx using the parent window handle as the starting search point.
There is one VERY important caveat:
FindWindowEx will ONLY find FIRST generation children.
Suppose for example, your top level window is a dialog box. The Dialog has a frame control. The window you want to find is a child of the frame.
Calling FindWindowEx using the parent will find the frame. But it will not find your desired window, because it only searches direct children.
So your strategy in this case would be:
1) Get dialog handle.
2) Use dialog handle as parent and find handle to the frame.
3) Then use the frame handle, NOT the dialog handle, as the new parent and continue the search.
This will now find your target because it is a direct child of the frame, not the dialog.
Because windows hierarchies can be complex, you need to use a tool like Spy which can show the relationships of a window. Then base you search strategy based on how Spy shows you the windows are related.
Hope this helps,
Robert
|
|
|
|
|
Thanks alot for your replaies....
but does this also work with a popup window?
I mean, many programs have option window... let's take Yahoo for example, if I click on option from the menu then a popup window will come and disable the main yahoo list, so can I also use FindWindowEx to find this popup window?
thanks alot
|
|
|
|
|
Well, usually the use of FindWindowEx implies that you are finding and possibly manipulating windows in a program external to your own program, because you should already inherently know how to find all windows your own program creates.
So, assuming you are doing what I think you are doing, the answer is yes, because the popup is modal to the browser window that spawned it, but it is not modal to your own program. So yes, you can still execute code and should be able to find it. Again, use Spy to help you design the strategy to find the popup.
I have a program that creates a browser window and then navigates to a site page that displays a popup modal dialog. I have no problems finding the login dialog, and entering the login automatically.
So I think the answer to your question is yes, unless you are doing something really weird.
Robert
|
|
|
|
|
well...
when I try using spy++ then I found that the class of the windows is #32770 (Dialog) and the window caption is option, and when I use FindWindow() and use SendMessage() to close it, nothing happen!
HWND optionwindow =::FindWindow(NULL, "option");
or
HWND optionwindow =::FindWindow("#32770", NULL);
or even
HWND optionwindow =::FindWindow("#32770", "option");
and
::SendMessage(optionwindow, WM_CLOSE, 0, 0);
but not working!
any help thanks?
|
|
|
|
|
I'm writing again since nobody has answered my previous post about the strange error I get under win98/ME and 2000 (debug assertion failure at daocore.cpp @ line 453, but the code actually works perfect under winxp sp2.
CDaoDatabase db;<br />
CDirectory dir;<br />
CString strDb = dir.GetCurDir() + _T("db.udb");<br />
<br />
if(GetFileAttributes(strDb) == 0xFFFFFFFF)<br />
{<br />
try{<br />
db.Create(strDb);<br />
CString strSQL;<br />
strSQL = _T("CREATE TABLE table (id COUNTER);");<br />
db.Execute(strSQL);<br />
db.Close();<br />
} catch (CDaoException *e)<br />
{<br />
e->ReportError();<br />
e->Delete();<br />
}<br />
}
Please help
|
|
|
|
|
I forgot to mention that it fails on the target machine (client), so may be it's something with redistribution or what?
|
|
|
|
|
|
The error is
debug assertion failed
File: daocore.cpp
Line: 453
the error is "there is no error message", it's so weird!!!!
|
|
|
|
|
I see that it's saying that it's failing on an ASSERT(FALSE) line. I'd go to the actual file, up a few lines where it says: BOOL bRetCode = FALSE; and put a breakpoint there.
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
I am using modaless CDialog
What is the or is there a command to update dialog window when you set data with new values? Or do I need to delete the old one and recreate new one?
I am trying to implement so that I can right click roll over objects on the screen and the dialog will update with new information, and dialog would be terminated when right click is released
|
|
|
|
|
UpdateData() assuming you are using MFC. Otherwise you'll need to repopulate the controls yourself.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
I tried UpdateData() and it didn't work
Although SetWindowText changes the title
|
|
|
|
|
UpdateData( FALSE ) must work. Any validation rules DDV_xx which fail will prevent updates though.
Have you tried stepping through it in the debugger to see what is happening?
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
I believe it was just yesterday that Blake Miller correctly suggested using a non-dialog approach. Just use a pop-up child window.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I want to try working with Dialog first(plus I want to learn how to use Dialog). If I really can't do it then I will switch over
|
|
|
|
|
Can this function call fail in some configuration of Windows NT 4.0 and later? The docs state that the complementary SetSystemTime call will fail if the user doesn't have the privileges to set the time on a system. I have an application that is failing to return this information. The function is void, so the only real valid check is to check the SYSTEMTIME struct for empty values.
|
|
|
|
|
It is very hard to believe that GetSystemTime() could fail and I certainly have never seen it. MSDN and Googling don't show anything like this.
It could be worth testing GetLastError() even though doc's don't mention it is relevant. Also try GetLocalTime() and time(NULL).
Maybe your code is clobbering the SYSTEMTIME struct. Are you checking it directly after the call to GetSystemTime() or later on?
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Are you passing the SYSTEMTIME structure in correctly?
The structure has to be an [out] parameter. So you need to call the API with the pointer to the structure.
This will NOT work:
////////////////////////////////////////
//Declare a SYSTEMTIME structure
SYSTEMTIME stSystemTime;
//Call GetSystemTime
GetSystemTime(stSystemTime);
////////////////////////////////////////
Instead you should call something like this:
////////////////////////////////////////
//Declare a SYSTEMTIME structure
SYSTEMTIME stSystemTime;
//Call GetSystemTime
GetSystemTime(&stSystemTime);
////////////////////////////////////////
Good Luck,
Robert
|
|
|
|
|
Please could someone help me with the Net API :
What I need my application to do is allow the user to type in their username, password and Domain and then using the Net API validate the password with the username and then see if the user is a member of a certain group (A group which I have set up).
Could anyone help me on this subject (Really struggling).
Any sample code (Using C++ MFC/win32) or guide lines would be very much appreciated.
For ever grateful
Regards
Richard
P.S. Thank you for your time!!!! =
|
|
|
|
|
Does LogonUserEx() help?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
If I create a function in an MFC app that does not reference the class, how can I get it to see any pointers that I have in this function
any point that is placed in this function works:
<br />
void CMyThread::OnClose()<br />
{<br />
<br />
}<br />
any point or variable referecnes in this function will not work
<br />
void OnClose()<br />
{<br />
<br />
}<br />
I know it won't because I'm not referencing my class any more. So how can I get it to work with out referencing my class?
God i hope this make sense
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|