Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Visual C++ question

  • 31-01-2002 10:29AM
    #1
    Registered Users, Registered Users 2 Posts: 2,917 ✭✭✭


    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, Registered Users 2 Posts: 2,917 ✭✭✭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