|
|
MSDN code[^]
Just change the notification flags in the above example to reflect your heart's desire.
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
Seehere[^]if its good for you
|
|
|
|
|
Hi people
I'm working with a windows hook, and I intercept WM_CREATE for all the windows.
I need to know if a window is going to be visible, I tried using IsWindowVisible(HWND) and checking WS_VISIBLE flag (wich are the same :S) and I always get false, because the window is not yet created.
Do someone knows how can I do to know if the window beign created is going to be visible?
Thanks in advance
|
|
|
|
|
Did you look at the CREATESTRUCT in the LPARAM of the message?
led mike
|
|
|
|
|
Yeap, im testing it like this
if(pCreateStruct->style & WS_VISIBLE == WS_VISIBLE)
and always is false
|
|
|
|
|
if((pCreateStruct->style & WS_VISIBLE) == WS_VISIBLE)
led mike
|
|
|
|
|
If I use
if((pCreateStruct->style & WS_VISIBLE) != WS_VISIBLE)
(notice the != )
it works, another computer science mystery.
Thanks a lot for the tips mate
|
|
|
|
|
Kharfax wrote: it works
Well if I follow the entire thread correctly it is not what you want since you are now testing that the WS_VISIBLE style is NOT set!
Consider this possible window creation sequence:
A) application code calls CreateWindow passing a style.... say WS_POPUP
B) OS sends a WM_CREATE containing the style
C) your hook recieves this message and the style WS_VISIBLE is not set
D) application code handles the WM_CREATE message and changes the window style to WS_VISIBLE
led mike
|
|
|
|
|
Damn, now it works because it shows all
|
|
|
|
|
I need to get only the applications that appear in the task administrator.
The filter only shows user apps with a visible window.
Im trying to do the same kind of filtering.
but it seems that WS_VISIBLE is troublesome...
Maybe I can check another style, and get the same results..
I dont know, for example, WS_SYSMENU or WS_CAPTION, the only problem I see is with skinned apps that have a simulated SYSMENU :S
What do you think about this approach?
|
|
|
|
|
Kharfax wrote: What do you think about this approach?
At this point I am not convinced that I have a complete understanding of the requirements.
Kharfax wrote: I need to get only the applications that appear in the task administrator.
I guess you refer to the "Windows Task Manager" and the list of processes in the "Applications" tab?
If so there is a completely different way to accomplish that rather than using a System hook. There are APIs that allow you to get the list of running processes.
I would think some Google would find articles and sample code to get you much of the way there. There might even be a Code Project Article. The MSDN Documentation[^] on Process Enumeration is a good place to start if you want to figure it out for yourself.
One example approach might be using the GetStartupInfo() API that returns a STARTUPINFO structure. The structure has a member for which the documentation states:
lpTitle
For console processes, this is the title displayed in the title bar if a new console
window is created. If NULL, the name of the executable file is used as the window title
instead. This parameter must be NULL for GUI or console processes that do not create a
new console window.
dwX
led mike
|
|
|
|
|
I will check that approach using GetStartupinfo
I have the hook, to know among other things, when a new window is created by a user.
The hook is used for my "single sign on" app, thats why i'm using it.
If that window belongs to an App like the one in task manager "applications" tab
I need to report the opening to a local service.
The problem is for example with the calculator and other apps.
I get
exe: calc.exe
windows title: calcMsgPump
or some crap like that, that's why I want only the visible windows.
|
|
|
|
|
Kharfax wrote: or some crap like that
What is wrong with that?
Kharfax wrote: that's why I want only the visible windows.
I don't understand, when you start the calculator it shows up in the "Task Manager - Applications" tab. So it "is" visible and therefore you want to find it, correct?
led mike
|
|
|
|
|
Check the win title.
I get as if two windows open
calc.exe Title:Calculator <- This one is OK
calc.exe Title:CalcMsgPumpWnd <- I dont see this one either in Applications tab or my screen
I would like to obtain only the apps I see in Task Manager apps tab.
|
|
|
|
|
ok that clears that up.
You might consider using the hook for WM_CREATE as just an event. Meaning that upon the event you use the process enumeration methods and process API's like GetStarupInfo() etc. to build your list.
led mike
|
|
|
|
|
This syntax with all those brackets is scaring me....
Can someone please tell me what is going on?
for ( unsigned int j = 0; j < ms_numInstances; j++ )<br />
{<br />
( *( (Ball*)(ms_instances[j]) ) ).m_stateTimeInterval = timeInterval;<br />
}
Thank You!
|
|
|
|
|
Is casting whatever there is inside ms_instances array to a Ball object pointer, and then is refering to that object that is beign pointed, you can resume it like this:
Ball b;
b.m_stateTimeInterval = timeInterbal;
Obviously dont replace the code, is just for you to see the same in a more simpler way
Hope it helps
|
|
|
|
|
It could also be written as:
for (...)
{
Ball *pBall = ms_instances[j];
( *pBall ).m_stateTimeInterval = timeInterval;
pBall->m_stateTimeInterval = timeInterval;
}
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I would prefer this:
for ( unsigned int j = 0; j < ms_numInstances; j++ )
{
Ball * const ball = ms_instances[j];
ball->m_stateTimeInterval = timeInterval;
}
Now it seems much clearer, I think. The ms_instances array contains pointers to Ball objects. This loop initializes the m_stateTimeInterval field of all of Ball objects.
|
|
|
|
|
Viorel. wrote: The ms_instances array contains pointers to Ball objects
What happens when j = 0;
Ball * const ball = ms_instance[0];
Does this mean it has no pointers because ms_instance[0] ?
Do you need atleast j = 1 to create a pointer ........ like ms_instance[1] means 1 pointer
.... ms_instance[2] means array of two pointers......... so what does 0 mean?
ball->m_stateTimeInterval = timeInterval;
--------------------------------------------------------------------------------------------
So for each j value, there will be an array of pointers created?
|
|
|
|
|
Jay03 wrote: Ball * const ball = ms_instance[0];
Arrays in C/C++ are 0-based. This line will access the first element in the ms_instance array and cast it to a pointer-to-a-Ball.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
ms_instances is apparently an array of pointers to instances of some kind of object.
this code gets element 'j' (a pointer) out of the array, then casts that pointer to a pointer-to-a-Ball: "compiler, treat this pointer as if it was a pointer to a Ball, instead of a pointer to whatever it is actually pointing at. then it dereferences the pointer and sets the m_state* member variable of what we all hope is an actual Ball object.
|
|
|
|
|
It is nothing more than the equivalent of doing the following:
for (unsigned int j = 0; j < ms_numInstances; j++)
{
Ball* pBall = (Ball*)ms_instances[j];
pBall->m_stateTimeInterval = timeInterval;
}
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
I'm using the web browser active-x control in an MFC application to browse some web sites. If I need to click links within this site however, sometimes it opens up a new IE window. I need it to always open up within the same window. In other words always target _SELF.
I tried looking through MSDN and other sites, but everything is always so cryptic and the examples are scarce.
Write now I call Browser.Navigate(myURL,NULL,NULL,NULL,NULL); to open a site. The 2nd NULL is supposed to be for the target name. I have yet to see an example where these 4 NULL's are actually set to anything else.
Can anyone shed some light as to how to do what I am trying to do.
Thanks in advance!!
|
|
|
|