|
|
Hi! everybody:
I'm developing a ActiveX control which is a windowless, If I find something special in my class, I want to SendMessage to this ctrl and let it do something , but I can not get the window handle of this ctrl, so this ctrl also can not get this message.(I have tried AfxGetMainWnd, it doesn't work)
Does anyone has similar experience? Plesae give me some ideas, I'll appreciate
your help.
Ray
|
|
|
|
|
Hi,
As far as I know, it is not possible. Windowless ActiveX controls have no HWND by definition. Of course, COM passes RPC calls using thread message queue (in a case if the object belongs to a single-threaded appartment) but it cannot be simulated (and must not be).
The simplest way to handle it is to call a method of your control at the moment you need. The result will be exactly the same as with SendMessage - the control will process your call and return back. This will requre your caller class to hold an interface pointer to the control or provide it via a callback function.
--
Best Regards,
Andrew
|
|
|
|
|
I have a vector of integer that can have around 10,000 into it. There are cases when all the values in this vector are same. Right now i am just iterating through all the vector to find this out. Just wondering if someone can advise any better and optimistic way of doing this.
|
|
|
|
|
You can make use of a map to increment a counter for every time your data has a value.
map <int,int> g_mapData;
void insert(int val)
{
map <int,int>::iterator it;
it = g_mapData.find(val);
if ( it != g_mapData.end() ) {
it->second++;
}
else
{
g_mapData.insert(pair<int,int>(val,1));
}
}
And here is a test program
void main()
{
insert(0);
insert(10);
insert(5);
insert(0);
insert(5);
insert(0);
map<int,int>::iterator i;
for(i=g_mapData.begin();i != g_mapData.end();i++) {
cout << i->first << " , " << i->second << endl;
}
}
And the results are:
0 , 3
5 , 2
10 , 1
John
|
|
|
|
|
Thanks for the reply, But is there some way of doing this within a vector without adding another data structure.
|
|
|
|
|
Either keep the values sorted when they are inserted, or keep an index as the previous answer said. Without keeping some sort of index on the data, all you can do is a brute-force search.
--Mike--
"Big handwavy generalizations made from a position of deep ignorance is one of the biggest wastes of time on the net today.
-- Joel Spolsky
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
|
|
|
|
|
If you want you can always add all items from the vector to the map only when you need to analyze your data.
John
|
|
|
|
|
Hi,
Ive been looking for examples of simple ActiveX applications (i have to convert an MFC program to an ATL one for a website. Instead of downloading an executable then running that file the dll is downloaded and the program is run off the website) and i cannot get my head round any of the resources ive found so far. Does anyone know a good place to start (with some simple examples)?
Thanks
|
|
|
|
|
Look at CodeProject COM section. Check CodeGuru and Mindcracker.
http://www.codeproject.com/atl/
http://www.codeguru.com/atl/index.shtml
http://www.mindcracker.com/mindcracker/c_cafe/atl.asp
Kuphryn
|
|
|
|
|
Hi,
I have added a menuitem to the systemmenu as..
xMenu.InsertItem(0, MF_POSITION, ID_SETTINGS, "&Settings");
Also, I have added a command handler as..
COMMAND_ID_HANDLER(ID_SETTINGS, OnSettings)
When I run the program, I can see the new menu item but when I click on it, the function OnSettings() doesn't get called!! What am I missing here?
thanx in advance
HV
|
|
|
|
|
make sure whether the menu message is send to your window
I am seeking...
For what?
Why did you ask me for what? I don't know!
|
|
|
|
|
You need to handle WM_SYSCOMMAND . Use MESSAGE_HANDLER .
rechi
|
|
|
|
|
|
Hi,
Can anyone point me towards a good example of using DBProp_ISequentialStream to save BLOBS with the VC7 ATL DB Consumer templates.
The AOTBLOB sample often referred to as the answer to such requests does not appear to work with VC7/JET 4.0 (as compiled straight from the MS archive) and I must confess to not being inclined to track down the specific problem.
Thanks,
Displaced Aussie. Currently in London, normally living in Melbourne.
modified 10-Jul-19 21:02pm.
|
|
|
|
|
The way that I've done this is to implement a C++ object that looks like ISequentialStream, and given the vtable (aka interface) to the provider.
You must provide the status for the column, and some providers may require that you provide the actual length of the blob.
Different providers were 'odd' though; for instance, with SQLServer it fills in the length and status for a blob column (and you need to do likewise when writing), whereas with Oracle's own provider, the length is always 4, which coincidentally is sizeof(void*). Never used Access/JET in this way though.
Displaced eh? I guess that means Melbourne, Australia, rather than Melbourne, Derbyshire.
Steve S
[This signature space available for rent]
|
|
|
|
|
Have you looked at Ed Gadziemski's "Using Blobs with WTL OLE DB Database Applications" on Code Project ( http://www.codeproject.com/wtl/oledb2.asp [^] )? While not specifically geared to VC7, it does address blobs and OLE DB. Perhaps you could adapt it for your needs.
|
|
|
|
|
How to prevent binding a Type library to a ATL Attributed DLL ?
need help
ty
tal halfon
|
|
|
|
|
My ActiveX controls
with property of
IPictureDisp, (Picture hanling -from AtlButton MSDN sample)
take much time for - unload - ,(for 20 controls 5 seconds -
- typical registry time).
All other program waits for this unload - so it is big problem.
How to solve it?
Does there is a method to prevent controls in a dialog to write to registry at destroying of owing them dialog?
I use only C++ property browser,
so can you say: what is unneed interfaces of this control:
<br />
class CAtlButton :<br />
public CTimer<CAtlButton, IAtlButton, &__uuidof(IAtlButton)>,
public CComControl<CAtlButton>,<br />
public CStockPropImpl<CAtlButton, IAtlButton, &__uuidof(IAtlButton), &CAtlModule::m_libid>,<br />
public ISpecifyPropertyPagesImpl<CAtlButton>,<br />
public IPersistStreamInitImpl<CAtlButton>,
public IOleControlImpl<CAtlButton>,<br />
public IOleObjectImpl<CAtlButton>,<br />
public IOleInPlaceActiveObjectImpl<CAtlButton>,<br />
public IViewObjectExImpl<CAtlButton>,<br />
public IOleInPlaceObjectWindowlessImpl<CAtlButton>,<br />
public IPersistPropertyBagImpl<CAtlButton>,
public IPersistStorageImpl<CAtlButton>,
public IQuickActivateImpl<CAtlButton>,<br />
public IDataObjectImpl<CAtlButton>,
public IObjectSafetyImpl<CAtlButton, INTERFACESAFE_FOR_UNTRUSTED_CALLER>
,public IPerPropertyBrowsingImpl <CAtlButton>
thanks you
|
|
|
|
|
I have embed excel into my application and would like to overide my onprint function. Upon entry into this function
pDC->m_hAttribDC; pDC->m_hDC; Are both NULL. the CDC* pDC however is not.
If I try calling onPrint before an excel spreadsheet is open, then neither member is NULL. Only when I have an excel spreadsheet open are these members NULL. Why is this so?
Sincerely,
Mardigin
|
|
|
|
|
Okay I was able to get the hdc in the following manner
<br />
void CBPReportView::OnPrint(CDC* pDC, CPrintInfo* pInfo)<br />
{<br />
<br />
if(pInfo->m_bDocObject)<br />
{<br />
CDC * pOleDC = this->GetDC();<br />
pDC->Attach(pOleDC->m_hDC);<br />
pDC->TextOut(100,100,"Muah ha ha h aa");<br />
COleDocObjectItem::OnPrint(this, pInfo, TRUE);<br />
ReleaseDC(pOleDC);<br />
}<br />
else<br />
CView::OnPrint(pDC, pInfo);<br />
}<br />
Only trouble is that "muah ha ha h aa" never shows up on my printed page, only the excel spreadsheet shows up. Any ideas?
Mardigin
|
|
|
|
|
Greetings people,
I have a strange question here [might not be strange to you *grins*].
I have created an ActiveX Composite control with a combo box in it. I filled the data into the combo box through it's properties->data tab. However, when I test it using the ActiveX Control Test Container or the browser, there is nothing in the combo box.
So, I tried another approach, by using a for loop like this:
char *m_cC[3]={"Cash","Cheque","Credit Card"};
for(int i_P=0;i_P<3;i_P++)
cbControl->AddString(m_cC[i_P]);
The same problem still persists, there is nothing in the combo box. Is there another way to initialize a combo box in ATL technology?
Please advise.
Thank you!
|
|
|
|
|
Hi all.
I have some COM object what contained inside itself another object and i want retrieved this inner object though some method of outer object.
I.e. make like that
HRESULT GetInnerObject(CoInnerObj** ppObj){
* ppObj = m_pInnerObj;//pointer to my inner objetc
return S_OK;
}
May i do this or its unproper way.
I has done my COM object this manner and its work fine, but me suggest don't use this way(and retrieved only interfaces through methods).
I want recognize why??
Also i watch in COM any microsoft applications same way of decision this problem.
Thanks.
|
|
|
|
|
COM is interface-based programming. In general, a thread seens an interface, not a pointer to a coclass. There are numerous possible problems. One problem is compatibility. What you are trying to do is unconventional.
Kuphryn
|
|
|
|
|
The following is a snippet is the code that actually embeds excel into my application and then attempts to remove the insert menuitem. I have read through more then one tutorial, but the most important one to note here is the following: http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q180/6/25.asp&NoWebContent=1
If anyone has anyideas of what is wrong with this code please reply.
Note: The above tutorial instructs to create a dlg based application, Mine is an MDI application. The above tutorial controls excel, my application embeds and then attempts to control excel. It works fine right up until it calles cbPop.SetVisible(FALSE);
Then it falls into the catch:
CException e.m_bAutoDelete = 1
CException e.m_bReadyForDelete = 0
The code I have included here shows how I embed excel and display it on the screen. This is all that i do differently from the above tutorial.
<br />
CBPReportCntrItem *pItem = NULL;<br />
CBPReportDoc *pDoc = NULL;<br />
CLSID clsid;<br />
TRY<br />
{<br />
pDoc = GetDocument();<br />
ASSERT_VALID(pDoc);<br />
<br />
pItem = new CBPReportCntrItem(pDoc);<br />
ASSERT_VALID(pItem);<br />
<br />
if(FAILED(::CLSIDFromProgID(L"Excel.sheet",&clsid)))<br />
{<br />
AfxMessageBox("Failed to create Excel.sheet");<br />
AfxThrowMemoryException();<br />
}<br />
<br />
if(!pItem->CreateNewItem(clsid))<br />
{<br />
AfxMessageBox("Failed to create the excel embeded item");<br />
AfxThrowMemoryException();<br />
}<br />
<br />
ASSERT_VALID(pItem);<br />
<br />
pItem->DoVerb(OLEIVERB_SHOW, this);<br />
<br />
m_pSelection = pItem;
pDoc->UpdateAllViews(NULL);<br />
<br />
lpDisp = pItem->GetIDispatch();<br />
<br />
app.AttachDispatch(lpDisp, TRUE);<br />
<br />
Then further down I did the following
<br />
cbPop.AttachDispatch(app.DetachDispatch(), TRUE);<br />
cbPop.SetVisible(FALSE);<br />
Sincerely,
Mardigin
|
|
|
|
|