|
I'm not sure why you think it ONLY works in doc/view.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I already try some cases, it works well in doc/view case.
I get some source codes from sourceforge.net, it uses ON_COMMAND_EX and is not doc/view case.
it just has CMainFrame and a view derived from CWnd, without doc.
|
|
|
|
|
this snippet below:
redmap::mapi::FoundProperty prop
= m_Message->FindProperty(PropertyID);
-----
will call this snippet:
class Message
{
enum Mode { CLOSED, OPEN };
IMessagePtr m_Message;
AutoMapiPtr<SPropValue> m_PropertyCache;
PropertyMap m_MessageProps;
SRowSet* m_AttachCache;
unsigned long m_AttachCount;
boost::scoped_array<PropertyMap> m_AttachProps;
Mode m_Mode;
public:
.
.
.
.
.
FoundProperty FindProperty(unsigned long PropertyTag)
{
assert(m_Mode == OPEN);
return m_MessageProps.find(PropertyTag);
}
now I am wondering as why m_Mode in the second snippet has no value at all.
Please enlighten me
If any of you requires additional code to expand this just say so.
Thank you,
Jj
-- modified at 4:12 Tuesday 18th September, 2007
|
|
|
|
|
As I read it, the programmer (I'm guessing it's not you) has just put an assert in there. (s)he could just be checking that things he expects to be true are actually true. Maybe unless m_Mode is OPEN, then m_MessageProps would be empty, and he wants to catch the reasons why the find routine would fail.
It's always possible this is a line of fossil code, and m_Mode is no longer necessary. But unless you understand the code, I'd leave it in also.
Iain.
|
|
|
|
|
hi,
I want to send a message on WinSock by calling socket.Send() in a thread.
UINT WorkerThreadForDelay1(LPVOID Param)<br />
{<br />
.<br />
.<br />
CMyView* ptr;<br />
iSent = ptr->m_sConnectSocket1.Send(LPCTSTR(m_strMessage), iLen);<br />
.<br />
.<br />
}
Note that:
1. CMyView is derived from CRecordView.
2. m_sConnectSocket1 is an object of a CAsyncSocket-derived class, declared in CMyView.
How do i initialize ptr here???
|
|
|
|
|
You could pass it as your thread argument. If you look at the documentation of the create thread function that you use, you'll see that it can accept an argument, that will be passed to your thread function through the LPVOID Param.
So, you can simply do that in your thread function:
UINT WorkerThreadForDelay1(LPVOID Param)<br />
{<br />
.<br />
.<br />
CMyView* ptr = (CMyView*)Param;<br />
But be carefull not to use the GUI object directly in your thread.
|
|
|
|
|
hey Cedric,
Thanks man....i tried this out and it works....thanks
I was calling the thread as follows:
.<br />
AfxBeginThread(WorkerThreadForDelay1,NULL,THREAD_PRIORITY_LOWEST,0,0,NULL);<br />
.
Now i changed it to:
CMyView* me;<br />
me=this;<br />
AfxBeginThread(WorkerThreadForDelay1,me,THREAD_PRIORITY_LOWEST,0,0,NULL);
and then ofcourse wat you wrote:
UINT WorkerThreadForDelay1(LPVOID Param)<br />
{<br />
.<br />
CMyView* ptr = (CMyView*)Param;<br />
iSent=ptr->m_sConnectSocket1.Send(.....);<br />
}
|
|
|
|
|
What you can do is to use the LPVOID parameter to hold a pointer to some class.
eg.
HANDLE CMyClass::CreateTheThread ()
{
m_hThread = CreateThread (MyThreadRoutine, ...., this, ...);
return m_hThread;
}
DWORD MyThreadRoutine (LPVOID pParam)
{
CMyClass *pThis = (CMyClass *)pParam;
....
return 0;
}
There are things to be careful of though. You have to ensure that the CMyClass object will last longer than the thread routine. Or at least longer than the thread routine will use it.
And in your routine, you are using CASyncSocket. This class uses asynchronous socket behaviour, and responds to messages from winsock, rather than blocking on them. It does *not* mean that it is thread safe. It *might* be if you only send from one thread, and read on another, but don't assume that. This is why I use pretty raw win32 code in my threads, as MFC is explicitly not thread friendly. I'll use CWnd derived classes for it, but only to get access to the m_hWnd member to post messages back to them.
Iain.
|
|
|
|
|
hey Iain,
Thanks for your support.
I m new to the concept of threads- in fact just 1 day old with threads :p
I found a very simple example yesterday on the net for using threads and used it:
AfxBeginThread(...);<br />
<br />
UINT Thread_name(LPVOID Param)<br />
{}
Now as to why i wanted to use threads is because i was losing quite a number of data strings(Machine->Software) as i wanted to provide a fixed-delay between two data transfer(Software->Machine). So i m using a thread to achieve this delay.
So now for the problem i posted i m now using LPVOID pointer to hold a pointer to my View class.
Thanks and Regards,
yash
P.S:
You would also like to see my reply to Cedric in this same thread
|
|
|
|
|
Hi,
I used VC6 earlier.In which i was able to see the Last error by placing "@err,hr" on the watch window.i.e the value returned by GetLastError() function.
But now im using VC2005, the statement will not evaluate in VC2005 at all..
Is there any methods to get the Last error in watch window of VC2005?
Regards,
Mohammed Asif
|
|
|
|
|
It is still there. You must be missing something very obvious.
Prasad
MS MVP - VC++
|
|
|
|
|
Hi Prasad,
Well i couldn figure it out what im missing to get the value evaluated in VC2005.VC2005 is freshly installled in my system.Is any settings to be done to get the same?
Regards,
Mohammed Asif
|
|
|
|
|
No, setting needs to be done. I hope, you are puting @err,hr in quotes("@err,hr" .
Prasad
MS MVP - VC++
|
|
|
|
|
Hi Prasad,
Yep.Im putting it inside quotes.
In watch window it display "@err,hr" under _Name_ coloumn, "@er,hr" in _Value_ column and wchar_* in _Type_ coloumn.It does not display Last errors value anywhere.
|
|
|
|
|
I want to retrive the Handle of the child window. But facing a problem.Threre are two child window with same name and when I use the Function FindWindowEx() I got the Handle of the First child. And don't know how to get the handle of second child.
It is hierarchy in Spy++ is as below. And I want to retrive the Handle of TExRichEdit
The code I am using Is like this.
HWND hChat= FindWindow(_T("TfrmChat"),0);<br />
hChat = FindWindowEx(hChat,0,_T("TPanel"),0);
- Window 000E03A2 ""TfrmChat
|
- Window 000903D8 ""Tpanel
| |
| -Window 001903D4 ""Tpanel
|
- Window 000803C4 ""Tpanel
|
-Window 001903D4 ""TExRichEdit
|
|
|
|
|
HWND hChat= FindWindow(_T("TfrmChat"),0);
HWND hPanel = FindWindow(_T("TPanel"),0);
hPanel = FindWindowEx(hChat,hPanel,_T("TPanel"),0);
Of course you might want to check that the first TPanel doesnt actually have the TExRichEdit as its child before looking for the second panel.
|
|
|
|
|
|
This should work
HWND hParent = FindWindow(_T("TfrmChat"),0);
HWND hChild = FindWindowEx(hParent,0,_T("TPanel"),0);
hParent = FindWindowEx(hParent,hChild,_T("TPanel"),0);
hChild = FindWindowEx(hParent,0,_T("TExRichEdit"),0);
|
|
|
|
|
|
try FindWindowEx
static CWnd* FindWindowEx(
HWND hwndParent,
HWND hwndChildAfter,
LPCTSTR lpszClass,
LPCTSTR lpszWindow
);
Sreedhar DV
[Real success is having courage to meet failure without being defeated.]
|
|
|
|
|
Hey guys,
I have to make an application in which i have to search on google.com for some search keyword and display the forst three links.
i am new to internet programming, if anybody can help me or suggest me any article i'll be very thankful.
Regards,
Pankaj Sachdeva
"There is no future lies in any job"
"but"
"future lies in the person who holds the job"
|
|
|
|
|
|
I have do the following: (1) create a GraphicsPath; (2) create a second GraphicsPath, (3) create Regions for each path; (4) intersect these two regions getting a Region*.
Now the question: how to construct a GraphicsPath around this intersection region?
|
|
|
|
|
Probally you need a custom class:
you can neme it MyDC , you have to link to it a DC and then specify the rectangle that sets its position.
Then you can create 2 DC ( points 1), 2) and 3) ).
The point 4) require that you prepare a function like
MyDC GetIntersect(MyDC dc1, MYDC dc2){...}
to create the new DC.
This function will extract the rectangle that describes the intersection (if exists), and it has to prepare the contents of the DC. To do this you can work pixel per pixel to get the color of the new pixel according on your intersection logic.
Remember that the function CDC::BitBlt[^] can help you here (look also the Binary Raster Operations[^])
Russell
|
|
|
|
|
i am new to vc++ and i havent worked in active X.. so can anybody help me how to create a gantt chart from vc++
thanks in advance
|
|
|
|