|
Mark Salsbery wrote: Generally you can pass an instance reference/pointer to methods that use a callback which will be passed to the callback.
In the callback it is cast to the proper type and used to access members.
I'm not sure I understand...
Could you please rephrase it...?
Mark Salsbery wrote: If it's your own callback scheme then it should be easy to add a parameter.
It's not my callback scheme...
I use SetWindowsHookEx(), thus I'm forced to use the following signature:
static LRESULT CALLBACK MsgCallback(UINT nCode, WPARAM wParam, LPARAM lParam)<br />
Again, I'm not really sure what you meant.
I'll point out again that I'm writing a native C++ dll.
|
|
|
|
|
shyagam wrote: I'm not sure I understand...
Could you please rephrase it...?
I was referring to callbacks like the one used with EnumChildWindows() where there's a parameter
(app-defined) that you can pass to EnumChildWindows() which will be passed to the callback
fuction. You can pass an object pointer as this parameter and retrieve it in the static callback
and use it to access members of the object class.
With SetWindowsHookEx() you don't have this available. You're going to need an object reference
or pointer in the callback to get at any of the object class' non-static members. You could
store this pointer/reference somewhere - global variable, static member variable. Without it
you only have access to static members, as you know.
|
|
|
|
|
Thanks for the quick reply...
Mark Salsbery wrote: You could store this pointer/reference somewhere - global variable, static member variable.
I was thinking of holding a static list to all class instances.
Each constructor call would add the this pointer to the list.
The class would have an inner callback function.
The callback sent to SetWindowsHookEx() would then run a loop and call the inner callback inside each of the list's elements.
Do you see any potential flows in this?
|
|
|
|
|
Sounds like a plan Don't forget to thread-protect access to that list
|
|
|
|
|
Mark Salsbery wrote: Don't forget to thread-protect access to that list
Absolutly right... I'll keep that in mind!
Thanks again!
|
|
|
|
|
Using VS2005, if I was to run NOTEPAD.EXE from within an application - how would this be achieved ?
Pete
|
|
|
|
|
Can anyone tell me how I make an application run like a service(to start with windows,do not have a bar in the tool box like whe you enter My Computer) please
|
|
|
|
|
Is this a Turbo C++ or a native C++ question? If yes, you are in the wrong forum.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
How do you make an app to like a windows app(the blue title bar) I've tried to find over the internet but no luck:
|
|
|
|
|
Is your question related to Turbo C++ (You asked a similar question in the C++ forum) or to C++/CLI which is a managed version of C++ for .NET?
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
using namespace System::Text::RegularExpression;
if (!Regex::IsMatch("[a-zA-Z0-9]{4,13]"))
{
MessageBox::Show("Username must be at least 4 char long, it can contain letters and numbers. Maximum lneght is 13 char");
}
Error 1 error C2352: 'System::Text::RegularExpressions::Regex::IsMatch' : illegal call of non-static member function c:\projects\cddvdorganizer\cddvdorganizer\frmAddUser.h 281
How can i avoid this problem.
Thanks in advance
|
|
|
|
|
The error message gave you the answer! Regex::IsMatch is not static. You have to create an instance of Regex first.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
George L. Jackson wrote: The error message gave you the answer! Regex::IsMatch is not static. You have to create an instance of Regex first.
No i don't need to create static. I yust found an error. IsMatch uses 2 parameters. Code belove works fine
if (Regex::IsMatch(txtUserName->Text, "[a-zA-Z0-9]{4,13}") == false)
|
|
|
|
|
My bad! I just noticed that IsMatch has four overloads. Two of them are static.
George
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Dear Friends..Can any one tell me about operator ":"
|
|
|
|
|
You cam use ":" with "?". In the following example, the "?" can be interpreted as "then" and the ":" as else.
int result = i > 10 ? 9 : 11;
This is equivalent to:
<br />
if (i > 10)<br />
result = 9;<br />
else<br />
result = 11;<br />
The ":" is also used with "public", "private" and "protected" to define security access within a class and inheritance.
<br />
clas Derived : public Base<br />
{<br />
public:<br />
protected:<br />
private:<br />
};<br />
You also use it to create a constructor initialize list in classes:
<br />
class Foo<br />
{<br />
public:<br />
Foo() : value(1) {}<br />
protected:<br />
private:<br />
int value;<br />
};<br />
George
|
|
|
|
|
the operator : doesn't exist
|
|
|
|
|
":" is not an operator by itself but in combination with "?" as a conditional operator "?:".
-- modified at 20:54 Sunday 10th December, 2006
-- modified at 20:54 Sunday 10th December, 2006
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
that's why i said that operator : doesn't exist
moreover, : appears in other situations, like classes inheriting in class definitions, construction list in class constructors definitions, etc...
but still this is not an operator per se.
|
|
|
|
|
I never said it was an operator. I just demonstrated its usage, and you explicited stated it was not an operator and restated my previous post.
Also, I believe the ":" falls under the category of punctuation. Punctuation and operators are lexemes.
Nevertheless, I appreciate your comments and hope we didn't confuse anyone.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hello,
I'm trying to accomplish the following:
A C++ dll project, which uses another dll (which I didn't write).
My project would contain certain unmanaged functions, and then a managed class to encapsulate those functions.
I'm new to C++.NET, and especially to the mixed projects stuff, so after a long unsuccessful journy of trial and error, I've decided to ask here...
What kind of project should I create?
What should I do to create this kind of project?
How and where should I #include "TheDllI'mUsing.h" ?
How do I tell the compiler to treat the "TheDllI'mUsing.h" as a pure unmanaged file?
Anything else I might need to know...?
A link to an article would be good too...
Thanks in advance,
Shy.
|
|
|
|
|
You can create a regular DLL project, and enable /clr compilation.
|
|
|
|
|
Hello,
I have written a program in c++.Now I want to make that program a part of a c# program. So to integrate the programs would I have to conver the unmanged c++ code to managed c++/CLI ?
Thanks in advance
|
|
|
|
|
Revant Jain wrote: I have to conver the unmanged c++ code to managed c++/CLI ?
Maybe. Or you could add mixed mode managed wrapper classes.
led mike
|
|
|
|
|
Hello there fellow programmers,
I'm coding a class library which deals with windows hooks.
It uses the SetWindowsHookEx() API function and provides classes for specific hook types.
So far, the code is written in C#, but I only got as far as low-level hooking (i.e. LLKeyboard, LLMouse hooking).
If I try to use global hooks which are not LL, they of course fail, as they are injected to all processes on the system, and not all processes support managed assemblies.
What I intend to do is write a C++ dll, and use it to communicate with my C# dll.
I know there's a way to compile C++.NET code to pure unmanaged C++ code.
How can I do this?
Is compiling managed C++ as unmanaged going to work with the hooks?
Or perhaps I should write my C++ dll directly in C++, and not through C++.NET code...
Thanks in advance,
Shy.
|
|
|
|