disable Search when there is no text

call SearchDialog when SearchNext is called without a string to search for

svn path=/trunk/; revision=32057
This commit is contained in:
Christoph von Wittich 2008-01-30 17:20:47 +00:00
parent 8e346ad979
commit d6dc1ebe36
3 changed files with 20 additions and 6 deletions

View file

@ -320,16 +320,16 @@ void DoOpenFile(LPCTSTR szFileName)
*/ */
if (GetWindowText(Globals.hEdit, log, SIZEOF(log)) && !_tcscmp(log, dotlog)) if (GetWindowText(Globals.hEdit, log, SIZEOF(log)) && !_tcscmp(log, dotlog))
{ {
static const TCHAR lf[] = _T("\r\n"); static const TCHAR lf[] = _T("\r\n");
SendMessage(Globals.hEdit, EM_SETSEL, GetWindowTextLength(Globals.hEdit), -1); SendMessage(Globals.hEdit, EM_SETSEL, GetWindowTextLength(Globals.hEdit), -1);
SendMessage(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)lf); SendMessage(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)lf);
DIALOG_EditTimeDate(); DIALOG_EditTimeDate();
SendMessage(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)lf); SendMessage(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)lf);
} }
SetFileName(szFileName); SetFileName(szFileName);
UpdateWindowCaption(); UpdateWindowCaption();
NOTEPAD_EnableSearchMenu();
done: done:
if (hFile != INVALID_HANDLE_VALUE) if (hFile != INVALID_HANDLE_VALUE)
CloseHandle(hFile); CloseHandle(hFile);
@ -344,6 +344,7 @@ VOID DIALOG_FileNew(VOID)
SetWindowText(Globals.hEdit, empty_str); SetWindowText(Globals.hEdit, empty_str);
SendMessage(Globals.hEdit, EM_EMPTYUNDOBUFFER, 0, 0); SendMessage(Globals.hEdit, EM_EMPTYUNDOBUFFER, 0, 0);
SetFocus(Globals.hEdit); SetFocus(Globals.hEdit);
NOTEPAD_EnableSearchMenu();
} }
} }
@ -783,6 +784,8 @@ VOID DIALOG_SearchNext(VOID)
{ {
if (Globals.find.lpstrFindWhat != NULL) if (Globals.find.lpstrFindWhat != NULL)
NOTEPAD_FindNext(&Globals.find, FALSE, TRUE); NOTEPAD_FindNext(&Globals.find, FALSE, TRUE);
else
DIALOG_Search();
} }
VOID DIALOG_Replace(VOID) VOID DIALOG_Replace(VOID)

View file

@ -27,6 +27,14 @@
NOTEPAD_GLOBALS Globals; NOTEPAD_GLOBALS Globals;
static ATOM aFINDMSGSTRING; static ATOM aFINDMSGSTRING;
VOID NOTEPAD_EnableSearchMenu()
{
EnableMenuItem(GetMenu(Globals.hMainWnd), CMD_SEARCH,
MF_BYCOMMAND | ((GetWindowTextLength(Globals.hEdit) == 0) ? MF_DISABLED | MF_GRAYED : MF_ENABLED));
EnableMenuItem(GetMenu(Globals.hMainWnd), CMD_SEARCH_NEXT,
MF_BYCOMMAND | ((GetWindowTextLength(Globals.hEdit) == 0) ? MF_DISABLED | MF_GRAYED : MF_ENABLED));
}
/*********************************************************************** /***********************************************************************
* *
* SetFileName * SetFileName
@ -346,6 +354,8 @@ static LRESULT WINAPI NOTEPAD_WndProc(HWND hWnd, UINT msg, WPARAM wParam,
case WM_COMMAND: case WM_COMMAND:
if (HIWORD(wParam) == EN_CHANGE || HIWORD(wParam) == EN_HSCROLL || HIWORD(wParam) == EN_VSCROLL) if (HIWORD(wParam) == EN_CHANGE || HIWORD(wParam) == EN_HSCROLL || HIWORD(wParam) == EN_VSCROLL)
DIALOG_StatusBarUpdateCaretPos(); DIALOG_StatusBarUpdateCaretPos();
if ((HIWORD(wParam) == EN_CHANGE))
NOTEPAD_EnableSearchMenu();
NOTEPAD_MenuCommand(LOWORD(wParam)); NOTEPAD_MenuCommand(LOWORD(wParam));
break; break;

View file

@ -85,3 +85,4 @@ void SaveSettings(void);
/* from main.c */ /* from main.c */
BOOL NOTEPAD_FindNext(FINDREPLACE *, BOOL , BOOL ); BOOL NOTEPAD_FindNext(FINDREPLACE *, BOOL , BOOL );
VOID NOTEPAD_EnableSearchMenu(VOID);