reference class varables from another class

Referencing a class varible from another class

Page 1 of 1

0 Replies - 4340 Views - Last Post: 08 September 2006 - 04:56 AM Rate Topic: -----

#1 nchannon  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 08-September 06

reference class varables from another class

Post icon  Posted 08 September 2006 - 04:56 AM

Hi sorry for sounding a bit stupid but I cant seem to work out how to refernce or call another varible set in once class and call it from another class. Below is a simple breakdown of my process with both ' *.cpp ' and ' *.h ' files. I have just included the basic code snipits but you should get what is happening.
1) Main Class used to start the application:
Class Name StartMain()
StartMain.cpp:
void StartMain::CreateWindow()
{
   m_MainVideoWindow = new WindowControl(); // WindowControl is the second class file WindowControl.cpp
   m_MainVideoWindow->Create(NULL,"",WS_POPUP | WS_THICKFRAME,rc,NULL,0,0); // bare window
   m_MainVideoWindow->MoveWindow(22,25,width,height,1);
   m_MainVideoWindow->SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE);
   m_MainVideoWindow->ShowWindow(SW_SHOW);
 }


StartMain.h:
#include "WindowControl.h"
class StartMain : public CWnd
{
public:
WindowControl* m_MainVideoWindow;
}


2)Class file that creates the multibile child windows
WindowControl.cpp:
int WindowControl::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
if (CWnd::OnCreate(lpCreateStruct) == -1)
   return -1;
memset(m_windows, 0, sizeof(m_windows)); 
for(int i=0;i<15;i++){
			  m_windows[j] = new CreateWindows();
			  m_windows[j]->Create(NULL,NULL,WS_CHILD |WS_THICKFRAME,rc,this,j,0);
		}
}
void WindowControl::Paint()
{
for(DWORD j=0;j<g_SplitInfo.scSplitConf.uNumRects;j++){ //Number of rects is 16 so 16 squares are painted on the MainVideoWindow each a new instance if it's self
		   RECT rc = g_SplitInfo.scSplitConf.rcRect[j];
			dc.Rectangle((int)(rc.left*gridX),(int)(rc.top*gridY),(int)(rc.right*gridX),(int)(rc.bottom*gridY));
			int thisWinX = (int)(rc.left*gridX+2);
			int thisWinY = (int)(rc.top*gridY+2);
			int thisWinWidth = (int)(rc.right*gridX-2);
			int thisWinLength =(int)(rc.bottom*gridY-2); 
			int	  width, height;
			width = thisWinWidth - thisWinX;
			height  = thisWinLength	 -  thisWinY;
			m_windows[j]->MoveWindow(thisWinX,thisWinY,width,height);
			m_windows[j]->ShowWindow(SW_SHOW);
 }
}


WindowControl.h:
#include "CreateWindows.h"
class WindowControl : public CWnd
{
public:
CreateWindows* m_windows[128]; //array for multibile instance of separate windows to display video signals
}


3)Class file to control functions from each video server connected to application this class is the backbone that controls every fuction related to each child video window.
###### This is the class that I want to be able to call each instance of m_windows[] #######

I hope someone can help me and thanks in advance

Is This A Good Question/Topic? 0
  • +

Page 1 of 1