Can Work thread get a windows class and manipulate it?

Suppose that I create a work thread when my dialog box started, then in the
thread I get the pointer to the dialog mfc class and call updateData method.
Does that work? I tried, but failed.

Is there any other way to do? thanks!!


0
7/26/2004 2:11:27 AM
vc.mfc 33608 articles. 0 followers. Follow

4 Replies
585 Views

Similar Articles

[PageSpeed] 49

No, it won't work, don't even waste time trying. It is almost guaranteed to fail. You do
not manipulate the windows owned by one thread from a different thread. What you do is
PostMessage requests from the worker thread to the main UI thread, usually to the window
that contains the controls. 

The fact that you are using UpdateData already says you are in trouble; this should not be
used in situations like this. If you want to set the text of a window, use SetWindowText,
for exmple. 

See my essays on worker threads and avoiding UPdateData, on my MVP Tips site.
					joe

On Mon, 26 Jul 2004 10:11:27 +0800, "kimi" <daniel2oversea@hotmail.com> wrote:

>Suppose that I create a work thread when my dialog box started, then in the
>thread I get the pointer to the dialog mfc class and call updateData method.
>Does that work? I tried, but failed.
>
>Is there any other way to do? thanks!!
>

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
7/26/2004 2:19:49 AM
kimi wrote:
> Suppose that I create a work thread when my dialog box started, then in the
> thread I get the pointer to the dialog mfc class and call updateData method.
> Does that work? I tried, but failed.
> 
> Is there any other way to do? thanks!!
> 
> 

No, MFC does not permit that.  Use PostMessage from the work thread to 
signal the GUI thread.  Then update the window in the GUI thread message 
handler.  See:

http://www.mvps.org/vcfaq/mfc/index.htm

-- 
Scott McPhillips [VC++ MVP]

0
Scott
7/26/2004 3:35:47 AM
yes thet are all right, but still if you insist, you call setwindowtext(...) 
for edit box, setcurSel(..) for combo box , (identify all such functions for 
all the controls you use) ... and so on . Put all these function call in a 
function ff(). Call ff() from another thread . Be sure you either pass the 
ids or the HWNDS also.

"Scott McPhillips [MVP]" wrote:

> kimi wrote:
> > Suppose that I create a work thread when my dialog box started, then in the
> > thread I get the pointer to the dialog mfc class and call updateData method.
> > Does that work? I tried, but failed.
> > 
> > Is there any other way to do? thanks!!
> > 
> > 
> 
> No, MFC does not permit that.  Use PostMessage from the work thread to 
> signal the GUI thread.  Then update the window in the GUI thread message 
> handler.  See:
> 
> http://www.mvps.org/vcfaq/mfc/index.htm
> 
> -- 
> Scott McPhillips [VC++ MVP]
> 
> 
0
DrSai (3)
9/2/2004 10:25:02 AM
Dr.Sai wrote:
> yes thet are all right, but still if you insist, you call setwindowtext(...) 
> for edit box, setcurSel(..) for combo box , (identify all such functions for 
> all the controls you use) ... and so on . Put all these function call in a 
> function ff(). Call ff() from another thread . Be sure you either pass the 
> ids or the HWNDS also.

This approach can work but is usually undesirable.  When a thread calls 
SetWindowText and other control functions for a control in the GUI 
thread the calling thread is suspended until the message has been 
processed by the GUI thread.  This slows down the worker thread 
unnecessarily.  And it can cause a deadlock if the GUI thread is 
suspended, such as waiting for the worker thread to exit.

-- 
Scott McPhillips [VC++ MVP]

0
Scott
9/2/2004 1:09:25 PM
Reply:

Similar Artilces:

Can we use WINCE 6.0 R2 or R3 to build Windows Phone OS Image??
Hi, Can we use WINCE 6.0 R2 or R3 platform builder to build Windows Phone OS Image?? If yes Which option I need to select while building the OS Image?? Since the Windows Phone 7 core is Windoes CE 6.0.I am curious to know whether Windows Phone 7 OS Image can be built using Platform builder. TIA, Nithin On 29 June, 10:29, Nithin <nithin.papd...@gmail.com> wrote: > Hi, > > Can we use WINCE 6.0 R2 or R3 platform builder to build Windows Phone > OS Image?? > > If yes Which option I need to select while building the OS Image?? > > Since the Win...

get paid now!!!
when you subscribe you'll be rewarded 10$$$ Check it now,don't wait!!!!!!! http://e-mailpaysu.com/members/index.cgi?andrusko ...

"#"##, or "#"@
Oh boy, iif there's a problem, it might take years but eventually, I find it! <g> I ran into the problem on Friday where I had a custom cell format that, for once, didn't always work because this sheet has number + letter combinations. "#"## results in: #1 #2 #3 1a 2a 3a, 3b Where "#"@ gives me: 1 2 3 #1a #2a #3a, 3b Is there any way to get it consistently, like so: #1 #2 #3 #1a #2a #3a, 3b with the user just entering the number or number + letter alone? Thank you! :oD I'm assuming you don't have negative values (if you do, show us where you ...

Junk Mail Filter
Environment: WinXP, Outlook 2003, both SP2/fully patched. Symptom: Some messages are incorrectly identified as Junk, even after both the Sender and the Sender's Domain have been added to the Safe Sender's list. This is verified by reviewing the Safe Senders list. The entries are not on the Blocked Senders list. One is an English language message from Germany. The ..DE domain is permitted, and confirmed on the International tab of Junk E-mail options. The protection level option is set to, Low. One of the messages is a Microsoft newsletter... Questions: 1. Why? 2. What...

i can change the font on the screen to be large but can't print t.
i am trying to make the print on my spreadsheet larger. i can change the font on the screen but it still prints the smaller font?????help!!!!!!!!!!!!!! Hi Maybe in the Page Setup you have this setting "fit to1 by 1 page" -- Regards Ron de Bruin http://www.rondebruin.nl "tj" <tj@discussions.microsoft.com> wrote in message news:244325C6-A407-4CD8-BE76-75AB3C93A78A@microsoft.com... >i am trying to make the print on my spreadsheet larger. i can change the > font on the screen but it still prints the smaller font?????help!!!!!!!!!!!!!! ...

can I add a link in Publisher to display, "join our email list"?
I am creating a fairly simply website and need to add a button for visitors to join our email list. Is this possible in Publisher? Please post your question in the web group and we will try to help you there: news://msnews.microsoft.com/microsoft.public.publisher.webdesign or http://www.microsoft.com/office/community/en-us/default.mspx?dg=microsoft.public.publisher.webdesign&lang=en&cr=US Always include the version of Publisher you are using, the URL of your site and as much detail as possible. DavidF "mfreecox" <mfreecox@discussions.microsoft.com> wr...

Can't connect with MSN Messenger on Mac OS X
I have a G5 with the latest version of OS X. I installed Office for OSX and every app works fine. Machine is connected to the Internet and browsing and email are flawless. When I run Messenger and try to sign in it immediately returns with an error saying that it can't connet since either MSN service is down or machine is not connected to the Internet. I checked my Passport login and it works perfectly from the MSN site. Any idea about what's going on? Thanks, -Vlad Vlad Vinogradsky <vvinogra@speakeasy.net> wrote: Hi Vlad, > I have a G5 with the latest version ...

tile window
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) does anyone know how to tile microsoft word windows vertically on an osx The closest you will come is Word>Window>Arrange All. Then fiddle them manually. Otherwise, you need an AppleScript: http://www.macosxhints.com/comment.php?mode=view&cid=96187 Or a utility: http://www.apple.com/downloads/macosx/system_disk_utilities/windowtiles.html Cheers On 23/05/10 10:15 AM, in article 59bb8dd9.-1@webcrossing.JaKIaxP2ac0, "aprilgsims@officeformac.com" <aprilgsims@officeformac.com> wrote: &...

how can I move the e-mail accounts from outlook 2002 to an other computer
how can I move the e-mail accunts from outlook 2002 to an other computer same program?? ...

FRx 6.7 vs 32-bit Windows 7
I'm getting the following error when trying to generate a report but only on the Windows 7 32-bit system. Running SQL Server 2005 on another server, Dynamics GP 9 client is installed on this machine. Component Error FRx is unable to process this output request for the following reason: C:\Windows\system32\msxml.dll could not be found. Generating a DrillDown Viewer or XML output file requires the following: -Microsoft Internet Explorer 6.0 or later -MSXML 4.0 SP1 or later It may be necessary to install (or reinstall) the component or components listed above. ** any suggestions or re...

can comment indicator color be changed?
Hi when you put a comment in a cell the indicator is red but I have cells that are conditionally formatted to come up red if out of spec and can't see the indicator. Can the color be changed and if so how please. Thanks Karl AFAIK, no, you can't change this. Maybe you can change your CF color. Bright yellow? On Wed, 27 Oct 2004 16:27:02 -0700, "Karl" <Karl@discussions.microsoft.com> wrote: >Hi when you put a comment in a cell the indicator is red but I have cells >that are conditionally formatted to come up red if out of spec and can't see >the indic...

how do i get font style back on toolbar?
new to this...when i started my document the font style was displayed on toolbar...now it is not...what do i do and thanks to those who help!!!!!!1 Melissa, try view, toolbars, and check formatting -- Paul B Always backup your data before trying something new Please post any response to the newsgroups so others can benefit from it Feedback on answers is always appreciated! Using Excel 2002 & 2003 "melissa" <melissa@discussions.microsoft.com> wrote in message news:852099EC-03A0-4B0F-91AD-0B9F61CF8C4B@microsoft.com... > new to this...when i started my document the fon...

Get Mallika Sherawath Bathing Videos in all Angles
Get Mallika Sherawath Bathing Videos At http://blogcreationandhosting.blogspot.com/2009/11/1-per-click-in-adsense-programs.html < Due to some issues,I have hidden these videos inside an image.In that website , click on the big vertical Image on right side of website & get the videos, Enjoy it > ...

Can I get my Dialog's background color already? :) Just can't figure it out
I'm trying to get the background color for the basic Dialog created using the Wizard GetSysColor(COLOR_WINDOW) isn't working (returns some other color) GetBkColor() for the DC isn't working (returns white) Where can I trap that? The dc->GetBkColor in OnPaint returns a white color I finally did GetSysColor(COLOR_3DFACE) because I noticed they are the same, but that's not really what I want Thank you. "Yasoo" <anonymous@discussions.microsoft.com> wrote in message news:D9FF1E6B-C815-41B0-92FA-846EDC82FBAE@microsoft.com... > I'm trying to get the ba...

can't send Entourage mail
5/4 List members: Today when I tried to send several messages using Entourage I received the error message "This message does not conform to RFC2822 Standard". The messages are still sitting in the Outgoing box. This has never happened to me before. I'd appreciate any insights into why this might be happening. I've verified the Microsoft Office 2004 database - no change. I'm working on a MacPro Intel Mac. Thank you in advance for any help. Sincerely, Mark Pavlick Hi Mark: It means the system does not like the Header of the message. Chances are, ...

How can I go to a specific page number in a large document
How do I go to a specific page number in a large word document. Read the replies to your earlier identical post -- <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org <>>< ><<> ><<> <>>< ><<> <>>< <>><<> "yisaajao" <yisaajao@discussions.microsoft.com> wrote in message news:CFC4289D-FC93-4C1B-951B-DB08CED833...

can't associate .pps with email attachment vista
-- marianne dagher You need to make the explanation / question a little clearer and please don't just use the subject area, the big message area just down a bit is easier to read!. "mariane" <mariane@discussions.microsoft.com> wrote in message news:AB4464FA-51BA-473C-9E5A-9013262D9EC0@microsoft.com... > > -- > marianne dagher > > __________ Information from ESET Smart Security, version of virus > signature database 4849 (20100208) __________ > > The message was checked by ESET Smart Security. > > http://www.eset.com ...

How can I convert my Archive Folder from its OL2002 style to the new OL2003 style?
Dear friends: The size of my Archive Folder is approaching 2 GB. How can I convert my Archive Folder from its OL2002 style to the new OL2003 style? I understand that the OL2003 style doesn't have the 2 GB limitation. I use Outlook 2003. Any hint? Thanks Juan I. Cahis Santiago de Chile (South America) Note: Please forgive me for my bad English, I am trying to improve it! In news:1kp8j1le66sp3j25022kl7pktvbj63hnrp@4ax.com, Juan I. Cahis <jiclbch@SINBASURAattglobal.net> typed: > Dear friends: > > The size of my Archive Folder is approaching 2 GB. > > How can I conv...

DPM 2010 Remote Agent Install (windows firewall settings)
I'm looking for the specific ports I need to unblock in order to push the agent from the console. All the documentation references point to firewall settings for the DPM server. I'm only interested in the windows firewall settings on the client (protected machine) necessary to push the agent. If I manually install on the client the installer opens the correct ports on the firewall for the agent to function so I'm not even concerned about those settings. I just need to be able to install/uninstall from the console and have been unable to do so unless I turn off the...

Word windows 07 docs let's crash win for mac 2008
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel Hello, <br><br>I got a problem with my word docs. <br> Everytime i would open and change something in my word doc (created on a pc) win for mac crashes. <br> When? on the moment a insert a frontpage, indexpage. <br><br>Who got a sollution for me? <br><br>Kind regards It's hard to say since you don't indicate; Whether Office is fully updated on your Mac, What your update level of OS X is, What version of Word was used to create the document, What f...

The Microsoft Community is a public forum where you can ask quest
The Microsoft Community is a public forum where you can ask quest Actually it is only a web based interface to the microsoft public newsgroups. Dessi Purnama Putra wrote: > The Microsoft Community is a public forum where you can ask quest Wow, you almost finished a sentence. "Dessi Purnama Putra" <Dessi Purnama Putra@discussions.microsoft.com> wrote in message news:17EFCDB1-9675-4413-BC27-6EC94D840DC6@microsoft.com... : The Microsoft Community is a public forum where you can ask quest ...

SHRINK TO FIT doesn't work properly
The subject above says it all: Since switching to Excel 2003, text that USED to be displayed correctly (via the 'shrink to fit' in cell formatting)now doesn't appear to get shrunk at all. Rather, it bleeds over into the next column. Duuno how it got broken, but it would sure be nice if it could be fixed! Did you try re-formatting the selection? Sometimes that will fix the conversion problem. --- Message posted from http://www.ExcelForum.com/ As a matter of fact, YES, SEVERAL times. This is VERY peculiar behavior. The columns on either side of it are formatted as number...

System Cleanup not working
I have a few 2003 enterprise servers which are all on the same Recipient & Mailbox Policy's. Mail does not move to system cleanup folder which is past msg age limit and mail is not being deleted from Deleted Items folder past msg age limit. I checked out the old msgs that should have moved and they meet the requirements noted in http://support.microsoft.com/?id=302804: • PR_MESSAGE_DELIVERY_TIME • PR_CLIENT_SUBMIT_TIME • PR_LAST_MODIFICATION_TIME I up'd the logging on server to max and I see no errors. The time between events 1206 & 1207 for "Cleanup of items pa...

User Activity window in GP 9
Hi! Does anyone know why GP removed the User Activity option under Tools-Setup-System in GP 9? How can you tell who's logged in the system without going to SQL Query Analyzer or Enterprise Mgr? Thanks -- Marisol Mortera Hi Marisol, Now found under Tools --> Utilities --> System Robert Marisol wrote: > Hi! > > Does anyone know why GP removed the User Activity option under > Tools-Setup-System in GP 9? How can you tell who's logged in the system > without going to SQL Query Analyzer or Enterprise Mgr? Thanks ...

can't create item
can't create item, when i hit a link to e mail on a internet explorer . i get the error mesge .cant create item ...