Create a new subdirectory for the common dialog box DLL and move all

code from /misc/commdlg.c to this directory.  Also made a start in
documenting the API calls.
This commit is contained in:
Klaas van Gend 1999-02-28 20:05:11 +00:00 committed by Alexandre Julliard
parent b0d52b0071
commit c912749be5
14 changed files with 4580 additions and 4306 deletions

View File

@ -30,6 +30,7 @@ LIBSUBDIRS = \
console \
dlls/advapi32 \
dlls/comctl32 \
dlls/commdlg \
dlls/imagehlp \
dlls/msacm \
dlls/msacm32 \
@ -101,6 +102,7 @@ LIBOBJS = \
console/console.o \
dlls/advapi32/advapi32.o \
dlls/comctl32/comctl32.o \
dlls/commdlg/commdlg.o \
dlls/imagehlp/imagehlp.o \
dlls/msacm/msacm.o \
dlls/msacm32/msacm32.o \

2
configure vendored
View File

@ -4598,6 +4598,7 @@ debugger/Makefile
dlls/Makefile
dlls/advapi32/Makefile
dlls/comctl32/Makefile
dlls/commdlg/Makefile
dlls/imagehlp/Makefile
dlls/msacm/Makefile
dlls/msacm32/Makefile
@ -4758,6 +4759,7 @@ debugger/Makefile
dlls/Makefile
dlls/advapi32/Makefile
dlls/comctl32/Makefile
dlls/commdlg/Makefile
dlls/imagehlp/Makefile
dlls/msacm/Makefile
dlls/msacm32/Makefile

View File

@ -623,6 +623,7 @@ debugger/Makefile
dlls/Makefile
dlls/advapi32/Makefile
dlls/comctl32/Makefile
dlls/commdlg/Makefile
dlls/imagehlp/Makefile
dlls/msacm/Makefile
dlls/msacm32/Makefile

View File

@ -1,6 +1,7 @@
SUBDIRS = \
advapi32 \
comctl32 \
commdlg \
imagehlp \
msacm \
msacm32 \

1
dlls/commdlg/.cvsignore Normal file
View File

@ -0,0 +1 @@
Makefile

20
dlls/commdlg/Makefile.in Normal file
View File

@ -0,0 +1,20 @@
DEFS = @DLLFLAGS@ -D__WINE__
TOPSRCDIR = @top_srcdir@
TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = commdlg
C_SRCS = \
colordlg.c \
filedlg.c \
finddlg.c \
fontdlg.c \
generic.c \
printdlg.c
all: $(MODULE).o
@MAKE_RULES@
### Dependencies:

1233
dlls/commdlg/colordlg.c Normal file

File diff suppressed because it is too large Load Diff

1359
dlls/commdlg/filedlg.c Normal file

File diff suppressed because it is too large Load Diff

518
dlls/commdlg/finddlg.c Normal file
View File

@ -0,0 +1,518 @@
/*
* COMMDLG - Find & Replace Text Dialogs
*
* Copyright 1994 Martin Ayotte
* Copyright 1996 Albrecht Kleine
* Copyright 1999 Klaas van Gend
*/
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "winbase.h"
#include "wine/winbase16.h"
#include "wine/winuser16.h"
#include "win.h"
#include "heap.h"
#include "message.h"
#include "commdlg.h"
#include "resource.h"
#include "dialog.h"
#include "dlgs.h"
#include "module.h"
#include "drive.h"
#include "debug.h"
#include "font.h"
#include "winproc.h"
extern DWORD CommDlgLastError;
/*
extern HBITMAP16 hFolder;
extern HBITMAP16 hFolder2;
extern HBITMAP16 hFloppy;
extern HBITMAP16 hHDisk;
extern HBITMAP16 hCDRom;
extern HBITMAP16 hBitmapTT;
extern const char defaultfilter[];
*/
/***********************************************************************
* FindText16 (COMMDLG.11)
*/
HWND16 WINAPI FindText16( SEGPTR find )
{
HANDLE16 hInst;
LPCVOID ptr;
LPFINDREPLACE16 lpFind = (LPFINDREPLACE16)PTR_SEG_TO_LIN(find);
/*
* FIXME : Should respond to FR_ENABLETEMPLATE and FR_ENABLEHOOK here
* For now, only the standard dialog works.
*/
if (lpFind->Flags & (FR_ENABLETEMPLATE | FR_ENABLETEMPLATEHANDLE |
FR_ENABLEHOOK)) FIXME(commdlg, ": unimplemented flag (ignored)\n");
ptr = SYSRES_GetResPtr( SYSRES_DIALOG_FIND_TEXT );
hInst = WIN_GetWindowInstance( lpFind->hwndOwner );
return DIALOG_CreateIndirect( hInst, ptr, TRUE, lpFind->hwndOwner,
(DLGPROC16)MODULE_GetWndProcEntry16("FindTextDlgProc"),
find, WIN_PROC_16 );
}
/***********************************************************************
* FindText32A (COMMDLG.6)
*/
HWND WINAPI FindTextA( LPFINDREPLACEA lpFind )
{
HANDLE16 hInst;
LPCVOID ptr;
/*
* FIXME : Should respond to FR_ENABLETEMPLATE and FR_ENABLEHOOK here
* For now, only the standard dialog works.
*/
if (lpFind->Flags & (FR_ENABLETEMPLATE | FR_ENABLETEMPLATEHANDLE |
FR_ENABLEHOOK)) FIXME(commdlg, ": unimplemented flag (ignored)\n");
ptr = SYSRES_GetResPtr( SYSRES_DIALOG_FIND_TEXT );
hInst = WIN_GetWindowInstance( lpFind->hwndOwner );
return DIALOG_CreateIndirect( hInst, ptr, TRUE, lpFind->hwndOwner,
(DLGPROC16)FindTextDlgProcA, (LPARAM)lpFind, WIN_PROC_32A );
}
/***********************************************************************
* FindText32W (COMMDLG.7)
*/
HWND WINAPI FindTextW( LPFINDREPLACEW lpFind )
{
HANDLE16 hInst;
LPCVOID ptr;
/*
* FIXME : Should respond to FR_ENABLETEMPLATE and FR_ENABLEHOOK here
* For now, only the standard dialog works.
*/
if (lpFind->Flags & (FR_ENABLETEMPLATE | FR_ENABLETEMPLATEHANDLE |
FR_ENABLEHOOK)) FIXME(commdlg, ": unimplemented flag (ignored)\n");
ptr = SYSRES_GetResPtr( SYSRES_DIALOG_FIND_TEXT );
hInst = WIN_GetWindowInstance( lpFind->hwndOwner );
return DIALOG_CreateIndirect( hInst, ptr, TRUE, lpFind->hwndOwner,
(DLGPROC16)FindTextDlgProcW, (LPARAM)lpFind, WIN_PROC_32W );
}
/***********************************************************************
* ReplaceText16 (COMMDLG.12)
*/
HWND16 WINAPI ReplaceText16( SEGPTR find )
{
HANDLE16 hInst;
LPCVOID ptr;
LPFINDREPLACE16 lpFind = (LPFINDREPLACE16)PTR_SEG_TO_LIN(find);
/*
* FIXME : We should do error checking on the lpFind structure here
* and make CommDlgExtendedError() return the error condition.
*/
if (lpFind->Flags & (FR_ENABLETEMPLATE | FR_ENABLETEMPLATEHANDLE |
FR_ENABLEHOOK)) FIXME(commdlg, ": unimplemented flag (ignored)\n");
ptr = SYSRES_GetResPtr( SYSRES_DIALOG_REPLACE_TEXT );
hInst = WIN_GetWindowInstance( lpFind->hwndOwner );
return DIALOG_CreateIndirect( hInst, ptr, TRUE, lpFind->hwndOwner,
(DLGPROC16)MODULE_GetWndProcEntry16("ReplaceTextDlgProc"),
find, WIN_PROC_16 );
}
/***********************************************************************
* ReplaceText32A (COMDLG32.19)
*/
HWND WINAPI ReplaceTextA( LPFINDREPLACEA lpFind )
{
HANDLE16 hInst;
LPCVOID ptr;
/*
* FIXME : Should respond to FR_ENABLETEMPLATE and FR_ENABLEHOOK here
* For now, only the standard dialog works.
*/
if (lpFind->Flags & (FR_ENABLETEMPLATE | FR_ENABLETEMPLATEHANDLE |
FR_ENABLEHOOK)) FIXME(commdlg, ": unimplemented flag (ignored)\n");
ptr = SYSRES_GetResPtr( SYSRES_DIALOG_REPLACE_TEXT );
hInst = WIN_GetWindowInstance( lpFind->hwndOwner );
return DIALOG_CreateIndirect( hInst, ptr, TRUE, lpFind->hwndOwner,
(DLGPROC16)ReplaceTextDlgProcA, (LPARAM)lpFind, WIN_PROC_32A );
}
/***********************************************************************
* ReplaceText32W (COMDLG32.20)
*/
HWND WINAPI ReplaceTextW( LPFINDREPLACEW lpFind )
{
HANDLE16 hInst;
LPCVOID ptr;
/*
* FIXME : We should do error checking on the lpFind structure here
* and make CommDlgExtendedError() return the error condition.
*/
if (lpFind->Flags & (FR_ENABLETEMPLATE | FR_ENABLETEMPLATEHANDLE |
FR_ENABLEHOOK)) FIXME(commdlg, ": unimplemented flag (ignored)\n");
ptr = SYSRES_GetResPtr( SYSRES_DIALOG_REPLACE_TEXT );
hInst = WIN_GetWindowInstance( lpFind->hwndOwner );
return DIALOG_CreateIndirect( hInst, ptr, TRUE, lpFind->hwndOwner,
(DLGPROC16)ReplaceTextDlgProcW, (LPARAM)lpFind, WIN_PROC_32W );
}
/***********************************************************************
* 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;
}
/***********************************************************************
* FINDDLG_WMCommand [internal]
*/
static LRESULT FINDDLG_WMCommand(HWND hWnd, WPARAM wParam,
HWND hwndOwner, LPDWORD lpFlags,
LPSTR lpstrFindWhat, WORD wFindWhatLen,
BOOL fUnicode)
{
int uFindReplaceMessage = RegisterWindowMessageA( FINDMSGSTRING );
int uHelpMessage = RegisterWindowMessageA( HELPMSGSTRING );
switch (wParam) {
case IDOK:
if (fUnicode)
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))
*lpFlags |= FR_WHOLEWORD;
else *lpFlags &= ~FR_WHOLEWORD;
if (IsDlgButtonChecked(hWnd, chx2))
*lpFlags |= FR_MATCHCASE;
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;
}
/***********************************************************************
* FindTextDlgProc16 (COMMDLG.13)
*/
LRESULT WINAPI FindTextDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
LPARAM lParam)
{
LPFINDREPLACE16 lpfr;
switch (wMsg) {
case WM_INITDIALOG:
lpfr=(LPFINDREPLACE16)PTR_SEG_TO_LIN(lParam);
return FINDDLG_WMInitDialog(hWnd, lParam, &(lpfr->Flags),
PTR_SEG_TO_LIN(lpfr->lpstrFindWhat), FALSE);
case WM_COMMAND:
lpfr=(LPFINDREPLACE16)PTR_SEG_TO_LIN(GetWindowLongA(hWnd, DWL_USER));
return FINDDLG_WMCommand(hWnd, wParam, lpfr->hwndOwner,
&lpfr->Flags, PTR_SEG_TO_LIN(lpfr->lpstrFindWhat),
lpfr->wFindWhatLen, FALSE);
}
return FALSE;
}
/***********************************************************************
* FindTextDlgProc32A
*/
LRESULT WINAPI FindTextDlgProcA(HWND hWnd, UINT wMsg, WPARAM wParam,
LPARAM lParam)
{
LPFINDREPLACEA lpfr;
switch (wMsg) {
case WM_INITDIALOG:
lpfr=(LPFINDREPLACEA)lParam;
return FINDDLG_WMInitDialog(hWnd, lParam, &(lpfr->Flags),
lpfr->lpstrFindWhat, FALSE);
case WM_COMMAND:
lpfr=(LPFINDREPLACEA)GetWindowLongA(hWnd, DWL_USER);
return FINDDLG_WMCommand(hWnd, wParam, lpfr->hwndOwner,
&lpfr->Flags, lpfr->lpstrFindWhat, lpfr->wFindWhatLen,
FALSE);
}
return FALSE;
}
/***********************************************************************
* FindTextDlgProc32W
*/
LRESULT WINAPI FindTextDlgProcW(HWND hWnd, UINT wMsg, WPARAM wParam,
LPARAM lParam)
{
LPFINDREPLACEW lpfr;
switch (wMsg) {
case WM_INITDIALOG:
lpfr=(LPFINDREPLACEW)lParam;
return FINDDLG_WMInitDialog(hWnd, lParam, &(lpfr->Flags),
(LPSTR)lpfr->lpstrFindWhat, TRUE);
case WM_COMMAND:
lpfr=(LPFINDREPLACEW)GetWindowLongA(hWnd, DWL_USER);
return FINDDLG_WMCommand(hWnd, wParam, lpfr->hwndOwner,
&lpfr->Flags, (LPSTR)lpfr->lpstrFindWhat, lpfr->wFindWhatLen,
TRUE);
}
return FALSE;
}
/***********************************************************************
* REPLACEDLG_WMInitDialog [internal]
*/
static LRESULT REPLACEDLG_WMInitDialog(HWND hWnd, LPARAM lParam,
LPDWORD lpFlags, LPSTR lpstrFindWhat,
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.
*/
if (fUnicode)
{
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;
}
/***********************************************************************
* 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)
{
int uFindReplaceMessage = RegisterWindowMessageA( FINDMSGSTRING );
int uHelpMessage = RegisterWindowMessageA( HELPMSGSTRING );
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))
*lpFlags |= FR_WHOLEWORD;
else *lpFlags &= ~FR_WHOLEWORD;
if (IsDlgButtonChecked(hWnd, chx2))
*lpFlags |= FR_MATCHCASE;
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
{
GetDlgItemTextA(hWnd, edt1, lpstrFindWhat, wFindWhatLen);
GetDlgItemTextA(hWnd, edt2, lpstrReplaceWith, wReplaceWithLen);
}
if (IsDlgButtonChecked(hWnd, chx1))
*lpFlags |= FR_WHOLEWORD;
else *lpFlags &= ~FR_WHOLEWORD;
if (IsDlgButtonChecked(hWnd, chx2))
*lpFlags |= FR_MATCHCASE;
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))
*lpFlags |= FR_WHOLEWORD;
else *lpFlags &= ~FR_WHOLEWORD;
if (IsDlgButtonChecked(hWnd, chx2))
*lpFlags |= FR_MATCHCASE;
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;
}
/***********************************************************************
* ReplaceTextDlgProc16 (COMMDLG.14)
*/
LRESULT WINAPI ReplaceTextDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
LPARAM lParam)
{
LPFINDREPLACE16 lpfr;
switch (wMsg) {
case WM_INITDIALOG:
lpfr=(LPFINDREPLACE16)PTR_SEG_TO_LIN(lParam);
return REPLACEDLG_WMInitDialog(hWnd, lParam, &lpfr->Flags,
PTR_SEG_TO_LIN(lpfr->lpstrFindWhat),
PTR_SEG_TO_LIN(lpfr->lpstrReplaceWith), FALSE);
case WM_COMMAND:
lpfr=(LPFINDREPLACE16)PTR_SEG_TO_LIN(GetWindowLongA(hWnd, DWL_USER));
return REPLACEDLG_WMCommand(hWnd, wParam, lpfr->hwndOwner,
&lpfr->Flags, PTR_SEG_TO_LIN(lpfr->lpstrFindWhat),
lpfr->wFindWhatLen, PTR_SEG_TO_LIN(lpfr->lpstrReplaceWith),
lpfr->wReplaceWithLen, FALSE);
}
return FALSE;
}
/***********************************************************************
* ReplaceTextDlgProc32A
*/
LRESULT WINAPI ReplaceTextDlgProcA(HWND hWnd, UINT wMsg, WPARAM wParam,
LPARAM lParam)
{
LPFINDREPLACEA lpfr;
switch (wMsg) {
case WM_INITDIALOG:
lpfr=(LPFINDREPLACEA)lParam;
return REPLACEDLG_WMInitDialog(hWnd, lParam, &lpfr->Flags,
lpfr->lpstrFindWhat, lpfr->lpstrReplaceWith, FALSE);
case WM_COMMAND:
lpfr=(LPFINDREPLACEA)GetWindowLongA(hWnd, DWL_USER);
return REPLACEDLG_WMCommand(hWnd, wParam, lpfr->hwndOwner,
&lpfr->Flags, lpfr->lpstrFindWhat, lpfr->wFindWhatLen,
lpfr->lpstrReplaceWith, lpfr->wReplaceWithLen, FALSE);
}
return FALSE;
}
/***********************************************************************
* ReplaceTextDlgProc32W
*/
LRESULT WINAPI ReplaceTextDlgProcW(HWND hWnd, UINT wMsg, WPARAM wParam,
LPARAM lParam)
{
LPFINDREPLACEW lpfr;
switch (wMsg) {
case WM_INITDIALOG:
lpfr=(LPFINDREPLACEW)lParam;
return REPLACEDLG_WMInitDialog(hWnd, lParam, &lpfr->Flags,
(LPSTR)lpfr->lpstrFindWhat, (LPSTR)lpfr->lpstrReplaceWith,
TRUE);
case WM_COMMAND:
lpfr=(LPFINDREPLACEW)GetWindowLongA(hWnd, DWL_USER);
return REPLACEDLG_WMCommand(hWnd, wParam, lpfr->hwndOwner,
&lpfr->Flags, (LPSTR)lpfr->lpstrFindWhat, lpfr->wFindWhatLen,
(LPSTR)lpfr->lpstrReplaceWith, lpfr->wReplaceWithLen, TRUE);
}
return FALSE;
}

986
dlls/commdlg/fontdlg.c Normal file
View File

@ -0,0 +1,986 @@
/*
* COMMDLG - Font Dialog
*
* Copyright 1994 Martin Ayotte
* Copyright 1996 Albrecht Kleine
* Copyright 1999 Klaas van Gend
*/
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "winbase.h"
#include "wine/winbase16.h"
#include "wine/winuser16.h"
#include "win.h"
#include "heap.h"
#include "message.h"
#include "commdlg.h"
#include "resource.h"
#include "dialog.h"
#include "dlgs.h"
#include "module.h"
#include "drive.h"
#include "debug.h"
#include "font.h"
#include "winproc.h"
extern DWORD CommDlgLastError;
static HBITMAP16 hBitmapTT = 0;
static void CFn_CHOOSEFONT16to32A(LPCHOOSEFONT16 chf16, LPCHOOSEFONTA chf32a)
{
chf32a->lStructSize=sizeof(CHOOSEFONTA);
chf32a->hwndOwner=chf16->hwndOwner;
chf32a->hDC=chf16->hDC;
chf32a->iPointSize=chf16->iPointSize;
chf32a->Flags=chf16->Flags;
chf32a->rgbColors=chf16->rgbColors;
chf32a->lCustData=chf16->lCustData;
chf32a->lpfnHook=NULL;
chf32a->lpTemplateName=PTR_SEG_TO_LIN(chf16->lpTemplateName);
chf32a->hInstance=chf16->hInstance;
chf32a->lpszStyle=PTR_SEG_TO_LIN(chf16->lpszStyle);
chf32a->nFontType=chf16->nFontType;
chf32a->nSizeMax=chf16->nSizeMax;
chf32a->nSizeMin=chf16->nSizeMin;
FONT_LogFont16To32A(PTR_SEG_TO_LIN(chf16->lpLogFont), chf32a->lpLogFont);
}
/***********************************************************************
* ChooseFont16 (COMMDLG.15)
*/
BOOL16 WINAPI ChooseFont16(LPCHOOSEFONT16 lpChFont)
{
HINSTANCE16 hInst;
HANDLE16 hDlgTmpl = 0;
BOOL16 bRet = FALSE, win32Format = FALSE;
LPCVOID template;
HWND hwndDialog;
CHOOSEFONTA cf32a;
LOGFONTA lf32a;
SEGPTR lpTemplateName;
cf32a.lpLogFont=&lf32a;
CFn_CHOOSEFONT16to32A(lpChFont, &cf32a);
TRACE(commdlg,"ChooseFont\n");
if (!lpChFont) return FALSE;
if (lpChFont->Flags & CF_ENABLETEMPLATEHANDLE)
{
if (!(template = LockResource16( lpChFont->hInstance )))
{
CommDlgLastError = CDERR_LOADRESFAILURE;
return FALSE;
}
}
else if (lpChFont->Flags & CF_ENABLETEMPLATE)
{
HANDLE16 hResInfo;
if (!(hResInfo = FindResource16( lpChFont->hInstance,
lpChFont->lpTemplateName,
RT_DIALOG16)))
{
CommDlgLastError = CDERR_FINDRESFAILURE;
return FALSE;
}
if (!(hDlgTmpl = LoadResource16( lpChFont->hInstance, hResInfo )) ||
!(template = LockResource16( hDlgTmpl )))
{
CommDlgLastError = CDERR_LOADRESFAILURE;
return FALSE;
}
}
else
{
template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_FONT );
win32Format = TRUE;
}
hInst = WIN_GetWindowInstance( lpChFont->hwndOwner );
/* lpTemplateName is not used in the dialog */
lpTemplateName=lpChFont->lpTemplateName;
lpChFont->lpTemplateName=(SEGPTR)&cf32a;
hwndDialog = DIALOG_CreateIndirect( hInst, template, win32Format,
lpChFont->hwndOwner,
(DLGPROC16)MODULE_GetWndProcEntry16("FormatCharDlgProc"),
(DWORD)lpChFont, WIN_PROC_16 );
if (hwndDialog) bRet = DIALOG_DoDialogBox(hwndDialog, lpChFont->hwndOwner);
if (hDlgTmpl) FreeResource16( hDlgTmpl );
lpChFont->lpTemplateName=lpTemplateName;
FONT_LogFont32ATo16(cf32a.lpLogFont,
(LPLOGFONT16)(PTR_SEG_TO_LIN(lpChFont->lpLogFont)));
return bRet;
}
/***********************************************************************
* ChooseFont32A (COMDLG32.3)
*/
BOOL WINAPI ChooseFontA(LPCHOOSEFONTA lpChFont)
{
BOOL bRet=FALSE;
HWND hwndDialog;
HINSTANCE hInst=WIN_GetWindowInstance( lpChFont->hwndOwner );
LPCVOID template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_FONT );
if (lpChFont->Flags & (CF_SELECTSCRIPT | CF_NOVERTFONTS | CF_ENABLETEMPLATE |
CF_ENABLETEMPLATEHANDLE)) FIXME(commdlg, ": unimplemented flag (ignored)\n");
hwndDialog = DIALOG_CreateIndirect(hInst, template, TRUE, lpChFont->hwndOwner,
(DLGPROC16)FormatCharDlgProcA, (LPARAM)lpChFont, WIN_PROC_32A );
if (hwndDialog) bRet = DIALOG_DoDialogBox(hwndDialog, lpChFont->hwndOwner);
return bRet;
}
/***********************************************************************
* ChooseFont32W (COMDLG32.4)
*/
BOOL WINAPI ChooseFontW(LPCHOOSEFONTW lpChFont)
{
BOOL bRet=FALSE;
HWND hwndDialog;
HINSTANCE hInst=WIN_GetWindowInstance( lpChFont->hwndOwner );
CHOOSEFONTA cf32a;
LOGFONTA lf32a;
LPCVOID template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_FONT );
if (lpChFont->Flags & (CF_SELECTSCRIPT | CF_NOVERTFONTS | CF_ENABLETEMPLATE |
CF_ENABLETEMPLATEHANDLE)) FIXME(commdlg, ": unimplemented flag (ignored)\n");
memcpy(&cf32a, lpChFont, sizeof(cf32a));
memcpy(&lf32a, lpChFont->lpLogFont, sizeof(LOGFONTA));
lstrcpynWtoA(lf32a.lfFaceName, lpChFont->lpLogFont->lfFaceName, LF_FACESIZE);
cf32a.lpLogFont=&lf32a;
cf32a.lpszStyle=HEAP_strdupWtoA(GetProcessHeap(), 0, lpChFont->lpszStyle);
lpChFont->lpTemplateName=(LPWSTR)&cf32a;
hwndDialog=DIALOG_CreateIndirect(hInst, template, TRUE, lpChFont->hwndOwner,
(DLGPROC16)FormatCharDlgProcW, (LPARAM)lpChFont, WIN_PROC_32W );
if (hwndDialog)bRet=DIALOG_DoDialogBox(hwndDialog, lpChFont->hwndOwner);
HeapFree(GetProcessHeap(), 0, cf32a.lpszStyle);
lpChFont->lpTemplateName=(LPWSTR)cf32a.lpTemplateName;
memcpy(lpChFont->lpLogFont, &lf32a, sizeof(CHOOSEFONTA));
lstrcpynAtoW(lpChFont->lpLogFont->lfFaceName, lf32a.lfFaceName, LF_FACESIZE);
return bRet;
}
#define TEXT_EXTRAS 4
#define TEXT_COLORS 16
static const COLORREF textcolors[TEXT_COLORS]=
{
0x00000000L,0x00000080L,0x00008000L,0x00008080L,
0x00800000L,0x00800080L,0x00808000L,0x00808080L,
0x00c0c0c0L,0x000000ffL,0x0000ff00L,0x0000ffffL,
0x00ff0000L,0x00ff00ffL,0x00ffff00L,0x00FFFFFFL
};
/***********************************************************************
* CFn_HookCallChk [internal]
*/
static BOOL CFn_HookCallChk(LPCHOOSEFONT16 lpcf)
{
if (lpcf)
if(lpcf->Flags & CF_ENABLEHOOK)
if (lpcf->lpfnHook)
return TRUE;
return FALSE;
}
/***********************************************************************
* CFn_HookCallChk32 [internal]
*/
static BOOL CFn_HookCallChk32(LPCHOOSEFONTA lpcf)
{
if (lpcf)
if(lpcf->Flags & CF_ENABLEHOOK)
if (lpcf->lpfnHook)
return TRUE;
return FALSE;
}
/*************************************************************************
* AddFontFamily [internal]
*/
static INT AddFontFamily(LPLOGFONTA lplf, UINT nFontType,
LPCHOOSEFONTA lpcf, HWND hwnd)
{
int i;
WORD w;
TRACE(commdlg,"font=%s (nFontType=%d)\n", lplf->lfFaceName,nFontType);
if (lpcf->Flags & CF_FIXEDPITCHONLY)
if (!(lplf->lfPitchAndFamily & FIXED_PITCH))
return 1;
if (lpcf->Flags & CF_ANSIONLY)
if (lplf->lfCharSet != ANSI_CHARSET)
return 1;
if (lpcf->Flags & CF_TTONLY)
if (!(nFontType & TRUETYPE_FONTTYPE))
return 1;
i=SendMessageA(hwnd, CB_ADDSTRING, 0, (LPARAM)lplf->lfFaceName);
if (i!=CB_ERR)
{
w=(lplf->lfCharSet << 8) | lplf->lfPitchAndFamily;
SendMessageA(hwnd, CB_SETITEMDATA, i, MAKELONG(nFontType,w));
return 1 ; /* store some important font information */
}
else
return 0;
}
typedef struct
{
HWND hWnd1;
HWND hWnd2;
LPCHOOSEFONTA lpcf32a;
} CFn_ENUMSTRUCT, *LPCFn_ENUMSTRUCT;
/*************************************************************************
* FontFamilyEnumProc32 [internal]
*/
INT WINAPI FontFamilyEnumProc(LPENUMLOGFONTA lpEnumLogFont,
LPNEWTEXTMETRICA metrics, UINT nFontType, LPARAM lParam)
{
LPCFn_ENUMSTRUCT e;
e=(LPCFn_ENUMSTRUCT)lParam;
return AddFontFamily(&lpEnumLogFont->elfLogFont, nFontType, e->lpcf32a, e->hWnd1);
}
/***********************************************************************
* FontFamilyEnumProc16 (COMMDLG.19)
*/
INT16 WINAPI FontFamilyEnumProc16( SEGPTR logfont, SEGPTR metrics,
UINT16 nFontType, LPARAM lParam )
{
HWND16 hwnd=LOWORD(lParam);
HWND16 hDlg=GetParent16(hwnd);
LPCHOOSEFONT16 lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER);
LOGFONT16 *lplf = (LOGFONT16 *)PTR_SEG_TO_LIN( logfont );
LOGFONTA lf32a;
FONT_LogFont16To32A(lplf, &lf32a);
return AddFontFamily(&lf32a, nFontType, (LPCHOOSEFONTA)lpcf->lpTemplateName,
hwnd);
}
/*************************************************************************
* SetFontStylesToCombo2 [internal]
*
* Fill font style information into combobox (without using font.c directly)
*/
static int SetFontStylesToCombo2(HWND hwnd, HDC hdc, LPLOGFONTA lplf)
{
#define FSTYLES 4
struct FONTSTYLE
{ int italic;
int weight;
char stname[20]; };
static struct FONTSTYLE fontstyles[FSTYLES]={
{ 0,FW_NORMAL,"Regular"},{0,FW_BOLD,"Bold"},
{ 1,FW_NORMAL,"Italic"}, {1,FW_BOLD,"Bold Italic"}};
HFONT16 hf;
TEXTMETRIC16 tm;
int i,j;
for (i=0;i<FSTYLES;i++)
{
lplf->lfItalic=fontstyles[i].italic;
lplf->lfWeight=fontstyles[i].weight;
hf=CreateFontIndirectA(lplf);
hf=SelectObject(hdc,hf);
GetTextMetrics16(hdc,&tm);
hf=SelectObject(hdc,hf);
DeleteObject(hf);
if (tm.tmWeight==fontstyles[i].weight &&
tm.tmItalic==fontstyles[i].italic) /* font successful created ? */
{
char *str = SEGPTR_STRDUP(fontstyles[i].stname);
j=SendMessage16(hwnd,CB_ADDSTRING16,0,(LPARAM)SEGPTR_GET(str) );
SEGPTR_FREE(str);
if (j==CB_ERR) return 1;
j=SendMessage16(hwnd, CB_SETITEMDATA16, j,
MAKELONG(fontstyles[i].weight,fontstyles[i].italic));
if (j==CB_ERR) return 1;
}
}
return 0;
}
/*************************************************************************
* AddFontSizeToCombo3 [internal]
*/
static int AddFontSizeToCombo3(HWND hwnd, UINT h, LPCHOOSEFONTA lpcf)
{
int j;
char buffer[20];
if ( (!(lpcf->Flags & CF_LIMITSIZE)) ||
((lpcf->Flags & CF_LIMITSIZE) && (h >= lpcf->nSizeMin) && (h <= lpcf->nSizeMax)))
{
sprintf(buffer, "%2d", h);
j=SendMessageA(hwnd, CB_FINDSTRINGEXACT, -1, (LPARAM)buffer);
if (j==CB_ERR)
{
j=SendMessageA(hwnd, CB_ADDSTRING, 0, (LPARAM)buffer);
if (j!=CB_ERR) j = SendMessageA(hwnd, CB_SETITEMDATA, j, h);
if (j==CB_ERR) return 1;
}
}
return 0;
}
/*************************************************************************
* SetFontSizesToCombo3 [internal]
*/
static int SetFontSizesToCombo3(HWND hwnd, LPCHOOSEFONTA lpcf)
{
static const int sizes[]={8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72,0};
int i;
for (i=0; sizes[i]; i++)
if (AddFontSizeToCombo3(hwnd, sizes[i], lpcf)) return 1;
return 0;
}
/***********************************************************************
* AddFontStyle [internal]
*/
INT AddFontStyle(LPLOGFONTA lplf, UINT nFontType,
LPCHOOSEFONTA lpcf, HWND hcmb2, HWND hcmb3, HWND hDlg)
{
int i;
TRACE(commdlg,"(nFontType=%d)\n",nFontType);
TRACE(commdlg," %s h=%d w=%d e=%d o=%d wg=%d i=%d u=%d s=%d"
" ch=%d op=%d cp=%d q=%d pf=%xh\n",
lplf->lfFaceName,lplf->lfHeight,lplf->lfWidth,
lplf->lfEscapement,lplf->lfOrientation,
lplf->lfWeight,lplf->lfItalic,lplf->lfUnderline,
lplf->lfStrikeOut,lplf->lfCharSet, lplf->lfOutPrecision,
lplf->lfClipPrecision,lplf->lfQuality, lplf->lfPitchAndFamily);
if (nFontType & RASTER_FONTTYPE)
{
if (AddFontSizeToCombo3(hcmb3, lplf->lfHeight, lpcf)) return 0;
} else if (SetFontSizesToCombo3(hcmb3, lpcf)) return 0;
if (!SendMessageA(hcmb2, CB_GETCOUNT, 0, 0))
{
HDC hdc= (lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC) ? lpcf->hDC : GetDC(hDlg);
i=SetFontStylesToCombo2(hcmb2,hdc,lplf);
if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC))
ReleaseDC(hDlg,hdc);
if (i)
return 0;
}
return 1 ;
}
/***********************************************************************
* FontStyleEnumProc16 (COMMDLG.18)
*/
INT16 WINAPI FontStyleEnumProc16( SEGPTR logfont, SEGPTR metrics,
UINT16 nFontType, LPARAM lParam )
{
HWND16 hcmb2=LOWORD(lParam);
HWND16 hcmb3=HIWORD(lParam);
HWND16 hDlg=GetParent16(hcmb3);
LPCHOOSEFONT16 lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER);
LOGFONT16 *lplf = (LOGFONT16 *)PTR_SEG_TO_LIN(logfont);
LOGFONTA lf32a;
FONT_LogFont16To32A(lplf, &lf32a);
return AddFontStyle(&lf32a, nFontType, (LPCHOOSEFONTA)lpcf->lpTemplateName,
hcmb2, hcmb3, hDlg);
}
/***********************************************************************
* FontStyleEnumProc32 [internal]
*/
INT WINAPI FontStyleEnumProc( LPENUMLOGFONTA lpFont,
LPNEWTEXTMETRICA metrics, UINT nFontType, LPARAM lParam )
{
LPCFn_ENUMSTRUCT s=(LPCFn_ENUMSTRUCT)lParam;
HWND hcmb2=s->hWnd1;
HWND hcmb3=s->hWnd2;
HWND hDlg=GetParent(hcmb3);
return AddFontStyle(&lpFont->elfLogFont, nFontType, s->lpcf32a, hcmb2,
hcmb3, hDlg);
}
/***********************************************************************
* CFn_WMInitDialog [internal]
*/
LRESULT CFn_WMInitDialog(HWND hDlg, WPARAM wParam, LPARAM lParam,
LPCHOOSEFONTA lpcf)
{
HDC hdc;
int i,j,res,init=0;
long l;
LPLOGFONTA lpxx;
HCURSOR hcursor=SetCursor(LoadCursorA(0,IDC_WAITA));
SetWindowLongA(hDlg, DWL_USER, lParam);
lpxx=lpcf->lpLogFont;
TRACE(commdlg,"WM_INITDIALOG lParam=%08lX\n", lParam);
if (lpcf->lStructSize != sizeof(CHOOSEFONTA))
{
ERR(commdlg,"structure size failure !!!\n");
EndDialog (hDlg, 0);
return FALSE;
}
if (!hBitmapTT)
hBitmapTT = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_TRTYPE));
/* This font will be deleted by WM_COMMAND */
SendDlgItemMessageA(hDlg,stc6,WM_SETFONT,
CreateFontA(0, 0, 1, 1, 400, 0, 0, 0, 0, 0, 0, 0, 0, NULL),FALSE);
if (!(lpcf->Flags & CF_SHOWHELP) || !IsWindow(lpcf->hwndOwner))
ShowWindow(GetDlgItem(hDlg,pshHelp),SW_HIDE);
if (!(lpcf->Flags & CF_APPLY))
ShowWindow(GetDlgItem(hDlg,psh3),SW_HIDE);
if (lpcf->Flags & CF_EFFECTS)
{
for (res=1,i=0;res && i<TEXT_COLORS;i++)
{
/* FIXME: load color name from resource: res=LoadString(...,i+....,buffer,.....); */
char name[20];
strcpy( name, "[color name]" );
j=SendDlgItemMessageA(hDlg, cmb4, CB_ADDSTRING, 0, (LPARAM)name);
SendDlgItemMessageA(hDlg, cmb4, CB_SETITEMDATA16, j, textcolors[j]);
/* look for a fitting value in color combobox */
if (textcolors[j]==lpcf->rgbColors)
SendDlgItemMessageA(hDlg,cmb4, CB_SETCURSEL,j,0);
}
}
else
{
ShowWindow(GetDlgItem(hDlg,cmb4),SW_HIDE);
ShowWindow(GetDlgItem(hDlg,chx1),SW_HIDE);
ShowWindow(GetDlgItem(hDlg,chx2),SW_HIDE);
ShowWindow(GetDlgItem(hDlg,grp1),SW_HIDE);
ShowWindow(GetDlgItem(hDlg,stc4),SW_HIDE);
}
hdc= (lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC) ? lpcf->hDC : GetDC(hDlg);
if (hdc)
{
CFn_ENUMSTRUCT s;
s.hWnd1=GetDlgItem(hDlg,cmb1);
s.lpcf32a=lpcf;
if (!EnumFontFamiliesA(hdc, NULL, FontFamilyEnumProc, (LPARAM)&s))
TRACE(commdlg,"EnumFontFamilies returns 0\n");
if (lpcf->Flags & CF_INITTOLOGFONTSTRUCT)
{
/* look for fitting font name in combobox1 */
j=SendDlgItemMessageA(hDlg,cmb1,CB_FINDSTRING,-1,(LONG)lpxx->lfFaceName);
if (j!=CB_ERR)
{
SendDlgItemMessageA(hDlg, cmb1, CB_SETCURSEL, j, 0);
SendMessageA(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE),
GetDlgItem(hDlg,cmb1));
init=1;
/* look for fitting font style in combobox2 */
l=MAKELONG(lpxx->lfWeight > FW_MEDIUM ? FW_BOLD:FW_NORMAL,lpxx->lfItalic !=0);
for (i=0;i<TEXT_EXTRAS;i++)
{
if (l==SendDlgItemMessageA(hDlg, cmb2, CB_GETITEMDATA, i, 0))
SendDlgItemMessageA(hDlg, cmb2, CB_SETCURSEL, i, 0);
}
/* look for fitting font size in combobox3 */
j=SendDlgItemMessageA(hDlg, cmb3, CB_GETCOUNT, 0, 0);
for (i=0;i<j;i++)
{
if (lpxx->lfHeight==(int)SendDlgItemMessageA(hDlg,cmb3, CB_GETITEMDATA,i,0))
SendDlgItemMessageA(hDlg,cmb3,CB_SETCURSEL,i,0);
}
}
}
if (!init)
{
SendDlgItemMessageA(hDlg,cmb1,CB_SETCURSEL,0,0);
SendMessageA(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE),
GetDlgItem(hDlg,cmb1));
}
if (lpcf->Flags & CF_USESTYLE && lpcf->lpszStyle)
{
j=SendDlgItemMessageA(hDlg,cmb2,CB_FINDSTRING,-1,(LONG)lpcf->lpszStyle);
if (j!=CB_ERR)
{
j=SendDlgItemMessageA(hDlg,cmb2,CB_SETCURSEL,j,0);
SendMessageA(hDlg,WM_COMMAND,cmb2,
MAKELONG(GetDlgItem(hDlg,cmb2),CBN_SELCHANGE));
}
}
}
else
{
WARN(commdlg,"HDC failure !!!\n");
EndDialog (hDlg, 0);
return FALSE;
}
if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC))
ReleaseDC(hDlg,hdc);
SetCursor(hcursor);
return TRUE;
}
/***********************************************************************
* CFn_WMMeasureItem [internal]
*/
LRESULT CFn_WMMeasureItem(HWND hDlg, WPARAM wParam, LPARAM lParam)
{
BITMAP bm;
LPMEASUREITEMSTRUCT lpmi=(LPMEASUREITEMSTRUCT)lParam;
if (!hBitmapTT)
hBitmapTT = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_TRTYPE));
GetObjectA( hBitmapTT, sizeof(bm), &bm );
lpmi->itemHeight=bm.bmHeight;
/* FIXME: use MAX of bm.bmHeight and tm.tmHeight .*/
return 0;
}
/***********************************************************************
* CFn_WMDrawItem [internal]
*/
LRESULT CFn_WMDrawItem(HWND hDlg, WPARAM wParam, LPARAM lParam)
{
HBRUSH hBrush;
char buffer[40];
BITMAP bm;
COLORREF cr, oldText=0, oldBk=0;
RECT rect;
#if 0
HDC hMemDC;
int nFontType;
HBITMAP hBitmap; /* for later TT usage */
#endif
LPDRAWITEMSTRUCT lpdi = (LPDRAWITEMSTRUCT)lParam;
if (lpdi->itemID == 0xFFFF) /* got no items */
DrawFocusRect(lpdi->hDC, &lpdi->rcItem);
else
{
if (lpdi->CtlType == ODT_COMBOBOX)
{
if (lpdi->itemState ==ODS_SELECTED)
{
hBrush=GetSysColorBrush(COLOR_HIGHLIGHT);
oldText=SetTextColor(lpdi->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
oldBk=SetBkColor(lpdi->hDC, GetSysColor(COLOR_HIGHLIGHT));
} else
{
hBrush = SelectObject(lpdi->hDC, GetStockObject(LTGRAY_BRUSH));
SelectObject(lpdi->hDC, hBrush);
}
FillRect(lpdi->hDC, &lpdi->rcItem, hBrush);
}
else
return TRUE; /* this should never happen */
rect=lpdi->rcItem;
switch (lpdi->CtlID)
{
case cmb1: /* TRACE(commdlg,"WM_Drawitem cmb1\n"); */
SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
(LPARAM)buffer);
GetObjectA( hBitmapTT, sizeof(bm), &bm );
TextOutA(lpdi->hDC, lpdi->rcItem.left + bm.bmWidth + 10,
lpdi->rcItem.top, buffer, lstrlenA(buffer));
#if 0
nFontType = SendMessageA(lpdi->hwndItem, CB_GETITEMDATA, lpdi->itemID,0L);
/* FIXME: draw bitmap if truetype usage */
if (nFontType&TRUETYPE_FONTTYPE)
{
hMemDC = CreateCompatibleDC(lpdi->hDC);
hBitmap = SelectObject(hMemDC, hBitmapTT);
BitBlt(lpdi->hDC, lpdi->rcItem.left, lpdi->rcItem.top,
bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
SelectObject(hMemDC, hBitmap);
DeleteDC(hMemDC);
}
#endif
break;
case cmb2:
case cmb3: /* TRACE(commdlg,"WM_DRAWITEN cmb2,cmb3\n"); */
SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
(LPARAM)buffer);
TextOutA(lpdi->hDC, lpdi->rcItem.left,
lpdi->rcItem.top, buffer, lstrlenA(buffer));
break;
case cmb4: /* TRACE(commdlg,"WM_DRAWITEM cmb4 (=COLOR)\n"); */
SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
(LPARAM)buffer);
TextOutA(lpdi->hDC, lpdi->rcItem.left + 25+5,
lpdi->rcItem.top, buffer, lstrlenA(buffer));
cr = SendMessageA(lpdi->hwndItem, CB_GETITEMDATA, lpdi->itemID,0L);
hBrush = CreateSolidBrush(cr);
if (hBrush)
{
hBrush = SelectObject (lpdi->hDC, hBrush) ;
rect.right=rect.left+25;
rect.top++;
rect.left+=5;
rect.bottom--;
Rectangle( lpdi->hDC, rect.left, rect.top,
rect.right, rect.bottom );
DeleteObject( SelectObject (lpdi->hDC, hBrush)) ;
}
rect=lpdi->rcItem;
rect.left+=25+5;
break;
default: return TRUE; /* this should never happen */
}
if (lpdi->itemState == ODS_SELECTED)
{
SetTextColor(lpdi->hDC, oldText);
SetBkColor(lpdi->hDC, oldBk);
}
}
return TRUE;
}
/***********************************************************************
* CFn_WMCtlColor [internal]
*/
LRESULT CFn_WMCtlColorStatic(HWND hDlg, WPARAM wParam, LPARAM lParam,
LPCHOOSEFONTA lpcf)
{
if (lpcf->Flags & CF_EFFECTS)
if (GetDlgCtrlID(lParam)==stc6)
{
SetTextColor((HDC)wParam, lpcf->rgbColors);
return GetStockObject(WHITE_BRUSH);
}
return 0;
}
/***********************************************************************
* CFn_WMCommand [internal]
*/
LRESULT CFn_WMCommand(HWND hDlg, WPARAM wParam, LPARAM lParam,
LPCHOOSEFONTA lpcf)
{
HFONT hFont;
int i,j;
long l;
HDC hdc;
LPLOGFONTA lpxx=lpcf->lpLogFont;
TRACE(commdlg,"WM_COMMAND wParam=%08lX lParam=%08lX\n", (LONG)wParam, lParam);
switch (LOWORD(wParam))
{
case cmb1:if (HIWORD(wParam)==CBN_SELCHANGE)
{
hdc=(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC) ? lpcf->hDC : GetDC(hDlg);
if (hdc)
{
SendDlgItemMessageA(hDlg, cmb2, CB_RESETCONTENT16, 0, 0);
SendDlgItemMessageA(hDlg, cmb3, CB_RESETCONTENT16, 0, 0);
i=SendDlgItemMessageA(hDlg, cmb1, CB_GETCURSEL16, 0, 0);
if (i!=CB_ERR)
{
HCURSOR hcursor=SetCursor(LoadCursorA(0,IDC_WAITA));
CFn_ENUMSTRUCT s;
char str[256];
SendDlgItemMessageA(hDlg, cmb1, CB_GETLBTEXT, i,
(LPARAM)str);
TRACE(commdlg,"WM_COMMAND/cmb1 =>%s\n",str);
s.hWnd1=GetDlgItem(hDlg, cmb2);
s.hWnd2=GetDlgItem(hDlg, cmb3);
s.lpcf32a=lpcf;
EnumFontFamiliesA(hdc, str, FontStyleEnumProc, (LPARAM)&s);
SetCursor(hcursor);
}
if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC))
ReleaseDC(hDlg,hdc);
}
else
{
WARN(commdlg,"HDC failure !!!\n");
EndDialog (hDlg, 0);
return TRUE;
}
}
case chx1:
case chx2:
case cmb2:
case cmb3:if (HIWORD(wParam)==CBN_SELCHANGE || HIWORD(wParam)== BN_CLICKED )
{
char str[256];
TRACE(commdlg,"WM_COMMAND/cmb2,3 =%08lX\n", lParam);
i=SendDlgItemMessageA(hDlg,cmb1,CB_GETCURSEL,0,0);
if (i==CB_ERR)
i=GetDlgItemTextA( hDlg, cmb1, str, 256 );
else
{
SendDlgItemMessageA(hDlg,cmb1,CB_GETLBTEXT,i,
(LPARAM)str);
l=SendDlgItemMessageA(hDlg,cmb1,CB_GETITEMDATA,i,0);
j=HIWORD(l);
lpcf->nFontType = LOWORD(l);
/* FIXME: lpcf->nFontType |= .... SIMULATED_FONTTYPE and so */
/* same value reported to the EnumFonts
call back with the extra FONTTYPE_... bits added */
lpxx->lfPitchAndFamily=j&0xff;
lpxx->lfCharSet=j>>8;
}
strcpy(lpxx->lfFaceName,str);
i=SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0);
if (i!=CB_ERR)
{
l=SendDlgItemMessageA(hDlg, cmb2, CB_GETITEMDATA, i, 0);
if (0!=(lpxx->lfItalic=HIWORD(l)))
lpcf->nFontType |= ITALIC_FONTTYPE;
if ((lpxx->lfWeight=LOWORD(l)) > FW_MEDIUM)
lpcf->nFontType |= BOLD_FONTTYPE;
}
i=SendDlgItemMessageA(hDlg, cmb3, CB_GETCURSEL, 0, 0);
if (i!=CB_ERR)
lpxx->lfHeight=-LOWORD(SendDlgItemMessageA(hDlg, cmb3, CB_GETITEMDATA, i, 0));
else
lpxx->lfHeight=0;
lpxx->lfStrikeOut=IsDlgButtonChecked(hDlg,chx1);
lpxx->lfUnderline=IsDlgButtonChecked(hDlg,chx2);
lpxx->lfWidth=lpxx->lfOrientation=lpxx->lfEscapement=0;
lpxx->lfOutPrecision=OUT_DEFAULT_PRECIS;
lpxx->lfClipPrecision=CLIP_DEFAULT_PRECIS;
lpxx->lfQuality=DEFAULT_QUALITY;
lpcf->iPointSize= -10*lpxx->lfHeight;
hFont=CreateFontIndirectA(lpxx);
if (hFont)
{
HFONT oldFont=SendDlgItemMessageA(hDlg, stc6,
WM_GETFONT, 0, 0);
SendDlgItemMessageA(hDlg,stc6,WM_SETFONT,hFont,TRUE);
DeleteObject(oldFont);
}
}
break;
case cmb4:i=SendDlgItemMessageA(hDlg, cmb4, CB_GETCURSEL, 0, 0);
if (i!=CB_ERR)
{
lpcf->rgbColors=textcolors[i];
InvalidateRect( GetDlgItem(hDlg,stc6), NULL, 0 );
}
break;
case psh15:i=RegisterWindowMessageA( HELPMSGSTRING );
if (lpcf->hwndOwner)
SendMessageA(lpcf->hwndOwner, i, 0, (LPARAM)GetWindowLongA(hDlg, DWL_USER));
/* if (CFn_HookCallChk(lpcf))
CallWindowProc16(lpcf->lpfnHook,hDlg,WM_COMMAND,psh15,(LPARAM)lpcf);*/
break;
case IDOK:if ( (!(lpcf->Flags & CF_LIMITSIZE)) ||
( (lpcf->Flags & CF_LIMITSIZE) &&
(-lpxx->lfHeight >= lpcf->nSizeMin) &&
(-lpxx->lfHeight <= lpcf->nSizeMax)))
EndDialog(hDlg, TRUE);
else
{
char buffer[80];
sprintf(buffer,"Select a font size between %d and %d points.",
lpcf->nSizeMin,lpcf->nSizeMax);
MessageBoxA(hDlg, buffer, NULL, MB_OK);
}
return(TRUE);
case IDCANCEL:EndDialog(hDlg, FALSE);
return(TRUE);
}
return(FALSE);
}
static LRESULT CFn_WMDestroy(HWND hwnd, WPARAM wParam, LPARAM lParam)
{
DeleteObject(SendDlgItemMessageA(hwnd, stc6, WM_GETFONT, 0, 0));
return TRUE;
}
/***********************************************************************
* FormatCharDlgProc16 (COMMDLG.16)
FIXME: 1. some strings are "hardcoded", but it's better load from sysres
2. some CF_.. flags are not supported
3. some TType extensions
*/
LRESULT WINAPI FormatCharDlgProc16(HWND16 hDlg, UINT16 message, WPARAM16 wParam,
LPARAM lParam)
{
LPCHOOSEFONT16 lpcf;
LPCHOOSEFONTA lpcf32a;
UINT uMsg32;
WPARAM wParam32;
LRESULT res=0;
if (message!=WM_INITDIALOG)
{
lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER);
if (!lpcf)
return FALSE;
if (CFn_HookCallChk(lpcf))
res=CallWindowProc16(lpcf->lpfnHook,hDlg,message,wParam,lParam);
if (res)
return res;
}
else
{
lpcf=(LPCHOOSEFONT16)lParam;
lpcf32a=(LPCHOOSEFONTA)lpcf->lpTemplateName;
if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf32a))
{
TRACE(commdlg, "CFn_WMInitDialog returned FALSE\n");
return FALSE;
}
if (CFn_HookCallChk(lpcf))
return CallWindowProc16(lpcf->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
}
WINPROC_MapMsg16To32A(message, wParam, &uMsg32, &wParam32, &lParam);
lpcf32a=(LPCHOOSEFONTA)lpcf->lpTemplateName;
switch (uMsg32)
{
case WM_MEASUREITEM:
res=CFn_WMMeasureItem(hDlg, wParam32, lParam);
break;
case WM_DRAWITEM:
res=CFn_WMDrawItem(hDlg, wParam32, lParam);
break;
case WM_CTLCOLORSTATIC:
res=CFn_WMCtlColorStatic(hDlg, wParam32, lParam, lpcf32a);
break;
case WM_COMMAND:
res=CFn_WMCommand(hDlg, wParam32, lParam, lpcf32a);
break;
case WM_DESTROY:
res=CFn_WMDestroy(hDlg, wParam32, lParam);
break;
case WM_CHOOSEFONT_GETLOGFONT:
TRACE(commdlg,"WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
lParam);
FIXME(commdlg, "current logfont back to caller\n");
break;
}
WINPROC_UnmapMsg16To32A(hDlg,uMsg32, wParam32, lParam, res);
return res;
}
/***********************************************************************
* FormatCharDlgProc32A [internal]
*/
LRESULT WINAPI FormatCharDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
LPARAM lParam)
{
LPCHOOSEFONTA lpcf;
LRESULT res=FALSE;
if (uMsg!=WM_INITDIALOG)
{
lpcf=(LPCHOOSEFONTA)GetWindowLongA(hDlg, DWL_USER);
if (!lpcf)
return FALSE;
if (CFn_HookCallChk32(lpcf))
res=CallWindowProcA(lpcf->lpfnHook, hDlg, uMsg, wParam, lParam);
if (res)
return res;
}
else
{
lpcf=(LPCHOOSEFONTA)lParam;
if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf))
{
TRACE(commdlg, "CFn_WMInitDialog returned FALSE\n");
return FALSE;
}
if (CFn_HookCallChk32(lpcf))
return CallWindowProcA(lpcf->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
}
switch (uMsg)
{
case WM_MEASUREITEM:
return CFn_WMMeasureItem(hDlg, wParam, lParam);
case WM_DRAWITEM:
return CFn_WMDrawItem(hDlg, wParam, lParam);
case WM_CTLCOLORSTATIC:
return CFn_WMCtlColorStatic(hDlg, wParam, lParam, lpcf);
case WM_COMMAND:
return CFn_WMCommand(hDlg, wParam, lParam, lpcf);
case WM_DESTROY:
return CFn_WMDestroy(hDlg, wParam, lParam);
case WM_CHOOSEFONT_GETLOGFONT:
TRACE(commdlg,"WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
lParam);
FIXME(commdlg, "current logfont back to caller\n");
break;
}
return res;
}
/***********************************************************************
* FormatCharDlgProc32W [internal]
*/
LRESULT WINAPI FormatCharDlgProcW(HWND hDlg, UINT uMsg, WPARAM wParam,
LPARAM lParam)
{
LPCHOOSEFONTW lpcf32w;
LPCHOOSEFONTA lpcf32a;
LRESULT res=FALSE;
if (uMsg!=WM_INITDIALOG)
{
lpcf32w=(LPCHOOSEFONTW)GetWindowLongA(hDlg, DWL_USER);
if (!lpcf32w)
return FALSE;
if (CFn_HookCallChk32((LPCHOOSEFONTA)lpcf32w))
res=CallWindowProcW(lpcf32w->lpfnHook, hDlg, uMsg, wParam, lParam);
if (res)
return res;
}
else
{
lpcf32w=(LPCHOOSEFONTW)lParam;
lpcf32a=(LPCHOOSEFONTA)lpcf32w->lpTemplateName;
if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf32a))
{
TRACE(commdlg, "CFn_WMInitDialog returned FALSE\n");
return FALSE;
}
if (CFn_HookCallChk32((LPCHOOSEFONTA)lpcf32w))
return CallWindowProcW(lpcf32w->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
}
lpcf32a=(LPCHOOSEFONTA)lpcf32w->lpTemplateName;
switch (uMsg)
{
case WM_MEASUREITEM:
return CFn_WMMeasureItem(hDlg, wParam, lParam);
case WM_DRAWITEM:
return CFn_WMDrawItem(hDlg, wParam, lParam);
case WM_CTLCOLORSTATIC:
return CFn_WMCtlColorStatic(hDlg, wParam, lParam, lpcf32a);
case WM_COMMAND:
return CFn_WMCommand(hDlg, wParam, lParam, lpcf32a);
case WM_DESTROY:
return CFn_WMDestroy(hDlg, wParam, lParam);
case WM_CHOOSEFONT_GETLOGFONT:
TRACE(commdlg,"WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
lParam);
FIXME(commdlg, "current logfont back to caller\n");
break;
}
return res;
}

40
dlls/commdlg/generic.c Normal file
View File

@ -0,0 +1,40 @@
/*
* COMMDLG functions
*
* Copyright 1994 Martin Ayotte
* Copyright 1996 Albrecht Kleine
* Copyright 1999 Klaas van Gend
*/
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "winbase.h"
#include "wine/winbase16.h"
#include "wine/winuser16.h"
#include "win.h"
#include "heap.h"
#include "message.h"
#include "commdlg.h"
#include "resource.h"
#include "dialog.h"
#include "dlgs.h"
#include "module.h"
#include "drive.h"
#include "debug.h"
#include "font.h"
#include "winproc.h"
static DWORD CommDlgLastError = 0;
/***********************************************************************
* CommDlgExtendedError (COMMDLG.26)
*/
DWORD WINAPI CommDlgExtendedError(void)
{
return CommDlgLastError;
}

417
dlls/commdlg/printdlg.c Normal file
View File

@ -0,0 +1,417 @@
/*
* COMMDLG - Print Dialog
*
* Copyright 1994 Martin Ayotte
* Copyright 1996 Albrecht Kleine
* Copyright 1999 Klaas van Gend
*/
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "winbase.h"
#include "wine/winbase16.h"
#include "wine/winuser16.h"
#include "win.h"
#include "heap.h"
#include "message.h"
#include "commdlg.h"
#include "resource.h"
#include "dialog.h"
#include "dlgs.h"
#include "module.h"
#include "drive.h"
#include "debug.h"
#include "font.h"
#include "winproc.h"
DWORD CommDlgLastError = 0;
extern HBITMAP16 hFolder;
extern HBITMAP16 hFolder2;
extern HBITMAP16 hFloppy;
extern HBITMAP16 hHDisk;
extern HBITMAP16 hCDRom;
extern HBITMAP16 hBitmapTT;
extern const char defaultfilter[];
/***********************************************************************
* PrintDlg16 (COMMDLG.20)
*/
BOOL16 WINAPI PrintDlg16( SEGPTR printdlg )
{
HANDLE16 hInst;
BOOL16 bRet = FALSE;
LPCVOID template;
HWND hwndDialog;
LPPRINTDLG16 lpPrint = (LPPRINTDLG16)PTR_SEG_TO_LIN(printdlg);
TRACE(commdlg,"(%p) -- Flags=%08lX\n", lpPrint, lpPrint->Flags );
if (lpPrint->Flags & PD_RETURNDEFAULT)
/* FIXME: should fill lpPrint->hDevMode and lpPrint->hDevNames here */
return TRUE;
if (lpPrint->Flags & PD_PRINTSETUP)
template = SYSRES_GetResPtr( SYSRES_DIALOG_PRINT_SETUP );
else
template = SYSRES_GetResPtr( SYSRES_DIALOG_PRINT );
hInst = WIN_GetWindowInstance( lpPrint->hwndOwner );
hwndDialog = DIALOG_CreateIndirect( hInst, template, TRUE,
lpPrint->hwndOwner,
(DLGPROC16)((lpPrint->Flags & PD_PRINTSETUP) ?
MODULE_GetWndProcEntry16("PrintSetupDlgProc") :
MODULE_GetWndProcEntry16("PrintDlgProc")),
printdlg, WIN_PROC_16 );
if (hwndDialog) bRet = DIALOG_DoDialogBox( hwndDialog, lpPrint->hwndOwner);
return bRet;
}
/***********************************************************************
* PrintDlgA (COMDLG32.17)
*
* Displays the the PRINT dialog box, which enables the user to specify
* specific properties of the print job.
*
* (Note: according to the MS Platform SDK, this call was in the past
* also used to display some PRINT SETUP dialog. As this is superseded
* by PageSetupDlg, this now results in an error!)
*
* RETURNS
* nonzero if the user pressed the OK button
* zero if the user cancelled the window or an error occurred
*
* BUGS
* The function is a stub only, returning TRUE to allow more programs
* to function.
*/
BOOL WINAPI PrintDlgA(
LPPRINTDLGA lppd /* ptr to PRINTDLG32 struct */
)
{
/* My implementing strategy:
*
* step 1: display the dialog and implement the layout-flags
* step 2: enter valid information in the fields (e.g. real printers)
* step 3: fix the RETURN-TRUE-ALWAYS Fixme by checking lppd->Flags for
* PD_RETURNDEFAULT
* step 4: implement all other specs
* step 5: allow customisation of the dialog box
*
* current implementation is in step 1.
*/
HWND hwndDialog;
BOOL bRet = FALSE;
LPCVOID ptr = SYSRES_GetResPtr( SYSRES_DIALOG_PRINT32 );
HINSTANCE hInst = WIN_GetWindowInstance( lppd->hwndOwner );
FIXME(commdlg, "KVG (%p): stub\n", lppd);
/*
* FIXME : Should respond to TEMPLATE and HOOK flags here
* For now, only the standard dialog works.
*/
if (lppd->Flags & (PD_ENABLEPRINTHOOK | PD_ENABLEPRINTTEMPLATE |
PD_ENABLEPRINTTEMPLATEHANDLE | PD_ENABLESETUPHOOK |
PD_ENABLESETUPTEMPLATE|PD_ENABLESETUPTEMPLATEHANDLE))
FIXME(commdlg, ": unimplemented flag (ignored)\n");
/*
* if lppd->Flags PD_RETURNDEFAULT is specified, the PrintDlg function
* does not display the dialog box, but returns with valid entries
* for hDevMode and hDevNames .
*
* Currently the flag is recognised, but we return empty hDevMode and
* and hDevNames. This will be fixed when I am in step 3.
*/
if (lppd->Flags & PD_RETURNDEFAULT)
{
WARN(commdlg, ": PrintDlg was requested to return printer info only."
"\n The return value currently does NOT provide these.\n");
CommDlgLastError=PDERR_NODEVICES; /* return TRUE, thus never checked! */
return(TRUE);
}
if (lppd->Flags & PD_PRINTSETUP)
{
FIXME(commdlg, ": PrintDlg was requested to display PrintSetup box.\n");
CommDlgLastError=PDERR_INITFAILURE;
return(FALSE);
}
hwndDialog= DIALOG_CreateIndirect(hInst, ptr, TRUE, lppd->hwndOwner,
(DLGPROC16)PrintDlgProcA, (LPARAM)lppd, WIN_PROC_32A );
if (hwndDialog)
bRet = DIALOG_DoDialogBox(hwndDialog, lppd->hwndOwner);
return bRet;
}
/***********************************************************************
* PrintDlg32W (COMDLG32.18)
*/
BOOL WINAPI PrintDlgW( LPPRINTDLGW printdlg )
{
FIXME(commdlg, "A really empty stub\n" );
return FALSE;
}
/***********************************************************************
* PRINTDLG_WMInitDialog [internal]
*/
LRESULT PRINTDLG_WMInitDialog(HWND hDlg, WPARAM wParam, LPARAM lParam,
LPPRINTDLGA lppd)
{
SetWindowLongA(hDlg, DWL_USER, lParam);
TRACE(commdlg,"WM_INITDIALOG lParam=%08lX\n", lParam);
if (lppd->lStructSize != sizeof(PRINTDLGA))
{
FIXME(commdlg,"structure size failure !!!\n");
/* EndDialog (hDlg, 0);
return FALSE;
*/ }
/* Flag processing to set the according buttons on/off and
* Initialise the various values
*/
/* Print range (All/Range/Selection) */
if (lppd->nMinPage == lppd->nMaxPage)
lppd->Flags &= ~PD_NOPAGENUMS;
/* FIXME: I allow more freedom than either Win95 or WinNT,
* as officially we should return error if
* ToPage or FromPage is out-of-range
*/
if (lppd->nToPage < lppd->nMinPage)
lppd->nToPage = lppd->nMinPage;
if (lppd->nToPage > lppd->nMaxPage)
lppd->nToPage = lppd->nMaxPage;
if (lppd->nFromPage < lppd->nMinPage)
lppd->nFromPage = lppd->nMinPage;
if (lppd->nFromPage > lppd->nMaxPage)
lppd->nFromPage = lppd->nMaxPage;
SetDlgItemInt(hDlg, edt2, lppd->nFromPage, FALSE);
SetDlgItemInt(hDlg, edt3, lppd->nToPage, FALSE);
CheckRadioButton(hDlg, rad1, rad3, rad1);
if (lppd->Flags & PD_NOSELECTION)
EnableWindow(GetDlgItem(hDlg, rad3), FALSE);
else
if (lppd->Flags & PD_SELECTION)
CheckRadioButton(hDlg, rad1, rad3, rad3);
if (lppd->Flags & PD_NOPAGENUMS)
{
EnableWindow(GetDlgItem(hDlg, rad2), FALSE);
EnableWindow(GetDlgItem(hDlg, stc10),FALSE);
EnableWindow(GetDlgItem(hDlg, edt2), FALSE);
EnableWindow(GetDlgItem(hDlg, stc11),FALSE);
EnableWindow(GetDlgItem(hDlg, edt3), FALSE);
}
else
{
if (lppd->Flags & PD_PAGENUMS)
CheckRadioButton(hDlg, rad1, rad3, rad2);
}
/* FIXME: in Win95, the radiobutton "All" is displayed as
* "Print all xxx pages"... This is not done here (yet?)
*/
/* Collate pages */
if (lppd->Flags & PD_COLLATE)
FIXME(commdlg, "PD_COLLATE not implemented yet\n");
/* print to file */
CheckDlgButton(hDlg, chx1, (lppd->Flags & PD_PRINTTOFILE) ? 1 : 0);
if (lppd->Flags & PD_DISABLEPRINTTOFILE)
EnableWindow(GetDlgItem(hDlg, chx1), FALSE);
if (lppd->Flags & PD_HIDEPRINTTOFILE)
ShowWindow(GetDlgItem(hDlg, chx1), SW_HIDE);
/* status */
TRACE(commdlg, "succesful!\n");
return TRUE;
}
/***********************************************************************
* PRINTDLG_ValidateAndDuplicateSettings [internal]
*/
BOOL PRINTDLG_ValidateAndDuplicateSettings(HWND hDlg, LPPRINTDLGA lppd)
{
WORD nToPage;
WORD nFromPage;
char TempBuffer[256];
/* check whether nFromPage and nToPage are within range defined by
* nMinPage and nMaxPage
*/
/* FIXMNo checking on rad2 is performed now, because IsDlgButtonCheck
* currently doesn't seem to know a state BST_CHECKED
*/
/* if (IsDlgButtonChecked(hDlg, rad2) == BST_CHECKED) */
{
nFromPage = GetDlgItemInt(hDlg, edt2, NULL, FALSE);
nToPage = GetDlgItemInt(hDlg, edt3, NULL, FALSE);
if (nFromPage < lppd->nMinPage || nFromPage > lppd->nMaxPage ||
nToPage < lppd->nMinPage || nToPage > lppd->nMaxPage)
{
FIXME(commdlg, "The MessageBox is not internationalised.");
sprintf(TempBuffer, "This value lies not within Page range\n"
"Please enter a value between %d and %d",
lppd->nMinPage, lppd->nMaxPage);
MessageBoxA(hDlg, TempBuffer, "Print", MB_OK | MB_ICONWARNING);
return(FALSE);
}
lppd->nFromPage = nFromPage;
lppd->nToPage = nToPage;
}
return(TRUE);
}
/***********************************************************************
* PRINTDLG_WMCommand [internal]
*/
static LRESULT PRINTDLG_WMCommand(HWND hDlg, WPARAM wParam,
LPARAM lParam, LPPRINTDLGA lppd)
{
switch (wParam)
{
case IDOK:
if (PRINTDLG_ValidateAndDuplicateSettings(hDlg, lppd) != TRUE)
return(FALSE);
MessageBoxA(hDlg, "OK was hit!", NULL, MB_OK);
DestroyWindow(hDlg);
return(TRUE);
case IDCANCEL:
MessageBoxA(hDlg, "CANCEL was hit!", NULL, MB_OK);
EndDialog(hDlg, FALSE);
/* DestroyWindow(hDlg); */
return(FALSE);
}
return FALSE;
}
/***********************************************************************
* PrintDlgProcA [internal]
*/
LRESULT WINAPI PrintDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
LPARAM lParam)
{
LPPRINTDLGA lppd;
LRESULT res=FALSE;
if (uMsg!=WM_INITDIALOG)
{
lppd=(LPPRINTDLGA)GetWindowLongA(hDlg, DWL_USER);
if (!lppd)
return FALSE;
}
else
{
lppd=(LPPRINTDLGA)lParam;
if (!PRINTDLG_WMInitDialog(hDlg, wParam, lParam, lppd))
{
TRACE(commdlg, "PRINTDLG_WMInitDialog returned FALSE\n");
return FALSE;
}
MessageBoxA(hDlg,"Warning: this dialog has no functionality yet!",
NULL, MB_OK);
}
switch (uMsg)
{
case WM_COMMAND:
return PRINTDLG_WMCommand(hDlg, wParam, lParam, lppd);
case WM_DESTROY:
return FALSE;
}
return res;
}
/***********************************************************************
* PrintDlgProc16 (COMMDLG.21)
*/
LRESULT WINAPI PrintDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
LPARAM lParam)
{
switch (wMsg)
{
case WM_INITDIALOG:
TRACE(commdlg,"WM_INITDIALOG lParam=%08lX\n", lParam);
ShowWindow16(hWnd, SW_SHOWNORMAL);
return (TRUE);
case WM_COMMAND:
switch (wParam)
{
case IDOK:
EndDialog(hWnd, TRUE);
return(TRUE);
case IDCANCEL:
EndDialog(hWnd, FALSE);
return(TRUE);
}
return(FALSE);
}
return FALSE;
}
/***********************************************************************
* PrintSetupDlgProc (COMMDLG.22)
*/
LRESULT WINAPI PrintSetupDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
LPARAM lParam)
{
switch (wMsg)
{
case WM_INITDIALOG:
TRACE(commdlg,"WM_INITDIALOG lParam=%08lX\n", lParam);
ShowWindow16(hWnd, SW_SHOWNORMAL);
return (TRUE);
case WM_COMMAND:
switch (wParam) {
case IDOK:
EndDialog(hWnd, TRUE);
return(TRUE);
case IDCANCEL:
EndDialog(hWnd, FALSE);
return(TRUE);
}
return(FALSE);
}
return FALSE;
}
/***********************************************************************
* PageSetupDlgA (COMDLG32.15)
*/
BOOL WINAPI PageSetupDlgA(LPPAGESETUPDLGA setupdlg) {
FIXME(commdlg,"(%p), stub!\n",setupdlg);
return FALSE;
}

View File

@ -9,7 +9,6 @@ C_SRCS = \
callback.c \
cdrom.c \
comm.c \
commdlg.c \
crtdll.c \
cpu.c \
ddeml.c \

File diff suppressed because it is too large Load Diff