schliessen eines programms nach sprachänderung im menü



  • moin

    hab da nen problem mit dem schliessen meines programms wenn ich zuvor die sprache geändert hab...

    also ich hab folgendes gemacht: im designer hab ich mir eine 2. menüleiste auf englisch erstellt. und wenn ich die spache nun per funktion ändere wird die menüleiste in englisch dargestellt... wenn ich nun das programm mit SendMessage(WM_CLOSE); schliesse bekomm ich jedoch eine widows-fehlermeldung:
    winfrm.cpp
    zeile 826
    debug assertion failed!

    was mach ich da falsch?

    so ändere ich das menü:

    LCID id = MAKELCID( MAKELANGID( LANG_ENGLISH, SUBLANG_ENGLISH_UK ), SORT_DEFAULT );
    		SetThreadLocale(id);
    		HMENU menu = GetMenu(((CPrinterClient2App *)AfxGetApp())->GetMainWnd()->GetSafeHwnd());
    		DestroyMenu( menu );
    		menu = CreateMenu();
    		CMenu menu2;
    		menu2.LoadMenu(IDR_MAINFRAME);
    		menu = menu2.GetSafeHmenu();
    		SetMenu( ((CPrinterClient2App *)AfxGetApp())->GetMainWnd()->GetSafeHwnd(), menu );
    

    mfg LT


  • Mod

    Und was steht an dieser Zeile?
    Die Bedingung die zu diesem ASSERT führt ist nützlich, genauso wie der Inhalt des Callstacks.



  • hmmm ka was du da meinst ... also die winfrm.cpp is ne standart c++ bibliothek ... ka was da drin steht ...

    im mom bekomm ich auch folgenden fehler :
    http://www.bilder-hochladen.net/files/dsfx-1.jpg

    fehler besteht jedoch weiter ...
    was für infos braucht ihr noch um mir zu helfen ???

    frohes neues euch allen noch !!
    mfg LT


  • Mod

    Nach mehr Infos zu dem ASSERT bist Du ja schon gefragt worden.

    Anmerkung zu Deinem Code: Dabei berücksichtigst Du aber nicht, dass die Menüs als Handles intern in den Document Templates gehalten und verwaltet werden.



  • sorry kann grad mit dem begriff ASSERT nix anfangen ...
    was genau möchtest du von mir ???
    und wie kann man das berücksichtigen das die menüs als handel gehandhabt werden ???



  • wenn ich das programm debugge (also auf wiederholen klick und dann auf debugg und mit ne visual stutio 2008 instanz aufmachen lass hält mein programm bei dieser fehlermeldung an:

    > MFC42D.DLL!CWinApp::DoMessageBox(const char * lpszPrompt=0xdddddddd, unsigned int nType=16, unsigned int nIDPrompt=0) Zeile 113 + 0x19 Bytes C++

    und in der zeile wo der debug drin steht springt er dann hin...

    int CWinApp::ShowAppMessageBox(CWinApp *pApp, LPCTSTR lpszPrompt, UINT nType, UINT nIDPrompt)
    {
    	// disable windows for modal dialog
    	DoEnableModeless(FALSE);
    	HWND hWndTop;
    	HWND hWnd = CWnd::GetSafeOwner_(NULL, &hWndTop);
    
    	// re-enable the parent window, so that focus is restored 
    	// correctly when the dialog is dismissed.
    	if (hWnd != hWndTop)
    		EnableWindow(hWnd, TRUE);
    
    	// set help context if possible
    	DWORD* pdwContext = NULL;
    
    	DWORD dwWndPid=0;
    	GetWindowThreadProcessId(hWnd,&dwWndPid);
    
    	if (hWnd != NULL && dwWndPid==GetCurrentProcessId() )
    	{
    		// use app-level context or frame level context
    		LRESULT lResult = ::SendMessage(hWnd, WM_HELPPROMPTADDR, 0, 0);
    		if (lResult != 0)
    			pdwContext = (DWORD*)lResult;
    	}
    	// for backward compatibility use app context if possible
    	if (pdwContext == NULL && pApp != NULL)
    		pdwContext = &pApp->m_dwPromptContext;
    
    	DWORD dwOldPromptContext = 0;
    	if (pdwContext != NULL)
    	{
    		// save old prompt context for restoration later
    		dwOldPromptContext = *pdwContext;
    		if (nIDPrompt != 0)
    			*pdwContext = HID_BASE_PROMPT+nIDPrompt;
    	}
    
    	// determine icon based on type specified
    	if ((nType & MB_ICONMASK) == 0)
    	{
    		switch (nType & MB_TYPEMASK)
    		{
    		case MB_OK:
    		case MB_OKCANCEL:
    			nType |= MB_ICONEXCLAMATION;
    			break;
    
    		case MB_YESNO:
    		case MB_YESNOCANCEL:
    			nType |= MB_ICONQUESTION;
    			break;
    
    		case MB_ABORTRETRYIGNORE:
    		case MB_RETRYCANCEL:
    			// No default icon for these types, since they are rarely used.
    			// The caller should specify the icon.
    			break;
    		}
    	}
    
    #ifdef _DEBUG
    	if ((nType & MB_ICONMASK) == 0)
    		TRACE(traceAppMsg, 0, "Warning: no icon specified for message box.\n");
    #endif
    
    	TCHAR szAppName[_MAX_PATH];
    	szAppName[0] = '\0';
    	LPCTSTR pszAppName;
    	if (pApp != NULL)
    		pszAppName = pApp->m_pszAppName;
    	else
    	{
    		pszAppName = szAppName;
    		DWORD dwLen = GetModuleFileName(NULL, szAppName, _MAX_PATH);
    		if (dwLen == _MAX_PATH)
    			szAppName[_MAX_PATH - 1] = '\0';
    	}
    
    	int nResult =
    		::AfxCtxMessageBox(hWnd, lpszPrompt, pszAppName, nType);
    
    	// restore prompt context if possible
    	if (pdwContext != NULL)
    		*pdwContext = dwOldPromptContext;
    
    	// re-enable windows
    	if (hWndTop != NULL)
    		::EnableWindow(hWndTop, TRUE);
    	DoEnableModeless(TRUE);
    
    	return nResult;
    }
    


  • ok das eine problem hab ich gelöst ...
    mein programm hatte nen problem nen char * zu löschen und als die fehlermeldung kommen sollte hat das irgendwie nicht funktioniert und darum is der mit dem oben gezeigten problem abgestürtz ...

    so nun kommen wir aber zum eigentlichen problem... denn als ich das herraus gefunden hatte und behoben hatte trat der ursprüngliche fehler wieder auf ...

    also im dubug springt er mir in diese funktion der winfrm.cpp:

    void CFrameWnd::OnClose()
    {
    	if (m_lpfnCloseProc != NULL)
    		(*m_lpfnCloseProc)(this);
    
    	// Note: only queries the active document
    	CDocument* pDocument = GetActiveDocument();
    	if (pDocument != NULL && !pDocument->CanCloseFrame(this))
    	{
    		// document can't close right now -- don't close it
    		return;
    	}
    	CWinApp* pApp = AfxGetApp();
    	if (pApp != NULL && pApp->m_pMainWnd == this)
    	{
    		// attempt to save all documents
    		if (pDocument == NULL && !pApp->SaveAllModified())
    			return;     // don't close it
    
    		// hide the application's windows before closing all the documents
    		pApp->HideApplication();
    
    		// close all documents first
    		pApp->CloseAllDocuments(FALSE);
    
    		// don't exit if there are outstanding component objects
    		if (!AfxOleCanExitApp())
    		{
    			// take user out of control of the app
    			AfxOleSetUserCtrl(FALSE);
    
    			// don't destroy the main window and close down just yet
    			//  (there are outstanding component (OLE) objects)
    			return;
    		}
    --------------
    		// there are cases where destroying the documents may destroy the
    		//  main window of the application.
    		if (!afxContextIsDLL && pApp->m_pMainWnd == NULL)
    		{
    			AfxPostQuitMessage(0);
    			return;
    		}
    	}
    
    	// detect the case that this is the last frame on the document and
    	// shut down with OnCloseDocument instead.
    	if (pDocument != NULL && pDocument->m_bAutoDelete)
    	{
    		BOOL bOtherFrame = FALSE;
    		POSITION pos = pDocument->GetFirstViewPosition();
    		while (pos != NULL)
    		{
    			CView* pView = pDocument->GetNextView(pos);
    			ENSURE_VALID(pView);
    			if (pView->GetParentFrame() != this)
    			{
    				bOtherFrame = TRUE;
    				break;
    			}
    		}
    		if (!bOtherFrame)
    		{
    			pDocument->OnCloseDocument();
    			return;
    		}
    
    		// allow the document to cleanup before the window is destroyed
    		pDocument->PreCloseFrame(this);
    	}
    
    	// then destroy the window
    	DestroyWindow();
    }
    

    als fehler bekomm ich:
    > MFC42D.DLL!CFrameWnd::OnDestroy() Zeile 862 + 0x28 Bytes C++
    die zeile die angesagt wird ist die die ich mit den vielen minusen markiert hab ...


Anmelden zum Antworten