|
I was wondering about the windowless aspect. Does layered windows play a part with this? Thanks for the feedback I will try what you suggested.
-SJ
Manufacturing Software Developer
Hewlett-Packard Company
|
|
|
|
|
Its been a while since I have been able to get back to this code but here I am.
Ok, to keep things simple I created a basic Windowless control that subclasses nothing. To cause the control to update I added a left mouse click handler in the control. I understand that IOleInPlaceObjectWindowless interface will redirect this mouse click from the container back to the control because since the control now has no window of its own it cannot handle the mouse message by itself. Because of the interface now it can. I added it so that I can manually cause the control to be updated therefore causing its OnDraw() method to be called.
So far so good. Then I put your code which calls the method MyControl::GetClientSiteMember() in the left mouse click handler. That works too.
How did you make sure the container had a valid window before calling any functions that report back stuff related to it's window handle? For example, calling GetClientRect() should get the rect for the control but I believe it uses the containers window handle or something like that. If I put GetClientRect in the control's OnDraw() is get an unhandled exception, basically the m_hWnd == NULL.
The whole thing im trying to do is draw a border around the control, draw a few shapes inside the control area rect and allow the container's background underneath the control to show through.
MSDN's Providing Windowless Activation talks about common examples of using windowless controls as having transparent controls. Text is painted but not the control background. They give no further direction as far as I could find.
Your help is appreciated but I think I need a little more direction.
BTW, in case you were wondering, I have successfully created a few MFC and one ATL ActiveX controls (windowed) and they work fine. But they are not transparent nor transluscent.
-SJ
Manufacturing Software Developer
Hewlett-Packard Company
|
|
|
|
|
Two Items:
1) Yes, the windowless control's 'window' is the parents window. GetClientRect should return the contorls size, not its location. When drawing the control, you could get the position/location of your control by using the passed in paramater "rcBounds".
[OnDraw(CDC* pDC, const CRect& rcBounds, const CRect& rcInvalid)]
It may not be necessary, for your control to be windowless. Depending on your needs, you may want to process OnEraseBkgnd function and return 1. This will tell the framework that you have taken care of the drawing/erasing of the background.
2) Second idea, again depending on your needs this may or may not work. Its an ALT 3.0 component and will demonstrate a transparency effect.
Do the following:
a) create an ALT COM component via "Alt COM Wizard" in Visual Studio MFC (I used VC++ 6.0 with MFC)
b) when specifying the control atrributes, unselect the 'Opaque' option (see figure: http://www.microsoft.com/msj/0299/atl3Activex/atlfig12.gif[^])
c) Add a ALT control to your project "Full Control"
d) Process the following messages WM_ERASEBKGND and WM_MOUSEMOVE (OnEraseBkgnd & OnMouseMove)
e) Declare a CPoint member variable name it "m_Point"
f) Drop in the following code for the OnDraw, OnEraseBkgnd and OnMouseMove funstions:
HRESULT OnDraw(ATL_DRAWINFO& di)
{
CString strTemp;
RECT& rc = *(RECT*)di.prcBounds;
//Set Background for text the be transparent
SetBkMode(di.hdcDraw, TRANSPARENT);
//Format Mouse Position Text
strTemp.Format("X: %d Y: %d ",m_Point.x,m_Point.y);
SetTextAlign(di.hdcDraw, TA_CENTER|TA_BASELINE);
LPCTSTR pszText = strTemp;
TextOut(di.hdcDraw, (rc.left + rc.right) / 2, (rc.top + rc.bottom) / 2, pszText, lstrlen(pszText));
return S_OK;
}
LRESULT OnEraseBkgnd(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
return 1;
}
LRESULT OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
m_Point.x = (short)LOWORD(lParam);
m_Point.y = (short)HIWORD(lParam);
HWND hParent = GetParent();
/*For better results, Determine the controls RECT and pass it in the InvalidateRect() fucntion below,
doing this this will result in only your control being redrawn, rather than having your parents entire rect be redrawn and result in flashing/blinking */
::InvalidateRect(hParent, NULL, true);
return 0;
}
Hope that helps you out a bit.
|
|
|
|
|
Hi,
Is it possible to create a com-addin , which can sync contacts,calender and tasks with the remote database using webservices.
The client side addin should be capable of interacting with the server component(typically webservice) which talks to the database.
the addin which sits on the client machine(outlook) should do the following.
1) provide automatic and manual sync ( Configurable)
2) provide UI for configuration
3) scheduling (incase of automatic sync)
4) perform conflict resolution ( data between the database and the outlook items)
last but not least!
is com-addin is the solution , or i have another best option?
Thanks in advance.
|
|
|
|
|
am having 2 problems. First problem has the highest priority. I mean I want to solve my first problem first ASAP.
1.) I am working with powerpoint Automation. Using VB Macro I have to call a function from a dll. This called function in turn has to call another function from another dll. I have been able to call the function from the first dll (using vb macro). Whats my problem is that I m not able to call the function(in second dll) from the first dll. I am using __declspec(dllexport) in the second dll and __declspec(dllimport) in the first dll. I think what I m missing here is that I don't know how to tell the first dll that which dll it shud consider for the called function.
My first dll is for keyboard hooking and second for displaying MS Agent. Can neone help me.
2.) Also, further if anyone can guide me about how to do mouse hooking???
|
|
|
|
|
well for mouse hooking you can use CBT hooks if I remember , see in MSDN for that.
I am still studying your first problem,
May be i will reply in another 10 minutes..
Regards
Tarundeep Singh Kalra
************************
www.tarunsadhana.com
************************
All men die. Not all men really live”. - “Braveheart”, 1995
|
|
|
|
|
Hi technojewel,
As i understand you are using dll in VB and your dll has some exported functions using __declspec(dllimport)...
If you are exporting functions using __declspec(dllimport), dont expect that VB will understand it (It will give an error Bad Calling Convension ).
Insead you should use WINAPI and .def file for exporting functions.
I thing it may help u !
Cheers,
Vishal
|
|
|
|
|
Hello guys, I'm trying to make a client/server .NET com+ application... My com+ class is done and enterprise services really knows it like com+ but when I try to "Export" this application at enterprise services it just enables me to Export as Server Application and I want to Export as Application Proxy.
How to export a .NET COM+ class at enterprise services as an application proxy or how to make this communication beteween 2 pcs.
Thanks...
Wender Oliveira
.NET Programmer
|
|
|
|
|
Hello,
I am getting very unique problem till now I haven't got any solution for this problem. I am describing the problem hope I will get solution from you.
I have created one ATL COM Component, this in turns call a third party library API which provide mapping solution. The main work of this COM Component is to create dynamic map upon request. I made this component to work with our ASP.net application. For testing purpose I have created a Standalone application in C# also. In my development machine this ATL COM Component runs fine with standalone application as well as in ASP.net Application. It instantiates then it instantiates third party 7Cs API. Checks for Registration of third party 7Cs API then do the other job.
But When I install this application in other machine this dll as well as application (Both StandAlone as well as ASP.Net) after registering the 7Cs Library and their data. The standalone application runs fine and do its work but through ASP.Net Web Application it hangs on the first API which checks the library has valid registration. It did not return from the function. The same thing runs fine from my development machine with both type of application. But fails in other machine with Web Application.
I thought it was permission problem under ASP.Net execution I have given all permission but still the problem persists.
Can any body give me any tips as I know you all people are very intelligent in your respective field.
Regards
Anuj Mishra
Software Engineer
|
|
|
|
|
Is there a way to find out more about the cause of the failure?
It used to work but not anymore.
It did that to me on two different computers.
The file other.dll doesn't get copied to C:\WINNT\system,
so myX.dll cannot be registered (since it depends on it).
See CAB, INF file and error log below...
Thanks!
-----------------
CAB FILE CREATION
-----------------
CabArc.exe n myX.cab other.dll myX.dll myX.inf
--------
INF file
--------
[Version]
; This section is required for compatibility on both Windows 95 and Windows NT.
Signature="$CHICAGO$"
AdvancedInf=2.0
[Add.Code]
other.dll=other.dll
myX.dll=myX.dll
[other.dll]
file-win32-x86=thiscab
FileVersion=1,0,0,1
DestDir=10
RegisterServer=no
[myX.dll]
file-win32-x86=thiscab
clsid={98B6686C-EF56-4FFF-ACBD-2BC5A853377D}
FileVersion=1,0,0,1
RegisterServer=yes
------------
IE Error log
------------
*** Code Download Log entry (02 Mar 2005 @ 14:34:52) ***
Code Download Error: (hr = 8007007e) The specified module could not be found.
Operation failed. Detailed Information:
CodeBase: file:///C:/Dev/myX/myX.cab
CLSID: {98B6686C-EF56-4FFF-ACBD-2BC5A853377D}
Extension:
Type:
LOG: Item other.dll being processed.
--- Detailed Error Log Follows ---
LOG: Download OnStopBinding called (hrStatus = 0 / hrResponseHdr = 0).
LOG: Item other.dll being processed.
LOG: Item myX.dll being processed.
LOG: URL Download Complete: hrStatus , hrOSB:1, hrResponseHdr , URL:(file://C:\Dev\myX\myX.cab)
LOG: File C:\WINNT\Downloaded Program Files\myX.dll being registered.
ERR: Setup Failed Error Code: (hr) = 8007007e, installing: myX.dll to (null) destination code(0)
LOG: Reporting Code Download Completion: (hr:8007007e (FAILED), CLASSID: 98b6686c..., szCODE:(file:///C:/Dev/myX/myX.cab), MainType:(null), MainExt:(null))
|
|
|
|
|
I'm being driven slowly mad trying to figure out how to make this function work!
I have a word document that I have in memory, and place this in an IStream derived class.
When I try to BindIFilterFromStream, the Stat method in my class is called, then BindIFilterFromStream returns E_FAIL. It doesn't seem to even inspect the data held in the stream.
Are there some special values I need to set during Stat?
Does this function even actually work?
|
|
|
|
|
i m building COM components in VC++ using ATL lib.
I want to dyanamically create listboxes on my dialog.
I hav tried using classes in "atlcontrols.h" but dont know which Window handle to pass to get the list box on dialog.
Same with Static text boxex n edit boxes.
Can u plz try n give me some soln .
Gaurav Jain
K.K. Wagh Institue of Engineering Education and Research,
Nashik,
Maharashtra,
India.
gauravjain911@yahoo.com
|
|
|
|
|
I have written a c# utility that monitors the status of a running application. The running application (lets call it ABC.EXE) exposes a com interface and I can obtain information such as the active customer number etc.
The first problem I had was that if I attempted to create a new ABC object it would automatically execute the ABC.EXE if it wasn’t already running. I managed to fix this by checking for the presence of the window (findwindow) beforehand.
However, the user may have more than one instance of ABC.EXE running, and I only want to communication with a specified one.
I’m a bit stuck on this. Any help appreciated.
|
|
|
|
|
Dear friends,
I have created a project in VB having MSFlexgrid. I have to fill records to that grid by VC code(ATL component). So how I get the reference of that grid in VC. Please help me.
|
|
|
|
|
Hello I am new to COM,OLE,AUTOMATION,ActiveX in Vc
so please provide me the difference among each there as well as their purpose
Thanks
Fahad Bilal
|
|
|
|
|
hi!!
im trying to create a Schema rowset as i want to display the tables existing in the database.
but im geting a Windows Error Report as soon as i execute getrowset function. Im building a COM using ATL.
any help is welcome.
STDMETHODIMP Cfuctcont::pop()
{
// TODO: Add your implementation code here
DBPROP InitProperties[5], InitProperty[3];
DBPROPSET rgInitPropSet;
IDataInitialize * pDataInit = NULL;
IDBInitialize * pDataSourceIDBInitialize = NULL;
IDBCreateSession * pSession = NULL;
IDBProperties * pProperties = NULL;
IDBCreateCommand * pCreateCommand = NULL;
ICommand * pCommand = NULL;
ICommandProperties * pCommandProperties = NULL;
ICommandText * pCommandText = NULL;
IOpenRowset * pOpenRowset = NULL;
IRowset * pRowset = NULL;
IRowsetChange * pRowsetChange = NULL;
IDBSchemaRowset * pSchemaRowset =NULL;
WCHAR wszProvider[] = L"MSDASQL"; // The Provider string
CLSID clsid;
HRESULT hr= S_OK;
// Init OLE and set up the data
CoInitialize(NULL);
// Setting up all the properties
// a) Setting up the Intitialization properties
for(long i=0;i<5; i++)
{
InitProperties[i].dwOptions = DBPROPOPTIONS_REQUIRED;
InitProperties[i].colid = DB_NULLID;
InitProperties[i].dwStatus = DBPROPSTATUS_OK;
}
// Data source string.
InitProperties[1].dwPropertyID = DBPROP_INIT_DATASOURCE;
InitProperties[1].colid = DB_NULLID;
InitProperties[1].vValue.vt = VT_BSTR;
InitProperties[1].vValue.bstrVal = SysAllocString(L"user");
InitProperties[4].dwPropertyID = DBPROP_INIT_OLEDBSERVICES;
InitProperties[4].vValue.vt = VT_I4;
InitProperties[4].vValue.lVal = DBPROPVAL_OS_ENABLEALL;
rgInitPropSet.guidPropertySet = DBPROPSET_DBINIT; // the property set
rgInitPropSet.cProperties = 5; // # of properties being set
rgInitPropSet.rgProperties = InitProperties; // array of DBPROP structures
// b) The Rowset properties
InitProperty[0].dwPropertyID = DBPROP_CANFETCHBACKWARDS;
InitProperty[1].dwPropertyID = DBPROP_IRowsetLocate;
for(i=0;i<2; i++)
{
InitProperty[i].dwOptions = DBPROPOPTIONS_REQUIRED;
InitProperty[i].colid = DB_NULLID;
InitProperty[i].dwStatus = DBPROPSTATUS_OK;
}
// 1. Data Source Initialization
hr = CoCreateInstance(CLSID_MSDAINITIALIZE, NULL, CLSCTX_INPROC_SERVER, IID_IDataInitialize, (void**)&pDataInit);
// Creating the IDBInitialize
hr = CLSIDFromProgID(wszProvider, &clsid);
hr = pDataInit->CreateDBInstance(clsid, NULL, CLSCTX_INPROC_SERVER, NULL, IID_IDBInitialize, (IUnknown**) &pDataSourceIDBInitialize);
// Setting the Initialization properties
hr = pDataSourceIDBInitialize->QueryInterface(IID_IDBProperties, (void**)&pProperties);
hr = pProperties->SetProperties(1,&rgInitPropSet);
hr = pDataSourceIDBInitialize->Initialize( );
hr = pDataInit->Release();
hr = pProperties->Release();
//session creation
hr = pDataSourceIDBInitialize->QueryInterface(IID_IDBCreateSession, (void**)&pSession);
hr = pDataSourceIDBInitialize->Release();
IUnknown *pUnkSession =NULL;
hr = pSession->CreateSession(NULL, IID_IOpenRowset, &pUnkSession);
IDBSchemaRowset * pIDBSchemaRowset = NULL;
// pUnkSession->QueryInterface(IID_IDBSchemaRowset, (void**)&pIDBSchemaRowset);
pSession->Release();
IUnknown * pUnkCommand = NULL;
IOpenRowset * pIOpenRowset = NULL;
WCHAR wszTableName[11] = {0};
DBID TableID;
IUnknown *ppUnkRowset;
IUnknown *ppRowset;
VARIANT rest[]={VT_EMPTY,VT_EMPTY,VT_EMPTY,VT_EMPTY};
::MessageBox(NULL,"Helooo",NULL,MB_OK);
const ULONG cProperties = 2;
DBPROP rgProperties[cProperties];
DBPROPSET rgPropSets[1];
// rgPropSets, cProperties, rgProperties);
//DBPROPSET* pPropSet, ULONG cProperties, DBPROP* rgProperties)
rgPropSets->rgProperties = rgProperties;
rgPropSets->cProperties = cProperties;
rgPropSets->guidPropertySet = DBPROPSET_ROWSET;
rgProperties[0].dwPropertyID = DBPROP_CANFETCHBACKWARDS;
rgProperties[1].dwPropertyID = DBPROP_IRowsetLocate;
for(i=0;i<2; i++)
{
rgProperties[i].dwOptions = DBPROPOPTIONS_REQUIRED;
rgProperties[i].colid = DB_NULLID;
rgProperties[i].dwStatus = DBPROPSTATUS_OK;
}
hr = pSchemaRowset->GetRowset (
NULL,
DBSCHEMA_TABLES,
0,
NULL,
IID_IRowset,
1,
rgPropSets,
&ppRowset);
if(hr==S_OK)
::MessageBox(NULL,"ok",NULL,MB_OK);
if(hr==DB_S_ERRORSOCCURRED )
::MessageBox(NULL,"HI",NULL,MB_OK);
if(hr==DB_S_ASYNCHRONOUS)
::MessageBox(NULL,"HI1",NULL,MB_OK);
//if(hr==DB_S_NOTSINGLETON )
//::MessageBox(NULL,"HI2",NULL,MB_OK);
if(hr==E_FAIL )
::MessageBox(NULL,"HI3",NULL,MB_OK);
if(hr==E_INVALIDARG )
::MessageBox(NULL,"HI4",NULL,MB_OK);
if(hr==E_NOINTERFACE )
::MessageBox(NULL,"HI5",NULL,MB_OK);
if(hr==DB_E_ABORTLIMITREACHED)
::MessageBox(NULL,"HI6",NULL,MB_OK);
if(hr==DB_E_ERRORSOCCURRED)
::MessageBox(NULL,"HI7",NULL,MB_OK);
if(hr==DB_E_NOAGGREGATION)
::MessageBox(NULL,"HI8",NULL,MB_OK);
if(hr==DB_E_NOTFOUND )
::MessageBox(NULL,"HI9",NULL,MB_OK);
if(hr==DB_E_NOTSUPPORTED)
::MessageBox(NULL,"HI10",NULL,MB_OK);
if(hr==DB_SEC_E_PERMISSIONDENIED)
::MessageBox(NULL,"HI11",NULL,MB_OK);
if(hr==DB_E_OBJECTOPEN )
::MessageBox(NULL,"HI12",NULL,MB_OK);
if(hr==E_OUTOFMEMORY )
::MessageBox(NULL,"HI13",NULL,MB_OK);
::MessageBox(NULL,"HIsfsf",NULL,MB_OK);
return S_OK;
}
thanking you.
Gaurav Jain
K.K. Wagh Institue of Engineering Education and Research,
Nashik,
Maharashtra,
India.
gauravjain911@yahoo.com
|
|
|
|
|
could you please help me in finding fft scale factor in Magnetic resonance Dicom images fromo the header information.
|
|
|
|
|
Greetings,
A dicom Server project contains several complete iods. I believe one is the mri iod.
|
|
|
|
|
How do i implement COM/activex objects in c++?
for example i want to use wscript.shell obj?
|
|
|
|
|
If you really need to program COM in raw C++ then get ready you have to read a lot as it is possible to create in raw C++ but it requires lot of efforts. You have to implement from Class factory to QueryInterface to Addref, Release on your own.
I you choose to implement COM through ATL then Most of your work are already done and you only have to concentrate on main programming logic.
Refer Book on COM Programming from DON BOX if you really need to implement COM in C++.
Anuj Mishra
Software Engineer
|
|
|
|
|
i am not having any idea about mfc & vc++
can anyone help me to clear concepts of mfc , window programing, vc++.
and also suggest some books to read as beginer
|
|
|
|
|
use Programming Windows in VC++ by Charles Petzold
|
|
|
|
|
|
I just want to know when we allocate a BSTR using SysAllocString(), where does COM allocate its memory? In process's own heap? some shared memory or where?
BSTR is just a wchar_t with size of string added in its start, if i create my own string in this format and pass it to any COM function, will that work?
+
LPWSTR allocated with CoTaskMemAlloc() doesnot have size in its start, how does COM decide whether to check size from start of string or check for null terminating string??
Muhammad Shoaib Khan
http://geocities.com/lansolution
|
|
|
|
|
1. wild guess - on the heap of the library that exported the SysAllocString ?
2. I think yes, as long as you will be the one who releases the memory back
3. when expects BSTR , it expects the size on the start, when parameter is LPWSTR , it checks for zero termination.
|
|
|
|
|