CRichEditCtrl::CanPaste() crashes app if Dialog is created in worker thread

Hi

I have workerthreads created with ::CreateThread that each creates and
manages the life of a CDialog. If a dialog contains a richedit control and a
call to
CRichEditCtrl::CanPaste() is made the application crashes. It seems the
crash occurs in

winctrl4.cpp:
BOOL CRichEditCtrl::CanPaste(UINT nFormat) in the call
COleMessageFilter* pFilter = AfxOleGetMessageFilter();


It seems that if the thread is created using AfxBeginThread instead of
::CreateThread, the crash do not occur.
I must however for other reasons create the threads using ::CreateThread

Any ideas?

best regards
Anders Sandberg


0
11/25/2004 10:56:11 AM
vc.mfc 33608 articles. 0 followers. Follow

1 Replies
371 Views

Similar Articles

[PageSpeed] 2

Anders Sandberg wrote:

> Hi
> 
> I have workerthreads created with ::CreateThread that each creates and
> manages the life of a CDialog. If a dialog contains a richedit control and a
> call to
> CRichEditCtrl::CanPaste() is made the application crashes. It seems the
> crash occurs in
> 
> winctrl4.cpp:
> BOOL CRichEditCtrl::CanPaste(UINT nFormat) in the call
> COleMessageFilter* pFilter = AfxOleGetMessageFilter();
> 
> 
> It seems that if the thread is created using AfxBeginThread instead of
> ::CreateThread, the crash do not occur.
> I must however for other reasons create the threads using ::CreateThread
> 
> Any ideas?
> 
> best regards
> Anders Sandberg
> 
> 

An MFC CDialog cannot work without a message pump.  AfxBeginThread 
creates the message pump.  It also calls ::CreateThread.  You should 
reexamine your "reasons" for using ::CreateThread.

-- 
Scott McPhillips [VC++ MVP]

0
Scott
11/25/2004 4:40:43 PM
Reply:

Similar Artilces:

How does one view a document created in Publisher.
I have gotten a document (calendar) in .pub format. Word does not recognize it. Is there a viewer? What's the link? I have Office 2000 with the converters installed. Collins wrote: >I have gotten a document (calendar) in .pub format. Word > does not recognize it. Is there a viewer? What's the > link? I have Office 2000 with the converters installed. ==================================== There is no viewer for Publisher files. Maybe you could ask the sender to convert it to a .pdf file. Or you could order the Trial version of Pub2003... which will still function as a viewer a...

Thread Pool, CWinThread Class and GetQueuedCompletionStatus
I am struggling to convert an ISAPI Extension to thread pooling. Specifically where do I listen (GetQueuedCompletionStatus) for Completion IO Requests? In a nutshell this is what I have, with the CSession constructor unsuccessfully listening (GetQueuedCompletionStatus) for requests: /* ISAPI EXTENSION */ BOOL CExtThreadPoolExtension::GetExtensionVersion() { . . m_hIoPort = CreateIoCompletionPort((HANDLE)INVALID_HANDLE_VALUE, NULL, 0, 0); for(long n = 0; n < m_nThreadCount; n++) { CWinThread* pWinThread = (CSession*)AfxBeginThread( ...

Creating conditional clause in a module
I am in the process of writing module using vba in ACCESS 2003 which imports forecasted financial data from a particular excel file based on three inputs. I am trying to include an "error check" that will end the process if the three inputs do not match specific data in the excel file. I'm not sure how to go about doing this. Do you have any ideas what the best way to do this would be? Below is the code I have for the import part so far if that is helpful. Sub Test1() Dim ImportDir As String Dim Forecast As String Dim Version As String Dim Country As Stri...

How to create web-based reports from RMS database.
The reports available in RMS is not specific enough for my apparel retail store. I need sell the through rate, average sale, sales/sf, return rate, discount analysis, all broken down by date, week, month, year, category, supplier, and then compare against last year's numbers. I want to create my own web-based reports accessing RMS's SQL database. Does anyone have a template of data access web page so all I have to do is change the SQL statement in getting to the right database table? mas wrote: > The reports available in RMS is not specific enough for my apparel retail > ...

MRP not creating planned orders in version 10.0
I'm testing version 10.0 on a test system and using a copy of my live database. Version 8.0 creates a planned PO when QTY Available falls below Order Point Qty. It's not working in 10.0. I've checked all my settings from 8.0 to 10.0 and they all look the same. Is there a setting I'm missing? Thanks, Ken Have you rebuilt your low level codes after the upgrade? -- Tim Foster "KRoy" wrote: > I'm testing version 10.0 on a test system and using a copy of my live > database. Version 8.0 creates a planned PO when QTY Available falls below > Ord...

Please Help: Toolbars in DLL Dialog
Hello, Creating toolbars in an EXE app is a relative piece of cake. However, I am trying to insert a toolbar into a DLL dialog. This is how my DLL dialog works: 1) Contents of a function exporting a dialog AFX_MANAGE_STATE(AfxGetStaticModuleState()); CSvg* dlg; try { dlg = new CSvg(); dlg->Create(IDD_MAIN_FRAME); dlg->ShowWindow(SW_SHOW); } catch (CSvg *dlg) { dlg->PostNcDestroy(); delete dlg; } 2) Use a function in my Dialog class to insert a toolbar: int CSvg::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CDialog::OnCreate(lpCreateStruct) == -1) return -...

How to use excel file created in version earlier than 4.0a in 4.0
Thanks to whomever answered my query but when I opened the email the screen was blank. My laptop is sick. My question was and still is, how can I use my Excel files created in a recent version on my laptop in my PC which is loaded only with Excel 4.0a . Please and thanks. -- Thanks, Ajimmo Hi Ajimmo You can't, the file format changes twice since version 4. You need a newer Excel version, a compatible spreadsheet program, or simply a viewer if all you want to do is view / print the file. HTH. Best wishes Harald "ajimmo" <ajimmo@discussions.microsoft.com> skrev i m...

Create Pivot Table Reports
I just finished installing Analysis Cube on the server, everything seemed working fine until when I try to create the Pivot Table Report (Tools->Analysis Cubes->Create Pivot Table Reprots). After I called up the pre-defined 'Definition ID' and click on the Excel icon, a message popped up saying " The WHTemplate.XLT file was not found." Anybody have any idea what that is, and how to resolve it?? Thanks. 1.) There are two pieces of software. Did you install both the server piece, and the client piece? 2.) Is Excel installed on the machine, on which you'r...

Help with creating a formula
Hello! I am trying to create a formula that will sum up certain criteria from one column as it relates to criteria in the same row in another column. For example, I want to sum up all the entries that begin with the letter "H" in column A as it relates to an entry of "2" from column B that is in the same row as the "H" entry from column A. COLUMN A COLUMN B H10 2 G01 2 H09 3 H15 2 H12 2 If there is such a formula...

Creating only a mailbox
I'm doing some DR testing and I was wondering if there is any way to create just a mailbox that isn't associated with an AD account. I could create an account with a mailbox and then disconnect it, but I'd like a way to build hundreds of mailboxes that aren't associated with any AD account. Any help would be great. Thanks. Eric In AD just add it as a Contact instead of a user, this will allow you to give it exchange attributes without an AD account. >-----Original Message----- >I'm doing some DR testing and I was wondering if there is >any way to cre...

Auto-create activity from Mobile
Hi all, We have CRM 4.0 Roll Up 7. We are looking for a solution that offers advanced mobile integration to CRM. We would like the mobile client to auto-generate an Activity in CRM whenever a phone call is made to a CRM contact. Has anyone done this? //Johan Johan; There are a few vendors that offer good mobile solutions. I know for certain that MobileAccess from Ten Digits (http://www.tendigits.com/) has that specific feature. Dave Ireland "Jobro" <Jobro@discussions.microsoft.com> wrote in message news:4F1B3A1D-E23E-4E49-933F-B221C0DD1ECE@microsoft.com... >...

dialog based app & command line
Hello, I'm trying to launch my application with command line arguments, but I received an error, without any identification number of it. The MessageBox tolds me: "Runtime error" "the path to my exe file" "This application has requested the Runtime to terminate it in an unusual way. Please contact...". Have somebody a ideea where is the problem? Thank you a lot in advance, Alex PS: When I debbutg the appllication with command line args. from project properties the app. starts very well Try setting the start command line options fro...

start app without setting focus
Hi, i want to start my app (modless dialog) and I do not want, that my application gets the focus. How can I realize that? I tried such tings like GetForeGroundWindow()->SetFocus, but nothing worked. Everytime my app has the focus (wether running hidden with tray icon or showed). Does anybody has some ideas how I can do that? thanks a lot, Holger -- www.kreissl.info In CDialog::OnInitDialog() return FALSE instead of TRUE -- With Regards Alok Gupta Visit me at http://alok.bizhat.com "I Believe this will Help" "Holger Krei´┐Żl" <n...

new threads.....
It is wierd and I would rather I didn't but for some bizarre reason reply group is not working Fix your application, Danny. :) ******************* ~Anne Troy www.OfficeArticles.com "DannyJ" <youhavegottobekidding@nospam.com> wrote in message news:eY0ykmYiFHA.3216@TK2MSFTNGP10.phx.gbl... > It is wierd and I would rather I didn't but for some bizarre reason reply > group is not working > > ...

Dynamically inserting popup menu into MDI app when there's a CView
I have an MFC MDI app. It has the standard IDR_MAINFRAME main menu, and one type of CView defined with its own IDR_AITYPE menu. Now I have to detect whether a custom DLL is loaded, and if so an extra popup menu is added to the main menu, defined & controlled from the DLL. I can modify the IDR_MAINFRAME menu from the mainframe's OnCreate handler. I call the DLL, which loads the custom menu resource & does an InsertMenu into the window's menu. This works well. But I can't figure out how (or where) to insert the popup menu into the main menu when a CView is active & re...

Direction of selection in CRichEditCtrl
I believe that CRichEditCtrl::GetSel() does not relay a key piece of information regarding the current selection, namely the direction of the selection. This function always returns the smaller position first, and the larger position second. I would expect this function to return the larger position first and the smaller position second in the case of the user selecting backwards (from right to left). The reason for my expectations is that CRichEditCtrl::SetSel() does support this scheme for relaying the direction of the selection, unlike CRichEditCtrl::GetSel(). I can put the cursor at the e...

Disabling a CButton in a dialog
Hallo, I want to disable a button directly after clicking on it with this code: void CElternDialog::OnBnClickedEdit() { CButton* pbEdit = (CButton*)GetDlgItem( IDC_EDIT ); pbEdit->EnableWindow( FALSE ); ... GetDlgItem( IDC_NAME1 )->SetFocus(); } At runtime the button text looks 'grayed' and the button is disabled. The focus is in the desired control, but the clicked button has a bold black frame like it is if it were the BS_DEFPUSHBUTTON style. Before clicking the button hadn't the black frame. Is it necessary to 'repaint' the disabled button to prevent...

PostNcDestroy()..unknown crash problem
Hi, I have a modeless dialog that has a close button. In a localization version, it crashes when user clicks the "x" button on the top rightmost corner. But the close button works just fine. Both events lead to my PostNcDestroy() handler. I really cannot see any difference between these events, namely the "x" button and my own close button. Is there any significant difference between these two in the MFC framework? Any hint or help is much appreciated. (Since it doesn't crash in the English version, I cannot debug it.) Tony This is a typical "my pro...

How to create 2 charts on one page
I have created a yearly chart for widgets accomplished in Excel (has 4 data lines). I would like to add another chart directly below this to show the turn-time for accomplishing the widgets. It would have the same X-axis values (months of the year). I tried using a secondary Y axis, and the chart is just unreadable with this approach. Can this be done. HELP. You haven't told us why it's unreadable, so I doubt that we can help. If your problem is that the two sets of data are overlapping, and you said you wanted the second chart *below* the first one, try adjusting the scales on...

"No indexers" on creating "New Shared Services Provider "
Hi to all, I've this problem, I what to create the new and first "Shared Services Provider", but on "Index Server" section I don't find any Index Server (in combo-box). What can I do? Where am I wrong? Bye Dario Concilio Make sure you configured and started the Search services. -- Daniel A. Galant Imagine what we could be... if we could just imagine. "Dario Concilio MCP" <dario.concilio@hotmail.it> wrote in message news:uhcKStDzKHA.5040@TK2MSFTNGP02.phx.gbl... > Hi to all, > I've this problem, I what to creat...

external usb HDD crashes Windows
It was supposed to be a good external HDD. after not using it for a while i connected it to two different PCs and first it is recognized and then screen goes black. both XP pro, one SP2 and the other SP3. If I leave it connected then the PC attempts to restart and crashes again. both PCs same deal. tried a different PSU and a different USB cable, same. Do not have a another enclosure, but am ordering one. It's a WD 5000AAKS not good timOleary wrote: > It was supposed to be a good external HDD. > after not using it for a while i connected it to two different PCs >...

verify that a dialog box exists
I want to verify that a dialog box exists before I send it some message. I have a pointer to its object. Can someone remind me please? Thanks George > I want to verify that a dialog box exists before I send it some message. I > have a pointer to its object. > Can someone remind me please? > if(pDlg && pDlg->m_hWnd) { .... } --- Ajay > I want to verify that a dialog box exists before I send it some message. I > have a pointer to its object. > Can someone remind me please? > You can use ASSERT_VALID as well. It works in Debug only but its of great...

Does Preview Pane create a virus vulnerability?
I have my Outlook 2002 set so that the headers are on top and a preview of the email is below. Does that open me up to the possibility of receiving a virus or malicious code even if I don't open attachments? Would anti-virus software guard against this? Thanks! Ed It's possible, yes - but you should have good AV software installed anyway, and a firewall - both are pretty much mandatory on all networked computers (connecting to the Internet through a modem counts as that, too!) Your AV software should be updated regularly - try daily if possible. Keep Windows and all your office ap...

What is 'crashing' the project and its effect?
What is 'crashing' the project and its effect? Johnny -- Crashing the project schedule is the process of shortening the remaining project schedule in an attempt to finish the project on time or early. One of the common techniques is to add resources as helpers on Effort Driven tasks to shorten the Duration of these tasks and to shorten the remaining schedule as a consequence. Why do you ask, out of curiosity? -- Dale A. Howard [MVP] VP of Educational Services msProjectExperts http://www.msprojectexperts.com http://www.projectserverexperts.com "We write the...

Help requested in formulating Functions and script to create a mat
Visual Studio.net 2003, SQL Server Report Designer, SQL Query Analyser. I have a table of milestones with data such as project, miletone name, baseline date, planned date and actual date. My task is to produce a chart that has months in the columns and for each month a set of blocks of data, made by concatenating fileds form the table, for milestones due in that month. I can extract the 'blocks' of data easily enough but when I put them in columns each successive month starts on a new line below those of the previous month. I need it so that the first milestone of each ...