Drag and drop and IAsyncOperation problems

Win32 Programming

    Next

  • 1. getting RichEdit size
    I try to get the width and height of a richedit, to be able to resize it to see all the text inside. I know there is the EN_REQUESTRESIZE notification, but it need to pass on the message loop, and i don't want that. I wonder how i can obtain this infos jsut after I did SetText()... (And I can't calculate myself as the text inside the rich edit is complex, with many formatting, etc...) thanks for your help
  • 2. win32 button
    if i create a button box like so , and i have vc++ express and no RE. I need to do it programmtically for directx prog hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "BUTTON", "weqw", WS_CHILD | WS_VISIBLE |WS_BORDER , 0, 0, 100, 100, hwnd, (HMENU) GetModuleHandle(NULL), NULL); hfDefault = GetStockObject(DEFAULT_GUI_FONT); SendMessage(hEdit, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0)); q)can you detect when a button has been pressed without going through the WM_COMMAND eg using a sendMessage
  • 3. SetWindowLongPtr within a class
    I use SetWindowLongPtr in a class as follow class TestSetWindow { private: static WNDPROC OriginalProc; static LRESULT CALLBACK OtherProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { // something not static ... return ::CallWindowProc(OriginalProc, hWnd, msg, wParam, lParam); } public: TestSetWindow() { OriginalProc= (WNDPROC)::SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)OtherProc); } }; Inside OtherProc not all instances and functions are define static, so the above code cannot compile. If I move everything out of the class, so that WNDPROC OriginalProc; LRESULT CALLBACK OtherProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { // something not static ... return ::CallWindowProc(OriginalProc, hWnd, msg, wParam, lParam); } OriginalProc= (WNDPROC)::SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)OtherProc); then, everything is all right. Any idea to implement that within a class? Thanks in advance.
  • 4. Expanding Tray Icons
    Hi, The tray icon section of the taskbar has a left pointing arrow with tool tip 'Show Hidden Icons' which can be used to expand the tray icon section. Is there an API I can call from within an application which will cause the tray icon section to expand or do I have to force a mouse click event over the arrow icon? Many thanks in advance James
  • 5. Listbox Scrollbar
    Hi I have two listboxes in .net windows application using c#. I want that when I change scroll postion of first listbox1, scroll position of listbox2 also gets changed. kindly help. Ram

Drag and drop and IAsyncOperation problems

Postby Highlander » Sun, 04 Apr 2004 01:34:58 GMT

Hello,

I'm developing db-based document management system. Currently I'm trying to
implement adding documents to the system through drag and drop from Windows
Explorer. This is quite lengthy operation involving some user input in
wizard that appears.
So I decided to use IAsyncOperation explosed by explorer's IDataObject.
The following problems occured (Win2K SP3):
1. IAsyncOperation->GetAsyncMode() returns TRUE but not VARIANT_TRUE as
noted in MSDN
2. When I'm even not using asynchronous drag and drop some file managers do
not remove files if I set pdwEffect to DROPEFFECT_MOVE and set
CFSTR_PERFORMEDDROPEFFECT format to the same value. Explorer deletes files
but, for example, Windows Commander doesn't
3. In asynchronous drag and drop mode I set CFSTR_PERFORMEDDROPEFFECT format
to DROPEFFECT_MOVE and call IAsyncOperation::EndOperation(S_OK, NULL,
DROPEFFECT_MOVE). Everything works fine but Windows Explorer doesn't delete
files :(
Adding files is made in the new spawned thread (from IDataObject::Drop
method) as well as CFSTR_PERFORMEDDROPEFFECT and EndOperation. IDataObject
interface pointer is marshalled through
CoMarshalInterThreadInterfaceInStream/CoGetInterfaceAndReleaseStream. No
AddRef/Release is performed (is this correct?).
IAsyncOperation::BeginOperation is called before spawning the thread

Any help is highly desired.



Re: Drag and drop and IAsyncOperation problems

Postby nikos » Tue, 06 Apr 2004 00:15:03 GMT

without being certain, a shot to nothing would be to set
CFSTR_LOGICALPERFORMEDDROPEFFECT too and see
if explorer respects it after the async operation

however, if _you_ are performing the operation, why don't
you follow the "optimized move operations" guidelines in MSDN
and delete the source files yourself?

----
www.netez.com/2xExplorer






to
Windows
do
format
delete



Re: Drag and drop and IAsyncOperation problems

Postby Highlander » Tue, 06 Apr 2004 16:33:28 GMT

Thanx for your reply.
I tried to set CFSTR_LOGICALPERFORMEDDROPEFFECT but it didn't help :(
My program stores documents in the database so I think that optimized move
is not the case.
As it follows from MSDN the unoptimized move is the case. Drop source is
responsible for deleting items.

Did I choose the correct way of transferring data object to the spawned
thread
(CoMarshalInterThreadInterfaceInStream/CoGetInterfaceAndReleaseStream) ? I
also make AddRef to data object in the main thread and release it after
EndOperation() in the spawned thread.

IAsyncOperation->GetAsyncMode() returns TRUE but not VARIANT_TRUE as noted
in MSDN :(

Are there any threading issues related to asynchronous mode? In what thread
BeginOperation() should be performed?




files
IDataObject



Re: Drag and drop and IAsyncOperation problems

Postby nikos » Tue, 06 Apr 2004 19:37:38 GMT





that is true when copying files _out_ of your database
when you accept files on the other hand, there's no stopping you
deleting the original files/documents, no?


I am not that familiar with IAsyncOperation, sorry
in general, if by the end all your object references are released
you don't have any problems with lockings
(Have you tried calling EndOperation from the main thread,
sending some custom message when the threaded operation finishes?)



that's life! :)
the good thing is that in C++ both values pass the if() test



Re: Drag and drop and IAsyncOperation problems

Postby Highlander » Tue, 06 Apr 2004 20:51:21 GMT

> > My program stores documents in the database so I think that optimized
move
Well, as I understood optimized move takes place when target application
__moves__ items (e.g. files in the file system) using its knowlenge of
physical storage (e.g. moving file from one folder to another without
unnecessary copies).
Sure, I can delete files. However it introduces some changes in code and a
lot of interesting work :)
IMHO source applications, such as explorer can do this better.

Thanx for idea, maybe I'll try this.
The interesting thing was discovered. If I set CFSTR_PASTESUCCEEDED (!!!)
everything works fine ... 8-0
Is this way wrong ?

Yea, unfortunately this is not the only place in MSDN considering drag&drop
where documentation confuses :)
"Using IASyncOperation" part of "Handling Shell Data Transfer Scenarios" is
too concise IMHO :(




Return to Win32 Programming

 

Who is online

Users browsing this forum: No registered users and 44 guest