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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Help testing a CDialog based class

Help testing a CDialog based class

Scheduled Pinned Locked Moved C / C++ / MFC
c++helptestingbeta-testingquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bulg
    wrote on last edited by
    #1

    I'm having trouble using the code that MFC app-wizard spits out for a custom dialog as the base class for another few custom dialogs. My problem is that I can't seem to write (or borrow) the simplest app possible that is able to instantiate one of my dialog classes. I copied Nishant Sivakumar's simplest MFC app in the world, FirstProg.zip, from somewhere on the internet, which looks something like this:

    //NWinApp.h
    class CNWinApp : public CWinApp
    {
    public:
    BOOL InitInstance();
    };

    //NWinApp.cpp
    #include #include "NWinApp.h"

    CNWinApp app;

    BOOL CNWinApp::InitInstance()
    {
    CFrameWnd *pnframe=new CFrameWnd;
    m_pMainWnd=pnframe;
    pnframe->Create(0,"Buster");
    pnframe->ShowWindow(SW_SHOW);
    return TRUE;
    }

    This also looks like the generic code for testing a CDialog based class generated by MFC AppWizard. I replaced the CFrameWnd bit like this

    CMyGuiDlg *pGuiDlg= new CMyGuiDlg;
    m_pMainWnd=pGuiDlg;
    pGuiDlg->DoModal();
    return TRUE;

    I can compile & run this project, and nothing shows up on the screen. If I compile and run the original AppWizard-produced project, the dialog (CMyGuiDlg) will show up no problem. I've also tried to write my own CWinApp derivation in a Win32Console App project, and got it to compile & run by calling _tWinMain(...), however my program was exiting as fast as it started. I think I need to use CWinApp as the basis for my program, and AfxWinMain(...). What am I missing? Currently I have resorted to creating all the dialog derivations in the same project, so that I can use the AppWizard generated test files to run them. I had hoped I could have a different project for each derivation.

    I 1 Reply Last reply
    0
    • B bulg

      I'm having trouble using the code that MFC app-wizard spits out for a custom dialog as the base class for another few custom dialogs. My problem is that I can't seem to write (or borrow) the simplest app possible that is able to instantiate one of my dialog classes. I copied Nishant Sivakumar's simplest MFC app in the world, FirstProg.zip, from somewhere on the internet, which looks something like this:

      //NWinApp.h
      class CNWinApp : public CWinApp
      {
      public:
      BOOL InitInstance();
      };

      //NWinApp.cpp
      #include #include "NWinApp.h"

      CNWinApp app;

      BOOL CNWinApp::InitInstance()
      {
      CFrameWnd *pnframe=new CFrameWnd;
      m_pMainWnd=pnframe;
      pnframe->Create(0,"Buster");
      pnframe->ShowWindow(SW_SHOW);
      return TRUE;
      }

      This also looks like the generic code for testing a CDialog based class generated by MFC AppWizard. I replaced the CFrameWnd bit like this

      CMyGuiDlg *pGuiDlg= new CMyGuiDlg;
      m_pMainWnd=pGuiDlg;
      pGuiDlg->DoModal();
      return TRUE;

      I can compile & run this project, and nothing shows up on the screen. If I compile and run the original AppWizard-produced project, the dialog (CMyGuiDlg) will show up no problem. I've also tried to write my own CWinApp derivation in a Win32Console App project, and got it to compile & run by calling _tWinMain(...), however my program was exiting as fast as it started. I think I need to use CWinApp as the basis for my program, and AfxWinMain(...). What am I missing? Currently I have resorted to creating all the dialog derivations in the same project, so that I can use the AppWizard generated test files to run them. I had hoped I could have a different project for each derivation.

      I Offline
      I Offline
      Iain Clarke Warrior Programmer
      wrote on last edited by
      #2

      When you say nothing appears... does the app actially close? You can debug the program line by line. My guess is that you forgot to set the WS_VISIBLE bit in your dialog settings... Iain.

      Codeproject MVP for C++, I can't believe it's for my lounge posts...

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

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