Emerald Editor Discussion
April 23, 2017, 08:55:16 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1] 2
  Print  
Author Topic: Closing tabs with middle mouse button  (Read 14984 times)
0 Members and 1 Guest are viewing this topic.
TrgDev
Prospector
*
Posts: 6


« on: November 04, 2007, 09:56:36 pm »

I just implemented this a few minutes ago on the 3.70 sources (I am using VC6 to compile).

I simply added an handler for WM_MOUSEACTIVATE in the CMDIFileTab (couldn't find any other way to get the middle mouse button) and then find the correct tab to close from the screen coordinates.
I am very new to MFC and expecially MDI coding so I can't guarantee that everything will be bug free or that this is the correct/best way to do it, but it seems to work fine from a quick test.

Here is the new handler code :

Code:
int CMDIFileTab::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)
{
TC_HITTESTINFO info;
CTabCtrl *pTabCtrl;
DWORD mPos;
CPoint cpMouse;

if(message == WM_MBUTTONDOWN)
{
mPos = GetMessagePos();
cpMouse = CPoint(LOWORD(mPos), HIWORD(mPos));

pTabCtrl = (CTabCtrl *)GetDlgItem(IDC_FILE_TAB);
ASSERT( pTabCtrl );

info.pt = cpMouse;
pTabCtrl->ScreenToClient( & info.pt );
INT nCurrTab = pTabCtrl->HitTest( & info );
if(nCurrTab >= 0 )
{
TC_ITEM item; item.mask = TCIF_PARAM;
pTabCtrl->GetItem(nCurrTab, &item);
CMDIChildWnd *pChild = (CMDIChildWnd *)item.lParam;

CDocument * pDoc = pChild->GetActiveDocument(); ASSERT( pDoc );
CCedtDoc * pCedtDoc = (CCedtDoc *)pDoc;
CCedtView * pView = (CCedtView *)pCedtDoc->GetFirstView();
CFrameWnd * pFrame = (CChildFrame *)pView->GetParentFrame();
if(pDoc->CanCloseFrame(pFrame)) pChild->MDIDestroy();
}

return MA_ACTIVATEANDEAT;
}
else
{
return CDialogBar::OnMouseActivate(pDesktopWnd, nHitTest, message);
}
}

Sorry, don't have time right now to mess with SVN or the new sources, just thought I would share this so that those interested might include it in the new sources or use it as a starting point.

Regards,
Gabriele.
Logged
Pvt_Ryan
Master Jeweller
******
Posts: 422



WWW
« Reply #1 on: November 04, 2007, 11:39:56 pm »

Thanks,

I'll have a play about with this tomorrow..
Logged
Pvt_Ryan
Master Jeweller
******
Posts: 422



WWW
« Reply #2 on: November 05, 2007, 10:55:47 am »

damn cant play with it... only have the laptop and no extra mouse.. ill play with it on wednesday evening.
Logged
rageboy
Jeweller
*****
Posts: 305

Ankit Singla


« Reply #3 on: November 05, 2007, 10:06:30 pm »

Hi Gabriele,

I just tried your patch against the 216 revision using VS2005, and it didn't seem to do anything. Also, there is a OnMButtonDown function in the CMDIFileTab class that you might be able to use like OnLButtonDblClick is used instead. I'm not sure why your code would have worked for you and not me.

Ankit
Logged
pn8830
Global Moderator
Jeweller
*****
Posts: 252



« Reply #4 on: November 05, 2007, 11:29:19 pm »

2 TrgDev,
Could you maybe post the files that you have changed. I would like to make sure that I did not miss anything.
Thanks,
Pavel.
Logged

Entities should not be multiplied beyond necessity
TrgDev
Prospector
*
Posts: 6


« Reply #5 on: November 06, 2007, 05:47:28 pm »

I just tried your patch against the 216 revision using VS2005, and it didn't seem to do anything. Also, there is a OnMButtonDown function in the CMDIFileTab class that you might be able to use like OnLButtonDblClick is used instead. I'm not sure why your code would have worked for you and not me.

Before going with the OnMouseActivate solution I also tried the WM_MBUTTONDOWN message but found out that it only gets sent to the dialog object containing the MDI tab control if you click where there are no tabs, so it's kind of useless for this solution. Strangely enough the left and right mouse button messages are instead sent as expected.

I suggest you use the Spy++ tool (in VC6 it's under "Microsoft Visual Studio 6.0 Tools") to check what messages are actually sent to the the different objects of an application. In CrimsonEditor's case only the mouse activate message and a few others are passed to the dialog.
Logged
TrgDev
Prospector
*
Posts: 6


« Reply #6 on: November 06, 2007, 05:57:48 pm »

Could you maybe post the files that you have changed. I would like to make sure that I did not miss anything.

Sure, here they are :

MDIFileTab.* : changes related to closing tabs with middle mouse buttons
cedtAppFile.cpp : .prj project opening
FileWindowDirectory.cpp : misc changes I made to speed up loading.

Changes to FileWindowDirectory.cpp are :

- InitLocalDriveList() : filter "A" drive to avoid calling GetVolumeInformation().
   On my pc the A drive clicks every time a call is made to GetVolumeInformation() and it was driving me crazy. Smiley

- SetBrowsingDirectory() : brutal hack to remove the prefetch of the directoy tree in the file window.
   On my system this was taking several seconds, with it removed Crimson Editor starts immediatly.

Regards,

* CrimsonEditorPatches.zip (10.49 KB - downloaded 430 times.)
Logged
Pvt_Ryan
Master Jeweller
******
Posts: 422



WWW
« Reply #7 on: November 06, 2007, 11:24:59 pm »

ok.

Not trying to put you off but some problems with your code, probably mostly to do with the fact you are:
A) using out of date code
and
B) using VC 6

1. You removed some INT and (INT) from areas in the code is VS2k5 they NEED to be there or it wont compile.
(well the INT needs to be there but the the (INT) just throws a data loss warning)

2. You never declared m_szPrevWorkspacePathName in VS 2k5 ALL variables MUST be declared.

3. You overloaded the SaveFtpAccountInfo(); function to SaveFtpAccountInfo(m_szInstallDirectory + "\\cedt.ftp"); but never declared an
overloaded function.

4. You changed some ULONGLONG to DW

I suspect that although i am saying "you" in the above i am partially incorrect as some of the above is mostly likely code that was changed by phil in order to update it and its simply you are using the older source code..

Note the attached patch munges the overloaded SaveFtpAccountInfo so it accepts the paramater and does nothing with it..

Can you also please heavily comment your code so that we can see what you are trying to do in each case.

Interestingly your code does allow middle click closing but breaks the double click opening of new tabs.. Smiley


* trgDev-fixesVS2k5.patch (12.55 KB - downloaded 457 times.)
Logged
TrgDev
Prospector
*
Posts: 6


« Reply #8 on: November 07, 2007, 06:26:34 pm »

Not trying to put you off but some problems with your code, probably mostly to do with the fact you are:

I am not sure who you are talking to and what problems you are refering to, but if those comments were directed to me please note that I did not remove and/or change anything related to any of your four points.

This code works perfectly on the 3.70 sources which I am using (as a matter of fact I have been using it heavily the last few days and it works with no problems whatsoever).
The only changes that I made to the 3.70 sources are those that I indicated and that are present in the attached files.

Of course this patches are not guaranteed to work out-of-the-box on a new/different code revision, but I guess that someone else with VS 2k5 will have to implement them Smiley

Quote
Interestingly your code does allow middle click closing but breaks the double click opening of new tabs..

Very strange since if the message is not  WM_MBUTTONDOWN it simply passes it over unchanged.
Logged
pn8830
Global Moderator
Jeweller
*****
Posts: 252



« Reply #9 on: November 07, 2007, 08:14:17 pm »

@ Pvt_Ryan
Yeah.. I saw these differences too. It looks like they are in original code from Ingyu.
PN
Logged

Entities should not be multiplied beyond necessity
rageboy
Jeweller
*****
Posts: 305

Ankit Singla


« Reply #10 on: December 03, 2007, 07:30:45 pm »

Ryan: I'm not sure what you mean about his code breaking anything (including building) unless the patch didn't apply right for you. Because although I didn't get it to do what it was supposed to, I didn't have problems with it.
Logged
Pvt_Ryan
Master Jeweller
******
Posts: 422



WWW
« Reply #11 on: December 03, 2007, 09:45:25 pm »

hmm can you create a diff of yours then and i'll try and apply that.

I am fairly sure that his code reverts some of the vars to VS6 types when they were changed to vs 2k5..
Logged
TrgDev
Prospector
*
Posts: 6


« Reply #12 on: December 07, 2007, 10:48:23 am »

As stated in my initial post, my changes and the files that I posted are all based on the original Crimson Editor 3.70 sources as posted here : http://www.crimsoneditor.com/ .
They compile with no errors and warning using VC6 and have been using the generated binary ever since my original post with no problems at all.

It's quite obvious that due to the many changes done in the later code revisions, you can't just make a diff of the files that I posted with the latest revision and expect it to work out-of-the-box.

But seriously, wouldn't it just be easier for someone with a vs2005 dev enviroment to make the needed changes to the new code revision? The changes I made are trivial at best and consist of just a few dozen lines of code.

Just make a diff of the code I posted to the original sources to extract them and convert them "by hand".
Logged
farok
Prospector
*
Posts: 2


« Reply #13 on: December 08, 2009, 03:51:03 pm »

Any update on this wanted feature  ??
 Wink
Logged
Phil
Administrator
Master Jeweller
*****
Posts: 427


« Reply #14 on: December 08, 2009, 10:33:08 pm »

Any update on this wanted feature  ??
 Wink

I don't think so. Here's the bug link: http://bugs.emeraldeditor.com/showreport.php?bugid=93
Logged
Pages: [1] 2
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.162 seconds with 18 queries.