|
Hi all,
Here is the situation. We have this driver box that we can communicate via USB using the libraries provided by the manufacturer. The library came with a .tlb, /lib and .h file and its written based on COM model and requires ATL support. So, in VC++ I can just create a MFC application and add an ATL object, include the .h file, import the .tlb file and create CComPtr variable derived for their object for the driver and communicate with the driver through that object. Everything works fine.
But now I need to use the library that they provided in LabWindows CVI where these libraries wont work. It doesnt have ATL support. I tried creating a MFC applciaiton where it listens to the serial port and CVI sending commands to the MFC application via serial port, but this is slow.
Is there any other way where I can create something that can be added into CVI as an object without bothering about the stuff in the object other than just communicating with it within the CVI program (ActiveX??).
thanks in advance.
PKNT
|
|
|
|
|
Usually you don't need either MFC nor ATL to cunsume COM components.
On LabWindows CVI website there are samples about using ActiveX components, see [^].
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
[My articles]
modified on Thursday, March 26, 2009 3:05 PM
|
|
|
|
|
Actually its not an ActiveX object, I just thought if I can use that type to interate in CVI.
Here is what the driver manual said,
"The Driver USB Library is implemented as an object that conforms to Microsoft's Component Object Model (COM). A COM object is an instance of a COM class. Clients interact with a COM object only through its interfaces.
To create an instance of the COM object in a C++ program, include the following lines of code in your program:"
#include "..\DriverUsbLib\DriverUsbLib.h"
#import "..\DriverUsbLib\_DriverUsbLib.tlb" no_namespace
using namespace std;
CComPtr<ihostdrv> pIHostDrv;
HRESULT hr = CoCreateInstance(__uuidof(CHostDrv), NULL, CLSCTX_INPROC,
__uuidof(IHostDrv),(LPVOID *) &pIHostDrv);</ihostdrv>
I was not able to do the same thing in CVI. I tried to search on NI forums, but couldnt get any useful info on dealing with COM objects. Will keep looking on it.
thanks,
PKNT
|
|
|
|
|
I'm having trouble with getting search results from Active Directory since I installed Microsoft Echange. After Exchange installation the enum order changed so that child SOME objects are enumerated before parent. Before installing Exchange everything was OK. Now I want to fix this behavior with following piece of code (but currently unsuccessfull). The flag LDAP_DIRSYNC_ANCESTORS_FIRST_ORDER does not work for me.
Here is the piece of code:
void ImportComputersFromAd()
{
CComPtr<IDirectorySearch> pSearch;
HRESULT hr = ::ADsGetObject(L"LDAP://DC=mydomain", IID_IDirectorySearch, (PVOID*)&pSearch);
ADS_SEARCHPREF_INFO rgSearchPrefs[4];
DWORD dwNumPrefs = 0;
rgSearchPrefs[dwNumPrefs].dwSearchPref = ADS_SEARCHPREF_SEARCH_SCOPE;
rgSearchPrefs[dwNumPrefs].vValue.dwType = ADSTYPE_INTEGER;
rgSearchPrefs[dwNumPrefs].vValue.Integer = ADS_SCOPE_SUBTREE;
dwNumPrefs++;
ADS_PROV_SPECIFIC dirsync;
dirsync.dwLength = 0;
dirsync.lpValue = NULL;
rgSearchPrefs[dwNumPrefs].dwSearchPref = ADS_SEARCHPREF_DIRSYNC;
rgSearchPrefs[dwNumPrefs].vValue.dwType = ADSTYPE_PROV_SPECIFIC;
//rgSearchPrefs[dwNumPrefs].vValue.ProviderSpecific.dwLength = sizeof(dirsync);
rgSearchPrefs[dwNumPrefs].vValue.ProviderSpecific = dirsync;
dwNumPrefs++;
rgSearchPrefs[dwNumPrefs].dwSearchPref = ADS_SEARCHPREF_DIRSYNC_FLAG;
rgSearchPrefs[dwNumPrefs].vValue.dwType = ADSTYPE_INTEGER;
rgSearchPrefs[dwNumPrefs].vValue.Integer = LDAP_DIRSYNC_ANCESTORS_FIRST_ORDER;
dwNumPrefs++;
hr = pSearch->SetSearchPreference(rgSearchPrefs, dwNumPrefs);
LPOLESTR pszAttribute[] = { L"ADsPath"};
CONST DWORD dwAttrNameSize = 1;
ADS_SEARCH_HANDLE hSearch;
hr = pSearch->ExecuteSearch(L"(|(objectClass=computer)(objectClass=organizationalUnit))", pszAttribute, dwAttrNameSize, &hSearch);
while(pSearch->GetNextRow(hSearch) != S_ADS_NOMORE_ROWS)
{
for(DWORD x = 0; x < dwAttrNameSize; x++)
{
ADS_SEARCH_COLUMN col;
HRESULT hr2 = pSearch->GetColumn(hSearch, pszAttribute[x], &col);
if(hr2 != E_ADS_PROPERTY_NOT_FOUND // 0x8000500d - The directory property cannot be found in the cache
&& hr2 != 0x8007200a // The specified directory service attribute or value does not exist.
&& hr2 != E_ADS_COLUMN_NOT_SET //0x80005010 - The specified column in the Active Directory was not set.
&& hr2 != 0x80005008)
{
CComPtr<IADs> srpiads;
hr2 = ::ADsGetObject(col.pADsValues->CaseIgnoreString, IID_IADs, (PVOID*)&srpiads);
//pThis->AddComputerProperties(srpiads);
pSearch->FreeColumn(&col);
}
}
}
pSearch->CloseSearchHandle(hSearch);
}
|
|
|
|
|
I want to set Footer in every page in Excel.
i am working with excel 2003 so i m using Excel.h and Excel.cpp.
below is my code
Application appExcel;
Workbooks wbs,books;
_Workbook wb,book;
Worksheets wss,sheets;
PageSetup ps;
_Worksheet ws,sheet;
wbs = appExcel.GetWorkbooks();
wb = wbs.Add(covOptional);
//Get the first sheet.
wss=wb.GetSheets();
ws=wss.GetItem(COleVariant((short)(1)) );
ps=ws.GetPageSetup();
ps.SetLeftHeader(_AsciiFileName);
ps.SetRightHeader( "&D" );
ps.SetCenterFooter("Hello World");
when i use this code my application is gone in infinite loop.
Thanks
Rakesh
modified on Friday, March 27, 2009 9:23 AM
|
|
|
|
|
rakeshmohangarg wrote: Please provide me method to to set Header and Footer with example ASAP
ASAP, urgentz, plz, send codez, ... are blacklisted words on CP. Using them will cause uncontrollable rage in other CP members.
|
|
|
|
|
Oh. Someone didn't like your reply. I wonder who that could be?
Well I liked it so I will weigh in for what it's worth. I'm also considering helping him myself.
|
|
|
|
|
Ok sir, I removed ASAP. Now why are you wasting time instead of providing me the f*?#?ing code?
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
[My articles]
|
|
|
|
|
_Worksheet sheet;
PageSetup pageSetup = sheet.GetPageSetup();
pageSetup.SetCenterHeader("Hello World");
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I have created a CFormView on which I have created a dialog and I have made the Formview Transparent using the code below:
HBRUSH CABCFormView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);
//This code is used to make the view transparent
if( CTLCOLOR_DLG == nCtlColor )
{
hbr = (HBRUSH)GetStockObject(HOLLOW_BRUSH);
pDC->SetBkMode( TRANSPARENT );
}
return hbr;
}
but by doing this when I am moving the dialog, view is not getting refreshed and facing the paint issue...
Kindly suggest.....
Ajit
|
|
|
|
|
You could add a WM_MOVE handler and invalidate the formview in that? Or maybe in an WM_EXITSIZEMOVE handler?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I have made an mfc activex control and want to call javascript function from it.Kindly tell me how to do so.
thanx in advance.
|
|
|
|
|
B0606115 wrote: I have made an mfc activex control and want to call javascript function from it.
Welcome to code project
Your post implies a context for your problem which you have not detailed in your post. We required those details to assist you.
|
|
|
|
|
led mike wrote: Your post implies a context for your problem which you have not detailed in your post. We required those details to assist you.
ROFL - Did you take the soothing happy pill?
|
|
|
|
|
led mike wrote: Welcome to code project
Your post implies a context for your problem which you have not detailed in your post. We required those details to assist you.
Get out of the body of Mike !
|
|
|
|
|
Happy birthday Mike (or perhaps you won the lottery)
Anyway you lost 100 led points.
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
[My articles]
|
|
|
|
|
CPallini wrote: Anyway you lost 100 led points.
LMAO Of course, I'm sure I have plenty to spare!
I attracted a crowd with that one eh? I do try to remember to check for new users before I get the led out. This was his first post on CP.
|
|
|
|
|
led mike wrote: This was his first post on CP.
Yes, anyway his Member Id looks promising...
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
[My articles]
|
|
|
|
|
Hi led mike,
i am new to this i only know how to make mfc activex control and basics of javascript.the activex control is a simple project for my final yr in college.if u want then i can post the projectctrl.cpp file and the web page.So kindly help me in making my final yr project i only need to know how can i call javascript function from my activex as i have to display some messsge from it.
|
|
|
|
|
hey mike
can u please help me its very urgent and i have to submit my project of activex the only thing left is calling javascript function from activex.
Please help me.
|
|
|
|
|
See here and here and here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
hey david
the links u send are not much help for me.i only want to know how to call my javascript function from my mfc activex control.please help me its very urgent.
|
|
|
|
|
Hello,
I have a problem with a program I'm working on where I am using a couple of dll's to share functions. My question is how to overcome the problem when one dll is written using unicode and the other is not using unicode.
As it seems to me, the problem is that the linker does not recognize the function created in the other dll (even thought it is defined in the same header).
I have tried turning off the Unicode and this will work.
This is what is defined in the StdAfx.h file in the project using unicode.
#define _UNICODE
#include <tchar.h>
#define UNICODE
#include <windows.h>
When I comment out the _UNICODE and UNICODE definitions I will compile but when they are present I get the error
LNK2019: Unresolved external symbol "__declspec(dllimport)int __cdecl SomeFunctin(wchar_t*, int)... "
The function that I am trying to reach has the following header definition
int SomeFunction(_TCHAR *pszPath, int accessMode );
My guess is that the _TCHAR has different definitions (for some reason) when using unicode and not using it since the compiler seems to expect the function to use wchar_t* as first parameter and not _TCHAR*
Anyone who has any ideas about how to solve this?
|
|
|
|
|
Change the headers so that the character encoding is hard coded to what it actually is in the compiled DLL. Based on your comments, this is probably what you want:
int SomeFunction(char* pszPath, int accessMode );
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
If you're mixing them, then you're going to have some fun...
While it is good practise to use TCHAR so you can make unicode / non-unicode apps from the same code base, there's nothing stopping you explicitly using char / wchar_t, and the A/W versions of function names.
So you could do...
#include "stdafx.h"
#undefine _UNICODE
#undefine UNICODE
#include "MyNonUnicode.dll"
#define _UNICODE
#define UNICODE
#include "MyUnicode.dll"
...
This will be a bit confusing, but it can be done.
I'd try and make them be more uniform if at all possible though!
Have a look at http://www.codeproject.com/KB/string/cppstringguide1.aspx[^] for more information on TCHAR and friends.
Iain.
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!
|
|
|
|