Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Visual C++ question

Options
  • 31-01-2002 10:29am
    #1
    Registered Users Posts: 2,911 ✭✭✭


    I have a function in a dll which is as follows

    long WINAPI SFMessage_Box(LPSTR message,LPSTR title,long mode)
    {
    AFX_MANAGE_STATE(AfxGetStaticModuleState());
    TRACE("Entering function displaydlg\n");

    sfmessage dlg;

    dlg.DoModal();

    return 0;
    }


    but if i was to add a dlg.m_Button.ShowWindow(SW_HIDE)

    into this function i get a DEBUG ASSERTION FAILED when called from say a VB application or a seperate C/C++ application

    Ive tried adding this line of code within the various class functions of sfmessage...like OnInitDialog and OnCreate.

    It never works? anyone got any ideas

    My knowloedge of MFC absolutely sucks


Comments

  • Closed Accounts Posts: 411 ✭✭Jay


    Did you try making the dlg global or static?

    static sfmessage dlg;

    Let me know if it helps.


  • Registered Users Posts: 2,911 ✭✭✭Washout


    Nope Im afraid it didnt work...Im at the end of my tether with this one.

    i reckon im going to have to get into HWND's and CWnd's but i dont know how to use those


  • Closed Accounts Posts: 411 ✭✭Jay


    That's a really strange error. I am sure I had something very similar there in November, I now remember how I fixed it.

    Basically I had an ATL/MFC COM dll that had to display a dialog.
    The thing is, it all compiled perfectly, but when I called it from VB, the dialog wouldn't always appear. Really ****ed up. It would appear sometimes and not other times.
    Anyway, when i got into it, I checked all the error values. And especially the error returned by the call to DoModal(). As it turned out the error returned was Invalid Window Handle.

    But WHY!?
    It turned out that I hadn't called
    InitCommonControlsEx() which is needed for some controls and window classes.

    So this is what I added and called near the beginning of the program or at the Dll entry point.
    INITCOMMONCONTROLSEX ComCtrls;
    	ComCtrls.dwSize = sizeof(INITCOMMONCONTROLSEX);
    	ComCtrls.dwICC = ICC_BAR_CLASSES | ICC_INTERNET_CLASSES;
    
    	if(InitCommonControlsEx(&ComCtrls) == TRUE)
    	{
    		return true;
    	}
    	else
    	{
    		return false;
    	}
    

    I have a feeling this will fix your problem.
    Let me know.


Advertisement