|
Thanks for your reply,
I already set it protected.
I do not want to access it from a derrived class, but from a really different class.
|
|
|
|
|
if you access it from a class that is not in the inheritance, you have to declare the struct public, or global.
|
|
|
|
|
ok thank you, i declared it public
|
|
|
|
|
Checker2003 wrote: i declared it public
what's wrong ? it's just a type... no one will access your datas from outside the class !!! no ?!
|
|
|
|
|
Instead of declaring it public, you could also add a constructor to structure to initialize its values, or add a method to the outer class to initialize it:
class OuterClass
{
public:
OuterClass() {}
~OuterClass() {}
private:
struct InnerClass
{
InnerClass() { _data = 0; }
int _data;
};
InnerClass _MyData;
};
class OuterClass
{
public:
OuterClass() {}
~OuterClass() {}
void Initialize() { _MyData._data = 0; }
private:
struct InnerClass
{
int _data;
};
InnerClass _MyData;
};
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Hi,
Probably your problem looks like this:
typedef struct TESTSTRUCT {
double a;
}
class testA
{
public:
TESTSTRUCT st;
...
};
class testB: private testA
{
public:
void MyFunc(double val) {
st.a = val;
};
...
};
int main (...) {
testB c;
c.st.a = 1.1;
Myfunc(1.1);
}
So, everything you have to do is to create publicly available function to access private member of your classes.
Hope that helps a bit.
Best regards
|
|
|
|
|
Thanks for your reply,
I already thought about this, but I do not want to access it from a derrived class, but from a really different class.
My problem is, that then I have to give my function the struct as parameter, and this does not work, because the compiler doesn't understand the struct as identifier...
Thanks a lot
|
|
|
|
|
You can always post a bit of your code , which would be very helpful.
Regards
|
|
|
|
|
LRESULT CALLBACK CBTProc(
int code, // hook code
WPARAM wParam, // removal flag
LPARAM lParam // address of structure with message
)
{
if (code < 0) return CallNextHookEx(CBTSysHook, code, wParam, lParam);
if(code == HCBT_ACTIVATE)
{
HWND hWnd = (HWND) wParam;
TCHAR cWind[512], cClass[512];
GetWindowText( hWnd, cWind, 512);
GetClassName( hWnd, cClass, 512);
/*if ( (GetParent(GetParent(hWnd))==NULL) && ( IsWindow(GetParent(hWnd))==TRUE ) )
{
CStringW strWind, strClass;
AfxDaoInit(); // preparing for DAO
CDaoDatabase database;
CDaoRecordset recordset(& database);
// Open database and recordset
database.Open(_T("d:\\╠юш фюъєьхэЄ√\\┴рч√ фрээ√ї\\hookBase.mdb"));
recordset.Open(AFX_DAO_USE_DEFAULT_TYPE,
_T("SELECT * FROM hookspy"), 0);
// getting know Window Title and Class Name of hwnd
strWind.AppendFormat(_T("%s"), cWind);
strClass.AppendFormat(_T("%s"), cClass);
// adding new record
recordset.AddNew();
recordset.SetFieldValue(_T("lpszName"), strWind.GetString());
recordset.SetFieldValue(_T("lpszClass"), strClass.GetString());
recordset.SetFieldValue(_T("lpszAction"), _T("CBT activated"));
recordset.Update();
recordset.Close();
database.Close();
AfxDaoTerm();
} */
//AfxBeginThread(threadActiv, NULL);
/*if(_tcscmp(buff,_T("Effects")) == 0)
{
ShowWindow(hWnd,SW_HIDE);
g_hWndEffects = hWnd;
}
if(_tcscmp(buff,_T("Display Properties")) == 0)
{
ShowWindow(hWnd,SW_HIDE);
}*/
}
|
|
|
|
|
Hi,
Most of your code seems to be commented out, so it will not be executing.
Could you point us where exactly problem occurs, and what kind of error it is, please?
Regards
|
|
|
|
|
There is no error when code is simply
LRESULT CALLBACK CBTProc(
int code, // hook code
WPARAM wParam, // removal flag
LPARAM lParam // address of structure with message
)
{
if (code < 0) return CallNextHookEx(CBTSysHook, code, wParam, lParam);
if(code == HCBT_ACTIVATE)
{
HWND hWnd = (HWND) wParam;
TCHAR cWind[512], cClass[512];
GetWindowText( hWnd, cWind, 512);
GetClassName( hWnd, cClass, 512);
}
return 0;
}
An error occurs when I add DAO support, exactly when program is run
and I open Light Alloy, press 'play' and further press X - to close,
it happens error sound, my program goes on to work
, and nothing else is different with normal closing
|
|
|
|
|
There is no error when code is simply
LRESULT CALLBACK CBTProc(
int code, // hook code
WPARAM wParam, // removal flag
LPARAM lParam // address of structure with message
)
{
if (code < 0) return CallNextHookEx(CBTSysHook, code, wParam, lParam);
if(code == HCBT_ACTIVATE)
{
HWND hWnd = (HWND) wParam;
TCHAR cWind[512], cClass[512];
GetWindowText( hWnd, cWind, 512);
GetClassName( hWnd, cClass, 512);
}
return 0;
}
An error occurs when I add DAO support, exactly when program is run
and I open Light Alloy, press 'play' and further press X - to close,
it happens error sound, my program goes on to work
, and nothing else is different with normal closing
|
|
|
|
|
There is no error when code is simply
LRESULT CALLBACK CBTProc(
int code, // hook code
WPARAM wParam, // removal flag
LPARAM lParam // address of structure with message
)
{
if (code < 0) return CallNextHookEx(CBTSysHook, code, wParam, lParam);
if(code == HCBT_ACTIVATE)
{
HWND hWnd = (HWND) wParam;
TCHAR cWind[512], cClass[512];
GetWindowText( hWnd, cWind, 512);
GetClassName( hWnd, cClass, 512);
}
return 0;
}
An error occurs when I add DAO support, exactly when program is run
and I open Light Alloy, press 'play' and further press X - to close,
it happens error sound, my program goes on to work
, and nothing else is different with normal closing
|
|
|
|
|
There is no error when code is simply
LRESULT CALLBACK CBTProc(
int code, // hook code
WPARAM wParam, // removal flag
LPARAM lParam // address of structure with message
)
{
if (code < 0) return CallNextHookEx(CBTSysHook, code, wParam, lParam);
if(code == HCBT_ACTIVATE)
{
HWND hWnd = (HWND) wParam;
TCHAR cWind[512], cClass[512];
GetWindowText( hWnd, cWind, 512);
GetClassName( hWnd, cClass, 512);
}
return 0;
}
An error occurs when I add DAO support, exactly when program is run
and I open Light Alloy, press 'play' and further press X - to close,
it happens error sound, my program goes on to work
, and nothing else is different with normal closing
|
|
|
|
|
You dont need to repeat your answer
|
|
|
|
|
I use CList instead of DAO, I mean I use back-write, here is it.
But except for my Program, which call CBT.dll, nothing is written.
I open the testHook table, and there is it
#1: myMonitor #32770
#2: myMonitor #32770
#3: myMonitor #32770
#4: myMonitor #32770
#5: myMonitor #32770
Why is it so? Is there any secret?
LRESULT CALLBACK CBTProc(
int code, // hook code
WPARAM wParam, // removal flag
LPARAM lParam // address of structure with message
)
{
if (code < 0) return CallNextHookEx(CBTSysHook, code, wParam, lParam);
if(code == HCBT_ACTIVATE)
{
HWND hwnd = (HWND) wParam;
if ( IsWindow( hwnd )== TRUE)
{
myStr str;
GetWindowText( hwnd, str.cWind, 250);
GetClassName( hwnd, str.cClass, 250);
AfxMessageBox( cStr );
myWindList.AddTail(str);
}
}
return 0;
}
...
void RunStopHook(BOOL State)
{
if (State == TRUE)
{
//SysHook = SetWindowsHookEx(WH_SHELL, &ShellProc, hInst, 0);
CBTSysHook = SetWindowsHookEx(WH_CBT, &CBTProc, hInst, 0);
//WNDSysHook = SetWindowsHookEx(WH_CALLWNDPROCRET, &CallWndRetProc, hInst, 0);
}
else
{
//UnhookWindowsHookEx(SysHook);
UnhookWindowsHookEx(CBTSysHook);
//UnhookWindowsHookEx(WNDSysHook);
AfxDaoInit(); // preparing for DAO
CDaoDatabase database;
CDaoRecordset recordset(& database);
// Open database and recordset
database.Open("d:\\╠юш фюъєьхэЄ√\\┴рч√ фрээ√ї\\hookBase.mdb");
recordset.Open(AFX_DAO_USE_DEFAULT_TYPE,
"SELECT * FROM testHook", 0);
myStr str;
POSITION pos = myWindList.GetHeadPosition();
for (int i=0;i < myWindList.GetCount();i++)
{
str = myWindList.GetNext(pos);
if ((strlen( str.cWind ) < 255) &&
(strlen( str.cClass ) < 255))
{
recordset.AddNew();
recordset.SetFieldValue("lpszName", (LPCSTR) str.cWind);
recordset.SetFieldValue("lpszClass", (LPCSTR) str.cClass);
recordset.Update();
}
else
{
CString strC, strD;
strC.AppendFormat("%i", strlen( str.cWind ));
strD.AppendFormat("%i", strlen( str.cClass));
recordset.AddNew();
recordset.SetFieldValue("lpszName", (LPCSTR) strC.GetString());
recordset.SetFieldValue("lpszClass", (LPCSTR) strD.GetString());
recordset.Update();
}
}
myWindList.RemoveAll();
recordset.Close();
database.Close();
AfxDaoTerm();
}
}
|
|
|
|
|
When it's commented it's all right,
When it's full open for compile an error occurs
when I close Light Alloy, while movie is being played,
|
|
|
|
|
I am creating a skinned window, which I want to be resizable. When I create the window I remove all the window styles in order to correctly display a bitmap
SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE)
& (~(WS_CAPTION | WS_BORDER | WS_SIZEBOX)));
I then handle the WM_NCHITTEST returing values for the new title bar, min/max buttons etc. I have also created a region around the edges of the bitmap within which the resizing should be possible. The problem is, after removing the WS_SIZEBOX style, DefWindowProc() no longer allows resizing of the window. Of course I can do it programatically using SetWindowPos() but this is a far cry from dragging the border. Is there any way I can use the WS_SIZEBOX style, without displaying the border?
|
|
|
|
|
Hi,
Currently you're using only client area of the window (that's why you removed caption/borders), did you try to use WM_NCPAINT instead of WM_PAINT?
In WM_NCPAINT you can erase/paint entire window area, discarding its default painting proc for caption and borders. This way you could probably save your sizing borders.
Best regards
|
|
|
|
|
I hava a programme that coulde transparence the window/dialog in 2000/XP, it use the SetLayeredWindowAttributes function to transparence window/dialog.But, the function coudle only transparence window. And i want transparence the client area in SDI/MDI. Who can tell i how to do it?
|
|
|
|
|
|
You can do it in a handler for WM_ERASEBKGND.
By just returning TRUE this will prevent any background from being drawn.
BOOL CMyMDIWnd::OnEraseBkgnd(CDC* pDC)
{
return TRUE;
}
|
|
|
|
|
Hi,
I have created a sdi in which the view is divided into three panes.Now i want to color the splitter bar,splitter box,borderetc.For that i have written a function like following in a class derived from CSplitterWnd.
void CMCSplitterWmd::OnDrawSplitter(CDC* pDC,ESplitType nType,const CRect& rect)
{
CBrush brush;
CBrush *ptrBrushOld;
if(pDC == NULL)
{
CSplitterWnd::OnDrawSplitter(pDC, nType, rect);
return;
}
switch(nType)
{
case splitBox:
{
VERIFY(brush.CreateSolidBrush(RGB(128, 255, 0)));
break;
}
case splitBar:
{
VERIFY(brush.CreateSolidBrush(RGB(128, 255, 0)));
break;
}
case splitIntersection:
case splitBorder:
{
CSplitterWnd::OnDrawSplitter(pDC, nType, rect);
return;
}
}
ptrBrushOld=pDC->SelectObject(&brush);
pDC->Rectangle(rect);
pDC->SelectObject(ptrBrushOld);
}
Now my doubt is ,where to call this function in mainframe class.Is this necessary to call this function in mainframe class.
Thanks
|
|
|
|
|
Hi,
I have an application that uses multiple threads in order to perform a calculation. When run on a multicore processor there does not seem to be any increase in speed. Is it a misconception to expect the operating system will split a multi threaded applications to different core's automatically?
Regards,
Ingo
|
|
|
|
|
Hi,
AFAIK, windows system doesn't split cores between different threads, but instead it split cores between processes. In order to assign specific core to a specific thread, you should use SetThreadAffinityMask . Before you set new affinity mask for thread, you should obtain current affinity mask for entire process (GetProcessAffinityMask ), and of course, affinity mask of your thread can only be a subset of mask of your process.
In order to specify new affinity mask for your process, use SetProcessAffinityMask .
Before you change anything, try to read multiple MSDN documents about: Multiple Processors, Processes and Threads, etc...
Regards
|
|
|
|
|