|
Never mind. According to Microsoft, this can't be done.
|
|
|
|
|
Hi !
My App has an Explorer-like interface, with a leftview and a rightview. The leftview is a Tree control and the right view is a List control. I would like to enable the drag'n drop, to allow the user to drag items from the list (right view) and drop them into the tree (left view).
What I cannot figure out is how the tree (left view) will be notified of an item dropped on a tree-item ? I implemented the 'BeginDrag' in the right view, with the WM_MOUSEMOVE, and WM_LBUTTONUP, but when I drop an item on the left view, no messages is sent to the left view. I tried to use SetCapture() with my MainFrame window, but it's not working !
Any help of hint will be greatly appreciated !
Thanks !
Jerome
|
|
|
|
|
It has been a while since I have had to implement drag and drop for a control, but I believe that you need to register your tree control that will accept the dragged object as a drop target. This will let OLE know that it will look at the data a possibly accept it.
Then you will handle the function calls in the interface IDropTarget, there are functions like DragEnter, DragLeave and Drop.
|
|
|
|
|
When using MFC, you can create a member variable of type COleDropTarget and call Register() passing in your CWnd*. Then the virtual methods OnDragEnter() , OnDrop() , etc. will be called (if they are implemented).
farewell goodnight last one out turn out the lights Smashing Pumpkins, Tales of a Scorched Earth
|
|
|
|
|
You have to send the message yourself, from the right view.
When you call setcapture from the right view, it's that view that get the drop message, then you can send a message to the windows undr the mouse, that you are dropping things in it...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Hi, I'd like to ask if anyone knows any good method to access a view's member functions or methods, from an outside class, in MFC Doc/View architecture, without using friend operators or methods, or with the scope resolution operator because that things does not work well on my project... (I'm trying to access from a TreeCtrl or TreeView potected code, some public functions and members from an other view and i got a compiler message "illegal call of non-static member functions").
What i ask is if there is a general way to override such member function calls or sth else to make this work. (The project i'm developing is an Image Viewer app which i will post in future, like ACD See or PolyView).
Sorry if these may sound funny for some experts, but although i program c/c++ 4 years i tried MFC the last months...Thanks.
|
|
|
|
|
"illegal call of non-static member functions"
The message seems to imply that the problem has not to do with public /private access, but rather with calling a non static member function as if it were static. Does this ring a bell for you, or am I totally off track?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for replying... actually i tried to use these functions as static and as non-static but none of them seems to work properly (same compiler message), because there is a fact that no need is a static call on this view. I found an article by another reply to my message which might work. (accessing a view from anywhere).If it doesn't work i think a must override some accessor member function of the view but i wanted sth simple to solve such a thing.
|
|
|
|
|
check this
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
Thanks for your suggestion, and for the very nice Pink Floyd song...but in contrast i will say the TIME song from them... "...ten years have left behind you..." (to check all the codeproj articles i may need ten years and without solution maybe...) But OK,this article seems to be working.
|
|
|
|
|
kostasdel wrote:
"...ten years have left behind you..." (to check all the codeproj articles
You have to become old in CP to know all the places of it(thats persian expression,I don't know if you got it in English)
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
Hi,
I want to pass a metafile to an ATL server, so I encapsulated it on a PictureBox object, and then saved it on one IStream, then I try to recover it in the ATL object, and it gives me on error, the code that I use is:
MFC client:
if(IPict) {
IStorage *pIStg;
Res = ::StgCreateDocfile(NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, &pIStg);
if(pIStg) {
IStream *TempStream = NULL;
Res = pIStg->CreateStream(OLESTR("MyPicture"), STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0,0, &TempStream);
IPict->SaveAsFile(TempStream, TRUE, NULL);
m_GDIGr.SetMetafile(TempStream);
}
}
ATL Server:
STDMETHODIMP CGDIGraphics::SetMetafile(IStream *pStream)
{
IPicture *Pict = NULL;
HRESULT Res = ::OleLoadPicture(pStream, 0, FALSE, IID_IPicture,(void **) &Pict);
if(Pict) {
::MessageBox(NULL, "PICT", "PICT", MB_OK);
}
return S_OK;
}
What I had made wrong ?, Thanks in advance, Bye !
Braulio
|
|
|
|
|
Hi Braulio
Braulio Díez wrote:
it gives me on error
You didn't mention what is that error
Anyway,Did Dr.Grimes reply you?If the answer is yes would you please tell the answer too?
Thanks
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
Hi,
Well the error message is quite dissapointing...
0x8000ffff E_UNEXPECTED
Dr. Grimes didn´t answer me, but well, I keep on researching, and it seems that you have to encapsulate the metafile in a PictureBox control ( IPicture), and the destination is not in the same DLL so I need to save the object in one stream ( I use for that IStream), and then in the ATL server I take that string and try to load the pic...
But... I when I´m going to read from the stream it doesn´t...
I know this is a quite common issue, just to pass a metafile from one process to another using COM, it´s one of the basic thing from COM, the sad thing is that anybody that knows the answer wants to give a hint....
Thanks for you interest mazdak, Bye !
Braulio
|
|
|
|
|
Hi:
Sorry,my ATL knowledge is not enough to help you.
It's very dissapointing that although there are lots of expert in CP but it seems
non of them (or few of them) have good ATL knowledge.
There are about 30000 members in this site...
Good luck and Bye
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
Hi Mazdak !
Finally I got the solution, Joao Vaz give me one URL to a nice article, and now it is working nice !!! ( there were some magic with the streams XDDD ).
I have to tidy up all the code and make a submission to codeproject. Bye !
Braulio
|
|
|
|
|
Hola !
As I promised you I Wrote the article about Streams and Pictures and ActiveX, you can check it out in:
http://www.codeproject.com/useritems/PictureTransfer.asp
The bad thing... something went wrong with the submission wizard and the Picture and the zip with the source is not there ( I sent one e-mail to chris with the files, let´s hope he fixes it).
Bye !
Braulio
|
|
|
|
|
Braulio, just one thought , you tried to create the stream on global memory
with the CreateStreamOnHGlobal and get the global handle from the server with
GetHGlobalFromStream , this without using Stg ?
Joao Vaz
|
|
|
|
|
Hi,
Thanks for the tip, I´m trying it now, but it gives me the same error, here it is the code that I use now:
MFC Client:
IStream *TempStream = NULL;
CreateStreamOnHGlobal (NULL, TRUE, &TempStream);
HGLOBAL hMem = NULL;
GetHGlobalFromStream(TempStream, &hMem);
LPVOID lpData = GlobalLock(hMem);
HRESULT HRes = IPict->SaveAsFile(TempStream, TRUE, 0);
GlobalUnlock(hMem);
m_GDIGr.SetMetafile(TempStream);
ATL Server:
STDMETHODIMP CGDIGraphics::SetMetafile(IStream *pStream)
{
IPicture *Pict = NULL;
HGLOBAL hMem = NULL;
GetHGlobalFromStream(pStream, &hMem);
LPVOID lpData = GlobalLock(hMem);
HRESULT Res = ::OleLoadPicture(pStream, 0, FALSE, IID_IPicture,(void **) &Pict);
GlobalUnlock(hMem);
I don´t know where I made the mess , ( I´m pasting the activeX in an automated Ms Word instance and from my app calling the method to insert the activex, all this should be easy-pc for Com isn´t it ? )
Thanks, Bye !
Braulio
|
|
|
|
|
|
Hi Joao !
I had that article before, but well I read it again, and you were right !!!, there is the solution !!!, thanks a lot !
See you and obrigado !
Braulio
|
|
|
|
|
Cool , now you can post a article on Code Project
Cheers,
Joao Vaz
|
|
|
|
|
Hi Braulio, unfortunately seems like most of us in this forum are COM-impaired but I'm following your investigations with great interest, and doing a little research myself. I've just sumbled upon these two functions:
<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/cmf_a2c_88tp.asp">CoMarshalInterThreadInterfaceInStream</a> ,
<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/cmf_a2c_1rjh.asp">CoGetInterfaceAndReleaseStream</a> ,
which seem to do the job of packing and unpacking an object with the aid of an IStream to pass things across threads. Maybe they're worth having a look at. Good luck.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for the tip !
MMm..., I don´t know too much about marshaling, but well it´s good time to start learning, I think I have to use maybe something like "CoMarshalInterface", because I have different process, I have:
MyApp -( Different Space Proccess)-> Word Automated Instance --> MyDll
I´m advancing but very slow, but now I can paste the ActiveX in a Word automated instance, modify it from my app, and even make serialize it !, the last step it´s to do something useful XD, like for example get the picture...
I swear that if I get all this things up and running I will write a mega article for codeguru talking about this stuff
Thanks for the help Joaquin, Hasta luego !
Braulio
|
|
|
|
|
I swear that if I get all this things up and running I will write a mega article for codeguru talking about this stuff
codeguru?
Suerte con la historia ésta, seguro que cuando acabes tendrás mogollón de información para un buen artículo.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|