clean up.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@313 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
donho 2008-09-09 23:57:57 +00:00
parent 6a73e62487
commit c2acd30423
26 changed files with 129 additions and 140 deletions

View File

@ -18,6 +18,7 @@
//#include "Common.h" //use force include
#include <memory>
#include <algorithm>
#include "Common.h"
WcharMbcsConvertor * WcharMbcsConvertor::_pSelf = new WcharMbcsConvertor;
@ -57,6 +58,87 @@ void writeLog(const TCHAR *logFileName, const TCHAR *log2write)
fclose(f);
}
void folderBrowser(HWND parent, int outputCtrlID)
{
// This code was copied and slightly modifed from:
// http://www.bcbdev.com/faqs/faq62.htm
// SHBrowseForFolder returns a PIDL. The memory for the PIDL is
// allocated by the shell. Eventually, we will need to free this
// memory, so we need to get a pointer to the shell malloc COM
// object that will free the PIDL later on.
LPMALLOC pShellMalloc = 0;
if (::SHGetMalloc(&pShellMalloc) == NO_ERROR)
{
// If we were able to get the shell malloc object,
// then proceed by initializing the BROWSEINFO stuct
BROWSEINFO info;
memset(&info, 0, sizeof(info));
info.hwndOwner = parent;
info.pidlRoot = NULL;
TCHAR szDisplayName[MAX_PATH];
info.pszDisplayName = szDisplayName;
info.lpszTitle = TEXT("Select a folder to search from");
info.ulFlags = 0;
info.lpfn = BrowseCallbackProc;
TCHAR directory[MAX_PATH];
::GetDlgItemText(parent, outputCtrlID, directory, sizeof(directory));
info.lParam = reinterpret_cast<LPARAM>(directory);
// Execute the browsing dialog.
LPITEMIDLIST pidl = ::SHBrowseForFolder(&info);
// pidl will be null if they cancel the browse dialog.
// pidl will be not null when they select a folder.
if (pidl)
{
// Try to convert the pidl to a display generic_string.
// Return is true if success.
TCHAR szDir[MAX_PATH];
if (::SHGetPathFromIDList(pidl, szDir))
// Set edit control to the directory path.
::SetDlgItemText(parent, outputCtrlID, szDir);
pShellMalloc->Free(pidl);
}
pShellMalloc->Release();
}
}
void ClientRectToScreenRect(HWND hWnd, RECT* rect)
{
POINT pt;
pt.x = rect->left;
pt.y = rect->top;
::ClientToScreen( hWnd, &pt );
rect->left = pt.x;
rect->top = pt.y;
pt.x = rect->right;
pt.y = rect->bottom;
::ClientToScreen( hWnd, &pt );
rect->right = pt.x;
rect->bottom = pt.y;
};
void ScreenRectToClientRect(HWND hWnd, RECT* rect)
{
POINT pt;
pt.x = rect->left;
pt.y = rect->top;
::ScreenToClient( hWnd, &pt );
rect->left = pt.x;
rect->top = pt.y;
pt.x = rect->right;
pt.y = rect->bottom;
::ScreenToClient( hWnd, &pt );
rect->right = pt.x;
rect->bottom = pt.y;
};
int filter(unsigned int code, struct _EXCEPTION_POINTERS *ep)
{
if (code == EXCEPTION_ACCESS_VIOLATION)

View File

@ -22,6 +22,7 @@
#include <string>
#include <vector>
#include <time.h>
#include <Shlobj.h>
#ifdef UNICODE
#include <wchar.h>
@ -72,6 +73,17 @@
#define COPYDATA_FILENAMES COPYDATA_FILENAMESA
#endif
void folderBrowser(HWND parent, int outputCtrlID);
// Set a call back with the handle after init to set the path.
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/callbackfunctions/browsecallbackproc.asp
static int __stdcall BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM, LPARAM pData)
{
if (uMsg == BFFM_INITIALIZED)
::SendMessage(hwnd, BFFM_SETSELECTION, TRUE, pData);
return 0;
};
void systemMessage(const TCHAR *title);
//DWORD ShortToLongPathName(LPCTSTR lpszShortPath, LPTSTR lpszLongPath, DWORD cchBuffer);
void printInt(int int2print);
@ -81,8 +93,9 @@ int filter(unsigned int code, struct _EXCEPTION_POINTERS *ep);
int getCpFromStringValue(const TCHAR * encodingStr);
std::generic_string purgeMenuItemString(const TCHAR * menuItemStr, bool keepAmpersand = false);
//void char2wchar(const char* pszCHAR, wchar_t* pszWCHAR, UINT codepage);
//void wchar2char(const wchar_t* pszWCHAR, char* pszCHAR, UINT codepage);
void ClientRectToScreenRect(HWND hWnd, RECT* rect);
void ScreenRectToClientRect(HWND hWnd, RECT* rect);
std::wstring string2wstring(const std::string & rString, UINT codepage);
std::string wstring2string(const std::wstring & rwString, UINT codepage);

View File

@ -20,6 +20,8 @@
#include <windows.h>
#include <string>
#include "Common.h"
using namespace std;
enum progType {WIN32_PROG, CONSOLE_PROG};

View File

@ -19,6 +19,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include <windows.h>
#include "regExtDlg.h"
#include "resource.h"
#include "Common.h"
const TCHAR *nppName = TEXT("Notepad++_file");
const TCHAR *nppBackup = TEXT("Notepad++_backup");

View File

@ -4841,7 +4841,7 @@ bool Notepad_plus::activateBuffer(BufferID id, int whichOne)
SCNotification scnN;
scnN.nmhdr.code = NPPN_DOCSWITCHINGOFF;
scnN.nmhdr.hwndFrom = _hSelf;
scnN.nmhdr.idFrom = oldBuf;
scnN.nmhdr.idFrom = (uptr_t)oldBuf;
_pluginsManager.notify(&scnN);
Buffer * pBuf = MainFileManager->getBufferByID(id);
@ -4872,8 +4872,8 @@ bool Notepad_plus::activateBuffer(BufferID id, int whichOne)
}
notifyBufferActivated(id, whichOne);
scnN.nmhdr.code = NPPN_DOCSWITCHINGIN;
scnN.nmhdr.hwndFrom = _hSelf;
scnN.nmhdr.idFrom = id;
//scnN.nmhdr.hwndFrom = _hSelf;
scnN.nmhdr.idFrom = (uptr_t)id;
_pluginsManager.notify(&scnN);
return true;
}

View File

@ -19,7 +19,6 @@
#include "ScintillaEditView.h"
#include "Notepad_plus_msgs.h"
#include "constant.h"
#include "common_func.h"
#include "UniConversion.h"
int Searching::convertExtendedToString(const TCHAR * query, TCHAR * result, int length) { //query may equal to result, since it always gets smaller

View File

@ -36,8 +36,8 @@ distribution.
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <windows.h>
#include "Common.h"
// Help out windows:
#if defined( _DEBUG ) && !defined( DEBUG )

View File

@ -18,7 +18,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "ColourPicker.h"
#include "Common.h"
void ColourPicker::init(HINSTANCE hInst, HWND parent)

View File

@ -18,6 +18,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "ColourPopup.h"
#include "Common.h"
DWORD colourItems[] = {
RGB( 0, 0, 0), RGB( 64, 0, 0), RGB(128, 0, 0), RGB(128, 64, 64), RGB(255, 0, 0), RGB(255, 128, 128),

View File

@ -24,8 +24,8 @@
#include "WindowInterface.h"
#include "ToolTip.h"
#include <Commctrl.h>
#include <shlobj.h>
#include "common_func.h"
//#include <shlobj.h>
#include "Common.h"
#ifndef WH_MOUSE_LL
#define WH_MOUSE_LL 14
@ -427,7 +427,7 @@ LRESULT DockingCont::runProcCaption(HWND hwnd, UINT Message, WPARAM wParam, LPAR
case WM_SIZE:
{
::GetWindowRect(hwnd, &_rcCaption);
ScreenToClient(hwnd, &_rcCaption);
ScreenRectToClientRect(hwnd, &_rcCaption);
break;
}
case WM_SETTEXT:
@ -601,7 +601,7 @@ eMousePos DockingCont::isInRect(HWND hwnd, INT x, INT y)
eMousePos ret = posOutside;
::GetWindowRect(hwnd, &rc);
ScreenToClient(hwnd, &rc);
ScreenRectToClientRect(hwnd, &rc);
if (_isTopCaption == TRUE)
{
@ -951,7 +951,7 @@ BOOL CALLBACK DockingCont::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
getWindowRect(rcWnd);
getClientRect(rcClient);
ClientToScreen(_hSelf, &rcClient);
ClientRectToScreenRect(_hSelf, &rcClient);
rcWnd.bottom = rcClient.top;
/* if in caption */

View File

@ -17,7 +17,7 @@
#include "DockingSplitter.h"
#include "Common.h"
BOOL DockingSplitter::_isVertReg = FALSE;
BOOL DockingSplitter::_isHoriReg = FALSE;

View File

@ -460,7 +460,7 @@ void Gripper::doTabReordering(POINT pt)
{
/* prevent flickering of tabs with different sizes */
::SendMessage(hTab, TCM_GETITEMRECT, iItem, (LPARAM)&rc);
ClientToScreen(hTab, &rc);
ClientRectToScreenRect(hTab, &rc);
if ((rc.left + (_rcItem.right - _rcItem.left)) < pt.x)
{
@ -749,13 +749,13 @@ DockingCont* Gripper::workHitTest(POINT pt, RECT *rc)
default:
break;
}
ClientToScreen(_dockData.hWnd, &rcCont);
ClientRectToScreenRect(_dockData.hWnd, &rcCont);
if (::PtInRect(&rcCont, pt) == TRUE)
{
if (rc != NULL)
{
ClientToScreen(_dockData.hWnd, rc);
ClientRectToScreenRect(_dockData.hWnd, rc);
rc->right -= rc->left;
rc->bottom -= rc->top;
}

View File

@ -23,7 +23,6 @@
#include "DockingCont.h"
#include "DockingManager.h"
#include "commctrl.h"
#include "common_func.h"
// Used by getRectAndStyle() to draw the drag rectangle
@ -79,11 +78,11 @@ protected :
void initTabInformation(POINT pt);
void CalcRectToScreen(HWND hWnd, RECT *rc) {
ClientToScreen(hWnd, rc);
ClientRectToScreenRect(hWnd, rc);
ShrinkRcToSize(rc);
};
void CalcRectToClient(HWND hWnd, RECT *rc) {
ScreenToClient(hWnd, rc);
ScreenRectToClientRect(hWnd, rc);
ShrinkRcToSize(rc);
};
void ShrinkRcToSize(RECT *rc) {

View File

@ -1,86 +0,0 @@
#include "common_func.h"
#include <string>
using namespace std;
void ClientToScreen(HWND hWnd, RECT* rect)
{
POINT pt;
pt.x = rect->left;
pt.y = rect->top;
::ClientToScreen( hWnd, &pt );
rect->left = pt.x;
rect->top = pt.y;
pt.x = rect->right;
pt.y = rect->bottom;
::ClientToScreen( hWnd, &pt );
rect->right = pt.x;
rect->bottom = pt.y;
};
void ScreenToClient(HWND hWnd, RECT* rect)
{
POINT pt;
pt.x = rect->left;
pt.y = rect->top;
::ScreenToClient( hWnd, &pt );
rect->left = pt.x;
rect->top = pt.y;
pt.x = rect->right;
pt.y = rect->bottom;
::ScreenToClient( hWnd, &pt );
rect->right = pt.x;
rect->bottom = pt.y;
};
void folderBrowser(HWND parent, int outputCtrlID)
{
// This code was copied and slightly modifed from:
// http://www.bcbdev.com/faqs/faq62.htm
// SHBrowseForFolder returns a PIDL. The memory for the PIDL is
// allocated by the shell. Eventually, we will need to free this
// memory, so we need to get a pointer to the shell malloc COM
// object that will free the PIDL later on.
LPMALLOC pShellMalloc = 0;
if (::SHGetMalloc(&pShellMalloc) == NO_ERROR)
{
// If we were able to get the shell malloc object,
// then proceed by initializing the BROWSEINFO stuct
BROWSEINFO info;
memset(&info, 0, sizeof(info));
info.hwndOwner = parent;
info.pidlRoot = NULL;
TCHAR szDisplayName[MAX_PATH];
info.pszDisplayName = szDisplayName;
generic_string title = TEXT("Select a folder to search from");
info.lpszTitle = title.c_str();
info.ulFlags = 0;
info.lpfn = BrowseCallbackProc;
TCHAR directory[MAX_PATH];
::GetDlgItemText(parent, outputCtrlID, directory, sizeof(directory));
info.lParam = reinterpret_cast<LPARAM>(directory);
// Execute the browsing dialog.
LPITEMIDLIST pidl = ::SHBrowseForFolder(&info);
// pidl will be null if they cancel the browse dialog.
// pidl will be not null when they select a folder.
if (pidl)
{
// Try to convert the pidl to a display generic_string.
// Return is true if success.
TCHAR szDir[MAX_PATH];
if (::SHGetPathFromIDList(pidl, szDir))
// Set edit control to the directory path.
::SetDlgItemText(parent, outputCtrlID, szDir);
pShellMalloc->Free(pidl);
}
pShellMalloc->Release();
}
}

View File

@ -1,20 +0,0 @@
#ifndef COMMON_FUNC_H
#define COMMON_FUNC_H
#include "windows.h"
// need this header for SHBrowseForFolder
#include <Shlobj.h>
void ClientToScreen(HWND hWnd, RECT* rect);
void ScreenToClient(HWND hWnd, RECT* rect);
void folderBrowser(HWND parent, int outputCtrlID);
// Set a call back with the handle after init to set the path.
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/callbackfunctions/browsecallbackproc.asp
static int __stdcall BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM, LPARAM pData)
{
if (uMsg == BFFM_INITIALIZED)
::SendMessage(hwnd, BFFM_SETSELECTION, TRUE, pData);
return 0;
};
#endif //COMMON_FUNC_H

View File

@ -11,6 +11,7 @@ Modified by Don HO <don.h@free.fr>
*/
#include "babygrid.h"
#include "Common.h"
#define MAX_GRIDS 20

View File

@ -17,7 +17,6 @@
#include <windows.h>
#include "preferenceDlg.h"
#include "common_func.h"
BOOL CALLBACK PreferenceDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam)
{

View File

@ -17,7 +17,7 @@
#include "Splitter.h"
//#include "resource.h"
#include "Common.h"
bool Splitter::_isHorizontalRegistered = false;
bool Splitter::_isVerticalRegistered = false;

View File

@ -16,7 +16,7 @@
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "SplitterContainer.h"
#include "Common.h"
bool SplitterContainer::_isRegistered = false;

View File

@ -21,6 +21,7 @@
#include "StaticDialog.h"
#include "RunDlg_rc.h"
#include <string>
#include "Common.h"
//static void extractArgs(TCHAR *cmd2Exec, TCHAR *args, const TCHAR *cmdEntier);

View File

@ -16,6 +16,7 @@
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "StaticDialog.h"
#include "Common.h"
void StaticDialog::goToCenter()
{

View File

@ -16,6 +16,7 @@
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "StatusBar.h"
#include "Common.h"
//#define IDC_STATUSBAR 789

View File

@ -16,6 +16,7 @@
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "TabBar.h"
#include "Common.h"
const COLORREF blue = RGB(0, 0, 0xFF);
const COLORREF black = RGB(0, 0, 0);

View File

@ -18,6 +18,7 @@
#include "TaskList.h"
#include "TaskListDlg_rc.h"
#include "colors.h"
#include "Common.h"
void TaskList::init(HINSTANCE hInst, HWND parent, HIMAGELIST hImaLst, int nbItem, int index2set)
{

View File

@ -24,6 +24,7 @@
#include "shortcutRc.h"
#include "StaticDialog.h"
#include "Scintilla.h"
#include "Common.h"
using namespace std;

View File

@ -135,7 +135,7 @@
FavorSizeOrSpeed="2"
OmitFramePointers="false"
WholeProgramOptimization="false"
AdditionalIncludeDirectories="..\src\WinControls\AboutDlg;..\..\scintilla\include;..\include;..\src\WinControls;..\src\WinControls\ImageListSet;..\src\WinControls\OpenSaveFileDialog;..\src\WinControls\SplitterContainer;..\src\WinControls\StaticDialog;..\src\WinControls\TabBar;..\src\WinControls\ToolBar;..\src\MISC\Process;..\src\ScitillaComponent;..\src\MISC;..\src\MISC\SysMsg;..\src\WinControls\StatusBar;..\src;..\src\WinControls\StaticDialog\RunDlg;..\src\tinyxml;..\src\WinControls\ColourPicker;..\src\Win32Explr;..\src\MISC\RegExt;..\src\WinControls\TrayIcon;..\src\WinControls\shortcut;..\src\WinControls\Grid;..\src\WinControls\ContextMenu;..\src\MISC\PluginsManager;..\src\WinControls\Preference;..\src\WinControls\WindowsDlg;..\src\WinControls\TaskList;..\src\WinControls\DockingWnd;..\src\WinControls\ToolTip;..\src\MISC\Exception"
AdditionalIncludeDirectories="..\src\WinControls\AboutDlg;..\..\scintilla\include;..\include;..\src\WinControls;..\src\WinControls\ImageListSet;..\src\WinControls\OpenSaveFileDialog;..\src\WinControls\SplitterContainer;..\src\WinControls\StaticDialog;..\src\WinControls\TabBar;..\src\WinControls\ToolBar;..\src\MISC\Process;..\src\ScitillaComponent;..\src\MISC;..\src\MISC\SysMsg;..\src\WinControls\StatusBar;..\src;..\src\WinControls\StaticDialog\RunDlg;..\src\tinyxml;..\src\WinControls\ColourPicker;..\src\Win32Explr;..\src\MISC\RegExt;..\src\WinControls\TrayIcon;..\src\WinControls\shortcut;..\src\WinControls\Grid;..\src\WinControls\ContextMenu;..\src\MISC\PluginsManager;..\src\WinControls\Preference;..\src\WinControls\WindowsDlg;..\src\WinControls\TaskList;..\src\WinControls\DockingWnd;..\src\WinControls\ToolTip;..\src\MISC\Exception;..\src\MISC\Common"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USE_64BIT_TIME_T;TIXML_USE_STL"
StringPooling="true"
ExceptionHandling="2"
@ -239,7 +239,7 @@
>
</File>
<File
RelativePath="..\src\WinControls\DockingWnd\common_func.cpp"
RelativePath="..\src\MISC\Common\Common.cpp"
>
</File>
<File
@ -362,10 +362,6 @@
RelativePath="..\src\WinControls\StatusBar\StatusBar.cpp"
>
</File>
<File
RelativePath="..\src\MISC\SysMsg\SysMsg.cpp"
>
</File>
<File
RelativePath="..\src\WinControls\TabBar\TabBar.cpp"
>
@ -488,7 +484,7 @@
>
</File>
<File
RelativePath="..\src\WinControls\DockingWnd\common_func.h"
RelativePath="..\src\MISC\Common\Common.h"
>
</File>
<File
@ -667,10 +663,6 @@
RelativePath="..\src\WinControls\StatusBar\StatusBar.h"
>
</File>
<File
RelativePath="..\src\MISC\SysMsg\SysMsg.h"
>
</File>
<File
RelativePath="..\src\WinControls\TabBar\TabBar.h"
>