 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Kerry Frater Guest
|
Posted: Thu Jun 02, 2005 10:46 am Post subject: Querying mailitem in target drop component |
|
|
I am trying to get to grip with Drag & Drop. I want to drag a mailitem from
Outlook and drop it onto a component on aform and then I can access the
different properties and methods of the mailitem. The first step is purly to
execute the saveas method for the mailitem so I can save the "msg" with a
predetermined name.
I have reading up about it since last Friday and accumulated half a dozen
example proglets all with different styles and structures, one of which
relates to Outlook. But I am at the point where I can't see the wood for the
trees.
I have got the code now that can accept the dropping of mail items onto the
component. An example for identifying the dragged object as a mailitem in
DragEnter is shown below. This code on using IStorage and IStream to
identify the dragged object as a mailitem is currently beyond me, but it
works.
The only general article I have suggests using QueryGetData to ask about a
data format. The SDK manual says that the FORMATETC is the only argument.
The Cfformat definition in the SDK states it can have the values:
Standard interchange formats, such as CF_TEXT.
Private application formats understood only by the application offering the
format, or by other applications offering similar features.
OLE formats, which are used to create linked or embedded objects.
Is there a definition for Ol Mailitems that I can use to build a
QueryGetData to verify the object as an outlook mailitem rather than reading
the data ?
//====== Example code that checks the content of the object being dragged
over being an outlook mail item
//====== from the DragEnter event
// Check for outlook mail item
accept:=False;
fc.cfFormat:=CF_FILECONTENTS;
fc.ptd:=nil;
fc.dwAspect:=1;
fc.lindex:=0;
fc.tymed:=TYMED_ISTORAGE;
if dataObj.GetData(fc, stgm) = S_OK then
begin
pstg:=IStorage(stgm.stg);
// Hard coded to open the outlook message item stream
if (pstg.OpenStream('__substg1.0_1000001E', nil, STGM_SHARE_EXCLUSIVE or
STGM_READ, 0, pstm) = S_OK) then
begin
accept:=True;
pstm:=nil;
end;
pstg:=nil;
ReleaseStgMedium(stgm);
end;
// Dont allow drop if not an outlook mail item
if not(accept) then
begin
result:=S_FALSE;
exit;
end;
|
|
| Back to top |
|
 |
Dmitry Streblechenko Guest
|
Posted: Thu Jun 02, 2005 5:43 pm Post subject: Re: Querying mailitem in target drop component |
|
|
IStorage format will the message in the MSG format (which you can only
manipulate using Extended MAPI).
An easier solution would be to assume that to drag and drop a message from
Outlook, the user must select it first. Instead of trying to parse the d'n'd
format, simply access the Application.ActiveExplorer.Selection collection
using the Outlook Object Model.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
"Kerry Frater" <kerry (AT) lawyersweb (DOT) net> wrote
| Quote: | I am trying to get to grip with Drag & Drop. I want to drag a mailitem from
Outlook and drop it onto a component on aform and then I can access the
different properties and methods of the mailitem. The first step is purly
to
execute the saveas method for the mailitem so I can save the "msg" with a
predetermined name.
I have reading up about it since last Friday and accumulated half a dozen
example proglets all with different styles and structures, one of which
relates to Outlook. But I am at the point where I can't see the wood for
the
trees.
I have got the code now that can accept the dropping of mail items onto
the
component. An example for identifying the dragged object as a mailitem in
DragEnter is shown below. This code on using IStorage and IStream to
identify the dragged object as a mailitem is currently beyond me, but it
works.
The only general article I have suggests using QueryGetData to ask about a
data format. The SDK manual says that the FORMATETC is the only argument.
The Cfformat definition in the SDK states it can have the values:
Standard interchange formats, such as CF_TEXT.
Private application formats understood only by the application offering
the
format, or by other applications offering similar features.
OLE formats, which are used to create linked or embedded objects.
Is there a definition for Ol Mailitems that I can use to build a
QueryGetData to verify the object as an outlook mailitem rather than
reading
the data ?
//====== Example code that checks the content of the object being dragged
over being an outlook mail item
//====== from the DragEnter event
// Check for outlook mail item
accept:=False;
fc.cfFormat:=CF_FILECONTENTS;
fc.ptd:=nil;
fc.dwAspect:=1;
fc.lindex:=0;
fc.tymed:=TYMED_ISTORAGE;
if dataObj.GetData(fc, stgm) = S_OK then
begin
pstg:=IStorage(stgm.stg);
// Hard coded to open the outlook message item stream
if (pstg.OpenStream('__substg1.0_1000001E', nil, STGM_SHARE_EXCLUSIVE
or
STGM_READ, 0, pstm) = S_OK) then
begin
accept:=True;
pstm:=nil;
end;
pstg:=nil;
ReleaseStgMedium(stgm);
end;
// Dont allow drop if not an outlook mail item
if not(accept) then
begin
result:=S_FALSE;
exit;
end;
|
|
|
| Back to top |
|
 |
Kerry Frater Guest
|
Posted: Thu Jun 02, 2005 9:42 pm Post subject: Re: Querying mailitem in target drop component |
|
|
Thank you for your reply but I think your solution (if I understand the
answer correctly) defeats my exercise.
I presume from this I select/highlight a message in Outlook, then switch to
a proglet that accesses ActiveExplorer to find what message has been
selected and manipulates the message accordingling.
My exercise it to drop different objects onto a component accepting dragged
objects and do different things depending on the object.
With Outlook I was looking to save the message as a single file (.msg)
I have found a little spy program which tells me the format id's of items
dropped onto it. I have cut down my DragEnter code to check for Outlook
messages to:
accept:=False;
// cfFormat taken from debugging OLE drop of mail message
fc.cfFormat:=49736;
fc.ptd:=nil;
fc.dwAspect:=DVASPECT_CONTENT;
fc.lindex:=-1;
fc.tymed:=TYMED_ISTREAM;
if dataObj.GetData(fc, stgm) = S_OK then
begin
accept := true; // If S_OK then it is an Outlook Message (on my box
anyway)
end;
ReleaseStgMedium(stgm);
Now to work out the syntax for drop!!!
Kerry
"Dmitry Streblechenko" <dmitry (AT) dimastr (DOT) com> wrote
| Quote: | IStorage format will the message in the MSG format (which you can only
manipulate using Extended MAPI).
An easier solution would be to assume that to drag and drop a message from
Outlook, the user must select it first. Instead of trying to parse the
d'n'd
format, simply access the Application.ActiveExplorer.Selection collection
using the Outlook Object Model.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
|
|
|
| Back to top |
|
 |
Dmitry Streblechenko Guest
|
Posted: Thu Jun 02, 2005 10:46 pm Post subject: Re: Querying mailitem in target drop component |
|
|
Again, the IStorage format that you get is the MSG file, all you need to do
is create a new IStorage on top of a file, and copy the d'n'd IStorage to
your file-based IStorage. You might need to set the storage class first. See
http://support.microsoft.com/?kbid=171907
I don't understand why using the Explorer.Selection collection defeats your
exercise: it gets the job done (using MailItem.SaveAs(..., olMsg), does it
not?
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
"Kerry Frater" <kerry (AT) lawyersweb (DOT) net> wrote
| Quote: | Thank you for your reply but I think your solution (if I understand the
answer correctly) defeats my exercise.
I presume from this I select/highlight a message in Outlook, then switch
to
a proglet that accesses ActiveExplorer to find what message has been
selected and manipulates the message accordingling.
My exercise it to drop different objects onto a component accepting
dragged
objects and do different things depending on the object.
With Outlook I was looking to save the message as a single file (.msg)
I have found a little spy program which tells me the format id's of items
dropped onto it. I have cut down my DragEnter code to check for Outlook
messages to:
accept:=False;
// cfFormat taken from debugging OLE drop of mail message
fc.cfFormat:=49736;
fc.ptd:=nil;
fc.dwAspect:=DVASPECT_CONTENT;
fc.lindex:=-1;
fc.tymed:=TYMED_ISTREAM;
if dataObj.GetData(fc, stgm) = S_OK then
begin
accept := true; // If S_OK then it is an Outlook Message (on my box
anyway)
end;
ReleaseStgMedium(stgm);
Now to work out the syntax for drop!!!
Kerry
"Dmitry Streblechenko" <dmitry (AT) dimastr (DOT) com> wrote in message
news:429f4523$1 (AT) newsgroups (DOT) borland.com...
IStorage format will the message in the MSG format (which you can only
manipulate using Extended MAPI).
An easier solution would be to assume that to drag and drop a message
from
Outlook, the user must select it first. Instead of trying to parse the
d'n'd
format, simply access the Application.ActiveExplorer.Selection collection
using the Outlook Object Model.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
|
|
|
| Back to top |
|
 |
Kerry Frater Guest
|
Posted: Fri Jun 03, 2005 12:26 am Post subject: Re: Querying mailitem in target drop component |
|
|
Dimitry,
Thanks again for your reply. I just don't know enough yet on this subject
matter to understand your answer fully. I am finding the learning experience
of Delphi in this area a little frustrating at the moment. Please don't take
this message the wrong way but it may help explain my issues in finding out
where to get info to learn.
I only started learning about drag & drop last Friday. The newsgroup has few
entries (that I have found) about IStorage and tells people to search for
entries and read about it. But that is all I can find - entries telling me
to read about IStorage but not where I can read about it or how it works?
The online manual has entries and is great when you know what you are
looking at (like the old Unix ones used to be good for when you know what
you are looking for) but doesn't help give context to people learning
totally new subject matter.
None of the demo apps with my D5 have example progs with IStorage. Google
searches show next to nothing. I am learning from the book Mastering Delphi
which also doesn't explain it.
The Win32 help reference gives some help but like the article you refer me
to is providing examples in C(++). A language I haven't touched in years. If
I have to spend time learning enough C on how it does the task in order to
be able to translate it and gain guidance in how to do it in Delphi, I think
I may as well buy a C compiler and just use that, but I have used Delphi in
DB applications and enjoy the environment.
So when you say create a new IStorage instance linked to a disk file and
copy the stream from one to the other is great but I cannot find any
readable pages that takes you through the mechanisms.
As to your second point about Explorer.Section I may have missed your point.
If to get the functionality I would have to 1. Select the messages in
Outlook 2. Alt-Tab to/start etc the proglet 3. Action the proglet to get the
selected items from Outlook, then from a user perspective this is
cumbersome. If the use of this does not mean this sort of user interface
then I have totally missed the point and my ignorance in this area shows up
even more
Whereas dragging a message from e.g. Outlook or Outlook Express onto a small
rectangle in the corner of the screen and the proglet working out
automatically which type of message/file it is and processing accordingly is
more "user friendly"
Please don't take this message as a complaint. It is more of a - I have
no-one around me who works in Delphi - My documentation/books are great in
their own areas but explain nothing about this area for usage - I am
frustrated by knowing that Delphi can do the work but not knowing where the
information is so that I can learn how it does the work.
I did find one entry from an experienced CB writer who gave an example of
manipulating a Drag object woth Outlook and published it because he was
frustrated about finding no reference material. Unfortunately most of the
articles are of an age where the email addresses of the contributors are no
longer valid.
Thank you for your patience.
Kerry
"Dmitry Streblechenko" <dmitry (AT) dimastr (DOT) com> wrote
| Quote: | Again, the IStorage format that you get is the MSG file, all you need to
do
is create a new IStorage on top of a file, and copy the d'n'd IStorage to
your file-based IStorage. You might need to set the storage class first.
See
http://support.microsoft.com/?kbid=171907
I don't understand why using the Explorer.Selection collection defeats
your
exercise: it gets the job done (using MailItem.SaveAs(..., olMsg), does it
not?
|
|
|
| Back to top |
|
 |
Kerry Frater Guest
|
Posted: Fri Jun 03, 2005 9:41 am Post subject: Re: Querying mailitem in target drop component |
|
|
Dimitry,
Having slept (a little) I think I am understanding your explorer point. If I
drag an item onto the component and I identify the dropped items as Outlook
Items then I can use std OLE link to Outlook to obtain the "selected"
messages and save that way. Never read or looked at the "Explorer.Selection"
bit but I do like the theory for handling Outlook messages. The one issue I
have is that I did write a small applet to get messages from Outlook. With
the recent changes (I don't use Exchange) everytime I start the outlook
object I get a dialog box telling me that something is trying to use Outlook
and I can set a timer of up to 10 mins to use it. This is a pain and MS
states that it can only be switched off if Outlook is linked to Exchange.
Again, my knowledge is still in its infancy here. I am reading as fast as I
can but retention is still weak until I get stronger in the foundation work.
Back to my IStorage work, I changed the way I did my searches and found 3
example snippets. None actually explain the full sequence but I have put the
following code together based on those 3 snippets (The solution doesn't work
by the way)
{Check the item is an Outlook Item}
fc.cfFormat:=49736; fc.ptd:=nil; fc.dwAspect:=DVASPECT_CONTENT;
fc.lindex:=dwcount; fc.tymed:=TYMED_ISTREAM;
if not (dataObj.GetData(fc, stgmItem) = S_OK) then
begin
{tidy up and exit}
end;
{Get access to the mail message - we are looping around a
PFileGroupDescriptor list of items dropped on the component
dwcount being the index to each MailItem in turn}
fc.cfFormat:=CF_FILECONTENTS; fc.ptd:=nil;
fc.dwAspect:=DVASPECT_CONTENT;
fc.lindex:=dwCount; fc.tymed:=TYMED_ISTORAGE;
if (dataObj.GetData(fc, stgmitem) = S_OK) then
begin
{refer to the storage property for ease}
pstg := IStorage(stgmitem.stg);
{Create a new Storage Item referring to a file on the disk}
Hr := StgCreateDocFile('c:a1.msg',
STGM_DIRECT or STGM_READWRITE or STGM_CREATE or
STGM_SHARE_EXCLUSIVE,0,HardFile);
if (not SUCCEEDED(Hr)) then
begin
pstg.CopyTo(0,nil,nil,HardFile);
HardFile.Commit(STGC_DEFAULT);
HardFile := nil;
end;
pstg := nil;
end;
ReleaseStgMedium(stgmItem);
"Dmitry Streblechenko" <dmitry (AT) dimastr (DOT) com> wrote
| Quote: | Again, the IStorage format that you get is the MSG file, all you need to
do
is create a new IStorage on top of a file, and copy the d'n'd IStorage to
your file-based IStorage. You might need to set the storage class first.
See
http://support.microsoft.com/?kbid=171907
I don't understand why using the Explorer.Selection collection defeats
your
exercise: it gets the job done (using MailItem.SaveAs(..., olMsg), does it
not?
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
"Kerry Frater" <kerry (AT) lawyersweb (DOT) net> wrote in message
news:429f7d45 (AT) newsgroups (DOT) borland.com...
Thank you for your reply but I think your solution (if I understand the
answer correctly) defeats my exercise.
I presume from this I select/highlight a message in Outlook, then switch
to
a proglet that accesses ActiveExplorer to find what message has been
selected and manipulates the message accordingling.
My exercise it to drop different objects onto a component accepting
dragged
objects and do different things depending on the object.
With Outlook I was looking to save the message as a single file (.msg)
I have found a little spy program which tells me the format id's of
items
dropped onto it. I have cut down my DragEnter code to check for Outlook
messages to:
accept:=False;
// cfFormat taken from debugging OLE drop of mail message
fc.cfFormat:=49736;
fc.ptd:=nil;
fc.dwAspect:=DVASPECT_CONTENT;
fc.lindex:=-1;
fc.tymed:=TYMED_ISTREAM;
if dataObj.GetData(fc, stgm) = S_OK then
begin
accept := true; // If S_OK then it is an Outlook Message (on my box
anyway)
end;
ReleaseStgMedium(stgm);
Now to work out the syntax for drop!!!
Kerry
"Dmitry Streblechenko" <dmitry (AT) dimastr (DOT) com> wrote in message
news:429f4523$1 (AT) newsgroups (DOT) borland.com...
IStorage format will the message in the MSG format (which you can only
manipulate using Extended MAPI).
An easier solution would be to assume that to drag and drop a message
from
Outlook, the user must select it first. Instead of trying to parse the
d'n'd
format, simply access the Application.ActiveExplorer.Selection
collection
using the Outlook Object Model.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
|
|
|
| Back to top |
|
 |
Kerry Frater Guest
|
Posted: Fri Jun 03, 2005 11:33 am Post subject: Re: Querying mailitem in target drop component |
|
|
Dimitry,
Having slept (a little) I think I am understanding your explorer point. If I
drag an item onto the component and I identify the dropped items as Outlook
Items then I can use std OLE link to Outlook to obtain the "selected"
messages and save that way. Never read or looked at the "Explorer.Selection"
bit but I do like the theory for handling Outlook messages. The one issue I
have is that I did write a small applet to get messages from Outlook. With
the recent changes (I don't use Exchange) everytime I start the outlook
object I get a dialog box telling me that something is trying to use Outlook
and I can set a timer of up to 10 mins to use it. This is a pain and MS
states that it can only be switched off if Outlook is linked to Exchange.
Again, my knowledge is still in its infancy here. I am reading as fast as I
can but retention is still weak until I get stronger in the foundation work.
Back to my IStorage work, I changed the way I did my searches and found 3
example snippets. None actually explain the full sequence but I have put the
following code together based on those 3 snippets (The solution doesn't work
by the way)
{Check the item is an Outlook Item - this will be changed as
49736 is a dynamic number}
fc.cfFormat:=49736; fc.ptd:=nil; fc.dwAspect:=DVASPECT_CONTENT;
fc.lindex:=dwcount; fc.tymed:=TYMED_ISTREAM;
if not (dataObj.GetData(fc, stgmItem) = S_OK) then
begin
{tidy up and exit}
end;
{Get access to the mail message - we are looping around a
PFileGroupDescriptor list of items dropped on the component
dwcount being the index to each MailItem in turn}
fc.cfFormat:=CF_FILECONTENTS; fc.ptd:=nil;
fc.dwAspect:=DVASPECT_CONTENT;
fc.lindex:=dwCount; fc.tymed:=TYMED_ISTORAGE;
if (dataObj.GetData(fc, stgmitem) = S_OK) then
begin
{refer to the storage property for ease}
pstg := IStorage(stgmitem.stg);
{Create a new Storage Item referring to a file on the disk}
Hr := StgCreateDocFile('c:a1.msg',
STGM_DIRECT or STGM_READWRITE or STGM_CREATE or
STGM_SHARE_EXCLUSIVE,0,HardFile);
if (SUCCEEDED(Hr)) then
begin
pstg.CopyTo(0,nil,nil,HardFile);
HardFile.Commit(STGC_DEFAULT);
HardFile := nil;
end;
pstg := nil;
end;
ReleaseStgMedium(stgmItem);
This creates a file called a1.msg but when I try and open it by association
it says it is a bad file. Have I missed out something obvious in the test?
Kerry
"Dmitry Streblechenko" <dmitry (AT) dimastr (DOT) com> wrote
| Quote: | Again, the IStorage format that you get is the MSG file, all you need to
do
is create a new IStorage on top of a file, and copy the d'n'd IStorage to
your file-based IStorage. You might need to set the storage class first.
See
http://support.microsoft.com/?kbid=171907
I don't understand why using the Explorer.Selection collection defeats
your
exercise: it gets the job done (using MailItem.SaveAs(..., olMsg), does it
not?
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
"Kerry Frater" <kerry (AT) lawyersweb (DOT) net> wrote in message
news:429f7d45 (AT) newsgroups (DOT) borland.com...
Thank you for your reply but I think your solution (if I understand the
answer correctly) defeats my exercise.
I presume from this I select/highlight a message in Outlook, then switch
to
a proglet that accesses ActiveExplorer to find what message has been
selected and manipulates the message accordingling.
My exercise it to drop different objects onto a component accepting
dragged
objects and do different things depending on the object.
With Outlook I was looking to save the message as a single file (.msg)
I have found a little spy program which tells me the format id's of
items
dropped onto it. I have cut down my DragEnter code to check for Outlook
messages to:
accept:=False;
// cfFormat taken from debugging OLE drop of mail message
fc.cfFormat:=49736;
fc.ptd:=nil;
fc.dwAspect:=DVASPECT_CONTENT;
fc.lindex:=-1;
fc.tymed:=TYMED_ISTREAM;
if dataObj.GetData(fc, stgm) = S_OK then
begin
accept := true; // If S_OK then it is an Outlook Message (on my box
anyway)
end;
ReleaseStgMedium(stgm);
Now to work out the syntax for drop!!!
Kerry
"Dmitry Streblechenko" <dmitry (AT) dimastr (DOT) com> wrote in message
news:429f4523$1 (AT) newsgroups (DOT) borland.com...
IStorage format will the message in the MSG format (which you can only
manipulate using Extended MAPI).
An easier solution would be to assume that to drag and drop a message
from
Outlook, the user must select it first. Instead of trying to parse the
d'n'd
format, simply access the Application.ActiveExplorer.Selection
collection
using the Outlook Object Model.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
|
|
|
| Back to top |
|
 |
Kerry Frater Guest
|
Posted: Sat Jun 04, 2005 10:46 am Post subject: Re: Querying mailitem in target drop component |
|
|
For anyone who follows and who may be interested in identifying mail objects
dragged into a separate program I have now got a way of identifying what I
want on drag enter. It may not be effiecient and would welcome feedback so
that I can learn more.
For DragEnter I only check the first item dropped not all. Working on the
principle that if the first item is invalid then they all probably are. If
the first is valid then I have at least one valid entry. This was a design
decision for the test.
I have surrounded my comments with ****** so that they can be seen more
easily.
Kerry
DragEnter(const dataObj: IDataObject; grfKeyState: Longint; pt: TPoint; var
dwEffect: Longint): HResult; stdcall;
// These are the vars I use
var fc: tagFORMATETC;
FormatEtc : TFormatEtc;
stgm: tagSTGMEDIUM;
accept: Boolean;
pFGD : PFileGroupDescriptor;
PtrPChar: PChar;
S: String;
begin
{I colour code the panel. Accepted input is Teal - unaccepted is normal
silver}
TPanel(FControl).Color := clTeal;
// Set default value is not to accept the object
accept:=False; dwEffect := DROPEFFECT_NONE;
*******************************************************
// To allow ordinary files to be dropped I have found that the format
CF_HDROP is provided
// For files there is a format described as 'FileName' with a code 49158
// I have NOT tested this code on another machine so I don't know if the
cfformat IS is universal
// Outlook & Outlook Express does NOT use HDROP
*******************************************************
With FormatEtc do
Begin
cfFormat := CF_HDROP; ptd := nil; dwAspect := DVASPECT_CONTENT;
lindex := 0; tymed := TYMED_HGLOBAL;
end;
if dataObj.QueryGetData(FormatEtc) = S_OK then
begin
// Get the Filename of the dropped item and see if it has an extension
// Not fool proof but it can help.
fc.cfFormat:=49158; fc.ptd:=nil; fc.dwAspect:=DVASPECT_CONTENT;
fc.lindex:=0; fc.tymed:=TYMED_HGLOBAL;
if dataObj.QueryGetData(fc) = S_OK then
if dataObj.GetData(fc, stgm) = S_OK then
begin
ptrPChar := GlobalLock(stgm.HGLOBAL);
S := string(ptrPChar);
if Length(ExtractFileExt(S)) > 1 then accept := true;
GlobalUnLock(stgm.HGLOBAL);
ReleaseStgMedium(stgm);
end;
end
else
*******************************************************
// If not HDROP be specific and look for Outlook & Outlook Express drop
// These items when dropped provide CF_FILEDESCRIPTOR data part of which
// are their equivalent filenames
// OExpress produces .EML file names and Outlook .MSG
// Ordinary files dos not produce this property with a dropped item
// So to pick up an OE or O message from the program or from a file copy
then I can check
// from both structures
*******************************************************
begin
// Check for outlook express mail item
fc.cfFormat:=CF_FILEDESCRIPTOR; fc.ptd:=nil;
fc.dwAspect:=DVASPECT_CONTENT;
fc.lindex:=0; fc.tymed:=TYMED_HGLOBAL;
if dataObj.GetData(fc, stgm) = S_OK then
begin
pfgd := PFileGroupDescriptor(GlobalLock(stgm.HGLOBAL));
S := ExtractFileExt(pfgd.fgd[0].cFileName);
if (uppercase(S) = '.EML') or (uppercase(S) = '.MSG') then
accept := true;
GlobalUnLock(stgm.HGLOBAL);
ReleaseStgMedium(stgm);
end;
end;
*******************************************************
// The rest of this is from an example DragEnter I had. Haven't fully
decifered the sequence of events
// I am unhappy with the net result because I lose the 'No Entry' cursor of
the DropTarget which implies
// an error, I think. It appears not to like the assignment to S_FALSE
// Net result is correct but it doesn't look right
// Haven't worked out how to set the colour to unacceptable AND have the 'No
Drop' cursor.
*******************************************************
// Dont allow drop if not an acceptable item
if not(accept) then
begin
TPanel(FControl).Color := clSilver;
dwEffect:=DROPEFFECT_NONE;
result:=S_FALSE;
exit;
end;
// Tidy up the end of drag enter by stating that
// Success
result:=S_OK;
// Send the drag enter message to the control (subclassed as panel)
*******************************************************
Since the example code says that the Control OnDragOver event must ALWAYS
set the accept argument to True The drop effect will always be COPY
*******************************************************
if Assigned(TPanel(FControl).OnDragOver) then
begin
accept:=False;
TPanel(FControl).OnDragOver(FControl, Self, pt.x, pt.y, dsDragEnter,
accept);
if not(accept) then dwEffect:=DROPEFFECT_NONE;
end
|
|
| Back to top |
|
 |
|
|
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
|
|