|
Handle the 'D' or 'U' and call the same code that you call when handling the 'up' or 'down' keys.
|
|
|
|
|
Maximilien wrote: call the same code that you call when handling the 'up' or 'down' keys.
He may not have any code to be called while the up or down arrow keys are pressed. I understand that his requirement was to just simulate an up arrow key press while 'U' is pressed and down arrow key press if 'D' is pressed.
Also, how do you handle 'D' or 'U'? Say, if there are multiple child controls in the application window, those child controls may be having the keyboard focus!
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Hi,
How can I change the background color of CToolBar ?
Regards,
Paresh.
modified on Monday, February 18, 2008 1:17 AM
|
|
|
|
|
I'm writing my first shell extension dll, and I'm trying to figure out how to pass the Recycle bin files/folders anme CShellExt::InvokeCommand at right click of menu item. I am getting others files and folders name.
Some sennipt is attached.
<br />
void CCoMenHandler::GetSelectedFiles(LPCITEMIDLIST pidlFolder,IDataObject *pdtobj)<br />
{<br />
g_szSelectedFiles.RemoveAll();<br />
<br />
if (pdtobj) <br />
{<br />
pdtobj->AddRef();<br />
<br />
STGMEDIUM medium;<br />
FORMATETC fe = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};<br />
<br />
<br />
HRESULT hr = pdtobj->GetData (&fe, &medium);<br />
if (FAILED (hr))<br />
{<br />
return ;<br />
}<br />
<br />
char path[MAX_PATH];<br />
<br />
UINT fileCount = DragQueryFile((HDROP)medium.hGlobal, 0xFFFFFFFF,<br />
path, MAX_PATH);<br />
<br />
if (fileCount>0)<br />
{<br />
g_szSelectedFiles.SetSize(fileCount);<br />
<br />
for (UINT i=0;i<fileCount;i++) <br />
{<br />
memset(path, 0, MAX_PATH);<br />
if (DragQueryFile((HDROP)medium.hGlobal, i, path, MAX_PATH)) <br />
{<br />
g_szSelectedFiles.SetAt(i, path);<br />
}<br />
}<br />
<br />
g_szSelectedFiles.FreeExtra();<br />
}<br />
<br />
ReleaseStgMedium(&medium);<br />
}<br />
<br />
<br />
}<br />
Thanx in advance.:
|
|
|
|
|
Hello everyone,
Unique pointer should not allow aliasing. But my code which contains unique pointer aliasing and also compile/run ok. Anything wrong?
__interface IFoo {
public:
virtual int foo ([unique] char *ptr1, [unique] char *ptr2) = 0;
};
class Foo : public IFoo {
public:
int foo (char *ptr1, char *ptr2)
{
char array1[] = "Hello";
ptr1 = array1;
ptr2 = array1;
return 0;
}
};
int main()
{
char* ptr1 = 0;
char* ptr2 = 0;
Foo f;
f.foo(ptr1, ptr2);
return 0;
}
thanks in advance,
George
|
|
|
|
|
Hi Friends,
I want to export a class and its static member from the DLL.
I could build the DLL.
And i want to use that exported class and its static members form that Dll in my C++ application. But when i am building application i am getting a link error for that static member.
error LNK2001: unresolved external symbol "public: static int CMyClass::i" (?i@CMyClass@@2HA).
The IDE that i am using is Visual Studio 6.0.
Plz help me
The details of the implementation is as follows...
//////////////////////DLL PART//////////////////////////
// MyClass.h: interface for the CMyClass class.
//---------------------------------------------
#define _MYDLL
#ifdef _MYDLL
#define MY_API __declspec(dllexport)
#else
#define MY_API __declspec(dllimport)
#endif
class MY_API CMyClass
{
public:
CMyClass();
virtual ~CMyClass();
public:
static int i;
};
// MyClass.cpp: implementation of the CMyClass class.
//-------------------------------------------------
#include "stdafx.h"
#include "MyClass.h"
int CMyClass::i;
CMyClass::CMyClass()
{
}
CMyClass::~CMyClass()
{
}
//////////////////////////////CALLING APPLICATION//////////////////////////
In my application i try to use that static member as below;
#include "MyClass.h"
_tmain()
{
int nValue = CMyClass::i;
}
|
|
|
|
|
See here [^]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Hi,
I corrected the code as follows.
And i defined _MYIF in the project settings.
The Dll could build successfully.
But when i ma using this in amy application , it is showing an error
error LNK2001: unresolved external symbol "public: static int CMyClass::nValue" (?nValue@CMyClass@@2HA)
Plase see the classs impelmentation as follows.
Does any have any idea?????
//MyClass.h
#ifdef _MYIF
#define MY_API __declspec(dllexport)
#else
#define MY_API __declspec(dllimport)
#endif
class MY_API CMyClass
{
public:
CMyClass();
virtual ~CMyClass();
public:
static int nValue;
};
//MyClass.cpp
#include "MyClass.h"
int CMyClass::nValue = 0;
CMyClass::CMyClass()
{
}
CMyClass::~CMyClass()
{
}
|
|
|
|
|
Prasanth M V wrote: But when i ma using this in amy application , it is showing an error
error LNK2001: unresolved external symbol "public: static int CMyClass::nValue" (?nValue@CMyClass@@2HA)
You need to link the importation library of the DLL (for instance if your DLL is MyClass.DLL , then you have to link your application with MyClass.lib ).
You may add MyClass.lib to the linker command line in the project settings.
Probably you need also to specify the folder wherein the linker may find the importation library (choose Tools->Options menu item then select the Project and Solutions->VC++ Directories , select Library files into the show directories for listbox and finally add the MyClass.lib folder path to the list).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Hi,
I have already given the import lib file to the project.
And i could access all the class members expect the Static member of the class.
Then ???
Thanks,
Prasanth
|
|
|
|
|
Prasanth M V wrote: I have already given the import lib file to the project.
And i could access all the class members expect the Static member of the class.
Then ???
Then I dont know. I mean, the following very simple test:
DLL header file
#ifdef CPPDLL_EXPORTS
#define CPPDLL_API __declspec(dllexport)
#else
#define CPPDLL_API __declspec(dllimport)
#endif
class CPPDLL_API CCppDll {
public:
CCppDll(void);
~CCppDll(void);
static int nValue;
};
DLL source file
CCppDll::CCppDll()
{
return;
}
CCppDll::~CCppDll()
{
return;
}
int CCppDll::nValue = 0;
client application
#include "stdafx.h"
#include "..\\..\\CppDLL\\CppDLL\CppDLL.h"
int _tmain(int argc, _TCHAR* argv[])
{
CCppDll::nValue =5;
} it's working fine on my system.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Hi All,
Its is workign fine
Thanks for your support
----------------------------------------
But one intesting thing i see is that i give the CPPDLL_EXPORTS in the project settings.
If i am giving it in StdAfx.h i will work.
OK NAy i worked.
Thanks
Alot
|
|
|
|
|
Hi All,
Its is workign fine
Thanks for your support
----------------------------------------
But one intesting thing i see is that i give the CPPDLL_EXPORTS in the project settings.
If i am giving it in StdAfx.h i will work.
OK Anyway it worked.
Thanks
Alot
|
|
|
|
|
Did you link with the lib file generated when you built the dll ?
EDIT: oww, I just saw your mistake: you are defining _MYDLL in the header file of CMyClass. So it will ALWAYS be defined (even in the code of the executable), so MY_API will always relate to __declspec(dllexport).
You should define _MYDLL in the preprocessor definitions of your dll only.
|
|
|
|
|
Hello everyone,
Could anyone show me a sample or where to find dual interface implementation for IDispatch please?
I have seached for MSDN and Google for half an hour and seems all I could get are MFC based.
Any non-MFC and non-ATL (pure C++) sample?
thanks in advance,
George
|
|
|
|
|
http://www.codeproject.com/KB/COM/com_in_c2.aspx[^]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Thanks CPallini,
I read through related code and find it uses the dual property to qualify the interface, here is the related code,
(IExample2.idl)
[uuid(B6127C55-AC5F-4ba0-AFF6-7220C95EEF4D), dual, oleautomation, hidden, nonextensible]
I feel I miss the concept (at least to some level) of the dual interface. Any benefits we could have if we add dual property?
regards,
George
|
|
|
|
|
A dual interface [^] can invoked both the classical, faster way (i.e. through VTABLE) and the automation, slower one.
For instance VB6 Clients can take advantage of the VTable approach while VBSCript ones have to use automation approach.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Thanks CPallini!
Good link!! Now my confusion is, to implement an interface for OLE automation, once we inherit from IDispatch interface, then it is always a dual interface, right?
What type of implementation in C++ for a component is not a dual interface? I can not imagine a sample. Any ideas?
regards,
George
|
|
|
|
|
George_George wrote: Good link!! Now my confusion is, to implement an interface for OLE automation, once we inherit from IDispatch interface, then it is always a dual interface, right?
You may also choose to not declare your interface dual, but, as stated in the MSDN page:
dual interfaces are recommended whenever possible
George_George wrote: What type of implementation in C++ for a component is not a dual interface?
For instance, a component that does not support automation.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Thanks CPallini,
CPallini wrote: For instance, a component that does not support automation.
In the context of supporting automation, when in implement a component in C++, are there any ways to implement it not as a dual interface?
I have this confusion is because, if I remember clearly, if a component supports automation, it must inherit from IDispatch interface, then it must be a dual interface.
Any ideas?
regards,
George
|
|
|
|
|
George_George wrote: In the context of supporting automation, when in implement a component in C++, are there any ways to implement it not as a dual interface?
Yes.
George_George wrote: I have this confusion is because, if I remember clearly, if a component supports automation, it must inherit from IDispatch interface, then it must be a dual interface.
Actually you can derive from IDispatch and at same time don't declare your interface as dual.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Thanks CPallini!
Two confusions,
1. What is the purpose of doing so "in practice"? Force user to use IDispatch other than efficient vtable?
2. Could we use vtable even if dual property is not added to interface? For example, using QueryInterface to get some interface other than IUnknown and IDispatch, then invoke its member function just the same as invoking through vtable?
regards,
George
|
|
|
|
|
George_George wrote: 1. What is the purpose of doing so "in practice"? Force user to use IDispatch other than efficient vtable?
In practice you use IDispatch on VTABLE capable client only if you need late binding.
George_George wrote: 2. Could we use vtable even if dual property is not added to interface? For example, using QueryInterface to get some interface other than IUnknown and IDispatch, then invoke its member function just the same as invoking through vtable?
You can always use VTABLE on all of the COM Interfaces. what dual really means is that the same functionalities that you can access via IDispatch mechanism are also available as standard COM methods (i.e. are part of the interface itself).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Thanks CPallini,
1.
CPallini wrote: In practice you use IDispatch on VTABLE capable client only if you need late binding.
You mean QueryInterface for IDispatch interface? What mean later binding?
2.
CPallini wrote: You can always use VTABLE on all of the COM Interfaces. what dual really means is that the same functionalities that you can access via IDispatch mechanism are also available as standard COM methods (i.e. are part of the interface itself).
So you mean even if we do not explicitly add dual to the property, we can still use dual (by vtable and by IDispatch.invoke()) functions if underlying component support it?
If yes, what is the function of dual keyword? It does not enforce anything strictly, right?
(non-dual does not mean there is single -- IDispatch.invoke -- method to access component)
regards,
George
|
|
|
|