|
I have a multi-threaded windows application
running on NT 4.0. Its actually based on a
class I found here called CThreadJob. It
continually performs an ODBC lookup and
displays the results. Pretty routine stuff.
If I build it, then launch it from explorer, it
seems to work fine. However, if I launch it
from within the Visual Studio IDE, in debug
or release mode, using F5 or Ctrl-F5, the
application deadlocks immediately and I
have to reboot to remove it (the rest of
the system is okay, I just can't get control
of the IDE or the app - even Task Manager
can't kill it).
I know this is sketchy and a really tough
one to diagnose remotely, but perhaps
someone has had a similar problem and
could give me something to look for. I
could swear this program is as thread
safe as they come, but the IDE seems
to feel otherwise.
jb
|
|
|
|
|
The first thing that comes to mind is that when you launch it in debug mode from the VS context, the exe is run from the \debug directory and also, the working directory is different and there might be different command line params set from the VS IDE.
I program multi-threaded apps every day (my job is programming servers) and the best way to find deadlocks is to add extensive logging to your application.
Put logs before and after every one of your wait functions (WaitForSingleObject, WaitForMultipleObjects, etc..) then see where the deadlock is.
Another thing that comes to mind when debugging multi-threaded applications is timing. The timing is completely different in debug mode than it is in release and deadlocks are all about timing.
Maybe the deadlock bugs are there, but they do not happen in release mode since it is faster and it catches up better.
Hope this helps,
Jeremy.
GFI
"Hey man, Taliban, Tali me Banana."
|
|
|
|
|
Hello,
i have a activex control.
it is only a treeviewctrl using wtl.
now i implemented a contextmenu handler, but if i
clicked on a menu point nothing happens.
in my message map i have:
COMMAND_ID_HANDLER (ID_OF_MENU_POINT, OnMyMenu)
What is my mistake?
|
|
|
|
|
Where is your message handler, in the treeview? Have you chained the context menu messages?
|
|
|
|
|
The massage handler is in my COM class (header file).
class ATL_NO_VTABLE CMyClass :
public CComObjectRootEx<ccomsinglethreadmodel>,
public CComCompositeControl<cmyclass>,
.....
BEGIN_MSG_MAP(CMyClass )
CHAIN_MSG_MAP(CComCompositeControl<cmyclass>)
......
......
MESSAGE_HANDLER(WM_CONTEXTMENU, OnContextMenu)
COMMAND_ID_HANDLER(ID_CHECKSERVER,OnDelete)
COMMAND_ID_HANDLER(ID_CHECK,OnDel)
END_MSG_MAP()
LRESULT OnDelete(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
MessageBox("asdsdasd");
return S_OK;
}
What do mean with chaining the messages?
|
|
|
|
|
Here is what i want to do.....
I want to print a tree from the CTreeCtrl.
Not the fully but only the selected tree nodes can any one tell how can i do this...
Thanks in Advance...
|
|
|
|
|
What's the problem? Printing from CTreeCtrl or finding selected items? CTreeCtrl doesn't support multiple selection natively; you have to implement it yourself and finding selected items depends on your implementation details.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Netmeisters
I am trying to write an application for the Pocket PC which, among other things, should connect to a Linux server via a secure socket. The server has OpenSSL installed.
Everything works with ordinary, unsecured sockets, and in principle, all I need to do now is "turn on" SSL for the sockets. As far as I can tell, this should require only two steps, setsocket()to "turn on" security, and wsaioctl() to register a certificate validation callback. These two steps should occur between the socket() call that creates the socket, and the connect() call that connects to the server.
Unfortunately, I haven't been able to get this to work.
I have
s=socket(AF_INET, SOCK_STREAM, 0);
DWORD optval = SO_SEC_SSL;
err=setsockopt(s, SOL_SOCKET, SO_SECURE, (const char *)&optval, sizeof(optval));
if (err==SOCKET_ERROR) {
errmsg.Format(_T("Error in setsockopt for SO_SECURE %d"), WSAGetLastError());
MessageBox(errmsg); }
connect(....
I get err=10042, "An unknown, invalid, or unsupported option or level was specified in a getsockopt or setsockopt call."
So setsockopt() doesn't work. I would like to know if anyone has any idea why. I should mention that I have only tested this with the Pocket PC emulator, since I don't currently have a physical device to test it on. Perhaps something is wrong with the emulator's support for SSL?
Any example code illustrating an SSL client for Windows CE would also be much appreciated.
Thank you,
Matthew Fleming
mgf@mcw.edu
|
|
|
|
|
I have a multiline CEdit control. The first pass through works fine. The buffer length is correct and the text that is retrieved is correct. All other passes through the loop retrieves the first buffer length, but gets the correct characters. Now, when I output that CString I have a bunch of garbage characters at the end of it. Is there any way to trim the characters off? Also, if the second line needs a larger buffer than the first line I will crash because of insufficient buffer length. The really strange thing is that each pass retrieves the correct text for the line it is on but not the correct length of the line. Any suggestions???
int LineCount = m_EditText.GetLineCount();
CString strText, strLine, TempSqlStatement;
int length = 0;
LPTSTR pBuffer;
for (int count = 0; count < LineCount; count++)
{
length = m_EditText.LineLength(count);
pBuffer = strText.GetBuffer(length);
m_EditText.GetLine(count, pBuffer);
strText.ReleaseBuffer();
strText += "\0";
strLine.Format(TEXT("%d%s\r\n")), count, (LPCTSTR) strText);
strLine.Delete(0, 1); // Need to remove the line number
// Create a temporary SQL string
TempSqlStatement += (strLine);
strText.Empty();
}
SqlStatement = TempSqlStatement;
|
|
|
|
|
Can't you just use GetWindowText? Is it really important to split these lines first and concatenate them later?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
You're right...i can't beleive that i didn't think about that. Thanks!
|
|
|
|
|
This always worked well for me:
void CEditBoxText::SetEditBoxText(CEdit* pEdit, ifstream* pDatain)
{
char buf[506];
CString strOut, tmpstr;
int iLineCount, n;
pDatain->getline(buf, 250); iLineCount = atoi(buf);
for (n=0; n<ilinecount; n++)
="" {
="" pdatain-="">getline(buf, 500); tmpstr=buf;
strOut += (n == 0 ? "" : "\r\n") + tmpstr;
}
pEdit->SetWindowText(strOut); strOut.Empty();
}
void CEditBoxText::GetEditBoxText(CEdit* pEdit, ofstream* pDataout)
{
CString csEditText, strOut, tmpstr;
int iLineLength, iLineCount, n;
LPTSTR lpTmp = NULL;
pEdit->GetWindowText(csEditText);
if (csEditText.IsEmpty())
*pDataout << 0 << "\n";
if (!csEditText.IsEmpty())
{
iLineCount = pEdit->GetLineCount();
for (n = 0; n < iLineCount; n++) // get each line, one at a time
{
lpTmp = tmpstr.GetBuffer(pEdit->LineLength(pEdit->LineIndex(n))+1);
iLineLength = pEdit->GetLine(n, lpTmp);
tmpstr.ReleaseBuffer();
tmpstr = tmpstr.Left(iLineLength);
strOut += (n == 0 ? "" : "\n") + tmpstr;
}
*pDataout << iLineCount << "\n" << strOut << "\n"; strOut.Empty();
}
}
|
|
|
|
|
Hi,
How do I make a library class (.lib or .dll) for a dialog box, that also includes this class's resources.
What I want is a dialog box class with complete functionality, that I can use in many projects. I do not know how to make a library with this class so as to include the resources (controls etc.) of the dialog. All my attempts failed.
Please help me,
Thanks,
Adi
|
|
|
|
|
You can't put the resources into .lib. This leaves only .dll option - just create a .dll with resources. Choose carefully between 'MFC regular' and 'MFC extension' dll versions if you're playing with MFC.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
"...Choose carefully between 'MFC regular' and 'MFC extension' dll versions if you're playing with MFC."
What's the difference?
Adi
|
|
|
|
|
you can move you resources into a separate resource file (.rc)and the associate header file and create a library from that.
e.g. MyLib.rc and MyLib.h (extracted from resource.rc and resource.h)
then in your project add the rc and header file via
view->resource include..
Add #include "MyLib.rc" to the compile time directive edit box
Add #include "MyLib.h" to Read Only symbol directive edit box
|
|
|
|
|
Hi
I used logical coordinates in my program,in such functions as MoveTo() ,LineTo()etc.But if I scroll the client are i am not able to get those points.i am using CScrollView only.how to convert the coordinates and get the points?
thanks in advance.
Pathi
bhikshapathi_g@semanticspace.com
|
|
|
|
|
Assuming that you're writing a method of CScrollView-derived class, you'd code like this:
CClientDC dc(this);
OnPrepareDC(&dc);
dc.LPtoDP(&point);
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I am using an CHtmlView in my application and was just wondering whether you could do something or not. Is it possible to know when a user clicks on a hyperlink?
I'll explain why I wish to do this for a bit more background. The user open's up a record which is an html page generated from a text file that is stored on the local disk. Depending on certain criteria, hyperlinks are built in to this record. Because this page is generated automatically I want to be able to track which hyperlink is clicked on so I can generate the relevant destination page automatically so I don't have to store (potentially) lots of html files on the local disk. Any ideas?
Thanks for any help or suggestions in advance,
Nick
|
|
|
|
|
You need to look at the IE4 Event "BeforeNavigate2". Look at the help for this and then work out how to get the code to work for CHtmlView...
|
|
|
|
|
yep just found it, cheers anyway
Nick
|
|
|
|
|
I have an ATL database program which I *think* I understand how to create a connection point for, but I can't find any examples for creating a sink in MFC from an ATL server. Could someone point me in the direction of a tutorial ? It seems to me too complex to explain in a post, although if you feel you can, I'll appreciate that also. I have a book that shows me how to use a connection point from VB or ATL, but not MFC, and I tried to MFCise the ATL exmaple to no avail.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
|
Fantastic - thank you so much. I've not written a line of useful code tonight, although between what I found to read, and the article you linked me to ( plus the MSDN CD I'll bring home from work tomorrow night !! ), I reckon I'll make up for it tomorrow night
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
1) I'm using CopyFile, which does what I need, but it does not copy the security attributes of the file (owner information particularly). I've rooted around in the documentation, but cannot seem to find how I can set the file security attributes of the copied file to match source file.
2) Also, I'd like to know how to set a file to 'my' owner name when I've copied it to a local machine. (Hopefully Q:1 will answer Q:2)
I'm hoping there is something easy and obvious I've overlooked. If you can point me to the right name I'd appreciate it.
Thanks in advance!
--Mark Terrano
www.ensemblestudios.com
(Creators of the Age of Empires series)
|
|
|
|