C++ coders: a request:

Status
Not open for further replies.

GodFather

Ars Legatus Legionis
10,202
Subscriptor++
As some of you know, I am developing a code/text editor called OmniPad. Well, part of that uses a C++ module, and I have run into a problem. the C++ module will not allow me to use ole drag and drop, so when I have a file open, I am unable to drag files onto OmniPad to have them open.

Well, I discovered a way around this, it was posted in May 1996 Microsoft System Journal, and it allows me to use drag and drop, no matter what control is in focus. However, it causes problems inside of an MDI interface. Rather than trying to explain the problems, I took screen caps.

This first screen cap is OmniPad in its open state with 2 blank documents open:

screen1.jpg


As you can see, all nice and fine, and the drag and drop works, now watch what happens when I close one of the open files:

screen2.jpg


note that the remaining window went into "restore" state, and all I have to do is touch the window, and it remaximizes the window, but that is where the real problem comes in:

screen3.jpg


Notice the red circles, how it is duplicating everything, well it adds one for every open file, so if you have 15 open files, that can get pretty bad.

Now, this only happens with that dragdrop control implemented, and I was hoping that someone could take a look at the source code available here: http://josh.ikonboard.com/VPMAY96.zip (its the dragdrop.zip inside the linked zip file) and see if they could help me determine what the problem is (I am NOT a C++ developer by any means).

You can reach me through any of the mediums below, or just post, but any help would be greatly appreciated, and you will of course be credited in the program.

AIM: mehatemicrosoft
ICQ: 31329682
MSN: jpliveshere@hotmail.com
Yahoo: mrbigglesworth8u

Thanks in advance for any help you can provide.
 
That line allows the MSJ control to intercept the WM_DROPFILES message, chances are its not forwarding other messages correctly, but you probobably already knew that. I din't have time to try it out, but you might want to check out the March 97 MSJ article "More fun with DIBS, Palettes, Subclassing, and a Gamut of Goodies, Part II", which develops a class for correctly subclassing existing MFC windows called CHookWnd (later renamed CSubclassWnd). If I get a chance I'll plug this code in and see what happens.
 

MrMills

Ars Praefectus
3,727
Moderator
Sorry to be less than helpful. :)

For interest's sake, here's some WM_DROPFILES Delphi code.

code:<HR>
Code:
procedure TMainForm.FormCreate(Sender: TObject);
begin
  // ...
  DragAcceptFiles(Handle, True);
  // ...
end;
 
procedure TMainForm.WMDropFiles(var Msg: TWMDROPFILES);
var
  NumFiles: Integer;
  I: Integer;
  Buffer: array[0..255] of Char;
  P: TPoint;
begin
  // How many files are being dropped?
  NumFiles := DragQueryFile(Msg.Drop, $FFFFFFFF, nil, 0);
 
  if NumFiles > 0 then begin
    // Get the point of drop (if important)
    DragQueryPoint(Msg.Drop, P);
 
    // Accept the dropped files
    for I := 0 to NumFiles - 1 do begin
      DragQueryFile(Msg.Drop, I, @Buffer, SizeOf(Buffer));
      // do processing per file
    end;
 
    DragFinish(Msg.Drop);  // Release drag struct
  end;
end;

I tried looking through your MSJDRAG control source, but I'm not a C++ programmer either. Nevertheless, I urge you to look at other implementations of subclassing, because that's the only method I can see working in VB.
 

MrMills

Ars Praefectus
3,727
Moderator
Hmm ...

VBFrWnd.cpp:

code:<HR>
Code:
void CVBFrameWnd::OnDropFiles(HDROP hDropInfo) 
{
	char lpszFile[128];
	UINT numFiles;
 
	numFiles = 	DragQueryFile(hDropInfo, 0xFFFF, NULL, 0);
 
	::DragQueryFile(hDropInfo, 0, lpszFile, 127);
	::DragFinish(hDropInfo);
	m_ctrlwnd->FireFileDrop((OLE_HANDLE) m_hWnd, (LPCTSTR) lpszFile);
 	
	CWnd::OnDropFiles(hDropInfo);
}

(0x0) That should be 0xFFFFFFFF, not 0xFFFF.
(0x1) It should handle multiple files, not just one. See my Delphi source code.
(0x2) It should allocate a bigger buffer; file names can be longer than 128 characters. (Yeah, mine should handle 260-character file names, not 256-character ones. Shrug.)

[This message was edited by MrMills on February 08, 2002 at 10:22.]
 
Status
Not open for further replies.