|
Use the IShellLink interface.
|
|
|
|
|
I have a series of menu callbacks that do the samething, create an object associated with the menu; for example, menu is create rectangle, the callback will create a rectanle, if menu is circle, the callback will create a circle;
Each callback is similar, except for the type of the object to create; all objects have a common base class.
Is there a pattern that I can use to remove all "similar" code into one function?
I'd like to be able to do something like :
void MyClass::OnRectangle()
{
MyFunction( ClassName );
}
void MyClass::MyFunction( )
{
new ClassName
}
Where ClassName is the name of the class, not an instance; I need the class because I'm doing some dynamic_cast with it.
The question could also be, can I pass a class as a parameter to a function ?
I could do a simple factory pattern, but that would only move the "problem" somewhere else.
Thanks.
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
i think you'll have to have a 'factory' somewhere, as C++ has no built-in support for linking the class name to an instance of the class. so you either have to pass an instance of the class you want, or some kind of token that can be mapped to a class type (ie. a switch statement somewhere that picks the class type based on your token). even with a template, you have to know the type of the object you want in order to invoke the specialized class, so you still need the switch statement to determine which template function/class to invoke.
-c
To vote with no response is to follow the way of the coward.
|
|
|
|
|
that's what I was thinking!
Thanks.
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
Hi
Any one have a link or a e-book about making Windows drivers (2k XP) and how we can use them in API Hooking
Thanks very very much
|
|
|
|
|
There are a few that spring to mind. If you want a good introduction to the overall concepts then I would suggest:
Title: Programming the Windows Driver Model
Publisher: Microsoft Press
ISBN: 0-7356-0588-2
Martin C Cook
Who needs cyberspace when you have CP space?
|
|
|
|
|
Here's one:
http://www.flounder.com/books.htm
|
|
|
|
|
Hi
I'm currently receiving an error when executing the program:
---
Program.exe: Ordinal not found
The ordinal 5084 could not be located in the dynamic link library MFC42D.DLL. Using VC5 here.
If i wait a little, i get an error from Microsoft Developer Studio too: 'DM0025: Error attaching to process'.
Anyone any idea?
Greetings
Jens
|
|
|
|
|
Is this the first time Visual C++ 5 has this error?
As an experiment, compile the MFC project using static DLL linking.
Kuphryn
|
|
|
|
|
Your program compiled/linked with different (most probobly newer) version of MFC
P.S. use depends.exe to find out what dll/function is missing
|
|
|
|
|
It isn't my first time i run a vc5 project.
I have vc5 + vc6 on 1 computer installed.
before i run vc5 i replace a .dll file (don't remember which one) and it always seemed to work. But now it gives me that error.
And what is 'depends.exe'?
|
|
|
|
|
JensB wrote:
And what is 'depends.exe'?
It's a Visual Studio tool. It shows the dependencies of a EXE or DLL.
|
|
|
|
|
See if MSDN article Q168847 is of any help.
|
|
|
|
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/w2kmsgs/971.asp
maybe it's this
|
|
|
|
|
Hello,
YARSQ (yet another ridiculously silly question) - please bear with me.
Can someone help me write a simple program that can be used to
1. kill a process in the taskbar,
2. will work on all windows* platforms
3. implemented in c/c++
I have a fairly cloogy signaling mechanism between programs to find out which ones are alive, etc - but ideally, I would like a clean start on all processes from a master.
Somewhat related topic, but what is the windows call to very reliably find out - given a process/exe name - if a instance of it is already running.
As many of you may have figured out, I am working with programs whose owners have long been dead, figuratively anyway Answers much appreciated.
RGB
|
|
|
|
|
One solution is EnumProcesses(). You may need other API to get module names. Go to MSDN. Open the process and close it via quit message. Another solution is to terminate the process.
Kuphryn
|
|
|
|
|
Terminate project ? The processes are detached. Thanks.
RGB
|
|
|
|
|
i try to pass the following global function pointer to a c library function (cvcamSetProperty) which required the third parameter as callback function pointer.
---------------------------------------------
BOOL CXFaceRecognitionDlg::OnInitDialog()
{
//
// some code had been eliminated
//
// making call the the c library function
cvcamSetProperty(0, CVCAM_PROP_CALLBACK, callback2);
}
void callback2(IplImage* image)
{
}
---------------------------------------------
the compilation stage works fine and no problem at all.
however, when i try to pass the member function pointer, it failed
---------------------------------------------
BOOL CXFaceRecognitionDlg::OnInitDialog()
{
//
// some code had been eliminated
//
// making call the the c library function
cvcamSetProperty(0, CVCAM_PROP_CALLBACK, &CXFaceRecognitionDlg::callback);
}
void CXFaceRecognitionDlg::callback(IplImage* image)
{
}
---------------------------------------------
here is the error message which i obtain when i try to compile the above code:
D:\Documents and Settings\Administrator\Desktop\XFaceRecognition\XFaceRecognitionDlg.cpp(144) : error C2664: 'cvcamSetProperty' : cannot convert parameter 3 from 'void (__thiscall CXFaceRecognitionDlg::*)(struct _IplImage *)' to 'void *'
There is no context in which this conversion is possible
may i now how can i solve this problem?
thank you.
regards
yccheok
|
|
|
|
|
I think it should be static function, if it is a member of a class(plus check the actual signature it might need to be __cdecl)
|
|
|
|
|
Declare the callback function as static function of the class
class CXFaceRecognitionDlg:: .......
{
:
static void callback(IplImage* image);
:
}
and i think you should not use the & for the call, just use the static function name :
cvcamSetProperty(0, CVCAM_PROP_CALLBACK, CXFaceRecognitionDlg::callback);
|
|
|
|
|
Hi all,
I'm trying to catch WebBrowserEvents from within the toolband. This is basicaly the code im using, but it doesnt seem to work. Has anyone done this before and/or sees what im doing wrong.
class ATL_NO_VTABLE CToolbar :
public CComObjectRootEx<ccomsinglethreadmodel>,
public CComCoClass<ctoolbar, &clsid_toolbar="">,
public IDeskBand,
public IObjectWithSiteImpl<ctoolbar>,
public IInputObject,
public IDispatchImpl<itoolbar, &iid_itoolbar,="" &libid_guciolib="">,
public IDispEventImpl<0, CToolbar, &DIID_DWebBrowserEvents2, &LIBID_SHDocVw, 1, 0>
...
BEGIN_SINK_MAP(CToolbar)
SINK_ENTRY_EX(0, DIID_DWebBrowserEvents2, DISPID_ONFULLSCREEN,OnFullScreen)
SINK_ENTRY_EX(0, DIID_DWebBrowserEvents2, DISPID_BEFORENAVIGATE2, BeforeNavigate2)
END_SINK_MAP()
...
public:
STDMETHOD(OnFullScreen) (BOOL FullScreen);
STDMETHOD(BeforeNavigate2) (LPDISPATCH pDisp , VARIANT* URL,VARIANT* Flags, VARIANT* TargetFrameName,VARIANT* PostData, VARIANT* Headers, BOOL* Cancel);
...
STDMETHODIMP CToolbar::FullScreen(LPDISPATCH pDisp, VARIANT *URL, VARIANT *Flags, VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers, BOOL *Cancel)
{
::MessageBox(NULL,"ONFULLSCREEN event!","IE",MB_OK);
return 0;
}
STDMETHODIMP CToolbar::BeforeNavigate2(LPDISPATCH pDisp, VARIANT *URL, VARIANT *Flags, VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers, BOOL *Cancel)
{
::MessageBox(NULL,"ONBEFORENAVIGATE event!","IE",MB_OK);
return 0;
}
Greeting
snajper
|
|
|
|
|
|
Hi all,
how can I customize the botton in the windows function MessageBox()?
Is there a class to do this?
Thanks
Piccinaco
|
|
|
|
|
define "customize the button"
|
|
|
|
|
One solution is to design your own simple message dialogbox.
Kuphryn
|
|
|
|