Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
P

panzerdivisionmarkus

@panzerdivisionmarkus
About
Posts
13
Topics
7
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Debug assertion when using AFX_MANAGE_STATE(AfxGetStaticModuleState())
    P panzerdivisionmarkus

    Slolved it. It was a stupid lib file I used that had to be unicode compiled as well. Didn't notice it because the compiler didn't complain. Thanks for your help.

    C / C++ / MFC help debugging learning

  • Debug assertion when using AFX_MANAGE_STATE(AfxGetStaticModuleState())
    P panzerdivisionmarkus

    finally found something. Seems like this code is causing the assertion:

    _AFXWIN_INLINE HINSTANCE AFXAPI AfxGetResourceHandle()
    { ASSERT(afxCurrentResourceHandle != NULL);
    return afxCurrentResourceHandle; }

    Seems like afxCurrentResourceHandle haven't been properly set. I thought that was what AFX_MANAGE_STATE(AfxGetStaticModuleState()) was doing. You wouldn't happen to know any reason why it would fail?

    C / C++ / MFC help debugging learning

  • Debug assertion when using AFX_MANAGE_STATE(AfxGetStaticModuleState())
    P panzerdivisionmarkus

    hmm...no, my Dlls are debug builds, but in that case it seems like the debugger can't find the MFC debug dlls where GetModuleFileName and AfxGetResourceHandle() is. Is there some sort of wierd switch? except for _DEBUG?

    C / C++ / MFC help debugging learning

  • Debug assertion when using AFX_MANAGE_STATE(AfxGetStaticModuleState())
    P panzerdivisionmarkus

    I tried to do that, I have a vague memory that I've managed to that before, but now the debugger couldn't find any source code, so I had to go to disassembly. Anyway, I managed to figure out that it uses afxCurrentResourceHandle, and when I use it in my code it return null, and thats probably why AfxGetResourceHandle() causes assrt failure. Isn't AFX_MANAGE_STATE(AfxGetStaticModuleState()) supposed to set me to the right resource? Do you know how can I get the handle to be a valid handle to my dll?

    C / C++ / MFC help debugging learning

  • Debug assertion when using AFX_MANAGE_STATE(AfxGetStaticModuleState())
    P panzerdivisionmarkus

    It's possible that I missed to redeclare some of the chars to TCHARs and messed up the sizing. Thanks for the tip, I'll have to check on that. But I don't understand why the GetModuleFileName casues an assetion when AFX_MANAGE_STATE(AfxGetStaticModuleState()) is used. As far as I can see that error shouldn't depend on any TCHAR/char mismatch.

    Cctm::Cctm(void)
    :m_lock("Cctm::lock")
    {
    AFX_MANAGE_STATE(AfxGetStaticModuleState());

    m_initialized=FALSE;
    m_session=NULL;
    m_sModuleStatus[0]=0;
    m_iApprovedModuleStatus = 0;
    m_sActivityStatus[0]=0;
    m_iApprovedActivityStatus = 0;
    m_showCode=TRUE;
    m_moduleTypes=NULL;
    m_usedDisplayMasks=0;
    m_dbinfo=NULL;

    std_functions_init();

    //path to the DLL
    HINSTANCE l = afxCurrentResourceHandle;
    CString sFile;
    GetModuleFileName(AfxGetResourceHandle(), sFile.GetBuffer(_MAX_PATH + 1), _MAX_PATH);

    Or could it have something to do with the sFile.GetBuffer(_MAX_PATH + 1)? Could that cause some wierd behaviout now when it's unicode?

    C / C++ / MFC help debugging learning

  • Debug assertion when using AFX_MANAGE_STATE(AfxGetStaticModuleState())
    P panzerdivisionmarkus

    Hi, I have a wierd problem that I hope someone here can help me out with. And if I posted in the wrong forum please redirect me. Anyway, I have a program where I load a Dll, which then loads a bunch of other dlls. I recently did some changes so that the program would support unicode. After the changes I got these wierd problems: One of the dlls causes a debug assertion failed when loading from it's resource, and another doesn't. They both use the following code:

    HRESULT CPictureWnd::LoadResource(WORD wId, LANGID wLangId) {
    LPCTSTR sTemplateName = MAKEINTRESOURCE(wId);
    HINSTANCE hInst = AfxFindResourceHandle(sTemplateName, _T("GIF_IMAGE"));

    HRSRC hResInfo = ::FindResourceEx(hInst, \_T("GIF\_IMAGE"), sTemplateName, wLangId); 
    if (!hResInfo) hResInfo = ::FindResourceEx(hInst, \_T("GIF\_IMAGE"), sTemplateName, 0x409); 
    

    ...(other code)
    return hr;
    }

    The Dll that manages to call the function uses this code:

    CTM_MODULE_API BOOL module_mtype_init(LPMODULE_MTYPE_DATA mtype)
    {
    AFX_MANAGE_STATE(AfxGetStaticModuleState());
    mtype->pUserData = (_MODULE_MTYPE_USER_DATA*)calloc(sizeof(_MODULE_MTYPE_USER_DATA),1);
    mtype->pUserData->m_picIcon = new CPictureWnd;
    mtype->pUserData->m_picIcon->LoadResource(IDB_PATHICON,mtype->langId);
    return TRUE;
    }

    And the one who gets the assertion uses this:

    CTM_MODULE_API BOOL module_mtype_init(LPMODULE_MTYPE_DATA mtype)
    {
    AFX_MANAGE_STATE(AfxGetStaticModuleState());
    mtype->pUserData = (_MODULE_MTYPE_USER_DATA*)calloc(sizeof(_MODULE_MTYPE_USER_DATA),1);
    mtype->pUserData->m_picIcon = new CPictureWnd;
    mtype->pUserData->m_picIcon->LoadResource(IDB_PATHICON,mtype->langId);
    return TRUE;
    }

    I get the debug assertion failes at the following row: HINSTANCE hInst = AfxFindResourceHandle(sTemplateName, _T("GIF_IMAGE")); I also get an assertion failure in my dll which loads the other dlls in the following code:

    Cctm::Cctm(void)
    :m_lock("Cctm::lock")
    {
    AFX_MANAGE_STATE(AfxGetStaticModuleState());

    m_initialized=FALSE;
    ...other code

    //path to the DLL

    CString sFile;
    GetModuleFileName(AfxGetResourceHandle(), sFile.GetBuffer(_MAX_PATH + 1), _MAX_PATH);

    ...other code
    }

    The last row causes an assertion. If I comment out AFX_MANAGE_STATE(AfxGetStaticModuleState()); things seems to work better, but then it fetches texts from the wrong resource file

    C / C++ / MFC help debugging learning

  • Vertical scrollbars locks in ChildWindows in XP
    P panzerdivisionmarkus

    Hi, I have a really annoying problem, and I can't find the solution to it. Hopefully someone here can help me. When I run my application on Win XP with themes activated, sometimes the vertical scrollbar in my childwindows locks and can't be used. Though I can still scroll with left/right on the keyboard. The app works fine on 2000/XP without theme. The app is an MDI application, and in one of the windowcontrols, I have a windowcontrol and then a childwindow control. :) It is the childwindow controls that locks, but only the ones I've created by myself. A CListCtrl for example works perfectly. It's like my controls doesn't get that the scrollbar is used. I really, really hope someone can shed some light on this for me /Markus "Computers are like airconditioners, they don't work properly when you open windows..."

    C / C++ / MFC help tutorial

  • Identifying OLE DB errors
    P panzerdivisionmarkus

    Hi, Hope someone can help me with this. I want to identify a specific OLE DB error and display an error message that my users can understand. The way it is displayed right now is like this: Source:"Microsoft OLE DB Provider for SQL Server" Description:"Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32)." hr = 0x80040e14 The hr should be equal to DB_E_ERRORSINCOMMAND, but this error code is used for other errors as well. How can I identify that it is the "Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32)" message that is displyed? I'd really like to change it to something that my users can understand. But I can't find anything to go on, please help me. I've included my error messaging function.

    void DisplayOLEDBErrorRecords(HRESULT hrErr) {
    	CDBErrorInfo ErrorInfo;
    	ULONG        cRecords;
    	HRESULT      hr;
    	ULONG        i;
    	CComBSTR     bstrDesc, bstrHelpFile, bstrSource;
    	GUID         guid;
    	DWORD        dwHelpContext;
    	WCHAR        wszGuid[40];
    	USES_CONVERSION;
    
    	LCID lcLocale = GetSystemDefaultLCID();
    
    	hr = ErrorInfo.GetErrorRecords(&cRecords);
    	if (FAILED(hr) && ErrorInfo.m_spErrorInfo == NULL) {
    		OLEDBErrorMessageBox( "No OLE DB Error Information found: hr = 0x%x\n", hr);
    		return;
    	}
    
    	for (i = 0; i < cRecords; i++) {
    		hr = ErrorInfo.GetAllErrorInfo(i, lcLocale, &bstrDesc, &bstrSource, &guid, &dwHelpContext, &bstrHelpFile);
    		if (FAILED(hr)) {
    			OLEDBErrorMessageBox("OLE DB Error Record dump retrieval failed: hr = 0x%x\n", hr);
    			return;
    		}
    
    		StringFromGUID2(guid, wszGuid, sizeof(wszGuid) / sizeof(WCHAR));
        
                    OLEDBErrorMessageBox( "Source:\"%s\"\nDescription:\"%s\"\nhr = 0x%x\n\n", OLE2T(bstrSource), OLE2T(bstrDesc), hrErr);
    
    		bstrSource.Empty();
    		bstrDesc.Empty();
    		bstrHelpFile.Empty();
    	}
    }
    
    C / C++ / MFC database help question sql-server com

  • Word automation problem with C++
    P panzerdivisionmarkus

    I do think this is the right place to post this, because as I understand Office Automation is just a fancier word for COM to Office. :) I've done a small program that generates a bunch of worddocumnets and sends it either to printer or as a attached file in an e-mail. The printing works fine, it prints all the generated docs with the recipients name and stuff. The problem is with the mail. When my program tells word to send it to the specified e-mails, I first get a warning that a program is trying to use my mail and I can allow it to do so for an amount of time. This is fine, I can live with that. :) But then there comes another warning(excuse my bad english translation, I get the error message in swedish): A program is trying to send automatic e-mail. Will you allow this? If this is unexpected, it could involve a virus and you should choose No. Then I have to wait for about 5 seconds before I can press Yes. Is there any way to get around this message, or should I try a diffent approach? I've already allowed the program to use my mail program. I use MailMerge functions from word to send the documents, both to printer and to mail. I really hope someone can help me out /Markus

    COM help c++ com testing tools

  • Making CEdit behave properly in a CWnd
    P panzerdivisionmarkus

    If I understood you right, I'm supposed to override the PreTranslateMessage handler in my CWnd, and call the IsDialogMessage from there, like this: BOOL CMyWnd::PreTranslateMessage( msg ) { if( IsDialogMessage( msg ) ) return TRUE; else return CWnd::PreTranslateMessage( msg ); } Sadly it didn't work, I still can't use delete or tab in my CEdit. And the messages doesn't come to the function, at least not what I can see. Did I misunderstood you, or have I done something wrong?

    C / C++ / MFC help

  • Making CEdit behave properly in a CWnd
    P panzerdivisionmarkus

    Hi, The subject may be a little off, but anyways... I wonder how I can make a CEdit behave "properly" in a CWnd. I want it to behave the way it does in a CDialog. When I place a CEdit in my CWnd, I can't use delete on it, I can't use tab to jump between ctrls and I can't select the text in a CEdit(yes, I've tried using setsel(0,-1)). So I wonder if anyone please can help make my CEdits behave like in a CDialog. Regards Markus

    C / C++ / MFC help

  • Problems with the new HTML Editing classes in MFC7
    P panzerdivisionmarkus

    I have some problems using the new HTML editing classes. I found a very intresting article about it here on Codeproject, sadly it could'nt help me with my problem. I wan't to use the IDM_HYPERLINK MSHTML identifier to insert a hyperlink in a html doc. But the function hyperlink(LPCTSTR szUrl = NULL) won't accept my links, it returns an HRESULT error. Am I supposed to make my URL's look in a special way? I've tried http://www.adress.com and URL:http://www.adress.com, but none of them works. Could someone please help me? /Markus P.S the one writing the article was Chris Maunder, sadly I couldn't find any ways of contacting him directly. I hope that at least he knows the answer to my question...

    C / C++ / MFC help question html com

  • Overriding HyperLink in CHtmlEditCtrl
    P panzerdivisionmarkus

    Hi. I'm having some troble overriding the HyperLink function in CHtmlEditCtrl. In what format am I supposed to have my URL that I send into the Hyperlink function? I've tried with http://www.bla.com and some variations but it won't accept them, and I don't want to use the auto dialog for adding a link, I wan't to make my own. But then I have to know how to format the LPCTSTR correct. Anyone who can help me? Thanks in advance... /Markus

    C / C++ / MFC com help tutorial question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups