|
Or without an explicit loop:
std::vector<myType> v1;
std::vector<myType> v2;
std::copy(v2.begin(), v2.end(), std::back_inserter(v1));
This code assumes:
#include <vector>
#include <algorithm>
#include <iterator>
Steve
|
|
|
|
|
If you mean make a third vector by summing two other vectors? If yes this code will do it:
vector<int> v1, v2, vout;
ASSERT(v2.size()>=v1.size());
transform(v1.begin(), v1.end(), v2.begin(), back_inserter(vout), plus());
This code assums the following:
#include <vector>
#include <algorithm>
#include <iterator>
#include <functional>
using namespace std;
Steve
|
|
|
|
|
Are the pixels in the RGBQUAD array stored from top left to bottom right of the image. I am trying to test sections of an image for color and I need to know how the pixels are stored.
For example:
bi->bmiColors[0].rgbBlue is the top left pixel and bi->bmiColors[lastindexvalue].rgbBlue is the bottom right pixel
Is that correct?
|
|
|
|
|
Yes that is where those pixels would be stored, provided the array was loaded properly. But working with images is usualy more complicated than that, it depends on the format of the image and who is filling the array.
INTP
Every thing is relative...
|
|
|
|
|
|
i have an activex control.
when i place it on a webpage like this
<OBJECT id="myObj" codebase="myObj.CAB#version=1,0,5,0" classid="clsid:57F..." border="0" height="514" width="655">
and in Javascript i write a func
myObj.OnSave();
it works perfectly, OnSave function is called successfully
but if i embed the same control on either VB or VC the OnSave function is not in the exported list at all
Not even in the object browser
so i tried
CString szStr("OnSave");
IDispatch *pObj;
pUnk->QueryInterface(IID_IDispatch,(void**)&pObj);
DISPID FuncID;
OLECHAR FAR* szMember = szStr.AllocSysString();
HRESULT hr = pObj->GetIDsOfNames(IID_NULL,&szMember,1,LOCALE_SYSTEM_DEFAULT,&FuncID);
::SysFreeString(szMember);
this also return DISP_E_UNKNOWNNAME
i am stumped the control is same then why this kind of stuff
can anyone shed more light on this
The control is not written by me and i cannot contact the guy who did wrote it
please help
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
i have a (Video Player like) activex control that is embedded on an IE window which in turn is embedded on my CDialog is there any way by which i can get the HWND of the activeX control.
i can get the IHTMLElement for the <object> tag in HTML but is there any way which can give me the HWND of the player
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
It may not have a window if it's a windowless control. If it has a window today it may not "tomorrow" if you upgrade the component and the implementers decide to optimize it by making it a windowless control. In general groveling around with the HWND s of an ActiveX controls is asking for trouble. What are you trying to do? Perhaps there is a way to do it without side stepping the ActiveX control framework - This would be preferable.
That said if it's got a window you can use the IOleWindow::GetWindow method to get its handle. The first step is to use IE's interfaces to get the IHTMLObjectElement interface of the object tag then you call the IHTMLObjectElement::get_object method to get the IDispatch interface of the control itself. You call QueryInterface on this for IOleWindow and then call the IOleWindow::GetWindow the get the HWND .
Good luck.
Steve
|
|
|
|
|
QueryInterface fails for IOleWindow
used get_object to get the IDispatch called a few functions of the control as well so this is the right IDispatch but it doesn't return IOleWindow
But this control is a windowed one i can see it if i use Spy++
This control is behaving very strangly as i mentioned in the other post (on top of this one)
maybe i should use WM_CREATE hook (don't really want to do that)
any suggestions
i Queried for IOleInPlaceObject instead and it succeeded and i call
GetWindow to get the window handle
thanks for all the help
-- modified at 2:59 Thursday 2nd March, 2006
|
|
|
|
|
Try QIing for IOleInPlaceObject in place of IOleWindow .
Steve
|
|
|
|
|
Hai,
I am a newbie to ATL COM.I have developed my ATL Server(dll server).When i try to access the server from a client i get error
" 'CsampleATL' uses undefined class 'ATL_NO_VTABLE' "
Pls help me to fix this.Any help appreciated.
Saravana Kumar
|
|
|
|
|
Can you post the code snippet for the way you are accessing your server?
Have a great day ahead!
Regards,
Sohail Kadiwala
(My Blog - http://blogs.wdevs.com/sohail/[^])
modified 21-Apr-21 21:01pm.
|
|
|
|
|
pWnd = new CMyWnd;
pWnd->Attach(hWnd);
pWnd->SetWindowText("dddd"); // it's ok.
but not handled WM_LBUTTONDOWN message? why?
-------------------------------------
class CMyWnd :<br />
public CWindowImpl<CMyWnd><br />
{<br />
public:<br />
BEGIN_MSG_MAP(CMyWnd)<br />
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)<br />
END_MSG_MAP()<br />
<br />
LRESULT OnLButtonDown(UINT , WPARAM , LPARAM , BOOL& )<br />
{<br />
MessageBox("");<br />
return 0;<br />
}<br />
};
----------------------------------
how can handle the exist window some message ,like Attach(), but it will use Detach(), i want use some function like MFC's CWnd::FromHandle(), only use it can Attach the window.
where use Detach() is good?
|
|
|
|
|
Have you tried pWnd->SubclassWindow(hWnd) instead of Attach?
delete this;
* poof! *
|
|
|
|
|
1.SubclassWindow() not need UnSubclassWindow()?
2.can SubclassWindow() and Attach() Attach other process windows?
3. pWnd = new CMyWnd;
can in CMyWnd delete itself? like MFC
void CMyDlg::PostNcDestroy() <br />
{<br />
delete this;<br />
}
|
|
|
|
|
I've only worked with SubclassWindow in the same process, so can't answer to that, other than to say give it a go and see what happens
delete this;
* poof! *
|
|
|
|
|
FlyWithYou wrote: 2.can SubclassWindow() and Attach() Attach other process windows?
No. I don't see how you could call the original window procedure, nor do I see how the other process can call the subclassed window procedure.
|
|
|
|
|
wtl or atl had some about this function?
|
|
|
|
|
I had an simple object by using ATL Object wizard and a generic class CTCPSocket.
The com object name is CTest and interface is ITest. This class had a interface Add and a connection point Fire_notify.
And CSocket had two methods add_in and notify.
The code as following:
//CTest class
CTest:Add(long port)
{
CTCPSocket sk;
sk.add_in(port);
}
CTest:OnNotify()
{
Fire_notify();
}
//CTCPSocket class
CTCPSocket:add_in(long port)
{
//create a socket and listening
}
CTCPSocket:notify()
{
//created a tcp connectiong?
//when created a socket accept,pass the event to CTest:OnNotify()
}
when the client call the CTest->Add method, CTCPSocket will create a socket and listening, but the problem is: when there is a tcp connection event,how to pass the event to CTest:OnNotify() from CTCPSocket:notify()?
Thanks
Brygid
www.ecq.name
brygid
www.ecq.name
|
|
|
|
|
Store the pointer to the CTest class in a CTCPSocket member and call the OnNotify() within CTCPSocket:notify().
CTest::Add(long port)<br />
{<br />
CTCPSocket sk;<br />
sk.m_ptest=this;<br />
sk.add_in(port);<br />
sk.m_ptest=0;<br />
}<br />
CTCPSocket::notify()<br />
{<br />
if(m_ptest) m_ptest->OnNotify();<br />
}
|
|
|
|
|
Hello
I'd like to have a specific hWnd's content drawn at my EMF's DC.
I've tried several techniques but they don't seem to work.
As I do
// >>>
HDC hDC = GetDC(hWnd);
hBmp = CreateCompatibleBitmap(hDC, width, height);
ReleaseDC(hWnd, hDC);
HGDIOBJ hOld = SelectObject(hDCMem, hBmp);
SendMessage(hWnd, WM_PRINT, (WPARAM) hDCMem, PRF_CHILDREN | PRF_CLIENT | PRF_ERASEBKGND | PRF_NONCLIENT | PRF_OWNED);
SelectObject(hDCMem, hOld);
DeleteObject(hDCMem);
// <<<
it successfully grabs the output to my bitmap
but the similar code
// >>>
HDC hDC = GetDC(hWnd);
hEmfDC = CreateEnhMetaFile(hDC, NULL, NULL, NULL);
ReleaseDC(hWnd, hDC);
SendMessage(hWnd, WM_PRINT, (WPARAM) hEmfDC, PRF_CHILDREN | PRF_CLIENT | PRF_ERASEBKGND | PRF_NONCLIENT | PRF_OWNED);// <<<
doesn't.
Guys at microsoft go further with recursive enumerating of child windows. That somehow improves the solution as most of dialog controls appear on EMF's DC.
But the window's header doesn't.
Now I doubt that it is possible at all.
I'd like to have any info about it.
Especially concerning grabbing output of non-client area and window's header.
|
|
|
|
|
Some printing routines distinguish between raster and vector devices. It's also possible that the printing routine decides that the enclosing rectangle is to small for printing. Try to call the CreateEnhMetaFile with a valid rectangle.
|
|
|
|
|
How do I write a function that will help sort my array, by some
dynamically specifiable criteria. For example:
class Sortable{<br />
int a;<br />
int b;<br />
int c;<br />
int d;<br />
int e;<br />
};<br />
<br />
void SomeFunction()<br />
{<br />
std::vector< Sortable> items;<br />
<br />
int sortBy = 2;
std::stable_sort(items.begin(), items.end(), SortByAorBorC);<br />
}<br />
Is it possible to write a function "SortByAorBorC" that takes a paramter (the int sortBy )??? Right now I'm writing a separate function for each (e.g. "SortByA" "SortByB" and then using a switch statement - it works but it's not very elegant.
I can't quite get it going...
Many Thanks
Warren
|
|
|
|
|
You want to use a function object. For example:
class CMySortFn
{
private:
int m_nSortBy;
public:
CMySortFn(int sortBy) : m_nSortBy(sortBy) { }
bool operator()(const Sortable& a, const Sortable& b) const
{
switch (m_nSortBy)
{
case 1:
return a.a < b.a;
case 2:
return a.b < b.b;
etc.
}
}
};
std::sort(items.begin(), items.end(), CMySortFn(2));
You could also use a struct as the function object, if you want it even simpler. e.g.:
struct mysortfn
{
int m_nSortBy;
mysortfn(int sortBy) : m_nSortBy(sortBy) { }
bool operator()(const Sortable& a, const Sortable& b) const
{
...
}
};
HTH. Have a good weekend.
|
|
|
|
|
Robert,
Yes! That's exactly what I was looking for, I just didn't know the syntax.
Thanks very much!
Warren
|
|
|
|