|
Hello,
I am in need of a NON MFC sample project or code fragment that accesses a non-windowed ActiveX control. i.e., a control that doesn't have a GUI aspect to it like MSCOMM. After doing searches here and on MSDN, the only posts I've found suggest not to use the Win32 SDK, but to use MFC. In this instance, that is not an option. However, if there is an article that can be used to convince the customer otherwise and use MFC, that would be better. Right now they want to use the Win32 SDK with one of our ActiveX controls.
Any help would be appreciated.
Regards,
Paul...
|
|
|
|
|
use #import. It only includes <comdef.h> and not other ATL/MFC.
|
|
|
|
|
Thanks for the suggestion, but it doesn't explain much to me.
Here is the call to the Create function of the control:
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName,<br />
DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID,<br />
CCreateContext* pContext = NULL)
What is used for the CWnd* parameter since the parent will get event messages?
Do you have an example of how #import can be used for the call above?
|
|
|
|
|
I am confused "..NON MFC sample ..." "...non-windowed ActiveX..." "...that doesn't have a GUI aspect...".
In the sample above, you are creating window(1) and using MFC(2) for it. It kind of does not match the original requirement .
What I was proposing is following
in stdafx.h (or main.h or whatever.h file you are using)
#import "libid:12345" no_namespace //12345 being libid of your control
in your code.cpp
void somefunction()
{
//Note: IYourControlMainInterfacePtr and
//YourControlsCoClass generated by #import
IYourControlMainInterfacePtr spMain(__uuidof(YourControlsCoClass));
spMain->SomeMethodOnTheControl();
.....
}
|
|
|
|
|
AlexO wrote:
In the sample above, you are creating window(1) and using MFC(2) for it. It kind of does not match the original requirement
Well, I see what you mean but actually I am not using MFC and I am not creating a CWnd based window. The line of code is the create function for the control. One of the parameters is a pointer to a CWnd. The application does have a Window but created using CreateWindow ...so this is where I am stuck. Can't use any temp CWnd object to attach to, but the window is needed to get messages from the control. The non-GUI aspect is that the control does not display a pie chart or something ...it is used to control an I/O device. I think I have a lot of reading to do, but not sure where to look to do this or even if I am going about it the right way.
Thanks for the help.
Regards,
Paul...
|
|
|
|
|
Thanks for the help. I really need to read up on this stuff!
|
|
|
|
|
Control is the word, which probably confused us both. Here is the deal: even if your control has UI, you still (in most cases) can use it as a simple COM object. Since your control does not have UI, it simplifies the problem. In my example I showed how to create a COM object and call in method on it. My guess you do not need window, or at least do not need to attach your control to it.
|
|
|
|
|
|
I'm trying to save CDIalog objects in a vector, and it doesnt like the push_back since no copy constructor is available. How do I get around this?
Appreciate your help,
ns
|
|
|
|
|
save the addresses of the dialogs.
myVector.push_back(&someDialog);
Max.
|
|
|
|
|
Thats what I am going to do now. IT will be fine for my current tests, but I dont know if I'll need the actual object later. If I do I can alwyas deref this pointer right?
Appreciate your help,
ns
|
|
|
|
|
if it's in a vector you need to do something like :
CDialog* pDialog = (*it);
Max.
|
|
|
|
|
Thanks very much! It seems like it will do, except I'm troubled by a null pView pointer so I cant test things out yet ...
I have another thread about it.........
Since I was getting a null pView I resorted to externing for the moment and now I am getting a crash on the
CImageDisplay* imageDisplay =m_imageDisplayVector[0];
imageDisplay->GetWindowPlacement(&wp);
GetWindowPlacement, and thats because the pointer coming out of the vector (I only had one element in it) is null!!!!!
I'm plagued by null pointers today...
Help!
Appreciate your help,
ns
|
|
|
|
|
I want the location and size of my CDialog that was spawned by a CView. In the OnDestroy of the mainframe I will save the location,size etc. I have access to the CDIalog object I created.
SO if I do
imageDisplay.GetWindowRect(&rect);
what will come back in rect?
imageDisplay = *pdlg where pdlg was the modeless dialog pointer used in pdlg->Create()
Is this rect.top, .left etc not in terms of the coordinates of the Computer screen? MSDN says :
Copies the dimensions of the bounding rectangle of the CWnd object to the structure pointed to by lpRect. The dimensions are given in screen coordinates
Someone said to use GetWindowPlacement. Wont the GetWindowRect give me everything I need?
For GetWindowPlacement MSDN says:
rcNormalPosition<br />
<br />
Specifies the window’s coordinates when the window is in the normal (restored) position. <br />
but doesnt tell me what the coordinates origin is...
Appreciate your help,
ns
|
|
|
|
|
GetWindowRect tells the current screen coordinates.
GetWindowPlacement will tell you if the window is minimized, maximized or restored (normal) and it will tell you the coordinates of the window in restored state. These may be different from the current ones e.g. when the window is maximized.
Oliver
|
|
|
|
|
I used CryptAcquireContext with MS_ENHANCED_PROV and then created an RC4 key. I want to export this key without any encryption. I tried using PLAINTEXTBLOB on CryptExportKey. It works fine on XP, but fails on 2000 (with Enhanced Provider installed) with error NTE_BADKEY.
m_sessionkey is valid at that point. I can export it using my public key.
The line of code:
<br />
if (!CryptExportKey(m_sessionkey, 0, PLAINTEXTKEYBLOB, 0, NULL, &length))<br />
{<br />
DWORD dwErr = GetLastError();<br />
LogError(dwErr);<br />
return false;<br />
}<br />
std::vector<BYTE > keydata;<br />
keydata.resize(length);<br />
if (!CryptExportKey(m_sessionkey, 0, PLAINTEXTKEYBLOB, 0, &keydata[0], &length))<br />
{<br />
DWORD dwErr = GetLastError();<br />
LogError(dwErr);<br />
return false;<br />
}<br />
My article on a reference-counted smart pointer that supports polymorphic objects and raw pointers
modified 29-Aug-18 21:01pm.
|
|
|
|
|
not being an expert with microsoft's cryptoapi I would check if the key is generated with Exportable flag.
Might be also the Q228786 will be usefull for you. Don't have any more clue with great microsoft's CryptoAPI
|
|
|
|
|
|
I understand, but having no idea what was changed in XP crypto provider. Might be some small change, don't know. Can it be a question of service pack installed in W2K?
|
|
|
|
|
If you want the key value try this article:
http://www.codeproject.com/cpp/plaintextsessionkey.asp
Raphael Amorim Dantas Leite
VC++, VB, Java, .NET and eMbedded Programmer
|
|
|
|
|
|
I was wondering, pondering even, what would be the easiest way to check 1 character in a CString to see if it was a number?
The scenario is I have a string that could either be www.blah.com or it could be 123.123.123.132 or some other domain name or IP. I want to check whether its a domain name or IP address before I process the details, but I can't decide on the easiest way to do it.
Would a nasty if (string.GetAt(0}=='1')||(string.GetAt(0)=='2'.......
be the easiest way or is there some other technique I've not noticed?
Cheers lads & lassies
|
|
|
|
|
|
fantastic, I knew there was something I was missing but I just couldn't see it.
Thanks for the great fast help
|
|
|
|
|