none
Filex.cpp line 117 -> Exception Unhandled RRS feed

  • Question

  • /////////////////////////////////////////////////////////////////////////////
    // CFileException helpers

    void __declspec(noreturn) AFXAPI AfxThrowFileException(int cause, LONG lOsError,
    LPCTSTR lpszFileName /* == NULL */)
    {
    #ifdef _DEBUG
    LPCSTR lpsz;
    if (cause >= 0 && cause < _countof(rgszCFileExceptionCause))
    lpsz = rgszCFileExceptionCause[cause];
    else
    lpsz = szUnknown;
    TRACE(traceAppMsg, 0, _T("CFile exception: %hs, File %Ts, OS error information = %ld.\n"),
    lpsz, (lpszFileName == NULL) ? _T("Unknown") : lpszFileName, lOsError);
    #endif
    THROW(new CFileException(cause, lOsError, lpszFileName));
    }

    Error -> Unhandled exception at 0x75D0FD62 in *.exe: Microsoft C++ exception: CFileException at memory location 0x0053F468.

    Friday, July 26, 2019 7:15 AM

Answers

  • I changed the way you told me and now it give it to me:

    File not found or Access denied

    Regards, Altun

    If I press OK it opens the window Select Data Source

    DSN Name

    Select the file data source that describes the driver that you wish to connect to. 

    You can use any file data source that refers to an ODBC driver which is installed on your machine.

     

    So your question here, the exception error, is solved.

    You must check if the "tcb"-file exist in the path.

    If it doesn't exist, OpenEx gets an empty CString and asks for what it should open. It looks like your class CTcbBdd has something to do with a database.

    You should check the result of Cadena before you call OpenEx like

    CString szCadena = Cadena();
    if (szCadena.GetLength() > 0)
    {
      OpenEx(szCadena);
    }
    else
    {
      // react on the error
      AfxMessageBox("Cadena not opened");
      return … or what ever you want to do when the error occurs
    }

    Regards, Guido



    Friday, July 26, 2019 10:45 AM

All replies

  • /////////////////////////////////////////////////////////////////////////////
    // CFileException helpers

    void __declspec(noreturn) AFXAPI AfxThrowFileException(int cause, LONG lOsError,
    LPCTSTR lpszFileName /* == NULL */)
    {
    #ifdef _DEBUG
    LPCSTR lpsz;
    if (cause >= 0 && cause < _countof(rgszCFileExceptionCause))
    lpsz = rgszCFileExceptionCause[cause];
    else
    lpsz = szUnknown;
    TRACE(traceAppMsg, 0, _T("CFile exception: %hs, File %Ts, OS error information = %ld.\n"),
    lpsz, (lpszFileName == NULL) ? _T("Unknown") : lpszFileName, lOsError);
    #endif
    THROW(new CFileException(cause, lOsError, lpszFileName));
    }

    Error -> Unhandled exception at 0x75D0FD62 in *.exe: Microsoft C++ exception: CFileException at memory location 0x0053F468.

    Hello,

    this is not your code that results in the exception. This is the exception handler. The error is before this in your code.

    You should debug your source code and check the line of your source Code when the exception is thrown. When you know which line causes the exception, you can show us the line and ask again.

    Regards, Guido

    Friday, July 26, 2019 7:24 AM
  • Appcore.cpp

    // initialize CWinThread state
    AFX_MODULE_STATE* pModuleState = _AFX_CMDTARGET_GETSTATE();
    ENSURE(pModuleState);
    AFX_MODULE_THREAD_STATE* pThreadState = pModuleState->m_thread;
    ENSURE(pThreadState);
    ASSERT(AfxGetThread() == NULL);
    pThreadState->m_pCurrentWinThread = this;
    ASSERT(AfxGetThread() == this);
    m_hThread = ::GetCurrentThread();
    m_nThreadID = ::GetCurrentThreadId();

    Debug Assertion Failed!

    Program: C:\Predica\ARESproject-vs2017\Debug\mfc140d.dll
    File: d:\agent\_work\3\s\src\vctools\vc7libs\ship\atlmfc\src\mfc\appcore.cpp
    Line: 196

    For information on how your program can cause an assertion
    failure, see the Visual C++ documentation on asserts.

    (Press Retry to debug the application)

    If there are more than one class inherits from CWinApp or create more than one CWinApp object in the MFC project, it will cause this issue, because each application that uses the MFC can contain only one object inherited from CWinApp.  

    I notified that Both CAres and CAresB have the gAres object. I tried to remove one?
    like this:

    // CAresB gAres; // remove the CAresB project 

    or 

    // CAres gAres;  // remove the CAresB project


    Friday, July 26, 2019 8:12 AM
  • I notified that Both CAres and CAresB have the gAres object. I tried to remove one?
    like this:

    // CAresB gAres; // remove the CAresB project 

    or 

    // CAres gAres;  // remove the CAresB project


    Only this is your code. Everything else in your answer was exception handling und gives no information to us.

    But both code blocks are only comments. I don't know what you do, the comments will not throw an exception. Show us what you do and where the exception is thrown. If it's something in the class CAres/CAresB, then there is an error in the class.

    Regards, Guido

    Friday, July 26, 2019 8:27 AM
  • Call Stack

    > TcbLib.dll!CTcbBdd::Cadena() Line 58 C++
    CString CTcbBdd::Cadena()
    {
    TCHAR buffer[_MAX_PATH];
    if (GetModuleFileName(AfxGetApp()->m_hInstance,buffer,sizeof buffer))
    {
    CString Nombre(buffer);
    Nombre.Replace(".exe",".tcb");
    CFile Ficher(Nombre,CFile::modeRead); -> Line 58
    int lon=Ficher.Read(buffer,sizeof buffer);
    buffer[lon]=0;
    Nombre=buffer;
    int numero=Nombre.Find('|');
    CString usuari=Nombre.Left(numero);
    CString claves=Nombre.Right(Nombre.GetLength()-numero-1);
    return CString("DSN=")+zNomBdd+CString(";UID=")+usuari+CString(";PWD=")+claves;
    }
    return CString();
    }

    > TcbLib.dll!CTcbBdd::Abre(const char * nombre, char bEmpres, char bBasDat) Line 76 C++
    void CTcbBdd::Abre(LPCTSTR nombre,char bEmpres,char bBasDat)
    {
    zNomBdd=nombre;
    if (bEmpres!='0') zNomBdd+=bEmpres;
    if (bBasDat!='0') zNomBdd+=bBasDat;
    try
    {
    OpenEx(Cadena()); -> Line 76
    }
    catch(CDBException *e)
    {
    if (bTcbBat)
    {
    CString error=e->m_strError;
    error+="\nError al abrir la Base de Datos: ";
    error+=zNomBdd;
    AfxMessageBox(error);
    }
    throw e;
    }
    SetQueryTimeout(0);
    }

    > TcbLib.dll!CTcbApp::InitInstance(const char * nombre, bool tamano) Line 41 C++

    BOOL CTcbApp::InitInstance(LPCTSTR nombre,bool tamano)
    {
    if (!AfxOleInit()) {AfxMessageBox("Fallo al iniciar OLE."); return FALSE;}
    setlocale(LC_ALL,"esp");
    ParseCommandLine(oParame);
    try
    {
    gBasDat.Abre(nombre,oParame.bEmpres,oParame.bBasDat);
    } -> Line 41
    catch(CDBException *e)
    {
    e->Delete();
    return FALSE;
    }
    CModulo::gBasDat=&gBasDat;
    CTcbPrn::IniImp();
    CRect r(0,0,tamano?1024:800,tamano?738:574);
    ((CFrameWnd*)m_pMainWnd)->Create(NULL,nombre,WS_POPUP|WS_CAPTION|WS_BORDER|WS_SYSMENU|WS_MINIMIZEBOX,r);
    if (oParame.bBasDat=='0')
    m_pMainWnd->SetIcon(LoadIcon(TCB_APLICA),TRUE);
    else
    m_pMainWnd->SetIcon(LoadIcon(TCB_PRUEBA),TRUE);
    m_pMainWnd->CenterWindow();
    m_pMainWnd->ShowWindow(SW_SHOW);
    m_pMainWnd->UpdateWindow();
    ((CTcbMar*)m_pMainWnd)->CreaMarco0(nombre,oParame.bMenues,oParame.bTcbMen,oParame.opcion);
    return TRUE;
    }

    Thank you for the help

    Friday, July 26, 2019 9:29 AM

  • CString CTcbBdd::Cadena()
    {
    TCHAR buffer[_MAX_PATH];
    if (GetModuleFileName(AfxGetApp()->m_hInstance,buffer,sizeof buffer))
    {
    CString Nombre(buffer);
    Nombre.Replace(".exe",".tcb");
    CFile Ficher(Nombre,CFile::modeRead);

    https://docs.microsoft.com/en-us/cpp/mfc/reference/cfile-class?view=vs-2019

    The constructor CFile var(file, mode) raises an exception if the file cannot be opened (it doesn't exist or you are not allowed to open the file, or or or).

    Try this instead:

    CFile Ficher;
    if (!Ficher.Open(Nombre, CFile::modeRead))
    {
       AfxMessageBox("File not found or Access denied");
       return "";
    }
    … read the file…
    
    

    Regards, Guido

    • Proposed as answer by Guido Franzke Friday, July 26, 2019 10:47 AM
    Friday, July 26, 2019 9:54 AM
  • I changed the way you told me and now it give it to me:

    File not found or Access denied

    Regards, Altun

     
    Friday, July 26, 2019 10:26 AM
  • If I press OK it opens the window Select Data Source

    DSN Name

    Select the file data source that describes the driver that you wish to connect to. 

    You can use any file data source that refers to an ODBC driver which is installed on your machine.

    Friday, July 26, 2019 10:30 AM
  • If I select Machine Data Source -> Ares -> type System -> ok

    SQL Server Login 

    Select -> Use Trused Connection -> OK

    Debug Assertion Failed!

    Program: C:\Predica\ARESproject-vs2017\Debug\mfc140d.dll
    File: d:\agent\_work\3\s\src\vctools\vc7libs\ship\atlmfc\src\mfc\dlgcore.cpp
    Line: 210

    For information on how your program can cause an assertion
    failure, see the Visual C++ documentation on asserts.

    (Press Retry to debug the application)

    TcbApl.cpp

    > TcbLib.dll!CTcbMar::CreaMarco2() Line 345 C++ Symbols loaded.

    void CTcbMar::CreaMarco2()
    {
    wOpcion=NULL;
    wMenues=new CTcbMen(this,bMenues,bTipMen);
    wMenues->Create(TCB_MENUES+bMenues,this);
    if (!nDirect) wMenues->ShowWindow(SW_SHOW);
    wAccion=new CTcbAcc(this); ->Line 345
    wAccion->Create(TCB_ACCION,this);
    wAccion->MoveWindow(rAccion);
    wAccion->ShowWindow(SW_HIDE);
    wEstado=new CTcbEst();
    wEstado->Create(TCB_ESTADO,this);
    wEstado->MoveWindow(rEstado);
    wEstado->ShowWindow(SW_HIDE);
    if (!nDirect) wMenues->SetFocus();
    }

    > TcbLib.dll!CTcbMar::CreaMarco0(const char * nombre, int menues, int tipMen, long opcion) Line 252 C++ Symbols loaded.

    void CTcbMar::CreaMarco0(LPCTSTR nombre,int menues,int tipMen,long opcion)
    {
    // gBasDat=CModulo::gBasDat;
    bMenues=menues;
    bTipMen=tipMen;
    tNomApp=nombre;
    nDirect=opcion?opcion+1000:0;
    CMenu* sysmen = GetSystemMenu(FALSE);
    if (sysmen != NULL)
    {
    for(int i=2; i<10; i++) sysmen->RemoveMenu(i, MF_BYPOSITION);
    // CString abomen("About");
    // sysmen->AppendMenu(MF_STRING, ID_ABOUT, abomen);
    }
    CreaMarco1();
    CreaMarco2();
    nReturn=0; -> Line 252
    nEscape=0;
    for (int n=0;n<20;n++) {aDialog[n].nDialog=0; aDialog[n].wDialog=NULL;}
    mDialog=0;
    cDialog=0;
    bDialog=false;
    wRetorn=NULL;
    wPrimer=NULL;
    bRetorn=0;
    Inicio();
    if (nDirect) SendMessage(WM_COMMAND,nDirect);
    }

    Friday, July 26, 2019 10:44 AM
  • I changed the way you told me and now it give it to me:

    File not found or Access denied

    Regards, Altun

    If I press OK it opens the window Select Data Source

    DSN Name

    Select the file data source that describes the driver that you wish to connect to. 

    You can use any file data source that refers to an ODBC driver which is installed on your machine.

     

    So your question here, the exception error, is solved.

    You must check if the "tcb"-file exist in the path.

    If it doesn't exist, OpenEx gets an empty CString and asks for what it should open. It looks like your class CTcbBdd has something to do with a database.

    You should check the result of Cadena before you call OpenEx like

    CString szCadena = Cadena();
    if (szCadena.GetLength() > 0)
    {
      OpenEx(szCadena);
    }
    else
    {
      // react on the error
      AfxMessageBox("Cadena not opened");
      return … or what ever you want to do when the error occurs
    }

    Regards, Guido



    Friday, July 26, 2019 10:45 AM
  • I put:

    CString szCadena = Cadena();
    {
    if (szCadena.GetLength() > 0)
    {
    OpenEx(szCadena);
    }
    else
    {
    // react on the error
    AfxMessageBox("Cadena not opened");
    }
    }

    before

    void CTcbBdd::Abre(LPCTSTR nombre,char bEmpres,char bBasDat)
    {
    zNomBdd=nombre;
    if (bEmpres!='0') zNomBdd+=bEmpres;
    if (bBasDat!='0') zNomBdd+=bBasDat;
    try
    {
    OpenEx(Cadena());
    }
    catch(CDBException *e)
    {
    if (bTcbBat)
    {
    CString error=e->m_strError;
    error+="\nError al abrir la Base de Datos: ";
    error+=zNomBdd;
    AfxMessageBox(error);
    }
    throw e;
    }
    SetQueryTimeout(0);
    }

    And it gives me this errors:

    C3861 'Cadena':identifer not fount

    C2447 '{':missing function header (old-style formal list?) 

    Friday, July 26, 2019 11:38 AM
  • I put:

    CString szCadena = Cadena();
    {
    if (szCadena.GetLength() > 0)
    {
    OpenEx(szCadena);
    }
    else
    {
    // react on the error
    AfxMessageBox("Cadena not opened");
    }
    }

    before

    void CTcbBdd::Abre(LPCTSTR nombre,char bEmpres,char bBasDat)
    {
    zNomBdd=nombre;
    if (bEmpres!='0') zNomBdd+=bEmpres;
    if (bBasDat!='0') zNomBdd+=bBasDat;
    try
    {
    OpenEx(Cadena());
    }
    catch(CDBException *e)
    {
    if (bTcbBat)
    {
    CString error=e->m_strError;
    error+="\nError al abrir la Base de Datos: ";
    error+=zNomBdd;
    AfxMessageBox(error);
    }
    throw e;
    }
    SetQueryTimeout(0);
    }

    And it gives me this errors:

    C3861 'Cadena':identifer not fount

    C2447 '{':missing function header (old-style formal list?) 

    Instead of OpenEx(Cadena()) you should insert the code block, not before any function.

    try
    {
      // OpenEx(Cadena());
      CString szCadena = Cadena();
      {
        if (szCadena.GetLength() > 0)
        {
          OpenEx(szCadena);
        }
        else
        {
         // react on the error
         AfxMessageBox("Cadena not opened");
        }
      }
    }

    Friday, July 26, 2019 11:43 AM
  • Friday, July 26, 2019 12:04 PM
  • Friday, July 26, 2019 12:07 PM
  • Yes, the file does not exist. This is not a problem in your code. Check in the Windows file directory if the file exists. We cannot help you with missig files in your filesystem.
    Friday, July 26, 2019 12:08 PM
  • Friday, July 26, 2019 12:08 PM
  • Friday, July 26, 2019 12:10 PM
  • Friday, July 26, 2019 12:12 PM

  • This is another exception somewhere else in your code.

    When you handle the missing file error, you should not go on with your code. That's why I put a "return …" into the code.


    Friday, July 26, 2019 12:21 PM
  • Cadena is the filesystem missing ?
    Friday, July 26, 2019 12:30 PM
  • Friday, July 26, 2019 12:43 PM
  • Can you tell me what file is missing in me filesystem?

    According to your code:

    if (GetModuleFileName(AfxGetApp()->m_hInstance,buffer,sizeof buffer))
    {
      CString Nombre(buffer);
      Nombre.Replace(".exe",".tcb");

    The file that is missing is called <Name of your App>.tcb, maybe "Ares2017.tcb" (if the exe-file is "Ares2017.exe")

    Regards, Guido


    Friday, July 26, 2019 12:57 PM

  • When you debug your code, the exe file is in the Debug directory but the project directory is not the Debug directory.

    According to your debug session:

    exe-file is C:\Predica\ARESproject-vs2017\Debug\Ares2017.exe

    The missing file is Ares2017.tcb.

    But the Debugger will try to open the file in the Project Directory C:\Predica\ARESproject-vs2017

    Regards, Guido


    Edit: When you have the Release Version, both exe and tcb files must be in the same Directory.
    Friday, July 26, 2019 1:00 PM
  • I have the file Ares.tcb 

    Friday, July 26, 2019 1:07 PM
  • Friday, July 26, 2019 1:11 PM
  • I have the file Ares.tcb 

    Put another copy of the file in the project directory C:\Predica\ARESproject-vs2017.

    Regards, Guido

    Monday, July 29, 2019 5:47 AM
  • Hello,

    I put the copy of the file Ares.tcb in the project directory C:\Predica\ARESproject-vs2017 and gives me same errors.

    Monday, July 29, 2019 6:19 AM
  • Monday, July 29, 2019 6:22 AM
  • If I press Abort 

    Monday, July 29, 2019 6:24 AM
  • If I press Ignore
    Monday, July 29, 2019 6:33 AM
  • If I press Ignore

    There is an error coming from CWnd. So this error has nothing to do with the existence of the tcb file. The error is somewhere else in the code. Check the call stack in your debugger. Then you will find your source code line which raises the exception, e.g., CTcbMar::CreaMarco2 line 345.
    Monday, July 29, 2019 6:50 AM
  • //////////////////////////////////////////////////////////////////////////////////
    // CTcbMar
    //////////////////////////////////////////////////////////////////////////////////
    void CTcbMar::CreaMarco0(LPCTSTR nombre,int menues,int tipMen,long opcion)
    {
    // gBasDat=CModulo::gBasDat;
    bMenues=menues;
    bTipMen=tipMen;
    tNomApp=nombre;
    nDirect=opcion?opcion+1000:0;
    CMenu* sysmen = GetSystemMenu(FALSE);
    if (sysmen != NULL)
    {
    for(int i=2; i<10; i++) sysmen->RemoveMenu(i, MF_BYPOSITION);
    // CString abomen("About");
    // sysmen->AppendMenu(MF_STRING, ID_ABOUT, abomen);
    }
    CreaMarco1();
    CreaMarco2();
    nReturn=0; -> TcbLib.dll!CTcbMar::CreaMarco0(const char * nombre, int menues, int tipMen, long opcion) Line 252
    nEscape=0;
    for (int n=0;n<20;n++) {aDialog[n].nDialog=0; aDialog[n].wDialog=NULL;}
    mDialog=0;
    cDialog=0;
    bDialog=false;
    wRetorn=NULL;
    wPrimer=NULL;
    bRetorn=0;
    Inicio();
    if (nDirect) SendMessage(WM_COMMAND,nDirect);
    }
    BEGIN_MESSAGE_MAP(CTcbMar,CFrameWnd)
    ON_WM_CLOSE()
    ON_COMMAND(TCB_FINALI,OnFinali)
    ON_COMMAND_RANGE(TCB_PRIMER,TCB_ULTIMA,OnAccion)
    ON_COMMAND_RANGE(IDD_PRIMER,IDD_ULTIMA,OnOpcion)
    ON_COMMAND_RANGE(IDC_PRIMER,IDC_ULTIMO,OnEvento)
    ON_COMMAND_RANGE(500,599,OnEvento)
    ON_MESSAGE(WM_USER+1,OnCheck)
    ON_WM_NCPAINT()
    ON_WM_NCACTIVATE()
    END_MESSAGE_MAP()
    void CTcbMar::OnAccion(UINT nAccion)
    {
    switch (nAccion)
    {
    case TCB_SALIDA: if (wOpcion->OnSalida()) OnSalida(); break;
    case TCB_ACEPTA: wOpcion->OnAcepta(); break;
    case TCB_CANCEL: wOpcion->OnCancel(); break;
    case TCB_NUEVOS: wOpcion->OnNuevos(); break;
    case TCB_CAMBIA: wOpcion->OnCambia(); break;
    case TCB_BORRAR: wOpcion->OnBorrar(); break;
    case TCB_BUSCAR: wOpcion->OnBuscar(); break;
    case TCB_LISTAR: wOpcion->OnListar(); break;
    case TCB_IMPRIM: wOpcion->OnImprim(); break;
    case TCB_EJECUT: wOpcion->OnEjecut(); break;
    case TCB_CONSUL: wOpcion->OnConsul(); break;
    case TCB_AVANZA: wOpcion->OnAvanza(); break;
    case TCB_VUELVE: wOpcion->OnVuelve(); break;
    case TCB_TERMIN: wOpcion->OnTermin(); break;
    case TCB_PREVIO: wOpcion->OnPrevio(); break;
    case TCB_ANULAR: wOpcion->OnAnular(); break;
    case TCB_CALCUL: wOpcion->OnCalcul(); break;
    case TCB_GRABAR: wOpcion->OnGrabar(); break;
    case TCB_ENVIAR: wOpcion->OnEnviar(); break;
    case TCB_FICHER: wOpcion->OnFicher(); break;
    }
    }
    LRESULT CTcbMar::OnCheck(WPARAM posici,LPARAM estado)
    {
    wOpcion->OnCheck(posici,estado);
    return 0;
    }
    void CTcbMar::OnNcPaint()
    {
    CFrameWnd::OnNcPaint();
    Empresa();
    }
    BOOL CTcbMar::OnNcActivate(BOOL estado)
    {
    CFrameWnd::OnNcActivate(estado);
    Empresa();
    return TRUE;
    }
    void CTcbMar::Empresa()
    {
    CWindowDC dc(this);
    CRect rTitulo;
    GetWindowRect(rTitulo);
    ScreenToClient(rTitulo);
    rTitulo.top=6;
    dc.SetTextColor(RGB(255,255,255));
    dc.SetBkMode(TRANSPARENT);
    dc.DrawText(tEmpres,rTitulo,DT_CENTER);
    }
    void CTcbMar::CreaMarco1()
    {
    GetClientRect(rMarcos);
    rAccion=rMarcos;
    rAccion.bottom=rAccion.top+80;
    rEstado=rMarcos;
    rEstado.top=rEstado.bottom-42;
    rOpcion=rMarcos;
    rOpcion.top=rAccion.bottom;
    rOpcion.bottom=rEstado.top;
    }
    void CTcbMar::CreaMarco2()
    {
    wOpcion=NULL;
    wMenues=new CTcbMen(this,bMenues,bTipMen);
    wMenues->Create(TCB_MENUES+bMenues,this); 
    if (!nDirect) wMenues->ShowWindow(SW_SHOW);
    wAccion=new CTcbAcc(this);  -> TcbLib.dll!CTcbMar::CreaMarco2() Line 345
    wAccion->Create(TCB_ACCION,this);
    wAccion->MoveWindow(rAccion);
    wAccion->ShowWindow(SW_HIDE);
    wEstado=new CTcbEst();
    wEstado->Create(TCB_ESTADO,this);
    wEstado->MoveWindow(rEstado);
    wEstado->ShowWindow(SW_HIDE);
    if (!nDirect) wMenues->SetFocus();
    }
    Monday, July 29, 2019 7:40 AM

  • wAccion=new CTcbAcc(this);  -> TcbLib.dll!CTcbMar::CreaMarco2() Line 345
    wAccion->Create(TCB_ACCION,this);
    wAccion->MoveWindow(rAccion);
    wAccion->ShowWindow(SW_HIDE);
    wEstado=new CTcbEst();
    wEstado->Create(TCB_ESTADO,this);
    wEstado->MoveWindow(rEstado);
    wEstado->ShowWindow(SW_HIDE);
    if (!nDirect) wMenues->SetFocus();
    }

    So the error occurs in the constructor. You create the dialog after the constructor. Something is in the constructor that calls ShowWindow or creates a dialog control. You cannot create controls in a constructor.

    Read this about modeless dailogs: https://www.codeproject.com/Articles/1651/Tutorial-Modeless-Dialogs-with-MFC

    Regards, Guido

    Edit: Show the source code of the constructor CTcbAcc if you need further help.


    Monday, July 29, 2019 7:52 AM
  • /*****************************************************************************************/
    /*						               CTcbAcc                                           */
    /*					                                                                     */
    /*		                     Ventana de Acción (botones superiores)                      */
    /*		                                                                                 */
    /*****************************************************************************************/
    
    BEGIN_MESSAGE_MAP(CTcbAcc,CDialog)
    	ON_COMMAND_RANGE(TCB_BOTON0_BUT,TCB_BOTONC_BUT,OnBotons)
    	ON_WM_PAINT()
    	ON_WM_SETFOCUS()
    END_MESSAGE_MAP()
    
    CTcbAcc::CTcbAcc(CWnd* pParent):CDialog(TCB_ACCION,pParent),dOpcion("TCB_Rotulo")
    {
    	nOpcion1=nOpcion2=nOpcion2=0;
    	iOpcion=kOpcion=0;
    	nBotons=0;
    	mBotons=12;
    	kBotons=13;
    	nSelecc=-1;
    	for (int n=0;n<14;n++) bOpcion[n]=0;
    }
    void CTcbAcc::DoDataExchange(CDataExchange* pDX)
    {
    	CDialog::DoDataExchange(pDX);
    	DDX_Control(pDX,TCB_BOTON0_BUT,wBoton[0]);
    	DDX_Control(pDX,TCB_BOTON1_BUT,wBoton[1]);
    	DDX_Control(pDX,TCB_BOTON2_BUT,wBoton[2]);
    	DDX_Control(pDX,TCB_BOTON3_BUT,wBoton[3]);
    	DDX_Control(pDX,TCB_BOTON4_BUT,wBoton[4]);
    	DDX_Control(pDX,TCB_BOTON5_BUT,wBoton[5]);
    	DDX_Control(pDX,TCB_BOTON6_BUT,wBoton[6]);
    	DDX_Control(pDX,TCB_BOTON7_BUT,wBoton[7]);
    	DDX_Control(pDX,TCB_BOTON8_BUT,wBoton[8]);
    	DDX_Control(pDX,TCB_BOTON9_BUT,wBoton[9]);
    	DDX_Control(pDX,TCB_BOTONA_BUT,wBoton[10]);
    	DDX_Control(pDX,TCB_BOTONB_BUT,wBoton[11]);
    	DDX_Control(pDX,TCB_BOTONC_BUT,wBoton[12]);
    }
    void CTcbAcc::PostNcDestroy()
    {
    	CDialog::PostNcDestroy();
    	delete this;
    }
    BOOL CTcbAcc::OnInitDialog()
    {
    	return CDialog::OnInitDialog();
    }
    void CTcbAcc::OnSetFocus(CWnd* wnd)
    {
    	if (MARCOS->wOpcion) MARCOS->wOpcion->SetFocus();
    }
    void CTcbAcc::OnBotons(UINT nIDD)
    {
    	if ((int)nIDD-TCB_BOTON0_BUT>kBotons&&bOculta) return;
    	if ((int)nIDD-TCB_BOTON0_BUT>kBotons&&bOpcion[nIDD-TCB_BOTON0_BUT]==0) return;
    	if ((int)nIDD-TCB_BOTON0_BUT>kBotons&&!MARCOS->SalOpcion(aBotons[nIDD-TCB_BOTON0_BUT])) return;
    	GetParentFrame()->SendMessage(WM_COMMAND,aBotons[nIDD-TCB_BOTON0_BUT]);
    }
    void CTcbAcc::OnPaint()
    {
    	CPaintDC dc(this);
    	CFont oLetras;
    	CDC Compat;
    	CBitmap Textura;
    	BITMAP DesTex;
    	Textura.LoadBitmap(TCB_ACCION);
    	Textura.GetBitmap(&DesTex);
    	Compat.CreateCompatibleDC(&dc);
    	Compat.SelectObject(&Textura);
    	dc.BitBlt(0,0,DesTex.bmWidth,DesTex.bmHeight,&Compat,0,0,SRCCOPY);
    }
    void CTcbAcc::PonBoton(UINT nIDD0,UINT nIDD1,UINT nIDD2,UINT nIDD3,UINT nIDD4,UINT nIDD5,UINT nIDD6,UINT nIDD7,UINT nIDD8,UINT nIDD9,UINT nIDDA,UINT nIDDB,UINT nIDDC)
    {
    	MARCOS->nReturn=0;
    	MARCOS->nEscape=0;
    	for (int n=0;n<mBotons;n++) Muestra(TCB_BOTON0_BUT+n,SW_HIDE);
    	nBotons=0;
    	mBotons=0;
    	PonBoton_(nIDD0);
    	PonBoton_(nIDD1);
    	PonBoton_(nIDD2);
    	PonBoton_(nIDD3);
    	PonBoton_(nIDD4);
    	PonBoton_(nIDD5);
    	PonBoton_(nIDD6);
    	PonBoton_(nIDD7);
    	PonBoton_(nIDD8);
    	PonBoton_(nIDD9);
    	PonBoton_(nIDDA);
    	PonBoton_(nIDDB);
    	PonBoton_(nIDDC);
    }
    void CTcbAcc::PonBoton_(UINT nIDD)
    {
    	TCHAR* ch=" RE";
    	if (nIDD>10000) MARCOS->PonBoton2(nIDD);
    	if (nIDD)
    	{
    		aBotons[nBotons]=nIDD%10000;
    		wBoton[nBotons].PonIcono(nIDD%10000,0,ch[nIDD/10000]);
    		mBotons=nBotons+1;
    		Muestra(TCB_BOTON0_BUT+nBotons,SW_SHOW);
    	}
    	nBotons++;
    }
    void CTcbAcc::PonOpcion(int opcion,UINT nIDD0,UINT nIDD1,UINT nIDD2,UINT nIDD3,UINT nIDD4,UINT nIDD5,UINT nIDD6,UINT nIDD7,UINT nIDD8,UINT nIDD9,UINT nIDDA,UINT nIDDB,UINT nIDDC)
    {
    	cOpcion=opcion;
    	for (int n=12;n>kBotons;n--) Muestra(TCB_BOTON0_BUT+n,SW_HIDE);
    	kBotons=12;
    // 	PonOpcion_(nIDD0);
    	PonOpcion_(nIDD1);
    	PonOpcion_(nIDD2);
    	PonOpcion_(nIDD3);
    	PonOpcion_(nIDD4);
    	PonOpcion_(nIDD5);
    	PonOpcion_(nIDD6);
    	PonOpcion_(nIDD7);
    	PonOpcion_(nIDD8);
    	PonOpcion_(nIDD9);
    	PonOpcion_(nIDDA);
    	PonOpcion_(nIDDB);
    	PonOpcion_(nIDDC);
    	bOculta=false;
    	Selecc(0);
    }
    void CTcbAcc::ActivaOpcion(int opcion,int estado)
    {
    	bOpcion[12-opcion]=estado;
    	wBoton[12-opcion].Activa(estado!=0);
    	if (cOpcion==2) Muestra(TCB_BOTON0_BUT+12-opcion,SW_SHOW);
    }
    void CTcbAcc::PonOpcion_(UINT nIDD)
    {
    	if (nIDD)
    	{
    		aBotons[kBotons]=nIDD;
    		bOpcion[kBotons]=cOpcion==0;
    		wBoton[kBotons].PonIcono(nIDD,bOpcion[kBotons],TCHAR(13-kBotons+'0'));
    		if (cOpcion<2) Muestra(TCB_BOTON0_BUT+kBotons,SW_SHOW);
    		kBotons--;
    	}
    }
    void CTcbAcc::InsertaOpcion(UINT nIDD,int po)
    {
    	if (nIDD)
    	{
    		if (po>12-kBotons) po=12-kBotons;
    		for (int n=kBotons;n<12-po;n++)
    		{
    			aBotons[n]=aBotons[n+1];
    			bOpcion[n]=bOpcion[n+1];
    			wBoton[n].PonIcono(aBotons[n+1],bOpcion[n+1],TCHAR(13-n+'0'));
    		}
    		aBotons[12-po]=nIDD;
    		bOpcion[12-po]=cOpcion==0;
    		wBoton[12-po].PonIcono(nIDD,bOpcion[12-po],TCHAR(13-12-po+'0'));
    		if (cOpcion<2) Muestra(TCB_BOTON0_BUT+12-po,SW_SHOW);
    		kBotons--;
    	}
    }
    void CTcbAcc::Selecc(int selecc)
    {
    	if (nSelecc>=0) wBoton[12-nSelecc].Selecc(false);
    	if (selecc>=0) wBoton[12-selecc].Selecc(true);
    	nSelecc=selecc;
    }
    void CTcbAcc::OcultaOpcion(UINT idc,bool estado)
    {
    	for (int n=12;n>kBotons;n--) Muestra(TCB_BOTON0_BUT+n,estado?SW_HIDE:SW_SHOW);
    }
    void CTcbAcc::OcultaOpcion(bool estado)
    {
    	bOculta=estado;
    	for (int n=12;n>kBotons;n--) Muestra(TCB_BOTON0_BUT+n,estado?SW_HIDE:SW_SHOW);
    }

    Monday, July 29, 2019 8:06 AM
  • Hm, the constructor looks ok. So it must be in the line before the new TcbArr.

    wMenues->Create(TCB_MENUES+bMenues,this);
    if (!nDirect) wMenues->ShowWindow(SW_SHOW);

    Check with the Debugger, mostly at the Create, if this is ok.

    Monday, July 29, 2019 8:56 AM
  • If I comment the lines:

    //wMenues->Create(TCB_MENUES+bMenues,this);

    //if (!nDirect) wMenues->ShowWindow(SW_SHOW);

    it gives me the error in: wAccion->ShowWindow(SW_HIDE);

    TcbLib.dll!CTcbMar::CreaMarco2() Line 348 C++ Symbols loaded.

    Monday, July 29, 2019 11:20 AM
  • If I comment the lines:

    //wMenues->Create(TCB_MENUES+bMenues,this);

    //if (!nDirect) wMenues->ShowWindow(SW_SHOW);

    it gives me the error in: wAccion->ShowWindow(SW_HIDE);

    TcbLib.dll!CTcbMar::CreaMarco2() Line 348 C++ Symbols loaded.

    Well it looks like as if you didn't create the Dialogs in the resource editor or there is an error? How are your TCB_* Dialogs defined in resource editor? Does w...->Create return TRUE everytime? For testing: what happens if you make wAccion a modal Dialog (just call DoModal() instead of Create and ShowWindow) - what happens then?

    There must be an error in creating the dialogs and menu.

    Monday, July 29, 2019 11:46 AM
  • Monday, July 29, 2019 1:01 PM
  • Now you have the same error as before in wMenue->ShowWindow. The Create before must be FALSE. Comment the wMenue as you commented in your post before, and look what happens only with your DoModals.

    Regards, Guido

    Edit: don't MoveWindow because after DoModal the dialog's hwnd is invalid already. By now, we only check the first DoModal. I think this should not work already.


    Monday, July 29, 2019 1:16 PM
  • You are right, now it gives error in wEsdato-> DoModal ();
    Tuesday, July 30, 2019 6:48 AM
  • You are right, now it gives error in wEsdato-> DoModal ();

    Don't use Create and MoveWindow when you open the Dialog with DoModal.

    Am I right that wAccion->DoModal is working without errors? If so, then there is an error somewhere in the (On)Create function when you use the Dialogs as modeless Dialogs. You should use the Debugger and step through the code.

    Tuesday, July 30, 2019 7:12 AM
  • Tuesday, July 30, 2019 7:37 AM
  • It pass the error that I have

    Tuesday, July 30, 2019 7:41 AM
  • It pass the error that I have

    The modal dialogs work without error. So you know it is a problem in the creation of your modeless dialogs.

    I still think that the call to "wMenues->Create(TCB_MENUES+bMenues,this)" returns FALSE.

    Read this about modeless dailogs: https://www.codeproject.com/Articles/1651/Tutorial-Modeless-Dialogs-with-MFC

    Regards, Guido

    Tuesday, July 30, 2019 7:54 AM
  • I read about modeless dialogs:

    CModeLess *m_pmodeless = new CModeLess(this);
    m_pmodeless->Create(CModeLess::IDD);
    m_pmodeless->ShowWindow(SW_SHOW);	

    wMenues=new CTcbMen(this,bMenues,bTipMen);
    wMenues->DoModal();
    //wMenues->Create(TCB_MENUES+bMenues,this);
    //if (!nDirect) wMenues->ShowWindow(SW_SHOW);

    I don't know how to make to return True  

    Tuesday, July 30, 2019 11:18 AM
  • I read about modeless dialogs:

    CModeLess *m_pmodeless = new CModeLess(this);
    m_pmodeless->Create(CModeLess::IDD);
    m_pmodeless->ShowWindow(SW_SHOW);	

    wMenues=new CTcbMen(this,bMenues,bTipMen);
    wMenues->DoModal();
    //wMenues->Create(TCB_MENUES+bMenues,this);
    //if (!nDirect) wMenues->ShowWindow(SW_SHOW);

    I don't know how to make to return True  

    I think it's a problem with the ID "TCB_MENUES+bMenues". It looks like you are cumulating the IDs. I think this is not a valid Dialog resource ID. If you have many menus, each menu still has its own resource ID. You should use a switch to select the correct menu.

    Tuesday, July 30, 2019 11:49 AM
  • TcbLib.rc

    //TCB_MENUES              BITMAP                "Menues.bmp"

    #include "windows.h" 
    #include "winresrc.h" 
    #include "afxres.h" 
    #include "TcbRes.h" 
    #include "verrsrc.h" 
    TCB_MENUES DIALOGEX 0, 0, 550, 350
    STYLE DS_SETFONT | WS_CHILD
    STYLE  WS_CHILD
    FONT 8, "MS Sans Serif", 0, 0, 0x1
    BEGIN
        CONTROL         "",TCB_AREAS0,"Button",BS_OWNERDRAW | BS_RIGHT | NOT 
                        WS_VISIBLE | WS_TABSTOP,7,30,144,45
        CONTROL         "",TCB_AREAS1,"Button",BS_OWNERDRAW | BS_RIGHT | NOT 
                        WS_VISIBLE | WS_TABSTOP,7,75,144,45
        CONTROL         "",TCB_AREAS2,"Button",BS_OWNERDRAW | BS_RIGHT | NOT 
                        WS_VISIBLE | WS_TABSTOP,7,120,144,45
        CONTROL         "",TCB_AREAS3,"Button",BS_OWNERDRAW | BS_RIGHT | NOT 
                        WS_VISIBLE | WS_TABSTOP,7,165,144,45
        CONTROL         "",TCB_AREAS4,"Button",BS_OWNERDRAW | BS_RIGHT | NOT 
                        WS_VISIBLE | WS_TABSTOP,7,210,144,45
        CONTROL         "",TCB_AREAS5,"Button",BS_OWNERDRAW | BS_RIGHT | NOT 
                        WS_VISIBLE | WS_TABSTOP,7,255,144,46
        CONTROL         "",TCB_OPCION00,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_GROUP | WS_TABSTOP,162,37,115,38
        CONTROL         "",TCB_OPCION01,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,284,37,115,38
        CONTROL         "",TCB_OPCION02,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,406,37,115,38
        CONTROL         "",TCB_OPCION03,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,162,81,115,38
        CONTROL         "",TCB_OPCION04,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,284,81,115,38
        CONTROL         "",TCB_OPCION05,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,406,81,115,38
        CONTROL         "",TCB_OPCION06,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,162,125,115,38
        CONTROL         "",TCB_OPCION07,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,284,125,115,38
        CONTROL         "",TCB_OPCION08,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,406,125,115,38
        CONTROL         "",TCB_OPCION09,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,162,169,115,38
        CONTROL         "",TCB_OPCION10,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,284,169,115,38
        CONTROL         "",TCB_OPCION11,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,406,169,115,38
        CONTROL         "",TCB_OPCION12,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,162,213,115,38
        CONTROL         "",TCB_OPCION13,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,284,213,115,38
        CONTROL         "",TCB_OPCION14,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,406,213,115,38
        RTEXT           "",TCB_TITULO,160,1,361,24,SS_CENTERIMAGE | WS_BORDER
        CTEXT           "",TCB_MENSAJ3,162,305,359,24,SS_CENTERIMAGE | WS_BORDER
        GROUPBOX        "",TCB_CUADRO,6,25,146,276
        CONTROL         440,TCB_LOGCIA,"Static",SS_BITMAP,6,1,308,55
        PUSHBUTTON      "Apagar",TCB_FINALI,6,305,71,24
        PUSHBUTTON      "Agenda",TCB_AGENDA,81,305,71,24
        CONTROL         "",TCB_OPCION15,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,162,257,115,38
        CONTROL         "",TCB_OPCION16,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,284,257,115,38
        CONTROL         "",TCB_OPCION17,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,406,257,115,38
    END

    Tuesday, July 30, 2019 12:38 PM
  • Ok, the Dialog resource Looks ok.

    I don't know why you add bMenues to the ID at Create.

    Try this instead:

    wMenues=new CTcbMen(this,bMenues,bTipMen);
    wMenues->Create(TCB_MENUES,this);
    if (!nDirect) wMenues->ShowWindow(SW_SHOW);
    

    Regards, Guido

    Tuesday, July 30, 2019 1:01 PM
  • I was also thinking of removing bMenues to the ID at Create. I didn't do the program, I took it and I have to carry out its migration from VS2003 to VS2017.

    Tuesday, July 30, 2019 1:26 PM
  • I was also thinking of removing bMenues to the ID at Create. I didn't do the program, I took it and I have to carry out its migration from VS2003 to VS2017.

    The addition would have been an error in VS2003 too.

    You can remove the DoModals again and uncomment the other Creates and ShowWindows. Then you have modeless dialogs again.

    If you need a different identifier inside many wMenue Dialogs, then you could add a variable inside the class (but I think you did it already because bMenues is a parameter of the constructor).

    Regards, Guido

    Tuesday, July 30, 2019 1:56 PM
  • In VS2003 is work.

    TCB_MENUES -> identifier "TCB_MENUES" is undefined


    • Edited by Altun Murat Wednesday, July 31, 2019 8:17 AM
    Wednesday, July 31, 2019 8:16 AM
  • TCB_MENUES -> identifier "TCB_MENUES" is undefined


    The identifiers (TCB_MENUES, TCB_ACCION,...)  that come from the resource editor are defined in resource.h .

    You didn't have this error in the beginning of this post. So you have changed the include files.

    Wednesday, July 31, 2019 9:19 AM
  • Wednesday, July 31, 2019 10:06 AM

  • Read the error list. The file does not exist any more. Where is it? Deleted? Moved to somewhere else? Check your directory. If it exists, then check your include directories in the project settings. But normally it is in the normal project directory, so what has happened with the file? I cannot help you with missing files.
    Wednesday, July 31, 2019 10:14 AM
  • The resource.h file exists in:

    C:\Predica\ARESproject-vs2017

    C:\Predica\TcbLib-Dll\Pro

    C:\Predica\ARESproject-vs2017\boost_1_69_0\libs\math\dot_net_example\boost_math

    C:\Predica\ARESproject-vs2017\Debug\Custom Drawing

    Wednesday, July 31, 2019 10:30 AM
  • But I think it's not the good one :(
    Wednesday, July 31, 2019 10:33 AM
  • C:\Predica\ARESproject-vs2017\resource.h

    //{{NO_DEPENDENCIES}}
    // Microsoft Visual C++ generated include file.
    // Used by Ares.rc
    //
    #define IDS_PROJNAME                    100
    #define IDR_WMDMLOGGER                  101
    #define IDS_LOG_SEV_INFO                201
    #define IDS_LOG_SEV_WARN                202
    #define IDS_LOG_SEV_ERROR               203
    #define IDC_BUTTON2                     204
    #define IDS_LOG_DATETIME                205
    #define IDC_EDIT1                       206
    #define IDS_LOG_SRCNAME                 207
    #define IDC_RADIO1                      208
    #define IDS_DEF_LOGFILE                 301
    #define IDS_DEF_MAXSIZE                 302
    #define IDS_DEF_SHRINKTOSIZE            303
    #define IDS_DEF_LOGENABLED              304
    #define IDS_MUTEX_TIMEOUT               401
    #define IDC_LISTAS_LIS4                 1003
    #define IDC_LIMITE_FEC3                 2009
    #define IDC_FINALI_FEC                  2010
    #define IDC_LIMITE_FEC4                 2012
    #define IDC_OPCION_COM6                 2033
    #define IDC_PREVIO_CHE2                 2046
    #define IDC_DNINIF_EDI3                 2115
    #define IDC_CUENTA_EDI3                 2122
    #define IDC_CUENTA_EDI4                 2123
    #define IDC_NUMERO_EDI2                 2156
    #define IDC_GASEXT_EDI3                 2161
    #define IDC_CTAASO_EDI3                 2164
    #define IDC_DESCUE_EDI                  2184
    #define IDC_OPCION_EDI13                2202
    #define IDC_RECARG_EDI2                 2262
    #define IDC_OPCION_STA2                 2602
    #define IDC_IMPORT_EDI8                 2631
    #define IDC_IMPORTE_EDI2                3017

    // Next default values for new objects
    // 
    #ifdef APSTUDIO_INVOKED
    #ifndef APSTUDIO_READONLY_SYMBOLS
    #define _APS_NEXT_RESOURCE_VALUE        209
    #define _APS_NEXT_COMMAND_VALUE         32768
    #define _APS_NEXT_CONTROL_VALUE         210
    #define _APS_NEXT_SYMED_VALUE           102
    #endif
    #endif


    • Edited by Altun Murat Wednesday, July 31, 2019 10:35 AM
    Wednesday, July 31, 2019 10:34 AM
  • C:\Predica\TcbLib-Dll\Pro\resource.h

    //{{NO_DEPENDENCIES}}
    // Microsoft Visual C++ generated include file.
    // Used by TcbLib.rc

    // Next default values for new objects
    // 
    #ifdef APSTUDIO_INVOKED
    #ifndef APSTUDIO_READONLY_SYMBOLS
    #define _APS_NEXT_RESOURCE_VALUE        101
    #define _APS_NEXT_COMMAND_VALUE         40001
    #define _APS_NEXT_CONTROL_VALUE         1001
    #define _APS_NEXT_SYMED_VALUE           101
    #endif
    #endif

    Wednesday, July 31, 2019 10:59 AM
  • I copy resource.h in C:\Predica\TcbLib\Hpp and now it recognize #include <resource.h> in TcbAp.cpp but it gives now error at  

    Wednesday, July 31, 2019 11:40 AM
  • Wednesday, July 31, 2019 12:08 PM
  • Yes, the IDs are not defined in the resource.h that you show here.

    Check the original VS2003 project if the resource.h was deleted.

    Wednesday, July 31, 2019 12:15 PM
  • XP - VS2003
    Wednesday, July 31, 2019 12:51 PM
  • Wednesday, July 31, 2019 12:56 PM
  • The program as it runs in VS2013
    Thursday, August 1, 2019 7:07 AM
  • The small resource.h looks like a standard resource.h: all IDs are defined with IDC_* .
    When you add a Dialog in resource edit, its ID starts with IDC_DIALOG* first.

    In your VS2003 Project, the IDs were renamed to TBC_* . But these defines are not in the resource.h files that you show here.

    Find the file, that has TBC_MENUES and all the other ids in the original VS2003 project. It should be resource.h because the resource editor uses this file, and in the rc-file the IDs are used, so they must be in resource.h .

    Open the Windows file explorer, search for TBC in the contents of all files in your project directory. If it is not found in the original VS2003 Project, then the original project cannot be compiled and run.

    But you didn't have this problem before, so search the original VS2003 project for the correct resource.h.

    Regards, Guido

    Thursday, August 1, 2019 8:40 AM
  • Thursday, August 1, 2019 11:00 AM
  • /*****************************************************************************************/
    /*	                                                                                     */
    /*                                       TcbRes.h                                        */
    /*                           Identificación de Recursos (controles)                      */
    /*	                                                                                     */
    /*****************************************************************************************/
    
    // Panes de la Barra de estado
    #define ID_STATUS_STATIC		100
    #define ID_STATUS_USUARI		101
    #define ID_STATUS_FECHAS		102
    // Recursos estructurales TCB
    #define TCB_ACCION				101
    #define TCB_ESTADO				102
    #define TCB_MENUES				103
    #define TCB_MENUES1				104
    #define TCB_MENUES2				105
    // Botones de CTcbAcc
    #define TCB_BOTON0_BUT			200
    #define TCB_BOTON1_BUT			201
    #define TCB_BOTON2_BUT			202
    #define TCB_BOTON3_BUT			203
    #define TCB_BOTON4_BUT			204
    #define TCB_BOTON5_BUT			205
    #define TCB_BOTON6_BUT			206
    #define TCB_BOTON7_BUT			207
    #define TCB_BOTON8_BUT			208
    #define TCB_BOTON9_BUT			209
    #define TCB_BOTONA_BUT			210
    #define TCB_BOTONB_BUT			211
    #define TCB_BOTONC_BUT			212
    // Acciones posibles suministradas por CTcbAcc
    #define TCB_PRIMER				300
    #define TCB_SALIDA				300
    #define TCB_ACEPTA				301
    #define TCB_CANCEL				302
    #define TCB_NUEVOS				303
    #define TCB_CAMBIA				304
    #define TCB_BORRAR				305
    #define TCB_BUSCAR				306
    #define TCB_LISTAR				307
    #define TCB_IMPRIM				308
    #define TCB_EJECUT				309
    #define TCB_CONSUL				310
    #define TCB_AVANZA				311
    #define TCB_VUELVE				312
    #define TCB_TERMIN				313
    #define TCB_PREVIO				314
    #define TCB_ANULAR				315
    #define TCB_CALCUL				316
    #define TCB_GRABAR				317
    #define TCB_ENVIAR				318
    #define TCB_PROCES				331
    #define TCB_FICHER				336
    #define TCB_FINALI				390
    #define TCB_ULTIMA				399
    #define TCB_R                 10000
    #define TCB_E	              20000
    
    // Controles de CTcbEst
    #define TCB_ESTADO_STA			211
    #define TCB_ESTADO_PRO          212
    #define TCB_REDUCE_STA          213
    #define TCB_IMPRES_BUT          214
    // Opciones de menu
    #define IDD_PRIMER				1000
    #define IDD_ULTIMA				1999
    
    // Rotulos coloreados
    /*
    #define IDC_ROTULO_A00                  6000
    #define IDC_ROTULO_A01                  6001
    #define IDC_ROTULO_A02                  6002
    #define IDC_ROTULO_A03                  6003
    #define IDC_ROTULO_A04                  6004
    #define IDC_ROTULO_A05                  6005
    #define IDC_ROTULO_A06                  6006
    #define IDC_ROTULO_A07                  6007
    #define IDC_ROTULO_A08                  6008
    #define IDC_ROTULO_A09                  6009
    #define IDC_ROTULO_A10                  6010
    #define IDC_ROTULO_A11                  6011
    #define IDC_ROTULO_A12                  6012
    #define IDC_ROTULO_A13                  6013
    #define IDC_ROTULO_A14                  6014
    #define IDC_ROTULO_A15                  6015
    #define IDC_ROTULO_A16					6016
    #define IDC_ROTULO_A17					6017
    #define IDC_ROTULO_A18					6018
    #define IDC_ROTULO_A19					6019
    #define IDC_ROTULO_A20					6020
    #define IDC_ROTULO_A21					6021
    #define IDC_ROTULO_A22					6022
    #define IDC_ROTULO_A23					6023
    #define IDC_ROTULO_A24					6024
    #define IDC_ROTULO_A25					6025
    #define IDC_ROTULO_A26					6026
    #define IDC_ROTULO_A27					6027
    #define IDC_ROTULO_A28					6028
    #define IDC_ROTULO_A29					6029
    #define IDC_ROTULO_A30					6030
    #define IDC_ROTULO_A31					6031
    #define IDC_ROTULO_A32					6032
    #define IDC_ROTULO_A33					6033
    #define IDC_ROTULO_A34					6034
    #define IDC_ROTULO_A35					6035
    #define IDC_ROTULO_B00                  6100
    #define IDC_ROTULO_B01                  6101
    #define IDC_ROTULO_B02                  6102
    #define IDC_ROTULO_B03                  6103
    #define IDC_ROTULO_B04                  6104
    #define IDC_ROTULO_B05                  6105
    #define IDC_ROTULO_B06                  6106
    #define IDC_ROTULO_B07                  6107
    #define IDC_ROTULO_B08                  6108
    #define IDC_ROTULO_B09                  6109
    #define IDC_ROTULO_B10                  6110
    #define IDC_ROTULO_B11                  6111
    #define IDC_ROTULO_B12                  6112
    #define IDC_ROTULO_B13                  6113
    #define IDC_ROTULO_B14                  6114
    #define IDC_ROTULO_B15                  6115
    #define IDC_ROTULO_B16                  6116
    #define IDC_ROTULO_B17                  6117
    #define IDC_ROTULO_B18                  6118
    #define IDC_ROTULO_B19                  6119
    #define IDC_ROTULO_B20                  6120
    #define IDC_ROTULO_C00                  6200
    #define IDC_ROTULO_C01                  6201
    #define IDC_ROTULO_C02                  6202
    #define IDC_ROTULO_C03                  6203
    #define IDC_ROTULO_C04                  6204
    #define IDC_ROTULO_C05                  6205
    #define IDC_ROTULO_C06                  6206
    #define IDC_ROTULO_C07                  6207
    #define IDC_ROTULO_C08                  6208
    #define IDC_ROTULO_C09                  6209
    #define IDC_ROTULO_C10                  6210
    #define IDC_ROTULO_C11                  6211
    #define IDC_ROTULO_C12                  6212
    #define IDC_ROTULO_C13                  6213
    #define IDC_ROTULO_C14                  6214
    
    #define IDC_FONDOS_A00                  6600
    #define IDC_FONDOS_A01                  6601
    #define IDC_FONDOS_A02                  6602
    #define IDC_FONDOS_A03                  6603
    #define IDC_FONDOS_A04                  6604
    #define IDC_FONDOS_A05                  6605
    #define IDC_FONDOS_A06                  6606
    #define IDC_FONDOS_A07                  6607
    #define IDC_FONDOS_A08                  6608
    #define IDC_FONDOS_A09                  6609
    #define IDC_FONDOS_A10                  6610
    #define IDC_FONDOS_A11                  6611
    #define IDC_FONDOS_A12                  6612
    #define IDC_FONDOS_A13                  6613
    #define IDC_FONDOS_A14                  6614
    #define IDC_FONDOS_A15                  6615
    
    #define IDC_FONDOS_B00                  6700
    #define IDC_FONDOS_B01                  6701
    #define IDC_FONDOS_B02                  6702
    #define IDC_FONDOS_B03                  6703
    #define IDC_FONDOS_B04                  6704
    #define IDC_FONDOS_B05                  6705
    #define IDC_FONDOS_B06                  6706
    #define IDC_FONDOS_B07                  6707
    #define IDC_FONDOS_B08                  6708
    #define IDC_FONDOS_B09                  6709
    #define IDC_FONDOS_B10                  6710
    #define IDC_FONDOS_B11                  6711
    #define IDC_FONDOS_B12                  6712
    #define IDC_FONDOS_B13                  6713
    #define IDC_FONDOS_B14                  6714
    #define IDC_FONDOS_B15                  6715
    #define IDC_FONDOS_B16					6716
    #define IDC_FONDOS_B17                  6717
    #define IDC_FONDOS_B18                  6718
    */
    // Recursos de Menu
    #define TCB_AREAS0						400
    #define TCB_AREAS1						401
    #define TCB_AREAS2						402
    #define TCB_AREAS3						403
    #define TCB_AREAS4						404
    #define TCB_AREAS5						405
    #define TCB_AREAS6						406
    #define TCB_AREAS7						407
    #define TCB_OPCION00					410
    #define TCB_OPCION01					411
    #define TCB_OPCION02					412
    #define TCB_OPCION03					413
    #define TCB_OPCION04					414
    #define TCB_OPCION05					415
    #define TCB_OPCION06					416
    #define TCB_OPCION07					417
    #define TCB_OPCION08					418
    #define TCB_OPCION09					419
    #define TCB_OPCION10					420
    #define TCB_OPCION11					421
    #define TCB_OPCION12					422
    #define TCB_OPCION13					423
    #define TCB_OPCION14					424
    #define TCB_OPCION15					425
    #define TCB_OPCION16					426
    #define TCB_OPCION17					427
    #define TCB_OPCION18					428
    #define TCB_OPCION19					429
    #define TCB_OPCION20					430
    #define TCB_OPCION21					431
    #define TCB_OPCION22					432
    #define TCB_OPCION23					433
    #define TCB_LOGCIA						440
    #define TCB_MENSAJ1						441
    #define TCB_MENSAJ2						442
    #define TCB_MENSAJ3						443
    #define TCB_MENSAJ4						444
    #define TCB_TITULO						445
    #define TCB_AGENDA						446
    #define TCB_CUADRO						449
    
    // Iconos
    #define TCB_APLICA				1
    #define TCB_ESTADO0				2
    #define TCB_ESTADO1				3
    #define TCB_ESTADO2				4
    #define TCB_PRUEBA				5
    
    #define IDC_LISTAS_LIS			1002
    #define IDC_PRIMER			2000
    #define IDC_ULTIMO			2999
    

    Thursday, August 1, 2019 11:02 AM
  • Ok, you find the definitions.

    Maybe you have lost the #include "tcbres.h" in your source file? Or something else is different after converting the VS2003 resource to VS2017.

    Nevertheless, now it's getting clearer why there is Create(TCB_MENUES+bMenues):

    #define TCB_MENUES 103
    #define TCB_MENUES1 104
    #define TCB_MENUES2 105

    If bMenues is 0,1 or 2, the Create will work too. What is bMenues in your Debugger session? Are TCB_MENUES1 and TCB_MENUES2 defined in the rc-file and in the source file correctly?

    Regards, Guido

    Thursday, August 1, 2019 11:08 AM
  • Thursday, August 1, 2019 12:07 PM
  • Thursday, August 1, 2019 12:27 PM
  • Thursday, August 1, 2019 12:39 PM
  • Do you find TCB_MENUES1 and TCB_MENUES2 in the resource as dialogs too?

    When bMenues is 0, does Create(TCB_MENUES+bMenues) return FALSE?

    If so, you should try a switch like:

    wMenues=new TcbMen(this,bMenues,bTipMen);
    if (bMenues == 0)
      wMenues->Create(TCB_MENUES, this);
    else if (bMenues == 1)
      wMenues->Create(TCB_MENUES1, this);
    else if (bMenues == 2)
      wMenues->Create(TCB_MENUES2, this);
    else
    {
      AfxMessageBox(_T("error!"));
      return; // or whatever you want to handle the error
    }
    if (!nDirect) wMenues->ShowWindow(SW_SHOW);
    

    Regards, Guido

    Thursday, August 1, 2019 12:40 PM
  • TcbLib.rc

    TCB_MENUES1 DIALOGEX 0, 0, 550, 350
    STYLE DS_SETFONT | WS_CHILD
    FONT 8, "MS Sans Serif", 0, 0, 0x1
    BEGIN
        CONTROL         "",TCB_AREAS0,"Button",BS_OWNERDRAW | BS_RIGHT | NOT 
                        WS_VISIBLE | WS_TABSTOP,14,28,129,36
        CONTROL         "",TCB_AREAS1,"Button",BS_OWNERDRAW | BS_RIGHT | NOT 
                        WS_VISIBLE | WS_TABSTOP,14,65,129,33
        CONTROL         "",TCB_AREAS2,"Button",BS_OWNERDRAW | BS_RIGHT | NOT 
                        WS_VISIBLE | WS_TABSTOP,14,99,129,33
        CONTROL         "",TCB_AREAS3,"Button",BS_OWNERDRAW | BS_RIGHT | NOT 
                        WS_VISIBLE | WS_TABSTOP,14,133,129,33
        CONTROL         "",TCB_AREAS4,"Button",BS_OWNERDRAW | BS_RIGHT | NOT 
                        WS_VISIBLE | WS_TABSTOP,14,167,129,33
        CONTROL         "",TCB_AREAS5,"Button",BS_OWNERDRAW | BS_RIGHT | NOT 
                        WS_VISIBLE | WS_TABSTOP,14,201,129,33
        CONTROL         "",TCB_AREAS6,"Button",BS_OWNERDRAW | BS_RIGHT | NOT 
                        WS_VISIBLE | WS_TABSTOP,14,235,129,33
        CONTROL         "",TCB_AREAS7,"Button",BS_OWNERDRAW | BS_RIGHT | NOT 
                        WS_VISIBLE | WS_TABSTOP,14,269,129,33
        CONTROL         "",TCB_OPCION00,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_GROUP | WS_TABSTOP,162,31,115,33
        CONTROL         "",TCB_OPCION01,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,284,31,115,33
        CONTROL         "",TCB_OPCION02,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,406,31,115,33
        CONTROL         "",TCB_OPCION03,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,162,65,115,33
        CONTROL         "",TCB_OPCION04,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,284,65,115,33
        CONTROL         "",TCB_OPCION05,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,406,65,115,33
        CONTROL         "",TCB_OPCION06,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,162,99,115,33
        CONTROL         "",TCB_OPCION07,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,284,99,115,33
        CONTROL         "",TCB_OPCION08,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,406,99,115,33
        CONTROL         "",TCB_OPCION09,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,162,133,115,33
        CONTROL         "",TCB_OPCION10,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,284,133,115,33
        CONTROL         "",TCB_OPCION11,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,406,133,115,33
        CONTROL         "",TCB_OPCION12,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,162,167,115,33
        CONTROL         "",TCB_OPCION13,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,284,167,115,33
        CONTROL         "",TCB_OPCION14,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,406,167,115,33
        CONTROL         "",TCB_OPCION15,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,162,201,115,33
        CONTROL         "",TCB_OPCION16,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,284,201,115,33
        CONTROL         "",TCB_OPCION17,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,406,201,115,33
        PUSHBUTTON      "Apagar",TCB_FINALI,6,305,71,24
        PUSHBUTTON      "Agenda",TCB_AGENDA,81,305,71,24
        RTEXT           "",TCB_TITULO,160,1,361,24,SS_CENTERIMAGE | WS_BORDER
        CTEXT           "",TCB_MENSAJ3,162,305,359,24,SS_CENTERIMAGE | WS_BORDER
        GROUPBOX        "",TCB_CUADRO,6,21,146,284
        CONTROL         440,TCB_LOGCIA,"Static",SS_BITMAP,6,1,308,55
        CONTROL         "",TCB_OPCION18,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,162,235,115,33
        CONTROL         "",TCB_OPCION19,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,284,235,115,33
        CONTROL         "",TCB_OPCION20,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,406,235,115,33
        CONTROL         "",TCB_OPCION21,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,162,269,115,33
        CONTROL         "",TCB_OPCION22,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,284,269,115,33
        CONTROL         "",TCB_OPCION23,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,406,269,115,33
    END

    TCB_MENUES2 DIALOGEX 0, 0, 550, 350
    STYLE DS_SETFONT | WS_CHILD
    FONT 8, "MS Sans Serif", 0, 0, 0x1
    BEGIN
        CONTROL         "",TCB_OPCION00,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_GROUP | WS_TABSTOP,40,29,115,44,
                        WS_EX_CLIENTEDGE
        CONTROL         "",TCB_OPCION01,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_GROUP | WS_TABSTOP,162,29,115,44,
                        WS_EX_CLIENTEDGE
        CONTROL         "",TCB_OPCION02,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,284,29,115,44,
                        WS_EX_CLIENTEDGE
        CONTROL         "",TCB_OPCION03,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,406,29,115,44,
                        WS_EX_CLIENTEDGE
        CONTROL         "",TCB_OPCION04,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,40,75,115,44,
                        WS_EX_CLIENTEDGE
        CONTROL         "",TCB_OPCION05,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,162,75,115,44,
                        WS_EX_CLIENTEDGE
        CONTROL         "",TCB_OPCION06,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,284,75,115,44,
                        WS_EX_CLIENTEDGE
        CONTROL         "",TCB_OPCION07,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,406,75,115,44,
                        WS_EX_CLIENTEDGE
        CONTROL         "",TCB_OPCION08,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,40,121,115,44,
                        WS_EX_CLIENTEDGE
        CONTROL         "",TCB_OPCION09,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,162,121,115,44,
                        WS_EX_CLIENTEDGE
        CONTROL         "",TCB_OPCION10,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,284,121,115,44,
                        WS_EX_CLIENTEDGE
        CONTROL         "",TCB_OPCION11,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,406,121,115,44,
                        WS_EX_CLIENTEDGE
        CONTROL         "",TCB_OPCION12,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,40,166,115,44,
                        WS_EX_CLIENTEDGE
        CONTROL         "",TCB_OPCION13,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,162,167,115,44,
                        WS_EX_CLIENTEDGE
        CONTROL         "",TCB_OPCION14,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,284,167,115,44,
                        WS_EX_CLIENTEDGE
        CONTROL         "",TCB_OPCION15,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,406,167,115,44,
                        WS_EX_CLIENTEDGE
        CONTROL         "",TCB_OPCION16,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,40,213,115,44,
                        WS_EX_CLIENTEDGE
        CONTROL         "",TCB_OPCION17,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,162,213,115,44,
                        WS_EX_CLIENTEDGE
        CONTROL         "",TCB_OPCION18,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,284,213,115,44,
                        WS_EX_CLIENTEDGE
        CONTROL         "",TCB_OPCION19,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,406,213,115,44,
                        WS_EX_CLIENTEDGE
        CONTROL         "",TCB_OPCION20,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,40,259,115,44,
                        WS_EX_CLIENTEDGE
        CONTROL         "",TCB_OPCION21,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,162,259,115,44,
                        WS_EX_CLIENTEDGE
        CONTROL         "",TCB_OPCION22,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,284,259,115,44,
                        WS_EX_CLIENTEDGE
        CONTROL         "",TCB_OPCION23,"Button",BS_OWNERDRAW | BS_MULTILINE | 
                        NOT WS_VISIBLE | WS_TABSTOP,406,259,115,44,
                        WS_EX_CLIENTEDGE
        PUSHBUTTON      "Apagar",TCB_FINALI,6,305,71,24
        PUSHBUTTON      "Agenda",TCB_AGENDA,81,305,71,24
        RTEXT           "",TCB_TITULO,160,1,361,24,SS_CENTERIMAGE | WS_BORDER
        CTEXT           "",TCB_MENSAJ3,162,305,359,24,SS_CENTERIMAGE | WS_BORDER
        CONTROL         440,TCB_LOGCIA,"Static",SS_BITMAP,6,1,308,55
    END

    Thursday, August 1, 2019 12:52 PM
  • Thursday, August 1, 2019 1:14 PM
  • I don't understand why doesn't find TCB_MENUE?
    Friday, August 2, 2019 7:28 AM
  • I don't understand why doesn't find TCB_MENUE?

    I don't know. It worked before. Does he find the tcbres.h file? Before there was TCB_MENUES defined.

    When you right click TCB_MENUES1 or TCB_MENUES2 and select "Go to Definition", does it open the tcbres.h file? Is there TCB_MENUES in the file?

    Friday, August 2, 2019 8:02 AM
  • Yes, it find tcbres.h file. 

    Yes, it open TcbRes.h and TCB_MENUES is in the file -TcbRes.h. 

    Friday, August 2, 2019 8:35 AM
  • Yes, it find tcbres.h file. 

    Yes, it open TcbRes.h and TCB_MENUES is in the file -TcbRes.h. 

    I think it isn't a compiler error. The error is shown in the Watch-window. AFAIK the Watch-window only Shows variables. It doesn't show constants. So this is not a problem in your code.

    What is important to know is if your originial question is solved: does the Create return TRUE and does the ShowWindow work?

    Friday, August 2, 2019 9:47 AM
  • I think Create return FALSE and the ShowWindow is not work.
    Friday, August 2, 2019 11:41 AM
  • I think Create return FALSE and the ShowWindow is not work.
    Have you checked with the debugger?
    Friday, August 2, 2019 11:46 AM
  • Crack when I put breakpoint on the line -> 347 if (! NDirect) wMenues-> ShowWindow (SW_SHOW);

    Friday, August 2, 2019 12:07 PM
  • Crack when I put breakpoint on the line -> 347 if (! NDirect) wMenues-> ShowWindow (SW_SHOW);

    This is the same as in the beginning of your post. It does not help me. You must stop before the assertion comes and check the variables. Stop at the create, step over it, check the return value. I think it is FALSE as in the beginning. Use the switch instead and check the return value of Create.
    Friday, August 2, 2019 12:47 PM
  • Friday, August 2, 2019 1:21 PM
  • It seems that the OP is working with a dll.  If the dialog resource is in the dll, then the code that creates the dialog should use AfxGetResourceHandle and AfxSetResourceHandle  to manage the HINSTANCE that MFC uses to find resources.  Perhaps the call to Create fails because MFC is looking for the dialog resource in the executable instead of in the dll.
    Friday, August 2, 2019 1:34 PM
  • Monday, August 5, 2019 1:47 PM
  • I read about AfxGetResourceHandle and AfxSetResourceHandle because I don't know do use them.

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/ef4b51dc-4641-4e38-813e-c893f84dd399/why-afxgetresourcehandle-causes-asserts?forum=vclanguage

     

    Does the function that creates modeless dialog reside in the .exe?

    Is the dialog resource used by the function in the .exe or in a dll?

    Monday, August 5, 2019 2:45 PM
  • Yes the function creates modeless dialog reside in the .exe.

    Dialog resource used by the function in the .dll

    Tuesday, August 6, 2019 7:19 AM
  • Following example demonstrates usage of AfxGetResourceHandle and AfxSetResourceHandle.  Error checking is omitted.

    HINSTANCE hOld = AfxGetResourceHandle();  // Save resource handle of exe
    HINSTANCE hResource = GetModuleHandle(L"ResLib.dll");  // Assumes dll is already loaded, could also use LoadLibrary
    AfxSetResourceHandle(hResource);  // Set resource handle to dll for dialog resource load
    CModeless *pdlg = new CModeless;
    pdlg->Create(IDD_DIALOG1);
    pdlg->ShowWindow(SW_SHOW);
    AfxSetResourceHandle(hOld);  // Restore handle
    

    Tuesday, August 6, 2019 9:52 AM
  • dlgcore.cpp

    INT_PTR CDialog::DoModal()
    {
    // can be constructed with a resource template or InitModalIndirect
    ASSERT(m_lpszTemplateName != NULL || m_hDialogTemplate != NULL ||
    m_lpDialogTemplate != NULL);

    // load resource as necessary
    LPCDLGTEMPLATE lpDialogTemplate = m_lpDialogTemplate;
    HGLOBAL hDialogTemplate = m_hDialogTemplate;
    HINSTANCE hInst = AfxGetResourceHandle();
    if (m_lpszTemplateName != NULL)
    {
    hInst = AfxFindResourceHandle(m_lpszTemplateName, RT_DIALOG);
    HRSRC hResource = ::FindResource(hInst, m_lpszTemplateName, RT_DIALOG);
    hDialogTemplate = LoadResource(hInst, hResource);
    }
    if (hDialogTemplate != NULL)
    lpDialogTemplate = (LPCDLGTEMPLATE)LockResource(hDialogTemplate);

    // return -1 in case of failure to load the dialog template resource
    if (lpDialogTemplate == NULL)
    return -1;

    // disable parent (before creating dialog)
    HWND hWndParent = PreModal();
    AfxUnhookWindowCreate();
    BOOL bEnableParent = FALSE;
    CWnd* pMainWnd = NULL;
    BOOL bEnableMainWnd = FALSE;
    if (hWndParent && hWndParent != ::GetDesktopWindow() && ::IsWindowEnabled(hWndParent))
    {
    ::EnableWindow(hWndParent, FALSE);
    bEnableParent = TRUE;
    pMainWnd = AfxGetMainWnd();
    if (pMainWnd && pMainWnd->IsFrameWnd() && pMainWnd->IsWindowEnabled())
    {
    //
    // We are hosted by non-MFC container
    // 
    pMainWnd->EnableWindow(FALSE);
    bEnableMainWnd = TRUE;
    }
    }


    • Edited by Altun Murat Tuesday, August 6, 2019 10:19 AM
    Tuesday, August 6, 2019 10:16 AM
  • What are you trying to say?
    Tuesday, August 6, 2019 10:22 AM
  • dlgcore.cpp

    BOOL CDialog::Create(LPCTSTR lpszTemplateName, CWnd* pParentWnd)
    {
    ASSERT(IS_INTRESOURCE(lpszTemplateName) ||
    AfxIsValidString(lpszTemplateName));

    m_lpszTemplateName = lpszTemplateName;  // used for help
    if (IS_INTRESOURCE(m_lpszTemplateName) && m_nIDHelp == 0)
    m_nIDHelp = LOWORD((DWORD_PTR)m_lpszTemplateName);

    #ifdef _DEBUG
    if (!_AfxCheckDialogTemplate(lpszTemplateName, FALSE))
    {
    ASSERT(FALSE);          // invalid dialog template name
    PostNcDestroy();        // cleanup if Create fails too soon
    return FALSE;
    }
    #endif //_DEBUG

    HINSTANCE hInst = AfxFindResourceHandle(lpszTemplateName, RT_DIALOG);
    HRSRC hResource = ::FindResource(hInst, lpszTemplateName, RT_DIALOG);
    HGLOBAL hTemplate = LoadResource(hInst, hResource);
    BOOL bResult = CreateIndirect(hTemplate, pParentWnd, hInst);
    FreeResource(hTemplate);

    return bResult;
    }

    Tuesday, August 6, 2019 10:24 AM
  • Yes, since the resource is in the dll and not in the exe it does not find the dialog resource.  That is the problem addressed by the example code that I posted.

    Did you try it?

    Tuesday, August 6, 2019 10:27 AM
  • Where should I try it, because HINSTANCE hInst = AfxGetResourceHandle (); is in the dlgcore.cpp file that is part of Visual Studio 2017

     C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\atlmfc\src\mfc\dlgcore.cpp(216):HINSTANCE hInst = AfxGetResourceHandle();

     C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\atlmfc\src\mfc\dlgcore.cpp(594): HINSTANCE hInst = AfxFindResourceHandle(lpszTemplateName, RT_DIALOG);

    Tuesday, August 6, 2019 10:48 AM
  • It goes in your code for the executable wherever you try to create and show a modeless dialog where the dialog resource is in a dll.

    Tuesday, August 6, 2019 10:56 AM
  • I think you're talking about this function:

    TcbBdd.cpp

    CString CTcbBdd::Cadena()
    {
    TCHAR buffer[_MAX_PATH];
    if (GetModuleFileName(AfxGetApp()->m_hInstance,buffer,sizeof buffer))
    {
    CString Nombre(buffer);
    Nombre.Replace(".exe",".tcb");
    CFile Ficher;//VBN
    if(!Ficher.Open(Nombre,CFile::modeRead)) //VBN
    {
    AfxMessageBox("File not found or Access denied");
    return "";
    } //VBN
    int lon=Ficher.Read(buffer,sizeof buffer);
    buffer[lon]=0;
    Nombre=buffer;
    int numero=Nombre.Find('|');
    CString usuari=Nombre.Left(numero);
    CString claves=Nombre.Right(Nombre.GetLength()-numero-1);
    return CString("DSN=")+zNomBdd+CString(";UID=")+usuari+CString(";PWD=")+claves;
    }
    return CString();
    }

    Tuesday, August 6, 2019 11:12 AM
  • Why would you think that?  Is there any code in that function to create and show a modeless dialog?
    Tuesday, August 6, 2019 11:50 AM
  • TcbApl.cpp

    void CTcbMar::CreaMarco2()
    {
    wOpcion=NULL;
    /*wMenues=new CTcbMen(this,bMenues,bTipMen);
    wMenues->Create(TCB_MENUES+bMenues,this);
    if (!nDirect) wMenues->ShowWindow(SW_SHOW);*/
    wMenues = new CTcbMen(this, bMenues, bTipMen);
    if (bMenues == 0)
    wMenues->Create(TCB_MENUES, this);
    else if (bMenues == 1)
    wMenues->Create(TCB_MENUES1, this);
    else if (bMenues == 2)
    wMenues->Create(TCB_MENUES2, this);
    else
    {
    AfxMessageBox(_T("error!"));
    return; // or whatever you want to handle the error
    }
    if (!nDirect) wMenues->ShowWindow(SW_SHOW);
    wAccion=new CTcbAcc(this);
    wAccion->Create(TCB_ACCION,this);
    wAccion->MoveWindow(rAccion);
    wAccion->ShowWindow(SW_HIDE);
    wEstado=new CTcbEst();
    wEstado->Create(TCB_ESTADO,this);
    wEstado->MoveWindow(rEstado);
    wEstado->ShowWindow(SW_HIDE);
    if (!nDirect) wMenues->SetFocus();
    }

    Tuesday, August 6, 2019 12:25 PM
  • Ok, you found what appears to be the creation of modeless dialogs.  Now what are you going to do?
    Tuesday, August 6, 2019 12:30 PM
  • CModeless *pdlg = new CModeless; -> is undefined

    IDD_DIALOG1 -> is undefined

    Tuesday, August 6, 2019 12:30 PM
  • CModeless *pdlg = new CModeless; -> is undefined

    IDD_DIALOG1 -> is undefined

    You cannot simply copy code from an example and expect it to work in your own projects.  You need to understand the concept in the example and adapt it to your particular circumstance.
    Tuesday, August 6, 2019 12:31 PM
  • I read and I hope I understood how to adapt the part with: AfxGetResourceHandle(); & GetModuleHandle

    I didn't understand the part with CModeless although I read: http://www.flounder.com/kb103788.htm

    Wednesday, August 7, 2019 1:18 PM
  • I read and I hope I understood how to adapt the part with: AfxGetResourceHandle(); & GetModuleHandle

    I didn't understand the part with CModeless although I read: http://www.flounder.com/kb103788.htm

    You are working with an MFC application and modeless dialogs.  Your code must certainly have one or more classes derived from CDialog(Ex) that are being used.  In the example I gave CModeless is such a class.
    Wednesday, August 7, 2019 2:17 PM
  • /*****************************************************************************************/
    /*                Ares825.h                                        */
    /*                                                                      */
    /*                               Definición Plan Contable                                */
    /*                                                                                  */
    /*****************************************************************************************/

    class D825 : public CDialog
    {
    public:
    D825();
    CString tCuenta1,tCuenta2;
    long nNivels1,nNivels2,nNivels3,nNivels4,nNivels5,nNivels6;
    void DoDataExchange(CDataExchange* pDX);
    BOOL OnInitDialog();
    };
    class P825 : public CTcbPan
    {
    private:
    void Inicio();
    void Pantalla();
    CTreeCtrl wArbole;
    CTcbInf gTcbInf;
    CString tCuenta,tSubCta,tTipCta;
    CString tTipCue,gTitulo1;
    CString tCuenta1,tCuenta2,tNivels;
    HTREEITEM xGrupos[5],xCuenta;
    int nGrupos,bOpcion;
    long bAccion,cCuenta;

    bool Valida();
    void LlenaArbol();
    void Calcula();
    void LlenaCuenta(int n);
    void OnSelecCta(NMHDR* pNotifyStruct,LRESULT* result);
    void LlenaLista();
    void OnSelecc();
    void OnNuevos();
    void TipoCuenta();
    void OnCambia();
    void OnBorrar();
    void OnAcepta();
    void OnCancel();
    void Habilita(bool hab);
    void HabTipo(bool hab);
    void OnImprim();
    void Imprim();
    bool Informe();
    DECLARE_MESSAGE_MAP();
    };
    Thursday, August 8, 2019 11:19 AM
  • What kind of response do you expect to receive to a post that only contains a code listing?
    Thursday, August 8, 2019 12:00 PM
  • Hi, I don't understand why it doesn't recognize TCB_MENUES although I introduced it at the beginning of the program #include "Tcbres.h" which defines #define TCB_MENUES 103 ?


    Friday, August 9, 2019 6:56 AM
  • Hi, I don't understand why it doesn't recognize TCB_MENUES although I introduced it at the beginning of the program #include "Tcbres.h" which defines #define TCB_MENUES 103 ?


    You have asked this question here: https://social.msdn.microsoft.com/Forums/en-US/543ece50-f420-4bc1-899a-f3190dfdbda9/error-in-showwindowswshow?forum=vcgeneral

    That an alias cannot be displayed in the Watch window is not the problem of your task of opening a modeless Dialog that is defined in a dll.

    I still think there is something in the programme that does not work so that the Dialogs are not shown. I suggest you to write a small example code where you use the dll and open the Dialog. Use the source commands that RLWA32 suggested. If you have problems with your small example programme then ask again in the forum and show what you have programmed.

    Regards, Guido

    Friday, August 16, 2019 8:09 AM
  • I made a small example program and I had error in pdlg-&gt; create(IDD_DIALOG1, this);

    Monday, August 19, 2019 11:48 AM
  • I made a small example program and I had error in pdlg-&gt; create(IDD_DIALOG1, this);

    The above displays a lack of understanding about general concepts.

    1)  It appears to be using a console application.  Of course, it does not contain a message pump that is necessary for a modeless dialog.

    2)  The CModeless class is an incorrect derivation from CDialog for an MFC modeless dialog.  By default, MFC's CDialog(Ex) classes call EndDialog when the virtual OnOK and OnCancel functions are invoked.  They must be overridden for a modeless dialog.   For example, see https://docs.microsoft.com/en-us/cpp/mfc/reference/cdialog-class?view=vs-2019#onok Read about MFC modeless dialogs again.

    3)  I won't bother about the various error messages displayed in the image.  Start again by creating a minimal MFC dialog-based application.  Use the Add Class wizard to add a class derived from MFC's CDialog(Ex) and implement the necessary overrides.  Add a button to your main dialog and in the handler for the button click insert the code to instantiate, create and display the modeless dialog.


    • Edited by RLWA32 Monday, August 19, 2019 12:19 PM typos
    Monday, August 19, 2019 12:02 PM
  • Tuesday, August 20, 2019 9:45 AM
  • AfxMessageBox is not a modeless dialog. What do you want to ask about this project?
    Tuesday, August 20, 2019 9:49 AM
  • I took a project with Modeless Dialogs with MFC but it does not work.
    Tuesday, August 20, 2019 10:24 AM
  • I took a project with Modeless Dialogs with MFC but it does not work.
    This is meaningless.  Go back and re-read point 3) in my earlier comment.  You must create a class for an MFC modeless dialog IN THE PROJECT FOR THE MFC DIALOG-BASED APPLICATION.
    Tuesday, August 20, 2019 10:28 AM
  • I took a project with Modeless Dialogs with MFC but it does not work.

    You cannot choose a project with modeless dialogs. You can only insert modeless dialogs into your SDI/MDI/dialog-based application.

    Regarding your last example code: instead of AfxMessageBox, you must insert the code for a modeless dialog as already suggested here before.

    It seems to me, as if you don't understand what we try to explain to you so far. Maybe you should read for example this tutorial on how to use modeless dialogs: https://www.codeproject.com/Articles/1651/Tutorial-Modeless-Dialogs-with-MFC

    When you know how to insert a modeless dialog from the project resource, then you can go on and insert the modeless dialog from your dll.

    Regards, Guido


    Tuesday, August 20, 2019 10:41 AM
  • Instead of AfxMessageBox, insert your code to open the modeless dialog.
    Tuesday, August 20, 2019 10:53 AM