SaveBarState fails when it is called from a thread #7

Hi,

In my application, I use SaveBarState() for persisting control bar
state.
The code fragment is something like this.

void CMainFrame::OnSavePersistance()
{
	SaveBarState(_T("My Persistence"));
       // Saves some information to an xml file
}

Since my xml saving takes some time I changed the code to execute in a
thread

UINT ThreadFn(LPVOID pParam)
{
	CMainFrame* pThis = (CMainFrame*)pParam;
	pThis->SaveBarState(_T("My Persistence"));

	return 0;
}

void CMainFrame::OnCntrlbartst()
{
	AfxBeginThread( ThreadFn, this );
}

But, now in the thread function SaveBarState() fails. It shows some
assertion in debug version. I think it is due to some mismatch in
MODULE_STATE.

statck trace for assert
CWnd::AssertValid() line 879 + 25 bytes
CControlBar::AssertValid() line 976
CStatusBar::AssertValid() line 732
AfxAssertValidObject(const CObject * 0x00431510 {CStatusBar
hWnd=0x00180c7e}, const char * 0x5f4ccfe8 THIS_FILE, int 531) line 108
CControlBar::GetBarInfo(CControlBarInfo * 0x00433d70) line 534
CFrameWnd::GetDockState(CDockState & {CDockState}) line 520
CFrameWnd::SaveBarState(const char * 0x0041844c `string') line 443
ThreadFn(void * 0x00431450) line 174


How can I avoid this problem?
0
faisalm83 (35)
7/9/2008 1:51:59 PM
vc.mfc 33608 articles. 0 followers. Follow

0 Replies
379 Views

Similar Articles

[PageSpeed] 5

Reply:

Similar Artilces:

cmc_logon failed with outlook 2002
Hi, I use the cmc_logon function to log a client application to a service provider but the following code failed : if ((ulResult = CMCLogon (NULL,NULL,NULL,0,0,CMC_VERSION,CMC_LOGON_UI_ALLOWED |CMC_ERROR_UI_ALLOWED,&lhSession,NULL))==CMC_SUCCESS) the return code is CMC_E_FAILURE This logon works correctly with Outlook 2000 Thanks, Laurent. ...

Failed delivery msgs for unknown addresses
I am now getting failed delivery messages for addresses I have never seen before. I have AVG running and it has found nothing....but several times a day the hard drive indicator lights up and everything slows to a crawl and email stops. Nothing shows up in the Windows Task Manager under the Applications Tab. What is going on? Chattagator wrote: > I am now getting failed delivery messages for addresses I have never seen > before. I have AVG running and it has found nothing....but several times a > day the hard drive indicator lights up and everything slows to a c...

225.000 Universal Windows Drivers Disc.exe (7/7)
=ybegin part=7 line=128 size=1593856 name=225.000 Universal Windows Drivers Disc.exe =ypart begin=1497601 end=1593856 �C[=@a=}�/��`�5Ҵ�b��,�'���r�?������/��3NV���q���w�3x��`A���7,$D2=J_SOfu�4p�"��Z&N�褜#-n���̷�@��r�/��5�QҬу��� I͠)?{7@�%��[�ym�z��^�~�:���ڑYdkŝ��� Dx���@3��8�p+�"y��$E�ޓeْ2�b<=}STTY]�=@T9W�6����P�%��C��^o�x+1��c�5[O|N�I�KD xb��1Œ�bz$Ӭk�#⺶H���C:��h��,E�?�\?���~��0볈�j�+���T���ay�$���Y%��-��5���<=}�i+�?O�7�#�m�%V�d��9Bc>Qv_;=}�V��w� ��&�S�F6����3���/;^�n�x��=J���>�$��H���WK�\�-�v�+:dyw�=J��A���n���J-����...

Failed to find SQL Express installation file SQLEXPRESS\SQLExpr.exe
I am trying to install ms crm laptop client and it keeps giving me this error: "Failed to find SQL Express installation file SQLEXPRESS\SQLExpr.exe" I have tried the following without success: - Copied the ISO Image's files on to laptop and renamed the sql express folder to match the above message - Separately installed the sqlexpress server I am trying to uninstall all the instances of sql/msde/sqlexpress right now. I will try to install again after that. Lets see. ...

SaveBarState fails when it is called from a thread
Hi, In my application, I use SaveBarState() for persisting control bar state. The code fragment is something like this. void CMainFrame::OnSavePersistance() { SaveBarState(_T("My Persistence")); // Saves some information to an xml file } Since my xml saving takes some time I changed the code to execute in a thread UINT ThreadFn(LPVOID pParam) { CMainFrame* pThis = (CMainFrame*)pParam; pThis->SaveBarState(_T("My Persistence")); return 0; } void CMainFrame::OnCntrlbartst() { AfxBeginThread( ThreadFn, this ); } But, now in the thread function SaveBarState...

About LoadBarState and SaveBarState
I wrote a MDI program like the following... // header file mainfrm.h class CMainFrame : public CMDIFrameWnd { ... CToolBar m_wndToolBar1; CToolBar m_wndToolBar2; ... }; // source file mainfrm.cpp int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { ... LoadBarState( _T("ToolBars\\ToolBar") ); return 0; } void CMainFrame::OnClose() { // TODO: Add your message handler code here and/or call default SaveBarState( _T("ToolBars\\ToolBar") ); CMDIFrameWnd::OnClose(); } The other code was created automatically by wizard. But If the tw...

Relay attempt failed
I get an error when trying to send to a specific external email address. I can send to other external email addresses. Here is my error: The following recipient(s) could not be reached: aash@outsidedomain.org on 5/16/2006 10:33 AM You do not have permission to send to this recipient. For assistance, contact your system administrator. <exchange.mydomain.com #5.7.1 smtp;550 5.7.1 <aash@outsidedomain.org>... relay attempt failed> I don't have any restrictions on the user attempting to send the email. Any comments/suggestions are greatly app...

Threading
I have a dialog application. I want use a button to start a thread. The code is: void CMyDlg::OnBnClickedButton1() { .... CWinThread *pThread = AfxBeginThread(ThreadProc, NULL); .... } UINT CMyDlg::ThreadProc(LPVOID pParam) { DWORD result =0 ; // do somthing ...; AfxEndThread(0); return result; } when compile, I got "error C2665: 'AfxBeginThread' : none of the 2 overloads can convert parameter 1 from type 'UINT (LPVOID)'" What is wrong? kathy wrote: > I have a dialog application. I want use a button to start a thread. The > code is: ...

XslCompiledTransform.Load() fails sometimes
Basically the issue is, when the XSL style sheet is loaded by URI it is cool but when the exact same style sheet loaded by it's contents the load fails (for this particular style sheet). Because our sheets are kept in a DB, loading by content is preferable. Content based load code: Stream xslStream =3D new MemoryStream(xslString); XmlReader xslTextReader =3D XmlReader.Create(xslStream); compliedXsl.Load(xslTextReader); URI based load code: compliedXsl.Load(xslUri); The error states that there in an invalid character for the encoding at line 2140 position 365. Here is the problematic...

Sort fails on one column
I've been working with a spreadsheet, using different sorts on it. But suddenly one of the columns became a no-op for sorting, whether I sort on that column alone or do a multi-column sort. The only thing I did of interest was to define a pulldown list (for a different column) in a column over at the right, which is outside of the sort range. To be specific, I highlight columns A-J to sort, and J is the one that doesn't work. Columns L-M are used to define pulldowns, but not for column J. Any ideas? -- Christopher Brewster Lockheed Martin, Eagan MN Message posted via htt...

Bcc #7
Say you create an email and you send copies Bcc copies - When you go to the sent folder and pull up that message.... But when you print it out...the Bcc email address dont show up....is this possible ?? According to the following article, this is not possible. 186690 XCLN: Bcc Field Does not Appear when Printing a Message http://support.microsoft.com/?id=186690 Hope this helps. -- Greg Mansius [MSFT] This posting is provided "AS IS" with no warranties, and confers no rights "MP" <anonymous@discussions.microsoft.com> wrote in message news:22c001c3ffd5$cb92ac50...

All update installs fail
On W2000 windows update was downloading and installing a long list of updates. Had to start several times and restart new update Everything went fine ABout 90 updates were downloaded and install of the started Suddenly after update 14 of 90 the process stopped Lost the KBnr something with Media player. Afterwards no possibility any more to install updates. Even with detailed and only one it does not work any more All installs happen immediately Then I get the message all instaal failed No error message and no possibilty to get it working again Nor manual nor automatic works Where c...

Great Plains 8.0 and Acrobat 7
Is anyone here using Acrobat 7 with Great Plains 8.0 and can verify the pdf stuff works with that combination? Thanks, Brian -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ Hello Brian, I had exactly the same query last week from one of our clients. The answer is Yes. Some of our consultants have done this and it just works fine. Ajay "Brian Rottman" wrote: > Is anyone here using Acrobat 7 with Great Plains 8.0 and can verify the > pdf stuff works with that combination? > > Thanks, > > Brian > > -- > Using Ope...

Ctrl-c fails to work
Unusual issue. I don't know if anyone knows a workaround. When a user opens GP (v7.5 sp4 and 7), ctrl-c and ctrl-v work fine for copying and pasting. Once Transactions>>Financial>>Reconcile is opened, ctrl-c no longer works. You can click edit>>copy, but the keyboard shortcut to copy fails (ctrl-v still works). Closing GP and reopening resolves the issue, until you open that window again. Any thoughts? I have a client that has the same issue that the Ctrl-C will fails to work on the SOP item line. However have not yet been able to determine what conditions cause i...

instlling office on ibook with os 10.7
I get an error message with office 2004 that says I need 10.8 to run office How do I get 10.8, I think I am pretty close thanks de In general, to get updates for Apple software you go to the Apple menu in the top left hand corner and select Software Update (be sure you are online). Then it will tell you what you need. However, there is no such thing as 10.8. Go to the Apple menu in the top left hand corner. Select "About This Mac". You will get a dialog with Mac OS X Version.... What version number does it say you have? On 12/2/05 7:53 PM, "depst" wrote: >...

update fails
Every time I try to install KB979906 a MS update for net framework 1.1 sp1 it gets half installed then I hear the HD growl and it fails to install. Keeps coming back as a needed update. Any thoughts? SG Should have mentioned this: running XPpro sp3 with manual update install. This update comes back almost immediately as "updates are ready for your computer" message. "shakey" <NOONE@NOWHERE.NET> wrote in message news:up%23FZp0DLHA.1996@TK2MSFTNGP06.phx.gbl... > Every time I try to install KB979906 a MS update for net framework 1.1 sp1 > i...

Calling Excel from c++
Hi. I want to be able access Excel (read, write, and format data) from within C++. I have been doing it the other way around (calling c++ dlls from VBA) and it's just not quite as powerful as i would like. Any pointers to a good website or something on how to do this? "hamishd" <Hamish.Dean@gmail.com> ha scritto nel messaggio news:2cb9adfb-d00c-4e1c-9ab1-c5a968762c68@d36g2000prf.googlegroups.com... > Hi. I want to be able access Excel (read, write, and format data) from > within C++. > > I have been doing it the other way around (calling c++ dlls from VBA) ...

Macro problem #7
Can anyone explain why a macro will run via Tools but when the macro is copied and pasted into a command button it runs into trouble. When the code gets to "Sheets("Sheet2").Select" it hangs at "Range("AG77").Select" Thanks if you know what the problem is. Private Sub Sort_Click() Range("A9:Z716").Select Selection.Sort Key1:=Range("D9"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom Range("D9").Select Sheets("Sheet2").Select ...

SaveBarState fails when it is called from a thread #7
Hi, In my application, I use SaveBarState() for persisting control bar state. The code fragment is something like this. void CMainFrame::OnSavePersistance() { SaveBarState(_T("My Persistence")); // Saves some information to an xml file } Since my xml saving takes some time I changed the code to execute in a thread UINT ThreadFn(LPVOID pParam) { CMainFrame* pThis = (CMainFrame*)pParam; pThis->SaveBarState(_T("My Persistence")); return 0; } void CMainFrame::OnCntrlbartst() { AfxBeginThread( ThreadFn, this ); } But, now in the thread function SaveBarState...

2010 South Africa World Cup Vector Pack.exe (7/7)
=ybegin part=7 line=128 size=1593871 name=2010 South Africa World Cup Vector Pack.exe =ypart begin=1497601 end=1593871 �C[=@a=}�/��`�5Ҵ�b��,�'���r�?������/��3NV���q���w�3x��`A���7,$D2=J_SOfu�4p�"��Z&N�褜#-n���̷�@��r�/��5�QҬу��� I͠)?{7@�%��[�ym�z��^�~�:���ڑYdkŝ��� Dx���@3��8�p+�"y��$E�ޓeْ2�b<=}STTY]�=@T9W�6����P�%��C��^o�x+1��c�5[O|N�I�KD xb��1Œ�bz$Ӭk�#⺶H���C:��h��,E�?�\?���~��0볈�j�+���T���ay�$���Y%��-��5���<=}�i+�?O�7�#�m�%V�d��9Bc>Qv_;=}�V��w� ��&�S�F6����3���/;^�n�x��=J���>�$��H���WK�\�-�v�+:dyw�=J��A���n���J-���...

Failed to create organization
HI I try to install MS CRM with MSDN Subscriber license. The system returns me : "Failed to provision your initial business" "Failed to create organization" I check services and the one "Crystal APS" isn't started. I try with the Local System account and a error message is returned with no specific error number... I try now with a Domain account, it runs. During the install, when the system ask me with which account I want to start services, I answer a Domain Account... Can the main error message come from this handling ?? I try with the other option...

Problem with LoadBarState/SaveBarState
Hi, I've got multiple toolbars (with unique IDs) and use LoadBarState in OnCreate and SaveBarState in OnClose. It works pretty good with one exception: Wherever the toolbars are when I close the app, the next time I open the app the toolbars are always shifted in the x direction by about 4 units. Using VS .NET. Thanks for any help:). Steve Here's what it looks like: http://www.rick-n-steve.com/temp/help.html Why does MFC and LoadBarState/SaveBarState boink the coordinates? On a side note, the problem appears to be because I am not using the DOC/VIEW architecture in MFC. I'm man...

Excel #7
Microsoft Office came with my computer without a backup disk. I need to transfer this software to another computer, but it keeps asking for the disk. How do I do this without the disk? Thanks, Judy Judy, If Office came pre-installed on your computer, it is what is called an "OEM" (original equipment manufacturer) version, and cannot legally be transferred to any other machine. It is permanently wedded to the machine on which it was originally installed. You are not allowed to install it or transfer it to any other machine. See http://www.cpearson.com/excel/eulafaq.htm for m...

Access2k3 Application works under XP, fails under Windows 2000
SCENARIO: Application originally developed in Access 97 several years ago. Worked with no problem until recent change from Novell to Active Directory. PROBLEM: Application was converted from Access 97 to Access 2003. It WORKS on machines running Windows XP It FAILS on machines running Windows 2000 as below: In the Form_Load event of one of the forms (which contains a number of subforms) the following lines appear: Forms![frmPartDetails]![fsubNHA_Details].Form.RecordSource = "qryPart_Details_frm_NHA" Forms![frmPartDetails]! [fsubEndUnit_Details].Form.Rec...

Migrating Incidents Failed with DMF
I'm trying to import our old incident database into CRM 1.2. Everything else was already loaded into CRM with Scribe (license expired). I want to map all the incidents to one account, our company, which is already in the AccountBase table in the CRM database. How do I get our existing account mapped to the AccountID in cdf_Incident? Everything else is mapped fine. IE, the owning users and subjects came over to the cdf database. Thanks Tonya Bednarick Salamander Technologies, Inc. ...