|
thank u for your reply.
but i think what i said is not clear.
my meaning is that the two ways are both in debug version:Ctrl+F5(not debug mode) and F5(debug mode), but not in release version.
|
|
|
|
|
I want to create a window in a thread. Instead of deriving a class from CWinThread and setting the m_pMainWnd variable, can I just create a worker thread and create the window in the controlling function. Then could I post messages to the window, and the resulting functions calls would occur in the new thread?
|
|
|
|
|
That's the way I've always done it. Unless there is something I'm unaware of, that seems to be the way to go.
|
|
|
|
|
Hi, I went to project properties, linker input and added the following library: "winmm.lib", then I clicked on resouces in the solution explorer and clicked on add existing resource and added a .wav file.. Then I manually created a resource script that I will show you here:
#include "Resource.h"
IDI_FISHL ICON "Res\\fishicon.ico"
IDI_FISHS ICON "Res\\fishiconsm.ico"
IDB_BACKGROUND BITMAP "Res\\background.bmp"
IDB_FISH BITMAP "Res\\fish.bmp"
IDB_BUBBLE BITMAP "Res\\bubble.bmp"
IDW_BUBBLES WAVE "Res\\bubbles.wav"
and here is the resource.h file
#define IDI_FISHL 1000
#define IDI_FISHS 1001
#define IDB_FISH 2000
#define IDB_BACKGROUND 2001
#define IDB_BUBBLE 2002
#define IDW_BUBBLES 3000
Okay and this is the error the compiler gives me: 1>.\Resource.h(21) : fatal error RC1004: unexpected end of file found
PLEASE PLEASE HELP ME!!!
|
|
|
|
|
This is what MSDN says about that error:
This error can be caused by missing linefeed and carriage return characters on the last line of a text file.
Try adding a few blank lines at the end of the resource.h file, making sure that each line has a CRLF.
|
|
|
|
|
I added some blank lines and that didn't work.. But I did take that last line and put in the front of the file and it worked okay.
|
|
|
|
|
Glad to hear it worked out.
Happy Holidays!
|
|
|
|
|
Hey guys...
I got a string from a web page. I wanted to match a string if it exists. Actually my search string doesnot include any reg-ex characters. (Pls do not advise me to use search string methods...)
Anyway.... When I call rgx.Match method it returns TRUE and marks start and end string (I saw it in debug mode) BUT m_uNumGroups variable is set to 0. So I could not get matched piece.. I got error......
So why this happens? Regex says there's a match but there are no match groups....
Thank you all...
|
|
|
|
|
|
The m_uNumGroups shows how many captures you have from using grouping characters (i.e. brackets) in the regexp.
e.g. If I match "abc" with the regexp "([a-z])(.+)" it'll match and I'll get two groups, the first containing "a" and the second containing "bc". If I match "abc" with the regexp "[a-z].+" (i.e. same as the first but without the brackets) it'll still match, but I'll get no groups.
So - I suspect your regexp has no brackets? Difficult to say without seeing it...
|
|
|
|
|
we have one dedicate m/c to do logging stuff only.The process which is doing logging get hanged for 5-15 min. By analyzing the problem,I have found that it hanged on closing the file.it hangs on API "fclose".It happens when we have file large log file(in between of 500MB to 1.3GB).
I have already tried following things:
1) just doing fflush before flose(fflush has been done successfully and very quickly)
2) to make sure this file has not been used by any other process,I tried to rename the file when fclose is in hanging state.I am able to do this.
3) After 500MB,I tried to close and open file again after each 50MB.Still hangs every time.
This problem is happening only on live system.It is not getting on my local m/c.I am not finding any reason now.
Do anyone have some suggestion or idea related to this problem?
Regards,
Vishal Soni
modified on Thursday, December 25, 2008 1:00 PM
|
|
|
|
|
How to use CAsyncSocket objects in CWinThread object Safely?!
(the tread should use ActiveX controls - a CListCtrl in the main CDialog dialogbox- to show notifications and events)
- i dint use threads in a first version, instead i used a RoundRobin Algo to answer the clients! but the server was slow
so now i need to get the threads work!
thank's in advance...
|
|
|
|
|
Mind Machine wrote: How to use CAsyncSocket objects in CWinThread object Safely?
The same way you'd use any other objects in a thread safely.
Do you have a specific question? If you don't know how to write
multi-threaded code, that would probably be a great place to start.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
well Mark, my problem exactly is;
when is, in my thread, when i use th listening socket wich is a member of my main dialog to accept connections; this last calls the runtime to terminate it, which is an unusual way to end a dialog! and also my thread cant call any ActiveX control! (assertion fails!!)
|
|
|
|
|
You're probably getting failed assertions because you are calling functions of your UI controls on a secondary thread.
Remember that you must only manipulate the UI with the thread that created the UI and its controls.
If you want a secondary thread to be able to affect the UI, you should have the secondary thread post window messages that are acted upon by the UI thread.
|
|
|
|
|
i want to connect my SQL server 2005 data base through c++ code.. please some one help me..
more precisely, when ever there is a update in the data base i have to pass the values of the field to another application thru c++ code..
|
|
|
|
|
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. <
|
|
|
|