|
Have you checked out one of these [^]?
i.e. a polite way of saying: "RTFM".
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
I create a process on another desktop using CreateProcess by providing another desktop information.
All the things go well. Then, i want to send some message to it.
But the problem is, if i send quit message to it, it get the message successfully, but if i use GetMenu to get its meneu and then get submenu, and send menu message to it, it gets nothing. But if i just send a WM_QUIT message to it, it gets it because the process will quit as excepted. I mean, GetMenu function would fail if the process runs on another virtual desktop
Im sure i got the window handle successfully and had called SetThreadDesktop to make my program can post messages to the process runs on another desktop.why?
Merry Christmas.
modified on Thursday, December 25, 2008 1:25 AM
|
|
|
|
|
There are security issues involved with sending window messages between desktops.
It would probably solve all your problems if you made the processes communicate with named pipes instead.
|
|
|
|
|
Yes, i agree with you. Named pipe can solve all the problems, but the final problem is that, the app witch i want send messages to is not my app.
Thanks for your reply. Maybe i should find another way, hook for example.
Regards.
|
|
|
|
|
Here's a wild idea:
Inject a DLL into the target app, and have the DLL send the messages.
Then communicate with the dll by named pipe.
Just a thought.
|
|
|
|
|
OK. I will have a try. It seems that your suggestion is easier than hooking resolution.
I will tell you the result as soon as i have tried it.
|
|
|
|
|
Hello Dear Friends,
1) I am creating an application which allows its user to log in to website.
2) For that I call the webservice(Written in C#.NET) from the MFC.
3) To call the webservices I use the XMLHttpRequest and it is working fine if I call the webservice using XMLHttpRequest with the member function of the class, However this method doesn't allow the parent program to continue until I get the webservice response.
4) So I am creating a thread and calling the webservice from the thread the problem is in the thread it won't allow to create the COM object of XMLHttpRequestPtr.Can anybody tell me what could be the reason that the creation of the COM object fails.
5) Please see the code below.
void LOGINTOWEB(void *Params)
{
CMFToolbar *m_pToolbar=(CMFToolbar*)Params;
try
{
CSingleLock m_lock(&(m_pToolbar->m_sema));
m_lock.Lock();
m_pToolbar->LoginToWeb1(m_pToolbar->m_strqpWebUser,m_pToolbar->m_strqpWebPass,m_pToolbar->m_strqpWebOrg,m_pToolbar->m_strqpWebUrl);
m_lock.Unlock();
_endthread();
}
catch(...)
{
}
}
And here is the member function of the class I've debug the code it fails in the creation of the COM object IXMLHttpRequestPrt
bool CMFToolbar::LoginToWeb1(CString UserName,CString Password,CString Organization,CString Url)
{
bool bFlg=false;
try
{
CString params;
MSXML::IXMLHttpRequestPtr httpReq(__uuidof(XMLHTTPRequest));
_bstr_t HTTPMethod ;
_variant_t noAsync = _variant_t( (bool)false );
_variant_t user=_variant_t((CString)UserName);
_variant_t pass=_variant_t((CString)Password);
CString strUrl=Url;
strUrl+=QPWEB_SUFFIX;
_bstr_t url(strUrl.GetBuffer(strUrl.GetLength()));
HTTPMethod = _bstr_t("GET");
httpReq->open(HTTPMethod,url,noAsync,vtMissing,vtMissing);
httpReq->setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
httpReq->setRequestHeader("Content-Length","0");
params.Empty();
params="UserName=";
params+=UserName;
params+="&Password=";
params+=Password;
params+="&Organization=";
params+=Organization;
VARIANT vRequest;
vRequest.vt = VT_BSTR;
vRequest.bstrVal = params.AllocSysString();
httpReq->send(vRequest);
BSTR strText;
int nPos1,nPos2;
CString strsession,szResult1,szResult;
_bstr_t bsResponse = httpReq->responseText;
CString response((LPCWSTR)bsResponse);
MessageBox(response);
nPos1=response.Find("<SessionId>");
nPos2=response.Find("</SessionId>");
nPos1+=11;
strsession=response.Mid(nPos1,(nPos2-nPos1));
m_qpWebSessionId=strsession;
nPos1=response.Find("<LoginToqpWebResult>");
nPos2=response.Find("</LoginToqpWebResult>");
nPos1+=20;
szResult1=response.Mid(nPos1,(nPos2-nPos1));
szResult=szResult1;
szResult.MakeLower();
if(szResult=="true")
{
bFlg=true;
}
else
MessageBox("Invalid account information.Please check your login details",_T("qpToolbar"),MB_ICONEXCLAMATION);
}
catch(...)
{
MessageBox("Login webservice not recheable");
}
return bFlg;
}
ritz1234
|
|
|
|
|
I think i read somewhere that you need to initialize and uninitialize COM in every thread that will use it, so maybe try calling CoInitialize (and CoUninitialize) in your thread and see if it changes anything.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
OK, here's one for you Win32 die-hards...
How can I check if a window (specified by its HWND ) is a top-most window - i.e. one that was brought to the top by calling SetWindowPos (..., HWND_TOPMOST, ...) ?
Thanks,
/ravi
|
|
|
|
|
You can use GetWindowLong() function with parameter GWL_EXSTYLE and then check for style WS_EX_TOPMOST..
I hope it helps..
Regards,
Sandip.
|
|
|
|
|
Heh, no - that only checks the if the window was created with that style or if the style is modified. Changing a window's Z-order (by calling SetWindowPos() ) doesn't affect the window's style.
Nasty li'l problem there...
/ravi
|
|
|
|
|
Ravi Bhavnani wrote: hanging a window's Z-order (by calling SetWindowPos()) doesn't affect the window's style.
May be but documentation for CreateWindowEx does not say that...
From MSDN:
WS_EX_TOPMOST
Specifies that a window created with this style should be placed above all non-topmost windows and should stay above them, even when the window is deactivated. To add or remove this style, use the SetWindowPos function.
Regards,
Sandip.
|
|
|
|
|
Argh! I'm an idiot - I was checking GWL_STYLE instead of GWL_EXSTYLE . Thank you, thank you, thank you!
/ravi
|
|
|
|
|
Check out GetWindow()
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Not quite - here's why: I'm writing an app (happens to be a C# app, so all calls to Win32 are PInvoked) that allows you to make any visible app window "always on top". Setting/unsetting a window's "always on top" state is easy.
What I want to do (or rather, would like to do ) is get the existing "always on top" states from each window instead of maintaining my own list of always-on-top windows (which could get out of sync). Hence the need to be able to check if a window is currently at the top of the Z order.
GetWindow() would allow me to get the collection of app windows (children of the desktop), but I'm already able to do this by iterating through the collection of running processes.
/ravi
|
|
|
|
|
How about iterating thorough the popup windows using GetNextWindow[^], and when there is no next window, then your current is at the top, right?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
No, because you can have several "always on top" windows (each belonging to a different app). What I'm looking for is a way to get the Z-order of any top-level window, i.e. a GetWindowPos() equivalent of SetWindowPos() .
/ravi
|
|
|
|
|
Am not sure what you mean, but even "always-on-top" windows are in the z-order, they are just kept over "non-always-on-top" windows, so one "always on top" window CAN overlap another "always on top" window.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Code-o-mat wrote: one "always on top" window CAN overlap another "always on top" window.
Correct. "always on top" means always on top of all non "always on top" windows. But that doesn't help in identifying which windows exhibit the "always on top" behavior.
/ravi
|
|
|
|
|
And you are absolutely sure that what is suggested here[^] does not work? I did a little test, made a window, set it to topmost using SetWindowPos and then checked its ex-style and it did become WS_EX_TOPMOST set. Am i missing the point here?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Argh! I'm an idiot - I was checking GWL_STYLE instead of GWL_EXSTYLE . Thank you, thank you, thank you!
/ravi
|
|
|
|
|
Ravi Bhavnani wrote: No, because you can have several "always on top" windows (each belonging to a different app).
But IIRC, the active apps windows will be at the front? So something like GetTopWindow(GetForegroundWindow()); should do? You'd need to check if the result of GetTopWindow was NULL, as that indicates a window with no child windows, so you would use the result of GetForegroundWindow instead.
HWND foreground = GetForegroundWindow();
HWND top = GetTopWindow(foreground);
top = top?top:foreground;
|
|
|
|
|
Better you use EnumWindows()[^] to enumerate all the windows and check the window handle you receive in the call back function with the handle retrieved with GetWindow()[^] function (by passing desktop window handle as first parameter and GW_CHILD as second parameter). Even you can compare the same handle with the handle returned by GetForegroundWindow()[^], but there could be chance that the foreground window isn't the topmost in the z-order.
|
|
|
|
|
I am currently working on a program which uses a GUI (written in C++ with MFC) to gather data from a user. When the user hits go, the program then analyzes the data and returns the results back to the user. The elapsed time between the time the user hits go and the results are returned is approximately 1 minute. In certain cases, it could be as high as 10 minutes. During that time, the program ignores any mouse clicks and when I bring up the Window’s task manager, the status of the program is that it is not responding. However, the calculations are complete, the program response as expected. However, for an end user, I do not believe that the program just hanging is acceptable. For example, if minimized and then restored it needs to be able to repaint the screen.
What should I do to remedy the situation? I am thinking that if I did the calculation in a separate thread that it would solve this problem. What do you think of this idea? Maybe somebody knows a better way to handle this situation.
Thanks
Bob
|
|
|
|