AfxThread question

I have a piece of code:

....
m_data.sThreadType = _T("Client1");
CWinThread* clientThread1 =
AfxBeginThread(ClientThreadFunction,(LPVOID)&m_data);
::Sleep(1);
m_data.sThreadType = _T("Client2");
CWinThread* clientThread2 =
AfxBeginThread(ClientThreadFunction,(LPVOID)&m_data);
....

UINT CDialog_MFC_WorkThread::ClientThreadFunction(LPVOID pParam)
{
	ThreadData* pData = (ThreadData*) pParam;

	CString cs = pData->sThreadType;
	if(cs == _T("Client1"))
		m_CListBox_Client1.AddString(_T("in ClientThreadFunction()"));
	else if(cs == _T("Client2"))
		m_CListBox_Client2.AddString(_T("in ClientThreadFunction()"));
	return 0;
}

it runs OK.

BUT, If I comment out the Sleep(1), I set break point at:
                m_CListBox_Client1.AddString(_T("in
ClientThreadFunction()"));
It never breaks. Why?

0
yqin_99 (193)
4/28/2006 6:46:07 PM
vc.mfc 33608 articles. 0 followers. Follow

9 Replies
821 Views

Similar Articles

[PageSpeed] 59

kathy wrote:

> I have a piece of code:
> 
> ...
> m_data.sThreadType = _T("Client1");
> CWinThread* clientThread1 =
> AfxBeginThread(ClientThreadFunction,(LPVOID)&m_data);
> ::Sleep(1);
> m_data.sThreadType = _T("Client2");
> CWinThread* clientThread2 =
> AfxBeginThread(ClientThreadFunction,(LPVOID)&m_data);
> ...
> 
> UINT CDialog_MFC_WorkThread::ClientThreadFunction(LPVOID pParam)
> {
> 	ThreadData* pData = (ThreadData*) pParam;
> 
> 	CString cs = pData->sThreadType;
> 	if(cs == _T("Client1"))
> 		m_CListBox_Client1.AddString(_T("in ClientThreadFunction()"));
> 	else if(cs == _T("Client2"))
> 		m_CListBox_Client2.AddString(_T("in ClientThreadFunction()"));
> 	return 0;
> }
> 
> it runs OK.
> 
> BUT, If I comment out the Sleep(1), I set break point at:
>                 m_CListBox_Client1.AddString(_T("in
> ClientThreadFunction()"));
> It never breaks. Why?
> 

kathy:

I'm not quite sure of the answer to your specific question, but you are 
manipulating controls in the main thread from the worker thread. This is 
a no-no.

Use a custom message to your CDialog_MFC_WorkThreadand with 
PostMessage() or SendMessage() to change the thread context, and have 
the dialog update the controls in the main thread.

David Wilkinson

0
no-reply8010 (1791)
4/28/2006 7:00:52 PM
It can't not get called at all. When you put the sleep call between the two
AfxBeginThread calls you are letting the first thread run a little, so it
will get called right at the sleep function call.  But when you remove it,
it won't run until the function that is calling AfxBeginThread exits. But it
will run.

By the way where is m_CListBox_Client1 coming from (since your
ClientThreadFunction must be static)?

AliR.

"kathy" <yqin_99@yahoo.com> wrote in message
news:1146249967.382180.310820@i40g2000cwc.googlegroups.com...
> I have a piece of code:
>
> ...
> m_data.sThreadType = _T("Client1");
> CWinThread* clientThread1 =
> AfxBeginThread(ClientThreadFunction,(LPVOID)&m_data);
> ::Sleep(1);
> m_data.sThreadType = _T("Client2");
> CWinThread* clientThread2 =
> AfxBeginThread(ClientThreadFunction,(LPVOID)&m_data);
> ...
>
> UINT CDialog_MFC_WorkThread::ClientThreadFunction(LPVOID pParam)
> {
> ThreadData* pData = (ThreadData*) pParam;
>
> CString cs = pData->sThreadType;
> if(cs == _T("Client1"))
> m_CListBox_Client1.AddString(_T("in ClientThreadFunction()"));
> else if(cs == _T("Client2"))
> m_CListBox_Client2.AddString(_T("in ClientThreadFunction()"));
> return 0;
> }
>
> it runs OK.
>
> BUT, If I comment out the Sleep(1), I set break point at:
>                 m_CListBox_Client1.AddString(_T("in
> ClientThreadFunction()"));
> It never breaks. Why?
>


0
AliR3470 (3236)
4/28/2006 7:09:44 PM
You mean use the PostMessage() or SendMessage() in work thread? GUI
thread can send/receive the message. Can work thread send/receive
message?

0
yqin_99 (193)
4/28/2006 7:17:49 PM
kathy wrote:

> You mean use the PostMessage() or SendMessage() in work thread? GUI
> thread can send/receive the message. Can work thread send/receive
> message?
> 

kathy:

All the windows should be in the main (GUI) thread. The worker thread 
can send or post messages to any window in the main thread. Worker 
threads cannot receive messages because they have no message pump.

David Wilkinson
0
no-reply8010 (1791)
4/28/2006 7:59:53 PM
kathy wrote:
> I have a piece of code:
> 
> ...
> m_data.sThreadType = _T("Client1");
> CWinThread* clientThread1 =
> AfxBeginThread(ClientThreadFunction,(LPVOID)&m_data);
> ::Sleep(1);
> m_data.sThreadType = _T("Client2");
> CWinThread* clientThread2 =
> AfxBeginThread(ClientThreadFunction,(LPVOID)&m_data);
> ...
> 
> UINT CDialog_MFC_WorkThread::ClientThreadFunction(LPVOID pParam)
> {
> 	ThreadData* pData = (ThreadData*) pParam;
> 
> 	CString cs = pData->sThreadType;
> 	if(cs == _T("Client1"))
> 		m_CListBox_Client1.AddString(_T("in ClientThreadFunction()"));
> 	else if(cs == _T("Client2"))
> 		m_CListBox_Client2.AddString(_T("in ClientThreadFunction()"));
> 	return 0;
> }
> 
> it runs OK.

If it runs OK that is due to sheer luck.  The time at which each thread 
looks at the string is not predictable or even repeatable.  For example, 
thread 1 might see the "Client1" or the "Client2" string or, even worse, 
it might look at the string while it is being changed.  You must use 
synchronization to access data that could be changed by one thread while 
another thread is reading it.  Even better, create a different 
ThreadData object for each thread and do not change it while the thread 
is running.

Then you need to learn about the MFC limitations on accessing windows 
from a thread that did not create them.  Basically, don't do that. You 
can start here: http://www.flounder.com/workerthreads.htm

-- 
Scott McPhillips [VC++ MVP]

0
Scott
4/28/2006 9:40:29 PM
Nice catch Scott, I didn't even realize the same structure was being passed
to both thread. :-x

AliR.

"Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp> wrote in message
news:%233q2MxwaGHA.4788@TK2MSFTNGP02.phx.gbl...
> kathy wrote:
> > I have a piece of code:
> >
> > ...
> > m_data.sThreadType = _T("Client1");
> > CWinThread* clientThread1 =
> > AfxBeginThread(ClientThreadFunction,(LPVOID)&m_data);
> > ::Sleep(1);
> > m_data.sThreadType = _T("Client2");
> > CWinThread* clientThread2 =
> > AfxBeginThread(ClientThreadFunction,(LPVOID)&m_data);
> > ...
> >
> > UINT CDialog_MFC_WorkThread::ClientThreadFunction(LPVOID pParam)
> > {
> > ThreadData* pData = (ThreadData*) pParam;
> >
> > CString cs = pData->sThreadType;
> > if(cs == _T("Client1"))
> > m_CListBox_Client1.AddString(_T("in ClientThreadFunction()"));
> > else if(cs == _T("Client2"))
> > m_CListBox_Client2.AddString(_T("in ClientThreadFunction()"));
> > return 0;
> > }
> >
> > it runs OK.
>
> If it runs OK that is due to sheer luck.  The time at which each thread
> looks at the string is not predictable or even repeatable.  For example,
> thread 1 might see the "Client1" or the "Client2" string or, even worse,
> it might look at the string while it is being changed.  You must use
> synchronization to access data that could be changed by one thread while
> another thread is reading it.  Even better, create a different
> ThreadData object for each thread and do not change it while the thread
> is running.
>
> Then you need to learn about the MFC limitations on accessing windows
> from a thread that did not create them.  Basically, don't do that. You
> can start here: http://www.flounder.com/workerthreads.htm
>
> -- 
> Scott McPhillips [VC++ MVP]
>


0
AliR3470 (3236)
4/28/2006 9:55:47 PM
"kathy" <yqin_99@yahoo.com> wrote in message
news:1146249967.382180.310820@i40g2000cwc.googlegroups.com...
> I have a piece of code:
>
> ...
> m_data.sThreadType = _T("Client1");
> CWinThread* clientThread1 =
> AfxBeginThread(ClientThreadFunction,(LPVOID)&m_data);
> ::Sleep(1);
> m_data.sThreadType = _T("Client2");
> CWinThread* clientThread2 =
> AfxBeginThread(ClientThreadFunction,(LPVOID)&m_data);
> ...
>
> UINT CDialog_MFC_WorkThread::ClientThreadFunction(LPVOID pParam)
> {
> ThreadData* pData = (ThreadData*) pParam;
>
> CString cs = pData->sThreadType;
> if(cs == _T("Client1"))
> m_CListBox_Client1.AddString(_T("in ClientThreadFunction()"));
> else if(cs == _T("Client2"))
> m_CListBox_Client2.AddString(_T("in ClientThreadFunction()"));
> return 0;
> }
>
> it runs OK.
>
> BUT, If I comment out the Sleep(1), I set break point at:
>                 m_CListBox_Client1.AddString(_T("in
> ClientThreadFunction()"));
> It never breaks. Why?
>

You're lucky that it "runs OK".  The call to Sleep(1) will cause the GUI
thread to relinquish its thread-slice, but there's no guarantee that Thread1
will be scheduled before the GUI thread gets another time-slice, overwrites
the contents of m_data, and starts up Thread2.

Create "new'd" ThreadData structures on the heap, one for each thread, and
let the thread be responsible for "delete'ing" them:

ThreadData* pTD = new ThreadData;
pTD->sThreadType = _T("Client1");
CWinThread* clientThread1 =
AfxBeginThread(ClientThreadFunction,(LPVOID)pTD);
/// sleep not required ::Sleep(1);
pTD=new ThreadData;
pTD->sThreadType = _T("Client2");
CWinThread* clientThread2 =
AfxBeginThread(ClientThreadFunction,(LPVOID)pTD);  // pass-by-value will
ensure that thread1 will not get an incorrect value of pTD
....

UINT CDialog_MFC_WorkThread::ClientThreadFunction(LPVOID pParam)
{
ThreadData* pData = (ThreadData*) pParam;

// ... use pData the way you want, but DON'T TOUCH THE GUI OF THE MAIN
THREAD

delete pData;
}


Mike


0
4/29/2006 1:39:49 AM
See below...
On 28 Apr 2006 11:46:07 -0700, "kathy" <yqin_99@yahoo.com> wrote:

>I have a piece of code:
>
>...
>m_data.sThreadType = _T("Client1");
>CWinThread* clientThread1 =
>AfxBeginThread(ClientThreadFunction,(LPVOID)&m_data);
>::Sleep(1);
*****
Whoops!  Serious design error here.  Why a Sleep()?  If you think this is required, then
you need to rethink your design.  You can assume that this is either (a) erroneous now or
(b) will be erroneous in the future.  If your program doesn't work without this, your
design is wrong.
****
>m_data.sThreadType = _T("Client2");
>CWinThread* clientThread2 =
>AfxBeginThread(ClientThreadFunction,(LPVOID)&m_data);
>...
>
>UINT CDialog_MFC_WorkThread::ClientThreadFunction(LPVOID pParam)
>{
>	ThreadData* pData = (ThreadData*) pParam;
****
Serious, serious problem here!  You are passing the same address into both threads!  This
is nonsensical!!!!!  There is ABSOLUTELY NO GUARANTEE of what each thread will see!!! This
code is irredeemably flawed, and must be rewritten.  The only correct approach here is to
do
	ThreadData * data = new ThreadData;
	data->sThreadType = _T("Client1");
	AfxBeginThread(ClientThreadFunction, data);
You must not under any circumstances imaginable pretend you have a clue that it is
possible to reuse the one-and-only parameter block until you are absolutely certain the
thread has finished with it.  This requires a great deal more effort than is possible to
expend, and is usually merely a slightly better poor design.  But the current code cannot
be used.  You MUST allocate a new object on the heap!
*****
>
>	CString cs = pData->sThreadType;
>	if(cs == _T("Client1"))
>		m_CListBox_Client1.AddString(_T("in ClientThreadFunction()"));
>	else if(cs == _T("Client2"))
>		m_CListBox_Client2.AddString(_T("in ClientThreadFunction()"));
*****
This is remarkably poor code.  First, why is it that you are comparing against one kind of
string to put out a message using different text?  But the complete disaster is that you
are doing AddString in a thread; you must NOT manipulate any control owned by one thread
from another thread.  You have violated a really, really fundamental design rule here, and
you must therefore change this whole design.  The only way you can add things to a listbox
is to use a PostMessage to the main GUI thread and let it do the update.   See my essay on
worker threads on my MVP Tips site.
****
>	return 0;
>}
>
>it runs OK.
>
>BUT, If I comment out the Sleep(1), I set break point at:
>                m_CListBox_Client1.AddString(_T("in
>ClientThreadFunction()"));
>It never breaks. Why?
******
It doesn't matter.  If you comment it out, and something doesn't work that used to work,
then your whole design is irremediably flawed and must be redone.  Since you do not say
anything else here about what is happening after you create the threads, there isn't even
a way to guess why the breakpoint isn't being taken.  There are far too many fundamental
errors here to even worry about what is going on until all of them have been fixed.
					joe
****
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
-- 
NewsGuy.Com 30Gb $9.95 Carry Forward and On Demand Bandwidth
0
newcomer (15975)
5/1/2006 11:27:22 PM
SendMessage is still a Realy Bad Idea and should be avoided.  Use only PostMessage.
				joe
On Fri, 28 Apr 2006 15:59:53 -0400, David Wilkinson <no-reply@effisols.com> wrote:

>kathy wrote:
>
>> You mean use the PostMessage() or SendMessage() in work thread? GUI
>> thread can send/receive the message. Can work thread send/receive
>> message?
>> 
>
>kathy:
>
>All the windows should be in the main (GUI) thread. The worker thread 
>can send or post messages to any window in the main thread. Worker 
>threads cannot receive messages because they have no message pump.
>
>David Wilkinson
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
-- 
NewsGuy.Com 30Gb $9.95 Carry Forward and On Demand Bandwidth
0
newcomer (15975)
5/1/2006 11:28:18 PM
Reply:

Similar Artilces:

Questions about rebuilding a db 03-28-10
Lateley I've notices my database freezing from time to time, so I tried the following... a) created a new data base b) imported all tables, queries, forms, ...... ,modules c) reset the References d) reset the Startup options e) compile Everything is working great now, but I have a few questions about this process. Did I miss any crucial steps? (don't want any surprises later) Is there a prefered order to do these steps? Finally, the database is now about 30% smaller, even though I was regularly compiling, compacting/repairing the former one. I'd like to know w...

microsoft publisher question
Is there any way to retrieve a document that wasn't saved? Doubtful. You might get lucky and Publisher created a temp file. In Windows Explorer, type %temp% in the address bar. Find any file that has a pub prefix. Change the .tmp to .pub and try opening it. -- Mary Sauer http://msauer.mvps.org/ "llcoby" <llcoby@discussions.microsoft.com> wrote in message news:F76C488D-E9CB-469C-AE5C-BC720692437A@microsoft.com... > Is there any way to retrieve a document that wasn't saved? ...

Installation of CRM on SBS 2003 Question
When installing CRM 3.0 on Microsoft SBS 2003 will installing into the default web site cause any problems with any thing else running from there such as Outook Web access, sharepoint, etc? Is it better to create a "new web site" when installing? Thanks, John Lammey You should create a new website. -- Matt Wittemann http://icu-mscrm.blogspot.com "John Lammey" wrote: > When installing CRM 3.0 on Microsoft SBS 2003 will installing into the > default web site cause any problems with any thing else running from there > such as Outook Web access, sharepoint,...

Excel question reposted
Hi I am reposting this problem with more detail in the hope that there is a workaround to this. Initially what I did was created a spreadsheet and then pasted 'screenshots' into the spreadsheet with comments bedside. I then shared the workbook, as I require other people's comments. Once they have entered their comments in the spreadsheet, I will then move the pasted screenshots and all comments to another 'Sheet'. The problem is that now that the spreadsheet is shared, I cant move the pictures. Thanks again Julia It's true that there are significant restricti...

Outlook 2010 question
I want to delete my existing pst folders and start over with a pst that I have saved to a safe location. How do I do that? You delete the present pst and put the pst files that you have backed up manually back in the same place from where you deleted the present pst -- Peter Please Reply to Newsgroup for the benefit of others Requests for assistance by email can not and will not be acknowledged. This posting is provided "AS IS" with no warranties, and confers no rights. http://www.microsoft.com/protect "RichCo" <richcolo@gmail.com> wrote in message news:4cd59...

Physical inventory question #3
I have a customer that is looking at an inventory last month and in the Summary box it shows what quantities and values were expected, however, when I click Print and export the data to CSV, the expected totals do not match what is in the summary box. Any ideas? Is there a way to subtotal the Active report when printed to screen? Thanks in advance. Phil Try the 2nd icon "select columns to group" on the top of the report. You can subtotal them by what column you choose to group them by. "Phil V" wrote: > I have a customer that is looking at an inventory last...

Exchange 5.5 IMC question
Hi, anyone know how to stop an Exchange 5.5 IMC from recieving but still allow it to send?? Cheers John On the Connections tab, set the Transfer Mode to Outbound Only. Restart the IMS. -- Denis McDowell [MSFT] "John" <John@4sol.com> wrote in message news:OnQV9krLEHA.2612@TK2MSFTNGP10.phx.gbl... > Hi, > > anyone know how to stop an Exchange 5.5 IMC from recieving but still allow > it to send?? > > Cheers > > John > > Great tip!! This is the answer to my problem (see the "Can I run NAV on received e-mails?"). I need to install NA...

User Form Security Question
Hi, I'm creating a form, which onces completed transfers the data over to the spreadsheet. But the guys in work don't really pay much attention to what they have entered , so i was wondering is there any way to make the user double check every entry? I was thinking, once the user clicks ok, a msgbox would appear giving the user the value they entered, click ok if correct or cancel to amend. Is there a easy way to do this? Cheers. -- harpscardiff ------------------------------------------------------------------------ harpscardiff's Profile: http://www.excelforum.com/mem...

Checkbox customization question
How can I implement checkbox in MSCRM ? I have a contacts with multiple professions. From a list of available professions as checkboxes, the user should be able to check all the applicable professions. Any ideas. Try Powertrak Core from www.axonom.com "Arch" <discussion11@yahoo.com> wrote in message news:b87a74db.0405210819.3232b5d8@posting.google.com... > How can I implement checkbox in MSCRM ? I have a contacts with > multiple professions. From a list of available professions as > checkboxes, the user should be able to check all the applicable > professions. Any...

address database question
I am setting up an address database in Excel 2003 that I need to be able to use to make labels for mailings. I have people that are in different "categories" and will want to group them by that category, depending on who I am sending the mailing to. For instance, I have a person, Person A, who is a general supporter, lives in the area, and sponsors a child. Person A is in three of the possible 5 categories. Another person, Person B, might be simply a general supporter (i.e., in one category). How can I best organize the data - and the headings - so that I can make labels ...

overtime charging question
A B C date hours worked 9 name hours offered 10 hours charged 3 Hi I have a sheet set up this way and want to chart overtime. Anything over 8 hours is time and a half, Saturday's are time and a half all day and Sunday is double charge.How can i set this up so it recognizes the date and charges correctly on the weekends. Will Excel recognize the date as weekend? The example above shows someone working 9 but offered 10 so charged 1 1/2 x 2 or 3 hours charged. Thanks Karl Karl Chip Pearson has a good sit...

eConnect question #3
When integrating inventory items via eConnect, is it possible to assign the item to all existing sites? Tony: Yes you can do that - by building your own code in the taUpdateCreateItemRcdPost procedure - I added the following code and now when I pass one item all of the sites of I have set up are now inserted into the IV00102 table. I just did a quick test and it seemed to work out fine. Here is the simple code you would add to the post procedure. I hope this is what you are looking for - I built this on 9.x (hopefully it pastes in here okay). Code to insert: insert into IV00102 (I...

Security Model Design Question
Poke a Hole in this Security Model! I think I have a pretty good security design, but wanted a second opinion :). The following Security model works – however, I have to lock the user out of Excel downloads and Mail merges so that the user can’t download the company’s entire contact list. Am I overlooking something that would allow users to own individual Accounts and Contact, yet preclude others from seeing opportunities attached to contacts they own? Background Assumptions 1 – Some sales reps are organized Geographically – others are organized Functionally (by industry). 2 – Sales...

Shared Borders Question....
Can 'Shared Borders' be .asp rather than .htm? There is a particular script I will like to run, but it can not be .htm. Thanks David No. -- Tom [Pepper] Willett Microsoft MVP - FrontPage Since 1997 --------------------------- "116" <116@discussions.microsoft.com> wrote in message news:52CEB706-E273-461F-9DD9-483EBA3C1F57@microsoft.com... : Can 'Shared Borders' be .asp rather than .htm? There is a particular script : I will like to run, but it can not be .htm. : : Thanks : David The shared border files must be .htm - left.htm, righ...

listview insert question
I am really having a time determining what is wrong with the inserting from a dropdownlist inside a listview. Everything else is working regarding the listview, except the insert. But, there must partially working as there is a new row added to the table, just not with information. When I add SelectedValue='<%# Bind("ApplicationItemID") %>' to the droplist I get an error. The error is as follows; "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control." I have an insertcommand a...

"newbie" question using exchange
we have a new install of exchange using sbs 2003. What we would like to do is setup mail folders for three different user accounts that are accessable by all users. I would like for mail that is sent to these accounts (eg: orders@companyname.com) to be sent to the appropriate "public" folder. Could someone give me some direction on setting this up? Any alternate suggestions would be appreciated. Here is a link that explains how to do what you are looking for: http://www.msexchange.org/articles/MF021.html The link relates to Exchange 2000 but the steps are the same. -- Mark Fuga...

Setup new acct question...
I am trying to add a new bank account in 2004. When it comes to assigning a FI I am only given the choice, in a drop down list, of the accts that have previously been set up. How do I manage to get a new bank name assigned? tia In microsoft.public.money, John h wrote: >I am trying to add a new bank account in 2004. When it comes to assigning a >FI I am only given the choice, in a drop down list, of the accts that have >previously been set up. How do I manage to get a new bank name assigned? AccountList->SetUpAccounts->AddANewAccount and type the name of the bank int...

A question about CCommandLineInfo
I want to write an application that if it is given no command line arguments, it will run in a GUI mode. However, if the user passes any command line arguments, it means that he wishes to execute the program in a "automatic" mode, therefore I want it to in this case run and eject information to the console. I want it to be a single application to help reduce redant code. - Christopher Dannemiller. This is a common question. I've never seen a good answer for it, mostly because I think the idea basically is a Bad Idea anyway. joe On 3 Jun 2005 15:54:00 -0700, chris.dannemil...

DISP_FUNCTION_ID and ON_EVENT question
Hi, When I used: AfxConnectionAdvise (pSrcUnk, __uuidof (ISomeInterfaceEvents), GetIDispatch(TRUE), TRUE, &m_cookie); in a CCmdTarget derived class. I expected that I will be able to use ON_EVENT but it didn't work but DISP_FUNCTION_ID. Can any one explain this and what is the difference between DISP_FUNCTION_ID and ON_EVENT Thanks in advance ...

Question on MDI Apps #2
I am creating an MDI app that will have a variety of dialog boxes that will be displayed from clicking on Menu items. ex. Customers, Vendors, Inventory etc. I want to have the ability to have a single copy of each of these open at the same time. ex. both the customer and inventory dialog box open at the same time in the app. I also want to have them both listed in the Window menu. Should I use a Modeless Dialog Box or should I use a FormView? If you say a FormView, I know how to display a dialog box from a menu click but how do you display a formview based on a menu click? Also if you say...

Capability questions
We are currently evaluating MSCRM and are wondering if it is possible to do a couple of things. 1) Mailmerge/emailmerge related party information. ie if we have a referral relationship can I send an email like... Hi {Lead:firstname}, you were referred to use by {referal:firstname} 2) Can you have relationship roles for a lead? 3) Can I run a workflow rule on a closed opportunity? I want to schedule a task based on a maturity date stored in the opportunity entity 4) Can I use attributes from a custom entity in an email or word merge? Can I create custom placehol...

Database design question
Just curious about any drawbacks to this type of database design. There is an organization table that has many types of organizations and structures dealing with organizations in it such as: Company, Region, Market, etc There is another table that is the linking table for all the organizations. The type of relationship you are looking at is by a RecordTypeID. So in essence, it is like having 6 diffent tables in one table with about 12+ different mapping tables in another table. So your queries would look something like: SELECT * FROM Organization Company JOIN Organ...

CString question #6
I am porting a project from VC6 to VC8, and had a problem regarding to CString, the code snippet is as following: CString str1; str1 =3D str2 (str2 is a CString returned from a stored procedure) in debug window, str2 is "N", but str1 is ""N=FD=FD=FD=FD=AB=AB=AB=AB=AB=AB= =AB=AB=FE=EE=FE" After I changed to str.Format("%s", str2), str is changed to "N" I am confused why str1=3Dstr2 doesn't work, could anyone please explain? Thanks I'm not aware of any changes that would cause that. When you are at the line str1 = str2, put this into t...

SetActiveView question
Got a problem with program control of the active view. I've got a magnify input in the main frame which only applies to one of the 4 views on the screen. So I have to make sure that it is active before I apply the magnification. Seemed reasonably straight forward, I store the view pointer, pview, when it is created at startup, in my root program and then when the user types in the magnification box, get the pview , do a SetActiveView(pview) and then call the pview->DoMagnify() routine I wrote. Things don't behave the way I expected. 1) none of the values I set in the view creation ...

Outlook Connector question
I'm using this with Outlook 2007; is there any way to get new messages to show up in Unread Mail instead of just in the email address's Inbox? Thanks, John No, not with the other unreads in your mailbox. You can have a search folder for the msn inbox though. -- Diane Poremsky [MVP - Outlook] Author, Teach Yourself Outlook 2003 in 24 Hours Need Help with Common Tasks? http://www.outlook-tips.net/beginner/ Outlook 2007: http://www.slipstick.com/outlook/ol2007/ Outlook Tips by email: dailytips-subscribe-request@lists.outlooktips.net Outlook Tips: http://www.outlook-tips.net/ Out...