1999-02-28 21:05:11 +01:00
|
|
|
/*
|
2000-08-19 01:05:44 +02:00
|
|
|
* COMMDLG - 16 bits Find & Replace Text Dialogs
|
1999-02-28 21:05:11 +01:00
|
|
|
*
|
|
|
|
* Copyright 1994 Martin Ayotte
|
|
|
|
* Copyright 1996 Albrecht Kleine
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wine/winbase16.h"
|
2000-08-19 01:05:44 +02:00
|
|
|
#include "wine/winuser16.h"
|
1999-02-28 21:05:11 +01:00
|
|
|
#include "commdlg.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
1999-04-25 20:31:35 +02:00
|
|
|
#include "cderr.h"
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
1999-04-25 20:31:35 +02:00
|
|
|
#include "cdlg.h"
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
struct FRPRIVATE
|
2000-08-19 01:05:44 +02:00
|
|
|
{
|
|
|
|
HANDLE16 hDlgTmpl16; /* handle for resource 16 */
|
|
|
|
HANDLE16 hResource16; /* handle for allocated resource 16 */
|
|
|
|
HANDLE16 hGlobal16; /* 16 bits mem block (resources) */
|
|
|
|
LPCVOID template; /* template for 32 bits resource */
|
|
|
|
BOOL find; /* TRUE if find dialog, FALSE if replace dialog */
|
|
|
|
FINDREPLACE16 *fr16;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define LFRPRIVATE struct FRPRIVATE *
|
|
|
|
|
2002-10-31 02:04:39 +01:00
|
|
|
BOOL16 CALLBACK FindTextDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
|
2000-05-27 00:26:06 +02:00
|
|
|
LPARAM lParam);
|
2002-10-31 02:04:39 +01:00
|
|
|
BOOL16 CALLBACK ReplaceTextDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
|
2000-05-27 00:26:06 +02:00
|
|
|
LPARAM lParam);
|
|
|
|
|
1999-07-24 12:27:58 +02:00
|
|
|
/***********************************************************************
|
2000-08-19 01:05:44 +02:00
|
|
|
* FINDDLG_Get16BitsTemplate [internal]
|
1999-07-24 12:27:58 +02:00
|
|
|
*
|
2000-08-19 01:05:44 +02:00
|
|
|
* Get a template (FALSE if failure) when 16 bits dialogs are used
|
|
|
|
* by a 16 bits application
|
|
|
|
* FIXME : no test was done for the user-provided template cases
|
1999-07-24 12:27:58 +02:00
|
|
|
*/
|
2000-08-19 01:05:44 +02:00
|
|
|
BOOL FINDDLG_Get16BitsTemplate(LFRPRIVATE lfr)
|
1999-07-24 12:27:58 +02:00
|
|
|
{
|
2000-08-19 01:05:44 +02:00
|
|
|
LPFINDREPLACE16 fr16 = lfr->fr16;
|
|
|
|
|
|
|
|
if (fr16->Flags & FR_ENABLETEMPLATEHANDLE)
|
|
|
|
{
|
|
|
|
lfr->template = GlobalLock16(fr16->hInstance);
|
|
|
|
if (!lfr->template)
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_MEMLOCKFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (fr16->Flags & FR_ENABLETEMPLATE)
|
|
|
|
{
|
|
|
|
HANDLE16 hResInfo;
|
|
|
|
if (!(hResInfo = FindResource16(fr16->hInstance,
|
2000-12-13 21:20:09 +01:00
|
|
|
MapSL(fr16->lpTemplateName),
|
2000-11-27 22:54:01 +01:00
|
|
|
RT_DIALOGA)))
|
2000-08-19 01:05:44 +02:00
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!(lfr->hDlgTmpl16 = LoadResource16( fr16->hInstance, hResInfo )))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
lfr->hResource16 = lfr->hDlgTmpl16;
|
|
|
|
lfr->template = LockResource16(lfr->hResource16);
|
|
|
|
if (!lfr->template)
|
|
|
|
{
|
|
|
|
FreeResource16(lfr->hResource16);
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_MEMLOCKFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ /* get resource from (32 bits) own Wine resource; convert it to 16 */
|
2002-09-17 00:47:05 +02:00
|
|
|
HRSRC hResInfo;
|
|
|
|
HGLOBAL hDlgTmpl32;
|
2000-08-19 01:05:44 +02:00
|
|
|
LPCVOID template32;
|
|
|
|
DWORD size;
|
|
|
|
HGLOBAL16 hGlobal16;
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
if (!(hResInfo = FindResourceA(COMMDLG_hInstance32,
|
2000-08-19 01:05:44 +02:00
|
|
|
lfr->find ?
|
|
|
|
MAKEINTRESOURCEA(FINDDLGORD):MAKEINTRESOURCEA(REPLACEDLGORD),
|
|
|
|
RT_DIALOGA)))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!(hDlgTmpl32 = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
|
|
|
|
!(template32 = LockResource( hDlgTmpl32 )))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
size = SizeofResource(GetModuleHandleA("COMDLG32"), hResInfo);
|
|
|
|
hGlobal16 = GlobalAlloc16(0, size);
|
|
|
|
if (!hGlobal16)
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_MEMALLOCFAILURE);
|
|
|
|
ERR("alloc failure for %ld bytes\n", size);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
lfr->template = GlobalLock16(hGlobal16);
|
|
|
|
if (!lfr->template)
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_MEMLOCKFAILURE);
|
|
|
|
ERR("global lock failure for %x handle\n", hGlobal16);
|
|
|
|
GlobalFree16(hGlobal16);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
ConvertDialog32To16((LPVOID)template32, size, (LPVOID)lfr->template);
|
|
|
|
lfr->hDlgTmpl16 = hGlobal16;
|
|
|
|
lfr->hGlobal16 = hGlobal16;
|
|
|
|
}
|
|
|
|
return TRUE;
|
1999-07-24 12:27:58 +02:00
|
|
|
}
|
|
|
|
|
2000-08-19 01:05:44 +02:00
|
|
|
|
1999-07-24 12:27:58 +02:00
|
|
|
/***********************************************************************
|
2000-08-19 01:05:44 +02:00
|
|
|
* FINDDLG_FreeResources [internal]
|
1999-07-24 12:27:58 +02:00
|
|
|
*
|
2002-06-01 01:06:46 +02:00
|
|
|
* Free resources allocated
|
1999-07-24 12:27:58 +02:00
|
|
|
*/
|
2000-08-19 01:05:44 +02:00
|
|
|
void FINDDLG_FreeResources(LFRPRIVATE lfr)
|
1999-07-24 12:27:58 +02:00
|
|
|
{
|
2000-08-19 01:05:44 +02:00
|
|
|
/* free resources */
|
|
|
|
if (lfr->fr16->Flags & FR_ENABLETEMPLATEHANDLE)
|
|
|
|
GlobalUnlock16(lfr->fr16->hInstance);
|
|
|
|
if (lfr->hResource16)
|
|
|
|
{
|
|
|
|
GlobalUnlock16(lfr->hResource16);
|
|
|
|
FreeResource16(lfr->hResource16);
|
|
|
|
}
|
|
|
|
if (lfr->hGlobal16)
|
|
|
|
{
|
|
|
|
GlobalUnlock16(lfr->hGlobal16);
|
|
|
|
GlobalFree16(lfr->hGlobal16);
|
|
|
|
}
|
1999-07-24 12:27:58 +02:00
|
|
|
}
|
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* FindText (COMMDLG.11)
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
|
|
|
HWND16 WINAPI FindText16( SEGPTR find )
|
|
|
|
{
|
|
|
|
HANDLE16 hInst;
|
2000-08-19 01:05:44 +02:00
|
|
|
HWND16 ret = 0;
|
|
|
|
FARPROC16 ptr;
|
|
|
|
LFRPRIVATE lfr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct FRPRIVATE));
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-08-19 01:05:44 +02:00
|
|
|
if (!lfr) return 0;
|
2000-12-13 21:20:09 +01:00
|
|
|
lfr->fr16 = MapSL(find);
|
2000-08-19 01:05:44 +02:00
|
|
|
lfr->find = TRUE;
|
|
|
|
if (FINDDLG_Get16BitsTemplate(lfr))
|
1999-04-25 20:31:35 +02:00
|
|
|
{
|
2002-09-06 22:40:42 +02:00
|
|
|
hInst = GetWindowLongA( HWND_32(lfr->fr16->hwndOwner), GWL_HINSTANCE);
|
2000-11-27 22:54:01 +01:00
|
|
|
ptr = GetProcAddress16(GetModuleHandle16("COMMDLG"), (LPCSTR) 13);
|
2000-08-19 01:05:44 +02:00
|
|
|
ret = CreateDialogIndirectParam16( hInst, lfr->template,
|
|
|
|
lfr->fr16->hwndOwner, (DLGPROC16) ptr, find);
|
|
|
|
FINDDLG_FreeResources(lfr);
|
1999-04-25 20:31:35 +02:00
|
|
|
}
|
2000-08-19 01:05:44 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, lfr);
|
|
|
|
return ret;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* ReplaceText (COMMDLG.12)
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
|
|
|
HWND16 WINAPI ReplaceText16( SEGPTR find )
|
|
|
|
{
|
|
|
|
HANDLE16 hInst;
|
2000-08-19 01:05:44 +02:00
|
|
|
HWND16 ret = 0;
|
|
|
|
FARPROC16 ptr;
|
|
|
|
LFRPRIVATE lfr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct FRPRIVATE));
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-08-19 01:05:44 +02:00
|
|
|
if (!lfr) return 0;
|
1999-02-28 21:05:11 +01:00
|
|
|
/*
|
|
|
|
* FIXME : We should do error checking on the lpFind structure here
|
|
|
|
* and make CommDlgExtendedError() return the error condition.
|
|
|
|
*/
|
2000-12-13 21:20:09 +01:00
|
|
|
lfr->fr16 = MapSL(find);
|
2000-08-19 01:05:44 +02:00
|
|
|
lfr->find = FALSE;
|
|
|
|
if (FINDDLG_Get16BitsTemplate(lfr))
|
1999-04-25 20:31:35 +02:00
|
|
|
{
|
2002-09-06 22:40:42 +02:00
|
|
|
hInst = GetWindowLongA( HWND_32(lfr->fr16->hwndOwner), GWL_HINSTANCE);
|
2000-11-27 22:54:01 +01:00
|
|
|
ptr = GetProcAddress16(GetModuleHandle16("COMMDLG"), (LPCSTR) 14);
|
2000-08-19 01:05:44 +02:00
|
|
|
ret = CreateDialogIndirectParam16( hInst, lfr->template,
|
|
|
|
lfr->fr16->hwndOwner, (DLGPROC16) ptr, find);
|
|
|
|
|
|
|
|
FINDDLG_FreeResources(lfr);
|
1999-04-25 20:31:35 +02:00
|
|
|
}
|
2000-08-19 01:05:44 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, lfr);
|
|
|
|
return ret;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FINDDLG_WMInitDialog [internal]
|
|
|
|
*/
|
|
|
|
static LRESULT FINDDLG_WMInitDialog(HWND hWnd, LPARAM lParam, LPDWORD lpFlags,
|
|
|
|
LPSTR lpstrFindWhat, BOOL fUnicode)
|
|
|
|
{
|
|
|
|
SetWindowLongA(hWnd, DWL_USER, lParam);
|
|
|
|
*lpFlags &= ~(FR_FINDNEXT | FR_REPLACE | FR_REPLACEALL | FR_DIALOGTERM);
|
|
|
|
/*
|
|
|
|
* FIXME : If the initial FindWhat string is empty, we should disable the
|
|
|
|
* FindNext (IDOK) button. Only after typing some text, the button should be
|
|
|
|
* enabled.
|
|
|
|
*/
|
|
|
|
if (fUnicode) SetDlgItemTextW(hWnd, edt1, (LPWSTR)lpstrFindWhat);
|
|
|
|
else SetDlgItemTextA(hWnd, edt1, lpstrFindWhat);
|
|
|
|
CheckRadioButton(hWnd, rad1, rad2, (*lpFlags & FR_DOWN) ? rad2 : rad1);
|
|
|
|
if (*lpFlags & (FR_HIDEUPDOWN | FR_NOUPDOWN)) {
|
|
|
|
EnableWindow(GetDlgItem(hWnd, rad1), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hWnd, rad2), FALSE);
|
|
|
|
}
|
|
|
|
if (*lpFlags & FR_HIDEUPDOWN) {
|
|
|
|
ShowWindow(GetDlgItem(hWnd, rad1), SW_HIDE);
|
|
|
|
ShowWindow(GetDlgItem(hWnd, rad2), SW_HIDE);
|
|
|
|
ShowWindow(GetDlgItem(hWnd, grp1), SW_HIDE);
|
|
|
|
}
|
|
|
|
CheckDlgButton(hWnd, chx1, (*lpFlags & FR_WHOLEWORD) ? 1 : 0);
|
|
|
|
if (*lpFlags & (FR_HIDEWHOLEWORD | FR_NOWHOLEWORD))
|
|
|
|
EnableWindow(GetDlgItem(hWnd, chx1), FALSE);
|
|
|
|
if (*lpFlags & FR_HIDEWHOLEWORD)
|
|
|
|
ShowWindow(GetDlgItem(hWnd, chx1), SW_HIDE);
|
|
|
|
CheckDlgButton(hWnd, chx2, (*lpFlags & FR_MATCHCASE) ? 1 : 0);
|
|
|
|
if (*lpFlags & (FR_HIDEMATCHCASE | FR_NOMATCHCASE))
|
|
|
|
EnableWindow(GetDlgItem(hWnd, chx2), FALSE);
|
|
|
|
if (*lpFlags & FR_HIDEMATCHCASE)
|
|
|
|
ShowWindow(GetDlgItem(hWnd, chx2), SW_HIDE);
|
|
|
|
if (!(*lpFlags & FR_SHOWHELP)) {
|
|
|
|
EnableWindow(GetDlgItem(hWnd, pshHelp), FALSE);
|
|
|
|
ShowWindow(GetDlgItem(hWnd, pshHelp), SW_HIDE);
|
|
|
|
}
|
|
|
|
ShowWindow(hWnd, SW_SHOWNORMAL);
|
|
|
|
return TRUE;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FINDDLG_WMCommand [internal]
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT FINDDLG_WMCommand(HWND hWnd, WPARAM wParam,
|
1999-02-28 21:05:11 +01:00
|
|
|
HWND hwndOwner, LPDWORD lpFlags,
|
2002-06-01 01:06:46 +02:00
|
|
|
LPSTR lpstrFindWhat, WORD wFindWhatLen,
|
1999-02-28 21:05:11 +01:00
|
|
|
BOOL fUnicode)
|
|
|
|
{
|
2001-01-22 03:13:58 +01:00
|
|
|
int uFindReplaceMessage = RegisterWindowMessageA( FINDMSGSTRINGA );
|
|
|
|
int uHelpMessage = RegisterWindowMessageA( HELPMSGSTRINGA );
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
switch (wParam) {
|
|
|
|
case IDOK:
|
2002-06-01 01:06:46 +02:00
|
|
|
if (fUnicode)
|
1999-02-28 21:05:11 +01:00
|
|
|
GetDlgItemTextW(hWnd, edt1, (LPWSTR)lpstrFindWhat, wFindWhatLen/2);
|
|
|
|
else GetDlgItemTextA(hWnd, edt1, lpstrFindWhat, wFindWhatLen);
|
|
|
|
if (IsDlgButtonChecked(hWnd, rad2))
|
|
|
|
*lpFlags |= FR_DOWN;
|
|
|
|
else *lpFlags &= ~FR_DOWN;
|
|
|
|
if (IsDlgButtonChecked(hWnd, chx1))
|
2002-06-01 01:06:46 +02:00
|
|
|
*lpFlags |= FR_WHOLEWORD;
|
1999-02-28 21:05:11 +01:00
|
|
|
else *lpFlags &= ~FR_WHOLEWORD;
|
|
|
|
if (IsDlgButtonChecked(hWnd, chx2))
|
2002-06-01 01:06:46 +02:00
|
|
|
*lpFlags |= FR_MATCHCASE;
|
1999-02-28 21:05:11 +01:00
|
|
|
else *lpFlags &= ~FR_MATCHCASE;
|
|
|
|
*lpFlags &= ~(FR_REPLACE | FR_REPLACEALL | FR_DIALOGTERM);
|
|
|
|
*lpFlags |= FR_FINDNEXT;
|
|
|
|
SendMessageA(hwndOwner, uFindReplaceMessage, 0,
|
|
|
|
GetWindowLongA(hWnd, DWL_USER) );
|
|
|
|
return TRUE;
|
|
|
|
case IDCANCEL:
|
|
|
|
*lpFlags &= ~(FR_FINDNEXT | FR_REPLACE | FR_REPLACEALL);
|
|
|
|
*lpFlags |= FR_DIALOGTERM;
|
|
|
|
SendMessageA(hwndOwner, uFindReplaceMessage, 0,
|
|
|
|
GetWindowLongA(hWnd, DWL_USER) );
|
|
|
|
DestroyWindow(hWnd);
|
|
|
|
return TRUE;
|
|
|
|
case pshHelp:
|
|
|
|
/* FIXME : should lpfr structure be passed as an argument ??? */
|
|
|
|
SendMessageA(hwndOwner, uHelpMessage, 0, 0);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* FindTextDlgProc (COMMDLG.13)
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2002-10-31 02:04:39 +01:00
|
|
|
BOOL16 CALLBACK FindTextDlgProc16(HWND16 hWnd16, UINT16 wMsg, WPARAM16 wParam,
|
1999-02-28 21:05:11 +01:00
|
|
|
LPARAM lParam)
|
|
|
|
{
|
2002-09-06 22:40:42 +02:00
|
|
|
HWND hWnd = HWND_32(hWnd16);
|
1999-02-28 21:05:11 +01:00
|
|
|
LPFINDREPLACE16 lpfr;
|
|
|
|
switch (wMsg) {
|
|
|
|
case WM_INITDIALOG:
|
2000-12-13 21:20:09 +01:00
|
|
|
lpfr=MapSL(lParam);
|
1999-02-28 21:05:11 +01:00
|
|
|
return FINDDLG_WMInitDialog(hWnd, lParam, &(lpfr->Flags),
|
2000-12-13 21:20:09 +01:00
|
|
|
MapSL(lpfr->lpstrFindWhat), FALSE);
|
1999-02-28 21:05:11 +01:00
|
|
|
case WM_COMMAND:
|
2000-12-13 21:20:09 +01:00
|
|
|
lpfr=MapSL(GetWindowLongA(hWnd, DWL_USER));
|
2002-09-06 22:40:42 +02:00
|
|
|
return FINDDLG_WMCommand(hWnd, wParam, HWND_32(lpfr->hwndOwner),
|
2000-12-13 21:20:09 +01:00
|
|
|
&lpfr->Flags, MapSL(lpfr->lpstrFindWhat),
|
1999-02-28 21:05:11 +01:00
|
|
|
lpfr->wFindWhatLen, FALSE);
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* REPLACEDLG_WMInitDialog [internal]
|
|
|
|
*/
|
|
|
|
static LRESULT REPLACEDLG_WMInitDialog(HWND hWnd, LPARAM lParam,
|
2002-06-01 01:06:46 +02:00
|
|
|
LPDWORD lpFlags, LPSTR lpstrFindWhat,
|
1999-02-28 21:05:11 +01:00
|
|
|
LPSTR lpstrReplaceWith, BOOL fUnicode)
|
|
|
|
{
|
|
|
|
SetWindowLongA(hWnd, DWL_USER, lParam);
|
|
|
|
*lpFlags &= ~(FR_FINDNEXT | FR_REPLACE | FR_REPLACEALL | FR_DIALOGTERM);
|
|
|
|
/*
|
|
|
|
* FIXME : If the initial FindWhat string is empty, we should disable the FinNext /
|
|
|
|
* Replace / ReplaceAll buttons. Only after typing some text, the buttons should be
|
|
|
|
* enabled.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
if (fUnicode)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
SetDlgItemTextW(hWnd, edt1, (LPWSTR)lpstrFindWhat);
|
|
|
|
SetDlgItemTextW(hWnd, edt2, (LPWSTR)lpstrReplaceWith);
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
SetDlgItemTextA(hWnd, edt1, lpstrFindWhat);
|
|
|
|
SetDlgItemTextA(hWnd, edt2, lpstrReplaceWith);
|
|
|
|
}
|
|
|
|
CheckDlgButton(hWnd, chx1, (*lpFlags & FR_WHOLEWORD) ? 1 : 0);
|
|
|
|
if (*lpFlags & (FR_HIDEWHOLEWORD | FR_NOWHOLEWORD))
|
|
|
|
EnableWindow(GetDlgItem(hWnd, chx1), FALSE);
|
|
|
|
if (*lpFlags & FR_HIDEWHOLEWORD)
|
|
|
|
ShowWindow(GetDlgItem(hWnd, chx1), SW_HIDE);
|
|
|
|
CheckDlgButton(hWnd, chx2, (*lpFlags & FR_MATCHCASE) ? 1 : 0);
|
|
|
|
if (*lpFlags & (FR_HIDEMATCHCASE | FR_NOMATCHCASE))
|
|
|
|
EnableWindow(GetDlgItem(hWnd, chx2), FALSE);
|
|
|
|
if (*lpFlags & FR_HIDEMATCHCASE)
|
|
|
|
ShowWindow(GetDlgItem(hWnd, chx2), SW_HIDE);
|
|
|
|
if (!(*lpFlags & FR_SHOWHELP)) {
|
|
|
|
EnableWindow(GetDlgItem(hWnd, pshHelp), FALSE);
|
|
|
|
ShowWindow(GetDlgItem(hWnd, pshHelp), SW_HIDE);
|
|
|
|
}
|
|
|
|
ShowWindow(hWnd, SW_SHOWNORMAL);
|
|
|
|
return TRUE;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* REPLACEDLG_WMCommand [internal]
|
|
|
|
*/
|
|
|
|
static LRESULT REPLACEDLG_WMCommand(HWND hWnd, WPARAM16 wParam,
|
|
|
|
HWND hwndOwner, LPDWORD lpFlags,
|
|
|
|
LPSTR lpstrFindWhat, WORD wFindWhatLen,
|
|
|
|
LPSTR lpstrReplaceWith, WORD wReplaceWithLen,
|
|
|
|
BOOL fUnicode)
|
|
|
|
{
|
2001-01-22 03:13:58 +01:00
|
|
|
int uFindReplaceMessage = RegisterWindowMessageA( FINDMSGSTRINGA );
|
|
|
|
int uHelpMessage = RegisterWindowMessageA( HELPMSGSTRINGA );
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
switch (wParam) {
|
|
|
|
case IDOK:
|
|
|
|
if (fUnicode)
|
|
|
|
{
|
|
|
|
GetDlgItemTextW(hWnd, edt1, (LPWSTR)lpstrFindWhat, wFindWhatLen/2);
|
|
|
|
GetDlgItemTextW(hWnd, edt2, (LPWSTR)lpstrReplaceWith, wReplaceWithLen/2);
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
GetDlgItemTextA(hWnd, edt1, lpstrFindWhat, wFindWhatLen);
|
|
|
|
GetDlgItemTextA(hWnd, edt2, lpstrReplaceWith, wReplaceWithLen);
|
|
|
|
}
|
|
|
|
if (IsDlgButtonChecked(hWnd, chx1))
|
2002-06-01 01:06:46 +02:00
|
|
|
*lpFlags |= FR_WHOLEWORD;
|
1999-02-28 21:05:11 +01:00
|
|
|
else *lpFlags &= ~FR_WHOLEWORD;
|
|
|
|
if (IsDlgButtonChecked(hWnd, chx2))
|
2002-06-01 01:06:46 +02:00
|
|
|
*lpFlags |= FR_MATCHCASE;
|
1999-02-28 21:05:11 +01:00
|
|
|
else *lpFlags &= ~FR_MATCHCASE;
|
|
|
|
*lpFlags &= ~(FR_REPLACE | FR_REPLACEALL | FR_DIALOGTERM);
|
|
|
|
*lpFlags |= FR_FINDNEXT;
|
|
|
|
SendMessageA(hwndOwner, uFindReplaceMessage, 0,
|
|
|
|
GetWindowLongA(hWnd, DWL_USER) );
|
|
|
|
return TRUE;
|
|
|
|
case IDCANCEL:
|
|
|
|
*lpFlags &= ~(FR_FINDNEXT | FR_REPLACE | FR_REPLACEALL);
|
|
|
|
*lpFlags |= FR_DIALOGTERM;
|
|
|
|
SendMessageA(hwndOwner, uFindReplaceMessage, 0,
|
|
|
|
GetWindowLongA(hWnd, DWL_USER) );
|
|
|
|
DestroyWindow(hWnd);
|
|
|
|
return TRUE;
|
|
|
|
case psh1:
|
|
|
|
if (fUnicode)
|
|
|
|
{
|
|
|
|
GetDlgItemTextW(hWnd, edt1, (LPWSTR)lpstrFindWhat, wFindWhatLen/2);
|
|
|
|
GetDlgItemTextW(hWnd, edt2, (LPWSTR)lpstrReplaceWith, wReplaceWithLen/2);
|
|
|
|
} else
|
2002-06-01 01:06:46 +02:00
|
|
|
{
|
1999-02-28 21:05:11 +01:00
|
|
|
GetDlgItemTextA(hWnd, edt1, lpstrFindWhat, wFindWhatLen);
|
|
|
|
GetDlgItemTextA(hWnd, edt2, lpstrReplaceWith, wReplaceWithLen);
|
|
|
|
}
|
|
|
|
if (IsDlgButtonChecked(hWnd, chx1))
|
2002-06-01 01:06:46 +02:00
|
|
|
*lpFlags |= FR_WHOLEWORD;
|
1999-02-28 21:05:11 +01:00
|
|
|
else *lpFlags &= ~FR_WHOLEWORD;
|
|
|
|
if (IsDlgButtonChecked(hWnd, chx2))
|
2002-06-01 01:06:46 +02:00
|
|
|
*lpFlags |= FR_MATCHCASE;
|
1999-02-28 21:05:11 +01:00
|
|
|
else *lpFlags &= ~FR_MATCHCASE;
|
|
|
|
*lpFlags &= ~(FR_FINDNEXT | FR_REPLACEALL | FR_DIALOGTERM);
|
|
|
|
*lpFlags |= FR_REPLACE;
|
|
|
|
SendMessageA(hwndOwner, uFindReplaceMessage, 0,
|
|
|
|
GetWindowLongA(hWnd, DWL_USER) );
|
|
|
|
return TRUE;
|
|
|
|
case psh2:
|
|
|
|
if (fUnicode)
|
|
|
|
{
|
|
|
|
GetDlgItemTextW(hWnd, edt1, (LPWSTR)lpstrFindWhat, wFindWhatLen/2);
|
|
|
|
GetDlgItemTextW(hWnd, edt2, (LPWSTR)lpstrReplaceWith, wReplaceWithLen/2);
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
GetDlgItemTextA(hWnd, edt1, lpstrFindWhat, wFindWhatLen);
|
|
|
|
GetDlgItemTextA(hWnd, edt2, lpstrReplaceWith, wReplaceWithLen);
|
|
|
|
}
|
|
|
|
if (IsDlgButtonChecked(hWnd, chx1))
|
2002-06-01 01:06:46 +02:00
|
|
|
*lpFlags |= FR_WHOLEWORD;
|
1999-02-28 21:05:11 +01:00
|
|
|
else *lpFlags &= ~FR_WHOLEWORD;
|
|
|
|
if (IsDlgButtonChecked(hWnd, chx2))
|
2002-06-01 01:06:46 +02:00
|
|
|
*lpFlags |= FR_MATCHCASE;
|
1999-02-28 21:05:11 +01:00
|
|
|
else *lpFlags &= ~FR_MATCHCASE;
|
|
|
|
*lpFlags &= ~(FR_FINDNEXT | FR_REPLACE | FR_DIALOGTERM);
|
|
|
|
*lpFlags |= FR_REPLACEALL;
|
|
|
|
SendMessageA(hwndOwner, uFindReplaceMessage, 0,
|
|
|
|
GetWindowLongA(hWnd, DWL_USER) );
|
|
|
|
return TRUE;
|
|
|
|
case pshHelp:
|
|
|
|
/* FIXME : should lpfr structure be passed as an argument ??? */
|
|
|
|
SendMessageA(hwndOwner, uHelpMessage, 0, 0);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* ReplaceTextDlgProc (COMMDLG.14)
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2002-10-31 02:04:39 +01:00
|
|
|
BOOL16 CALLBACK ReplaceTextDlgProc16(HWND16 hWnd16, UINT16 wMsg, WPARAM16 wParam,
|
1999-02-28 21:05:11 +01:00
|
|
|
LPARAM lParam)
|
|
|
|
{
|
2002-09-06 22:40:42 +02:00
|
|
|
HWND hWnd = HWND_32(hWnd16);
|
1999-02-28 21:05:11 +01:00
|
|
|
LPFINDREPLACE16 lpfr;
|
|
|
|
switch (wMsg) {
|
|
|
|
case WM_INITDIALOG:
|
2000-12-13 21:20:09 +01:00
|
|
|
lpfr=MapSL(lParam);
|
1999-02-28 21:05:11 +01:00
|
|
|
return REPLACEDLG_WMInitDialog(hWnd, lParam, &lpfr->Flags,
|
2000-12-13 21:20:09 +01:00
|
|
|
MapSL(lpfr->lpstrFindWhat),
|
|
|
|
MapSL(lpfr->lpstrReplaceWith), FALSE);
|
1999-02-28 21:05:11 +01:00
|
|
|
case WM_COMMAND:
|
2000-12-13 21:20:09 +01:00
|
|
|
lpfr=MapSL(GetWindowLongA(hWnd, DWL_USER));
|
2002-09-06 22:40:42 +02:00
|
|
|
return REPLACEDLG_WMCommand(hWnd, wParam, HWND_32(lpfr->hwndOwner),
|
2000-12-13 21:20:09 +01:00
|
|
|
&lpfr->Flags, MapSL(lpfr->lpstrFindWhat),
|
|
|
|
lpfr->wFindWhatLen, MapSL(lpfr->lpstrReplaceWith),
|
1999-02-28 21:05:11 +01:00
|
|
|
lpfr->wReplaceWithLen, FALSE);
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|