|
Sorry I didn't see your post about the timer. Why don't you use Spy++ to monitor it and see if it gets any timer messages? If it doesn't, then your code behaves correctly. If it does, I suggest you to add a bunch of debug messages where the timer starts, ends, etc and analyze them in DebugView.
|
|
|
|
|
When an application's form is minmum to the taskbar or hide,how to hook the messages of the form?I have developed an application that can hook a form's messages when the form on the desktop.But when the form is minmum to the taskbar or the form is hidden,the hook message application could not hook nothing of the form.In fact ,the messages of the form happen,such as a message that a disable button is changed to an enable button.Please help me!
Thanks alot!
|
|
|
|
|
please help me.I have searched on google and msdn,but all ways can only hook the application with forms.But when the form is hidden,how to hook the messages when the states of the components on the form is changing?Please help me!
|
|
|
|
|
Hello, I am new to programming C++. Can anyone help me with this problem:
C2248: cannot access protected struct declared in class.
It occurs when I want to fill a struct in another class, which is declared private (and should stay private).
Do I have to develop a public function in this class which acceses my struct ?
I do not know how to proceed...
Thanks for your help
|
|
|
|
|
externalize the declaration of the struct type outside the class, or set it to public/protected within the class.
don't confuse, i talk about the struct type declaration, not the members of that type.
|
|
|
|
|
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?
|
|
|
|
|