[CODE_ENHANCEMENT] Code enhancement.

This commit is contained in:
Don Ho 2015-05-28 01:22:28 +02:00
parent c123fd1a01
commit 7f6dd17f03
13 changed files with 115 additions and 102 deletions

View File

@ -129,16 +129,11 @@ BOOL Process::run()
void Process::listenerStdOut() void Process::listenerStdOut()
{ {
//BOOL Result = 0;
//DWORD size = 0;
DWORD bytesAvail = 0; DWORD bytesAvail = 0;
BOOL result = 0; BOOL result = 0;
HANDLE hListenerEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("listenerEvent")); HANDLE hListenerEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("listenerEvent"));
//FILE *fp = NULL;
int taille = 0;
TCHAR bufferOut[MAX_LINE_LENGTH + 1]; TCHAR bufferOut[MAX_LINE_LENGTH + 1];
//TCHAR bufferErr[MAX_LINE_LENGTH + 1];
int nExitCode = STILL_ACTIVE; int nExitCode = STILL_ACTIVE;
@ -150,8 +145,7 @@ void Process::listenerStdOut()
while (goOn) while (goOn)
{ // got data { // got data
memset(bufferOut,0x00,MAX_LINE_LENGTH + 1); memset(bufferOut,0x00,MAX_LINE_LENGTH + 1);
//memset(bufferErr,0x00,MAX_LINE_LENGTH + 1); int taille = sizeof(bufferOut) - sizeof(TCHAR);
taille = sizeof(bufferOut) - sizeof(TCHAR);
Sleep(50); Sleep(50);
@ -171,7 +165,7 @@ void Process::listenerStdOut()
break; break;
} }
} }
//outbytesRead = strlen(bufferOut);
bufferOut[outbytesRead] = '\0'; bufferOut[outbytesRead] = '\0';
generic_string s; generic_string s;
s.assign(bufferOut); s.assign(bufferOut);
@ -198,19 +192,13 @@ void Process::listenerStdOut()
void Process::listenerStdErr() void Process::listenerStdErr()
{ {
//BOOL Result = 0;
//DWORD size = 0;
DWORD bytesAvail = 0; DWORD bytesAvail = 0;
BOOL result = 0; BOOL result = 0;
HANDLE hListenerEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("listenerStdErrEvent")); HANDLE hListenerEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("listenerStdErrEvent"));
int taille = 0; int taille = 0;
//TCHAR bufferOut[MAX_LINE_LENGTH + 1];
TCHAR bufferErr[MAX_LINE_LENGTH + 1]; TCHAR bufferErr[MAX_LINE_LENGTH + 1];
int nExitCode = STILL_ACTIVE; int nExitCode = STILL_ACTIVE;
DWORD errbytesRead;
::ResumeThread(_hProcessThread); ::ResumeThread(_hProcessThread);
@ -221,7 +209,7 @@ void Process::listenerStdErr()
taille = sizeof(bufferErr) - sizeof(TCHAR); taille = sizeof(bufferErr) - sizeof(TCHAR);
Sleep(50); Sleep(50);
DWORD errbytesRead;
if (!::PeekNamedPipe(_hPipeErrR, bufferErr, taille, &errbytesRead, &bytesAvail, NULL)) if (!::PeekNamedPipe(_hPipeErrR, bufferErr, taille, &errbytesRead, &bytesAvail, NULL))
{ {
bytesAvail = 0; bytesAvail = 0;
@ -238,7 +226,6 @@ void Process::listenerStdErr()
break; break;
} }
} }
//outbytesRead = strlen(bufferOut);
bufferErr[errbytesRead] = '\0'; bufferErr[errbytesRead] = '\0';
generic_string s; generic_string s;
s.assign(bufferErr); s.assign(bufferErr);

View File

@ -606,7 +606,7 @@ private:
int getLangFromMenuName(const TCHAR * langName); int getLangFromMenuName(const TCHAR * langName);
generic_string getLangFromMenu(const Buffer * buf); generic_string getLangFromMenu(const Buffer * buf);
generic_string Notepad_plus::exts2Filters(generic_string exts) const; generic_string exts2Filters(generic_string exts) const;
int setFileOpenSaveDlgFilters(FileDialog & fDlg, int langType = -1); int setFileOpenSaveDlgFilters(FileDialog & fDlg, int langType = -1);
void markSelectedTextInc(bool enable); void markSelectedTextInc(bool enable);
Style * getStyleFromName(const TCHAR *styleName); Style * getStyleFromName(const TCHAR *styleName);

View File

@ -86,7 +86,7 @@ public:
::DestroyWindow(_hSelf); ::DestroyWindow(_hSelf);
}; };
static const TCHAR * Notepad_plus_Window::getClassName() { static const TCHAR * getClassName() {
return _className; return _className;
}; };
static HWND gNppHWND; //static handle to Notepad++ window, NULL if non-existant static HWND gNppHWND; //static handle to Notepad++ window, NULL if non-existant

View File

@ -306,7 +306,7 @@ BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isRecursive, bool isRe
if (isWow64Off) if (isWow64Off)
{ {
pNppParam->safeWow64EnableWow64FsRedirection(TRUE); pNppParam->safeWow64EnableWow64FsRedirection(TRUE);
isWow64Off = false; //isWow64Off = false;
} }
return buffer; return buffer;
} }
@ -439,7 +439,7 @@ void Notepad_plus::doClose(BufferID id, int whichOne, bool doDeleteBackup)
if (isWow64Off) if (isWow64Off)
{ {
pNppParam->safeWow64EnableWow64FsRedirection(TRUE); pNppParam->safeWow64EnableWow64FsRedirection(TRUE);
isWow64Off = false; //isWow64Off = false;
} }
} }

View File

@ -860,15 +860,14 @@ BOOL Notepad_plus::notify(SCNotification *notification)
if (_rebarBottom.getHSelf() == lpnm->hdr.hwndFrom) if (_rebarBottom.getHSelf() == lpnm->hdr.hwndFrom)
notifRebar = &_rebarBottom; notifRebar = &_rebarBottom;
//If N++ ID, use proper object //If N++ ID, use proper object
switch(lpnm->wID) { if (lpnm->wID == REBAR_BAR_TOOLBAR)
case REBAR_BAR_TOOLBAR: { {
POINT pt; POINT pt;
pt.x = lpnm->rc.left; pt.x = lpnm->rc.left;
pt.y = lpnm->rc.bottom; pt.y = lpnm->rc.bottom;
ClientToScreen(notifRebar->getHSelf(), &pt); ClientToScreen(notifRebar->getHSelf(), &pt);
_toolBar.doPopop(pt); _toolBar.doPopop(pt);
return TRUE; return TRUE;
break; }
} }
//Else forward notification to window of rebarband //Else forward notification to window of rebarband
REBARBANDINFO rbBand; REBARBANDINFO rbBand;

View File

@ -222,7 +222,6 @@ static bool getPathsForPathCompletion(generic_string input, generic_string &rawP
} }
else else
{ {
locale loc;
size_t last_occurrence = rawPath.rfind(L"\\"); size_t last_occurrence = rawPath.rfind(L"\\");
if(last_occurrence == std::string::npos) // No match. if(last_occurrence == std::string::npos) // No match.
return false; return false;
@ -765,10 +764,10 @@ bool AutoCompletion::setLanguage(LangType language) {
//Cache the keywords //Cache the keywords
//Iterate through all keywords //Iterate through all keywords
TiXmlElement *funcNode = _pXmlKeyword; TiXmlElement *funcNode = _pXmlKeyword;
const TCHAR * name = NULL;
for (; funcNode; funcNode = funcNode->NextSiblingElement(TEXT("KeyWord")) ) for (; funcNode; funcNode = funcNode->NextSiblingElement(TEXT("KeyWord")) )
{ {
name = funcNode->Attribute(TEXT("name")); const TCHAR *name = funcNode->Attribute(TEXT("name"));
if (name) if (name)
{ {
size_t len = lstrlen(name); size_t len = lstrlen(name);

View File

@ -217,7 +217,7 @@ bool Buffer::checkFileState() { //returns true if the status has been changed (i
if (isWow64Off) if (isWow64Off)
{ {
pNppParam->safeWow64EnableWow64FsRedirection(TRUE); pNppParam->safeWow64EnableWow64FsRedirection(TRUE);
isWow64Off = false; //isWow64Off = false;
} }
return isOK; return isOK;
} }
@ -1121,12 +1121,11 @@ BufferID FileManager::bufferFromDocument(Document doc, bool dontIncrease, bool d
int FileManager::detectCodepage(char* buf, size_t len) int FileManager::detectCodepage(char* buf, size_t len)
{ {
int codepage = -1;
uchardet_t ud = uchardet_new(); uchardet_t ud = uchardet_new();
uchardet_handle_data(ud, buf, len); uchardet_handle_data(ud, buf, len);
uchardet_data_end(ud); uchardet_data_end(ud);
const char* cs = uchardet_get_charset(ud); const char* cs = uchardet_get_charset(ud);
codepage = EncodingMapper::getInstance()->getEncodingFromString(cs); int codepage = EncodingMapper::getInstance()->getEncodingFromString(cs);
uchardet_delete(ud); uchardet_delete(ud);
return codepage; return codepage;
} }
@ -1203,7 +1202,7 @@ bool FileManager::loadFileData(Document doc, const TCHAR * filename, Utf8_16_Rea
do { do {
lenFile = fread(data+incompleteMultibyteChar, 1, blockSize-incompleteMultibyteChar, fp) + incompleteMultibyteChar; lenFile = fread(data+incompleteMultibyteChar, 1, blockSize-incompleteMultibyteChar, fp) + incompleteMultibyteChar;
if (lenFile <= 0) break; if (lenFile == 0) break;
// check if file contain any BOM // check if file contain any BOM
if (isFirstTime) if (isFirstTime)

View File

@ -38,19 +38,22 @@ FindOption FindReplaceDlg::_options;
#define SHIFTED 0x8000 #define SHIFTED 0x8000
int Searching::convertExtendedToString(const TCHAR * query, TCHAR * result, int length) { //query may equal to result, since it always gets smaller int Searching::convertExtendedToString(const TCHAR * query, TCHAR * result, int length)
{ //query may equal to result, since it always gets smaller
int i = 0, j = 0; int i = 0, j = 0;
int charLeft = length; int charLeft = length;
bool isGood = true;
TCHAR current; TCHAR current;
while(i < length) { //because the backslash escape quences always reduce the size of the generic_string, no overflow checks have to be made for target, assuming parameters are correct while (i < length)
{ //because the backslash escape quences always reduce the size of the generic_string, no overflow checks have to be made for target, assuming parameters are correct
current = query[i]; current = query[i];
--charLeft; --charLeft;
if (current == '\\' && charLeft) { //possible escape sequence if (current == '\\' && charLeft)
{ //possible escape sequence
++i; ++i;
--charLeft; --charLeft;
current = query[i]; current = query[i];
switch(current) { switch(current)
{
case 'r': case 'r':
result[j] = '\r'; result[j] = '\r';
break; break;
@ -70,38 +73,54 @@ int Searching::convertExtendedToString(const TCHAR * query, TCHAR * result, int
case 'd': case 'd':
case 'o': case 'o':
case 'x': case 'x':
case 'u': { case 'u':
{
int size = 0, base = 0; int size = 0, base = 0;
if (current == 'b') { //11111111 if (current == 'b')
{ //11111111
size = 8, base = 2; size = 8, base = 2;
} else if (current == 'o') { //377 }
else if (current == 'o')
{ //377
size = 3, base = 8; size = 3, base = 8;
} else if (current == 'd') { //255 }
else if (current == 'd')
{ //255
size = 3, base = 10; size = 3, base = 10;
} else if (current == 'x') { //0xFF }
else if (current == 'x')
{ //0xFF
size = 2, base = 16; size = 2, base = 16;
} else if (current == 'u') { //0xCDCD }
else if (current == 'u')
{ //0xCDCD
size = 4, base = 16; size = 4, base = 16;
} }
if (charLeft >= size) {
if (charLeft >= size)
{
int res = 0; int res = 0;
if (Searching::readBase(query+(i+1), &res, base, size)) { if (Searching::readBase(query+(i+1), &res, base, size))
{
result[j] = (TCHAR)res; result[j] = (TCHAR)res;
i+=size; i += size;
break; break;
} }
} }
//not enough chars to make parameter, use default method as fallback //not enough chars to make parameter, use default method as fallback
} }
default: { //unknown sequence, treat as regular text
default:
{ //unknown sequence, treat as regular text
result[j] = '\\'; result[j] = '\\';
++j; ++j;
result[j] = current; result[j] = current;
isGood = false;
break; break;
} }
} }
} else { }
else
{
result[j] = query[i]; result[j] = query[i];
} }
++i; ++i;

View File

@ -269,14 +269,17 @@ bool FunctionCallTip::getCursorFunction()
/* /*
Find function in XML structure and parse it Find function in XML structure and parse it
*/ */
bool FunctionCallTip::loadFunction() { bool FunctionCallTip::loadFunction()
{
reset(); //set everything back to 0 reset(); //set everything back to 0
//The functions should be ordered, but linear search because we cant access like array //The functions should be ordered, but linear search because we cant access like array
_curFunction = NULL; _curFunction = NULL;
//Iterate through all keywords and find the correct function keyword //Iterate through all keywords and find the correct function keyword
TiXmlElement *funcNode = _pXmlKeyword; TiXmlElement *funcNode = _pXmlKeyword;
const TCHAR * name = NULL;
for (; funcNode; funcNode = funcNode->NextSiblingElement(TEXT("KeyWord")) ) { for (; funcNode; funcNode = funcNode->NextSiblingElement(TEXT("KeyWord")) )
{
const TCHAR * name = NULL;
name = funcNode->Attribute(TEXT("name")); name = funcNode->Attribute(TEXT("name"));
if (!name) //malformed node if (!name) //malformed node
continue; continue;
@ -356,9 +359,9 @@ void FunctionCallTip::showCalltip()
//Check if the current overload still holds. If the current param exceeds amounti n overload, see if another one fits better (enough params) //Check if the current overload still holds. If the current param exceeds amounti n overload, see if another one fits better (enough params)
stringVec & params = _overloads.at(_currentOverload); stringVec & params = _overloads.at(_currentOverload);
size_t psize = params.size()+1, osize; size_t psize = params.size()+1;
if ((size_t)_currentParam >= psize) { if ((size_t)_currentParam >= psize) {
osize = _overloads.size(); size_t osize = _overloads.size();
for(size_t i = 0; i < osize; ++i) { for(size_t i = 0; i < osize; ++i) {
psize = _overloads.at(i).size()+1; psize = _overloads.at(i).size()+1;
if ((size_t)_currentParam < psize) { if ((size_t)_currentParam < psize) {

View File

@ -1561,11 +1561,11 @@ BOOL CALLBACK StylerDlg::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM
::SetProp(hwnd, TEXT("Styler dialog prop"), (HANDLE)lParam); ::SetProp(hwnd, TEXT("Styler dialog prop"), (HANDLE)lParam);
dlg = (StylerDlg *)::GetProp(hwnd, TEXT("Styler dialog prop")); dlg = (StylerDlg *)::GetProp(hwnd, TEXT("Styler dialog prop"));
Style & style = SharedParametersDialog::_pUserLang->_styleArray.getStyler(dlg->stylerIndex); Style & style = SharedParametersDialog::_pUserLang->_styleArray.getStyler(dlg->_stylerIndex);
// move dialog over UDL GUI (position 0,0 of UDL window) so it wouldn't cover the code // move dialog over UDL GUI (position 0,0 of UDL window) so it wouldn't cover the code
RECT wrc; RECT wrc;
::GetWindowRect(dlg->parent, &wrc); ::GetWindowRect(dlg->_parent, &wrc);
wrc.left = wrc.left < 0 ? 200 : wrc.left; // if outside of visible area wrc.left = wrc.left < 0 ? 200 : wrc.left; // if outside of visible area
wrc.top = wrc.top < 0 ? 200 : wrc.top; wrc.top = wrc.top < 0 ? 200 : wrc.top;
::SetWindowPos(hwnd, HWND_TOP, wrc.left, wrc.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER); ::SetWindowPos(hwnd, HWND_TOP, wrc.left, wrc.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
@ -1612,10 +1612,10 @@ BOOL CALLBACK StylerDlg::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM
if (style._bgColor == COLORREF(-1)) if (style._bgColor == COLORREF(-1))
style._bgColor = white; style._bgColor = white;
dlg->pFgColour->init(dlg->hInst, hwnd); dlg->_pFgColour->init(dlg->_hInst, hwnd);
dlg->pFgColour->setColour(style._fgColor); dlg->_pFgColour->setColour(style._fgColor);
dlg->pBgColour->init(dlg->hInst, hwnd); dlg->_pBgColour->init(dlg->_hInst, hwnd);
dlg->pBgColour->setColour(style._bgColor); dlg->_pBgColour->setColour(style._bgColor);
POINT p1, p2; POINT p1, p2;
RECT rc1, rc2; RECT rc1, rc2;
@ -1635,24 +1635,24 @@ BOOL CALLBACK StylerDlg::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM
p1.x += 10; p2.x += 10; p1.x += 10; p2.x += 10;
p1.y -= 6; p2.y -= 6; p1.y -= 6; p2.y -= 6;
::MoveWindow(dlg->pFgColour->getHSelf(), p1.x, p1.y, 30, 30, TRUE); ::MoveWindow(dlg->_pFgColour->getHSelf(), p1.x, p1.y, 30, 30, TRUE);
::MoveWindow(dlg->pBgColour->getHSelf(), p2.x, p2.y, 30, 30, TRUE); ::MoveWindow(dlg->_pBgColour->getHSelf(), p2.x, p2.y, 30, 30, TRUE);
dlg->pFgColour->display(); dlg->_pFgColour->display();
dlg->pBgColour->display(); dlg->_pBgColour->display();
map<int, int>::iterator iter = globalMappper().nestingMapper.begin(); map<int, int>::iterator iter = globalMappper().nestingMapper.begin();
for (; iter != globalMappper().nestingMapper.end(); ++iter) for (; iter != globalMappper().nestingMapper.end(); ++iter)
{ {
::SendDlgItemMessage(hwnd, iter->first, BM_SETCHECK, style._nesting & iter->second, 0); ::SendDlgItemMessage(hwnd, iter->first, BM_SETCHECK, style._nesting & iter->second, 0);
::EnableWindow(::GetDlgItem(hwnd, iter->first), dlg->enabledNesters & iter->second); ::EnableWindow(::GetDlgItem(hwnd, iter->first), dlg->_enabledNesters & iter->second);
} }
return TRUE; return TRUE;
} }
case WM_COMMAND : case WM_COMMAND :
{ {
Style & style = SharedParametersDialog::_pUserLang->_styleArray.getStyler(dlg->stylerIndex); Style & style = SharedParametersDialog::_pUserLang->_styleArray.getStyler(dlg->_stylerIndex);
if (HIWORD(wParam) == CBN_SELCHANGE) if (HIWORD(wParam) == CBN_SELCHANGE)
{ {
int i = ::SendDlgItemMessage(hwnd, LOWORD(wParam), CB_GETCURSEL, 0, 0); int i = ::SendDlgItemMessage(hwnd, LOWORD(wParam), CB_GETCURSEL, 0, 0);
@ -1691,7 +1691,7 @@ BOOL CALLBACK StylerDlg::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM
{ {
if (wParam == IDCANCEL) if (wParam == IDCANCEL)
{ {
style = dlg->initialStyle; style = dlg->_initialStyle;
// show changes to user, re-color document // show changes to user, re-color document
if (SharedParametersDialog::_pScintilla->getCurrentBuffer()->getLangType() == L_USER) if (SharedParametersDialog::_pScintilla->getCurrentBuffer()->getLangType() == L_USER)
@ -1709,14 +1709,14 @@ BOOL CALLBACK StylerDlg::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM
return TRUE; return TRUE;
} }
style._fgColor = dlg->pFgColour->getColour(); style._fgColor = dlg->_pFgColour->getColour();
style._bgColor = dlg->pBgColour->getColour(); style._bgColor = dlg->_pBgColour->getColour();
if (dlg->pFgColour->isEnabled()) if (dlg->_pFgColour->isEnabled())
style._colorStyle |= COLORSTYLE_FOREGROUND; style._colorStyle |= COLORSTYLE_FOREGROUND;
else else
style._colorStyle &= ~COLORSTYLE_FOREGROUND; style._colorStyle &= ~COLORSTYLE_FOREGROUND;
if (dlg->pBgColour->isEnabled()) if (dlg->_pBgColour->isEnabled())
style._colorStyle |= COLORSTYLE_BACKGROUND; style._colorStyle |= COLORSTYLE_BACKGROUND;
else else
style._colorStyle &= ~COLORSTYLE_BACKGROUND; style._colorStyle &= ~COLORSTYLE_BACKGROUND;

View File

@ -279,6 +279,7 @@ protected :
bool setPropertyByCheck(HWND hwnd, WPARAM id, bool & bool2set); bool setPropertyByCheck(HWND hwnd, WPARAM id, bool & bool2set);
virtual void setKeywords2List(int ctrlID) = 0; virtual void setKeywords2List(int ctrlID) = 0;
}; };
class FolderStyleDialog : public SharedParametersDialog class FolderStyleDialog : public SharedParametersDialog
{ {
public: public:
@ -292,6 +293,7 @@ private :
void retrieve(TCHAR *dest, const TCHAR *toRetrieve, TCHAR *prefix) const; void retrieve(TCHAR *dest, const TCHAR *toRetrieve, TCHAR *prefix) const;
URLCtrl _pageLink; URLCtrl _pageLink;
}; };
class KeyWordsStyleDialog : public SharedParametersDialog class KeyWordsStyleDialog : public SharedParametersDialog
{ {
public: public:
@ -301,6 +303,7 @@ protected :
BOOL CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam); BOOL CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam);
void setKeywords2List(int id); void setKeywords2List(int id);
}; };
class CommentStyleDialog : public SharedParametersDialog class CommentStyleDialog : public SharedParametersDialog
{ {
public : public :
@ -313,6 +316,7 @@ private :
void convertTo(TCHAR *dest, const TCHAR *toConvert, TCHAR *prefix) const; void convertTo(TCHAR *dest, const TCHAR *toConvert, TCHAR *prefix) const;
void retrieve(TCHAR *dest, const TCHAR *toRetrieve, TCHAR *prefix) const; void retrieve(TCHAR *dest, const TCHAR *toRetrieve, TCHAR *prefix) const;
}; };
class SymbolsStyleDialog : public SharedParametersDialog class SymbolsStyleDialog : public SharedParametersDialog
{ {
public : public :
@ -325,6 +329,7 @@ private :
void convertTo(TCHAR *dest, const TCHAR *toConvert, TCHAR *prefix) const; void convertTo(TCHAR *dest, const TCHAR *toConvert, TCHAR *prefix) const;
void retrieve(TCHAR *dest, const TCHAR *toRetrieve, TCHAR *prefix) const; void retrieve(TCHAR *dest, const TCHAR *toRetrieve, TCHAR *prefix) const;
}; };
class UserDefineDialog : public SharedParametersDialog class UserDefineDialog : public SharedParametersDialog
{ {
friend class ScintillaEditView; friend class ScintillaEditView;
@ -411,6 +416,7 @@ protected :
void setKeywords2List(int){}; void setKeywords2List(int){};
void updateDlg(); void updateDlg();
}; };
class StringDlg : public StaticDialog class StringDlg : public StaticDialog
{ {
public : public :
@ -434,34 +440,36 @@ private :
generic_string _static; generic_string _static;
int _txtLen; int _txtLen;
}; };
class StylerDlg class StylerDlg
{ {
public: public:
StylerDlg( HINSTANCE hInst, HWND parent, int stylerIndex = 0, int enabledNesters = -1): StylerDlg( HINSTANCE hInst, HWND parent, int stylerIndex = 0, int enabledNesters = -1):
hInst(hInst), parent(parent), stylerIndex(stylerIndex), enabledNesters(enabledNesters) _hInst(hInst), _parent(parent), _stylerIndex(stylerIndex), _enabledNesters(enabledNesters) {
{ _pFgColour = new ColourPicker;
pFgColour = new ColourPicker; _pBgColour = new ColourPicker;
pBgColour = new ColourPicker; _initialStyle = SharedParametersDialog::_pUserLang->_styleArray.getStyler(stylerIndex);
initialStyle = SharedParametersDialog::_pUserLang->_styleArray.getStyler(stylerIndex);
}; };
~StylerDlg()
{ ~StylerDlg() {
pFgColour->destroy(); _pFgColour->destroy();
pBgColour->destroy(); _pBgColour->destroy();
delete pFgColour; delete _pFgColour;
delete pBgColour; delete _pBgColour;
} };
long doDialog() { long doDialog() {
return long (::DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_STYLER_POPUP_DLG), parent, (DLGPROC)dlgProc, (LPARAM)this)); return long (::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_STYLER_POPUP_DLG), _parent, (DLGPROC)dlgProc, (LPARAM)this));
}; };
static BOOL CALLBACK dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); static BOOL CALLBACK dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
public: public:
HINSTANCE hInst; HINSTANCE _hInst;
HWND parent; HWND _parent;
int stylerIndex; int _stylerIndex;
int enabledNesters; int _enabledNesters;
ColourPicker * pFgColour; ColourPicker * _pFgColour;
ColourPicker * pBgColour; ColourPicker * _pBgColour;
Style initialStyle; Style _initialStyle;
}; };
#endif //USER_DEFINE_H #endif //USER_DEFINE_H

View File

@ -82,7 +82,6 @@ generic_string NativeLangSpeaker::getSpecialMenuEntryName(const char *entryName)
if (!mainMenu) return TEXT(""); if (!mainMenu) return TEXT("");
TiXmlNodeA *entriesRoot = mainMenu->FirstChild("Entries"); TiXmlNodeA *entriesRoot = mainMenu->FirstChild("Entries");
if (!entriesRoot) return TEXT(""); if (!entriesRoot) return TEXT("");
const char *idName = NULL;
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
@ -92,7 +91,7 @@ generic_string NativeLangSpeaker::getSpecialMenuEntryName(const char *entryName)
{ {
TiXmlElementA *element = childNode->ToElement(); TiXmlElementA *element = childNode->ToElement();
idName = element->Attribute("idName"); const char *idName = element->Attribute("idName");
if (idName) if (idName)
{ {
const char *name = element->Attribute("name"); const char *name = element->Attribute("name");
@ -397,11 +396,12 @@ void NativeLangSpeaker::changeLangTabDrapContextMenu(HMENU hCM)
{ {
const int POS_GO2VIEW = 0; const int POS_GO2VIEW = 0;
const int POS_CLONE2VIEW = 1; const int POS_CLONE2VIEW = 1;
const char *goToViewA = NULL;
const char *cloneToViewA = NULL;
if (_nativeLangA) if (_nativeLangA)
{ {
const char *goToViewA = NULL;
const char *cloneToViewA = NULL;
TiXmlNodeA *tabBarMenu = _nativeLangA->FirstChild("Menu"); TiXmlNodeA *tabBarMenu = _nativeLangA->FirstChild("Menu");
if (tabBarMenu) if (tabBarMenu)
tabBarMenu = tabBarMenu->FirstChild("TabBar"); tabBarMenu = tabBarMenu->FirstChild("TabBar");

View File

@ -315,11 +315,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
generic_string quotFileName = TEXT(""); generic_string quotFileName = TEXT("");
// tell the running instance the FULL path to the new files to load // tell the running instance the FULL path to the new files to load
size_t nrFilesToOpen = params.size(); size_t nrFilesToOpen = params.size();
const TCHAR * currentFile;
for(size_t i = 0; i < nrFilesToOpen; ++i) for(size_t i = 0; i < nrFilesToOpen; ++i)
{ {
currentFile = params.at(i); const TCHAR * currentFile = params.at(i);
if (currentFile[0]) if (currentFile[0])
{ {
//check if relative or full path. Relative paths dont have a colon for driveletter //check if relative or full path. Relative paths dont have a colon for driveletter