FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

how to use IDropTarget?

 
Post new topic   Reply to topic     Forum Index -> DFL
View previous topic :: View next topic  
Author Message
ilitirit



Joined: 28 Dec 2004
Posts: 7

PostPosted: Thu Jan 06, 2005 6:18 am    Post subject: how to use IDropTarget? Reply with quote

i'm trying to make a form a drop target. the form has already been created with all it's event handlers and controls. so all i want to do now is add drag & drop functionality, but as soon as i implement the interface i get hundreds of compiler errors.

this code compiles:
Code:

private import dfl.all;
private import dfl.winapi;
private import dfl.wincom;

class MainForm : Form, IDropTarget
{
   HRESULT QueryInterface(IID* riid, void** pvObject){return 0;}
    ULONG AddRef(){return 0;}
    ULONG Release(){return 0;}
   
   public HRESULT DragEnter(dfl.wincom.IDataObject pDataObject, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect){return 0;}
   public HRESULT DragLeave(){return 0;}
   public HRESULT DragOver(DWORD grfKeyState, POINTL pt, DWORD* pdwEffect){return 0;}
   public HRESULT Drop(dfl.wincom.IDataObject pDataObject, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect){return 0;}
}

void main()
{
   Application.run(new MainForm);
}

now look what happens when i start adding event handlers to 'MainForm'

Code:

   void closeHandler(Object o, EventArgs ea)
   {
      return;
   }
   
   this()
   {
      /*
       The following line fails with:
       test.d(18): function dfl.event.Event!(...).Event.opCatAssign (void delegate(Object ,EventArgs )handler) does not match argument types (void delegate(Object o,EventArgs ea))
       test.d(18): cannot implicitly convert expression &this.closeHandler of type void delegate(Object o,EventArgs ea) to void delegate(Object ,EventArgs )
      */
      // closed ~= &closeHandler;
      
      // Compiles without errors
      closed ~= delegate   void(Object o, EventArgs ea){ return; };
      
      void nestedFunction(Object o, EventArgs ea)
      {
         return;
      }
      
      // Compiles without errors
      closed ~= &nestedFunction;
      
      void delegate (Object o, EventArgs ea) dg;
      
      // dg = &closeHandler;  <- This line fails
      
      dg = &nestedFunction;
      // Compiles without errors
      closed ~= dg;
   }


any ideas? what am i doing wrong?
Back to top
View user's profile Send private message
Chris Miller



Joined: 27 Mar 2004
Posts: 514
Location: The Internet

PostPosted: Thu Jan 06, 2005 8:10 am    Post subject: Reply with quote

IDropTarget is an extern(Windows) interface and it seems that it's turning all your MainForm's member functions into extern(Windows) as well. After all your IDropTarget function implementations put extern(D): and it should work as expected.
Back to top
View user's profile Send private message
ilitirit



Joined: 28 Dec 2004
Posts: 7

PostPosted: Fri Jan 07, 2005 1:55 am    Post subject: Reply with quote

Vathix wrote:
IDropTarget is an extern(Windows) interface and it seems that it's turning all your MainForm's member functions into extern(Windows) as well. After all your IDropTarget function implementations put extern(D): and it should work as expected.


OK that worked. Do I have to call OleInitialize/OleUninitialize explicitly or is that handled by DFL?

edit: Nevermind. It OleInitialize as if they are called in the constructor of the Application so I don't need to worry about it
Back to top
View user's profile Send private message
Chris Miller



Joined: 27 Mar 2004
Posts: 514
Location: The Internet

PostPosted: Fri Jan 07, 2005 3:55 am    Post subject: OleInitialize Reply with quote

ilitirit wrote:
Do I have to call OleInitialize/OleUninitialize explicitly or is that handled by DFL?
It currently calls them, but doesn't promise to. You may want to call them anyway; the calls can be nested.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DFL All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group