[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

must CListBox::InsertString() be called on the dialog's onInitDialog?

Posted on 2005-04-05
20
Medium Priority
?
758 Views
Last Modified: 2013-11-20
I have a dialog, on there it has a listbox, with a control called m_output;

I have another class, that calls the parent class (that contains an obj of the dialog)...and I want to print out some data to the list box inside this class:

ie

class CMainDlg
{
.
.
.
Cchild m_child;
.
.
.
}


someclass::someFunc(...)
{

     // crashes on this line
    // note: m_output is a CListBox
    // m_child is an object of a dialog
    // someclass is not a dialog, just a regular class
   ((CMainDlg*)AfxGetMainWnd())->m_child.m_output.InsertString(-1, "my string");   }
}

am I not initializing something somewhere to cause it to crash?

0
Comment
Question by:jade03
  • 10
  • 7
  • 2
  • +1
20 Comments
 
LVL 11

Expert Comment

by:KurtVon
ID: 13710360
Yes, something isn't being initialized, but I can't guess what.  The simple solution is just to assert all your assumptions and see what happens:

someclass::someFunc(...)
{
    ASSERT(AfxGetMainWnd() != NULL);  // main window is created
    ASSERT(((CMainDlg*)AfxGetMainWnd())->m_child.GetSafeHwnd());  // Dialog is created
    ASSERT(((CMainDlg*)AfxGetMainWnd())->m_child.m_output.GetSafeHwnd()); // list box is subclassed
    ((CMainDlg*)AfxGetMainWnd())->m_child.m_output.InsertString(-1, "my string");
}

Once you know what is not initialized, you need to figure out how to handle it.

Hope this helps.
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 13711247
You have to create control first, MFC constructors doesn't create the GDI object really, this is done when corresponding Create() function is called.
0
 
LVL 14

Expert Comment

by:wayside
ID: 13711521
Add a function to your dialog class that will store a list of strings, then add them in OnInitDialog:

class CChild {
...

 CStringArray outputlist;

 void AddMyString(const wchar_t* str) { outputlist.Add(str) }


}

then in OnInitDialog:

for (int i=0; i<outputlist.GetSize(); i++) {
   m_output.InsertString(-1, outputlist[i]);
}


Then in your other code your can do this:

someclass::someFunc(...)
{

     // crashes on this line
    // note: m_output is a CListBox
    // m_child is an object of a dialog
    // someclass is not a dialog, just a regular class
   ((CMainDlg*)AfxGetMainWnd())->m_child.AddMyString("my string");
}

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:jade03
ID: 13712234
wayside,

 i'm a bit confused on the order of things working from what you have...I thought OnInitDialog() is called when the dialog is created? In your code it looks like it will populate m_output only if outputlist has something in there, and it won't have anythign in there until someFunc adds it in...I guess I just dont' understand when OnInitDialog() gets executed...
0
 

Author Comment

by:jade03
ID: 13712363
jaime_olivares,

I thought the control is already created when I added the member variable to the box? This should mean the same as explicitly calling CListBox::Create() right?
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 13712386
>I thought the control is already created when I added the member variable to the box? This should mean the same as explicitly calling CListBox::Create() right?

NO.
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 13712413
It is really hard to figure out what it happening in your code because you has sent too few information (source code). Will be better for you to share more with us.

It is a common error to think that will be enough to put a control as a member and will automatically be created because you have put a control in the dialog template.
Standard MFC solution for this is to create control as a dialog's "member variable", using the ClassWizard tool. The creation and relation between MFC object and true control will be done trough DoDataExchange() function.
0
 
LVL 14

Expert Comment

by:wayside
ID: 13715736
Is your dialog modal or modeless?

If modal, the controls aren't actually created until the DoModal() call, which means you can't put text directly in them before you have called DoModal(). That's why I suggested using a CStringArray to hold the text until the control is actually created, and then populating the control in OnInitDialog(). OnInitDialog() is called at some point after the dialog is created (actually, in response to a WM_INITDIALOG message), and is really the first place where you can assume that the controls have actually been created,

If your dialog is modeless, the controls aren't created until the Create() call. So you can't put text directly in the control until after the Create() call.

And, as Jaime pointed out, the control variable has to be tied to the control via some code in the DoDataExchange() function in your dialog class. If you added the control variable via Class Wizard you should be all set, otherwise you will need to add a DDX_Control() call by hand.
0
 

Author Comment

by:jade03
ID: 13717748
wayside,

I had actually inherited the structure of the code from someone, so I'm not sure if the dialog is modal or modeless; I assume it is modeless because the only place DoModal() is called is in the main dialog, not any of the child dialogs. But I had created my control in the child dialog using the class wizard, and inside the DoDataExchange() function I see the control variable is already tied to the control.

I also tried inserting the AddString() call inside the main class's OnInitDialog() method, and still I get an assertion...

because there are quite a few dialogs involved, it's hard for me to paste all the code here...that's why I've chosen to simplify it by putting only what's relevant earlier...but if you need more info, I'll try to see if I can paste more code...
0
 

Author Comment

by:jade03
ID: 13719925
k, here's the gist of my code...

look mainly at my main dialog's OnInitDialog func where I try to call AddString() and my

OnReceive() function where I try to use InsertString()

those are the places where the program crashes...


**************
main dialog header
**************
// MyTabExampleDlg.h : header file
//

#if !defined(AFX_MYTABEXAMPLEDLG_H__15269A97_2EC1_4F60_B247_3F634C1AAE19__INCLUDED_)
#define AFX_MYTABEXAMPLEDLG_H__15269A97_2EC1_4F60_B247_3F634C1AAE19__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "MyTabCtrl.h"
#include "myAsyncSocket.h"

class CTabOne;
class TabFive;

/////////////////////////////////////////////////////////////////////////////
// CMyTabExampleDlg dialog

class CMyTabExampleDlg : public CDialog
{
      // Construction
public:
      CMyTabExampleDlg(CWnd* pParent = NULL);      // standard constructor

      myAsyncSocket *m_socket;
      CString m_appTitle;

// Dialog Data
      //{{AFX_DATA(CMyTabExampleDlg)
      enum { IDD = IDD_MYTABEXAMPLE_DIALOG };
      CMyTabCtrl      m_tabMyTabCtrl;
      //}}AFX_DATA

      // ClassWizard generated virtual function overrides
      //{{AFX_VIRTUAL(CMyTabExampleDlg)
      protected:
      virtual void DoDataExchange(CDataExchange* pDX);      // DDX/DDV support
      //}}AFX_VIRTUAL

protected:
      HICON m_hIcon;

      // Generated message map functions
      //{{AFX_MSG(CMyTabExampleDlg)
      virtual BOOL OnInitDialog();
      afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
      afx_msg void OnPaint();
      afx_msg HCURSOR OnQueryDragIcon();
      //}}AFX_MSG
      DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_MYTABEXAMPLEDLG_H__15269A97_2EC1_4F60_B247_3F634C1AAE19__INCLUDED_)

**********************************************************************
main dialog implementation - MyTabExampleDlg.cpp
**********************************************************************
#include "stdafx.h"
#include "MyTabExample.h"
#include "MyTabExampleDlg.h"
#include "TabOne.h"
#include "TabFive.h"
#include "TabThree.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

class CAboutDlg : public CDialog
{
public:
      CAboutDlg();

// Dialog Data
      //{{AFX_DATA(CAboutDlg)
      enum { IDD = IDD_ABOUTBOX };
      //}}AFX_DATA

      // ClassWizard generated virtual function overrides
      //{{AFX_VIRTUAL(CAboutDlg)
      protected:
      virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
      //}}AFX_VIRTUAL

// Implementation
protected:
      //{{AFX_MSG(CAboutDlg)
      //}}AFX_MSG
      DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
      //{{AFX_DATA_INIT(CAboutDlg)
      //}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
      CDialog::DoDataExchange(pDX);
      //{{AFX_DATA_MAP(CAboutDlg)
      //}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
      //{{AFX_MSG_MAP(CAboutDlg)
            // No message handlers
      //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyTabExampleDlg dialog

CMyTabExampleDlg::CMyTabExampleDlg(CWnd* pParent /*=NULL*/)
      : CDialog(CMyTabExampleDlg::IDD, pParent)
{
      //{{AFX_DATA_INIT(CMyTabExampleDlg)
            // NOTE: the ClassWizard will add member initialization here
      //}}AFX_DATA_INIT
}

void CMyTabExampleDlg::DoDataExchange(CDataExchange* pDX)
{
      CDialog::DoDataExchange(pDX);
      //{{AFX_DATA_MAP(CMyTabExampleDlg)
      DDX_Control(pDX, IDC_MY_TAB, m_tabMyTabCtrl);
      //}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CMyTabExampleDlg, CDialog)
      //{{AFX_MSG_MAP(CMyTabExampleDlg)
      ON_WM_SYSCOMMAND()
      ON_WM_PAINT()
      ON_WM_QUERYDRAGICON()
      //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyTabExampleDlg message handlers

BOOL CMyTabExampleDlg::OnInitDialog()
{
      CDialog::OnInitDialog();

      // Add "About..." menu item to system menu.

      // IDM_ABOUTBOX must be in the system command range.
      ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
      ASSERT(IDM_ABOUTBOX < 0xF000);

      CMenu* pSysMenu = GetSystemMenu(FALSE);
      if (pSysMenu != NULL)
      {
            CString strAboutMenu;
            strAboutMenu.LoadString(IDS_ABOUTBOX);
            if (!strAboutMenu.IsEmpty())
            {
                  pSysMenu->AppendMenu(MF_SEPARATOR);
                  pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
            }
      }

      // Set the icon for this dialog.  The framework does this automatically
      //  when the application's main window is not a dialog
      SetIcon(m_hIcon, TRUE);                  // Set big icon
      SetIcon(m_hIcon, FALSE);            // Set small icon
      
      // initialize tab titles
      m_tabMyTabCtrl.InsertItem(0, _T("Start Up"));
      m_tabMyTabCtrl.InsertItem(1, _T("OLSR Config"));
      m_tabMyTabCtrl.InsertItem(2, _T("Client Config"));
      m_tabMyTabCtrl.InsertItem(3, _T("Outputs"));


      CString err;
      WSADATA wsaData;

      SetWindowText(m_appTitle);
      UpdateData(FALSE);

      if (WSAStartup(0x202,&wsaData) == SOCKET_ERROR)
      {
            err.Format("WSAStartup failed with error %d\n",WSAGetLastError());
            AfxMessageBox(err);
            WSACleanup();
            return FALSE;
      }

      m_socket = new myAsyncSocket();
      
      if(!m_socket->Create())
      {
            err.Format("can't create socket due to this error: %d\n", WSAGetLastError());
            AfxMessageBox(err);
            return FALSE;
      }

      if(!m_socket->Connect())
      {      
            err.Format("can't connect socket due to this error: %d\n", WSAGetLastError());
            AfxMessageBox(err);;
            return FALSE;
      }

            // create tabs
      m_tabMyTabCtrl.Init();

            // initialize tab five listbox
      //m_tabFive.m_clientOutput.AddString("");  <---------------------------------FAILS HERE
      
      return TRUE;  // return TRUE  unless you set the focus to a control
}

void CMyTabExampleDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
      if ((nID & 0xFFF0) == IDM_ABOUTBOX)
      {
            CAboutDlg dlgAbout;
            dlgAbout.DoModal();
      }
      else
      {
            CDialog::OnSysCommand(nID, lParam);
      }
}

**********************************************************************
child dialog header
**********************************************************************
#pragma once

class TabFive : public CDialog
{
      DECLARE_DYNAMIC(TabFive)

public:
      TabFive(CWnd* pParent = NULL);   // standard constructor
      virtual ~TabFive();

// Dialog Data
      enum { IDD = IDD_TABFIVE };

protected:
      virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

      DECLARE_MESSAGE_MAP()
public:
      CListBox m_clientOutput;
};

**********************************************************************
child dialog implementation - TabFive.cpp
**********************************************************************
#include "stdafx.h"
#include "MyTabExample.h"
#include "TabFive.h"
#include "MyTabExampleDlg.h"
#include "tabfive.h"
#include ".\tabfive.h"

IMPLEMENT_DYNAMIC(TabFive, CDialog)
TabFive::TabFive(CWnd* pParent /*=NULL*/)
      : CDialog(TabFive::IDD, pParent)
{

}

TabFive::~TabFive()
{
}

void TabFive::DoDataExchange(CDataExchange* pDX)
{
      CDialog::DoDataExchange(pDX);
      DDX_Control(pDX, IDC_LIST_OUTPUT, m_clientOutput);
}


BEGIN_MESSAGE_MAP(TabFive, CDialog)
END_MESSAGE_MAP()

**********************************************************************
regular class header - myAsyncSocket.h **********************************************************************
#ifndef MY_ASYNC_SOCKET_H
#define MY_ASYNC_SOCKET_H

#include <windows.h>
#include <winsock.h>
#include <string>
#include <afxsock.h>

#include "resource.h"
class CMyTabExampleDlg;

#define  WTRP_STATE_FLOATING          0x01
#define  WTRP_STATE_OFFLINE           0x02
#define  WTRP_STATE_SOLICITING        0x03
#define  WTRP_STATE_IDLE              0x04
#define  WTRP_STATE_MONITORING        0x05
#define  WTRP_STATE_HAVE_TOKEN        0x06
#define  WTRP_STATE_JOINING           0x07
#define  WTRP_STATE_PASS_NEW_TOKEN    0x09
#define  WTRP_STATE_RELAYING          0x0b
#define  WTRP_STATE_RELAY_MONITORING  0x0c
#define  WTRP_STATE_SELF_RING         0x0f
#define  WTRP_STATE_SEEKING           0x10
#define  WTRP_STATE_PAIRING           0x20


class myAsyncSocket : public CAsyncSocket  
{
public:

      // Constructor
      myAsyncSocket();

    // Destructor
  ~myAsyncSocket();

  void OnReceive(int nErrorCode);
  BOOL SendTo(const void* strMessage, int nSize);

  int m_port;
  CString m_host;
  char m_strBuffer[1024*32];
  CString m_strRecv;

  void Close();
  BOOL Connect();
  BOOL ChkRecvOK(int numBytes);

};

#endif

**********************************************************************
regular class implementation - myAsyncSocket.cpp
**********************************************************************
#include "stdafx.h"
#include "myAsyncSocket.h"
#include "MyTabExampleDlg.h"
#include "Math.h"

myAsyncSocket::myAsyncSocket()
{
            // initialize port and host info
            // with user entered values, or
            // if user does not enter values,
            // get old value from config file
            //
            // _ttoi changes cstring to int
      m_port =  _ttoi(((CMyTabExampleDlg*)AfxGetMainWnd())->m_tabOne.m_tabone_portNum);
                m_host = ((CMyTabExampleDlg*)AfxGetMainWnd())->m_tabOne.m_tabone_hostName;
}

myAsyncSocket::~myAsyncSocket()
{
      Close();
}

BOOL myAsyncSocket::SendTo(const void* strMessage, int nSize)
{
         // do something
        return TRUE;
}

void myAsyncSocket::OnReceive(int nErrorCode)
{
      int nNumBytes;
      int buffLen = 1;
      //char *buffPtr;
      
      //AfxMessageBox("inside onReceive");

      ZeroMemory(m_strBuffer,1024*32);

      //buffPtr = m_strBuffer;

            // if successful, Receive() returns
            // number of bytes received
      //nNumBytes = Receive(buffPtr, buffLen);
      nNumBytes = Receive(m_strBuffer, buffLen);

            // successful receive
      if(ChkRecvOK(nNumBytes))
      {
               // check what type of msg
           switch(m_strBuffer[0])
          {
            case 1:
              AfxMessageBox("received type 1 msg");

                  
            //Type 1 msg, next get state
            nNumBytes = Receive(m_strBuffer, buffLen);

            if(ChkRecvOK(nNumBytes))
            {
               AfxMessageBox("got state");
                                                
               switch(m_strBuffer[0]) // check which state
               {
                   case WTRP_STATE_FLOATING:
      DIES HERE      --->         ((CMyTabExampleDlg*)AfxGetMainWnd())->m_tabFive.m_clientOutput.InsertString(-1, "FLOATING\n");
                   break;
                   default:
                  AfxMessageBox("unknown state");
                  break;
              } // end switch
                            } // check if ChkRecvOK()
      
                 break;

                  case 4:
                                         // will do something
               break;
            default:
                  AfxMessageBox("unknown type");
                  break;
            
            } // end switch stmt
      } // end if(ChkRecvOK(nNumBytes))
      else
            return;
}

BOOL myAsyncSocket::Connect()
{
      CString err;
      
      
      //AfxMessageBox("after call to socket, will call connect");

      if(!CAsyncSocket::Connect(m_host,m_port))
      {
              // Async == non-blocking, so
              // normal to get WSAEWOULDBLOCK back
              // as socket will not wait for connection
              // therefore, report error only if
              // error is not WSAEWOULDBLOCK or 10035
            if (GetLastError() != WSAEWOULDBLOCK)
            {
                  err.Format("connect failed with error %d\n", WSAGetLastError());
                  AfxMessageBox(err);
                  WSACleanup();
                  return FALSE;
            }
      }

      //AfxMessageBox("after connect");

      return TRUE;
}

void myAsyncSocket::Close()
{

      CAsyncSocket::Close();
      WSACleanup();
}

// Function to check if Receive is successful
BOOL myAsyncSocket::ChkRecvOK(int numBytes)
{
      CString err;

      if(numBytes == SOCKET_ERROR)
      {
            if (GetLastError() != WSAEWOULDBLOCK)
            {
                  err.Format("Error receiving data: %d\n", WSAGetLastError());
                  AfxMessageBox(err);
                  WSACleanup();
                  return FALSE;
            }
      }
      else if(numBytes == 0)
      {
            AfxMessageBox("Connection closed by peer.");
            Close();
            return FALSE;
      }
      
      return TRUE;
}
0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 2000 total points
ID: 13720194
I will assume that m_tabFive is a child dialog of CMyTabExampleDlg class (this is not explicit in your posted code)

This will force m_tabFive DIALOG OBJECT to be CONSTRUCTED when CMyTabExampleDlg object is constructed.
But, where do you CREATE m_tabFive dialog? If this object is not created (using Create or DoModal) then contained object m_clientOutput won't be created.

So I think you are trying to call a method (AddString) of an MFC object (m_clientOutput ) that still is not created, just constructed.
0
 

Author Comment

by:jade03
ID: 13721300
oh ok...I didn't create the m_tabFive dialog...I simply declared it in the main dialog's header file...but I was able to access m_tabOne's member variables in myAsyncSocket.cpp like so, even tho m_tabOne was also only declared in the main dialog's header file:

m_port =  _ttoi(((CMyTabExampleDlg*)AfxGetMainWnd())->m_tabOne.m_tabone_portNum);
m_host = ((CMyTabExampleDlg*)AfxGetMainWnd())->m_tabOne.m_tabone_hostName;

so I figured I could just as well call on m_tabFive's variables, controls etc...
0
 

Author Comment

by:jade03
ID: 13721440
wait, I take that back...it does get created...inside another class I have something like this:

m_tabPages[0]->Create(IDD_TAB_ONE, this);
m_tabPages[1]->Create(IDD_TAB_TWO, this);
m_tabPages[2]->Create(IDD_TAB_THREE, this);
m_tabPages[3]->Create(IDD_TABFIVE, this);
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 13721467
>so I figured I could just as well call on m_tabFive's variables, controls etc...
No, you can't access control methods until them have been created...

>wait, I take that back...it does get created...inside another class I have something like this:
But, this happends BEFORE control is accessed?

0
 

Author Comment

by:jade03
ID: 13722666
k, this is driving me crazy...I've checked and verified that the dialog (tabFive) is created before the control is access. However, I do think that I may need to explicitly call create on that control, bec I was able to do an InsertString inside the tabFive class itself, but I'm not able to do InsertString across classes, like the way I currently have it:

((CMyTabExampleDlg*)AfxGetMainWnd())->m_tabFive.m_clientOutput.InsertString(-1, "FLOATING\n");

which means I may have to do something like:

((CMyTabExampleDlg*)AfxGetMainWnd())->m_tabFive.m_clientOutput.Create(....) first before calling InsertString, but here's where I'm confused, what do I put inside the create function? I know there are 4 args I need to give it, but based on my particular situation, I dont' know what parentWnd to give it and what Rect values to give it.

If you can make sense out of my code above to tell me what to put for those I will greatly appreciate it...and will upgrade the point value on this question as well.
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 13722728
jade03,
I will suggest a simpler solution:
After creating tabs, put inside some tab's member a pointer to the actual data, then inside every tab's OnInitDialog() event, use this pointer to retrieve data and fill the internal controls.
Hope you understand me...
0
 

Author Comment

by:jade03
ID: 13729941
None of the tab classes have an OnInitDialog(), should I add them in manually? I read somewhere that it's not good to add this function manually, in that case, how can I add it using the wizard?

My thought is to create OnInitDialog() in all my tab classes, then grab the handle to each of the tab dialogs (currently they are all null when I do:

((CMyTabExampleDlg*)AfxGetMainWnd())->m_tabFive.GetSafeHwnd()

then once I can get the dialog's handle, I want to call SendMessage(..) and use that to send the string to the dialog's list control instead.

hopefully that will lead me towards teh right track...but first I need to get the dialog's handle...and I can't cuz I dont' hae an OnInitDialog() function in any of my tab dialogs....
0
 

Author Comment

by:jade03
ID: 13731673
k, I'm able to create the tab's onInitDialog() func now.

In there, I tried to get the dialog's handle and setting it to a member variable like so:

m_tabFiveDlgHandle = GetSafeHwnd();

//m_tabFiveDlgHandle is declared as:
//HWND m_tabFiveDlgHandle; in side the tabFive.h file


I also have the following function declared in tabFive.cpp:

BEGIN_MESSAGE_MAP(TabFive, CDialog)
      ON_MESSAGE(WM_USER+1, OnMyMessage)
END_MESSAGE_MAP()

LRESULT TabFive::OnMyMessage(WPARAM wParam, LPARAM lParam)
{
      MessageBox("inside OnMyMessage");

      char *ptr = (char*)lParam;

      MessageBox(ptr);
      m_clientOutput.InsertString(-1, ptr);

      return 0L;
}


then inside myAsyncSocket.cpp, under the switch cases, I have this call to SendMessage:


SendMessage(((CMyTabExampleDlg*)AfxGetMainWnd())->m_tabFive.m_tabFiveDlgHandle, WM_USER+1, 0, (LPARAM)"SEEKING");

I'm not getting any errors, but I'm not seeing my list box control in the tabFive dialog being updated with anything either.

I have an AfxMessageBox() inside onMyMessage() saying it got in there, but it never printed out that line.

Does that mean there's a problem with SendMessage?

Or am I not sending it with the right dialog handle?

How do I check to see if the handle I got is the correct one?

I only checked if it's null or not (which in this case, it tells me it's not)

What about inside onMyMessage()? am I converting teh incoming msg back correctly?

I just dont' know where the problem could be....


0
 

Author Comment

by:jade03
ID: 13732380
thanx, jaime_olivares, for bearing with me thru all that code...

I seemed to have fixed my problem now...

I gave up on what I was doing, that is, creating the tab obj and trying access it's handle...seems like I wasn't getting the handle no matter what I tried.

Instead, I went deeper into the code and grabbed the dialog from the m_tabPages[] array, and accessed the list control from there...and it seems to work now. :)

thank you for your efforts!
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 13733173
Ok, sorry for not answering you last posts, but I had an Internet break all the day...
Thanks for the points
Jaime.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses
Course of the Month18 days, 15 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question