mirror of
https://github.com/reactos/wine.git
synced 2024-11-26 05:00:30 +00:00
d30dfd24d6
Sun Sep 27 14:25:38 1998 Petter Reinholdtsen <pere@td.org.uit.no> * [files/drive.c] Make sure GetDriveType32A() handles param NULL. Added some doc on function. Sun Sep 27 14:07:26 1998 Huw D M Davies <daviesh@abacus.physics.ox.ac.uk> * [controls/edit.c] [windows/win.c] Don't call SetWindowLong() in EDIT_WM_NCREATE. Fix SetWindowLong(GWL_[EX]STYLE) to work for 16bit windows. Remove UpdateWindow() call. Sun Sep 27 13:41:22 1998 Alexandre Julliard <julliard@lrc.epfl.ch> * [scheduler/*.c] [server/event.c] [server/mutex.c] [server/semaphore.c] Implemented server-side synchronisation objects. Sun Sep 27 01:13:35 1998 Alex Priem <alexp@sci.kun.nl> * [dlls/comctl32/treeview.c] [include/treeview.h] [include/comctl.h] Treeview implementation. * [dlls/comctl32/trackbar.c] [include/trackbar.h] Trackbar implementation. Sat Sep 26 20:49:13 1998 Ulrich Weigand <weigand@informatik.uni-erlangen.de> * [if1632/thunk.c] [tools/build.c] [win32/kernel32.c] Bugfix: several problems with flat thunks fixed. * [memory/selector.c] Bugfix: IsBad...Ptr16 didn't work for limit_in_pages segments. * [scheduler/thread.c] Bugfix: CreateThread: Allow id parameter == NULL. * [objects/gdiobj.c] Bugfix: IsGDIObject: Return correct object type for stock objects. * [msdos/dpmi.c] Bugfix: fixed typo in INT_DoRealModeInt. * [msdos/int21.c] Bugfix: int21 READ *must* use WIN16_hread, not _hread16. * [if1632/kernel.spec] [if1632/dummy.c] [if1632/thunk.c] [loader/ne/module.c] [scheduler/event.c] [scheduler/synchro.c] [scheduler/thread.c] [win32/kernel32.c] [win32/ordinals.c] Added names/stubs for all undocumented KERNEL routines (Win95). Added the following undoc. 16-bit equivalents to Win32 routines: KERNEL.441-443,449-453,456-462,471-476,479-486,488. Added stubs for some other KERNEL routines. * [memory/heap.c] [memory/global.c] [include/global.h] Implemented Local32... 32-bit local heap routines (KERNEL.208-215, 229). * [miscemu/instr.c] [loader/module.c] [include/module.h] Implemented __GP fault handling and HasGPHandler (KERNEL.338). * [misc/error.c] Implemented LogParamErrorRegs (KERNEL.327). * [loader/task.c] [include/windows.h] Implemented GetCodeInfo (KERNEL.104). * [loader/task.c] [scheduler/thread.c] [include/thread.h] Implemented [GS]etThreadQueue and [GS]etFastQueue (KERNEL.463/4, 624/5). * [if1632/gdi.spec] [objects/dc.c] [objects/dib.c] [objects/bitmap.c] [include/windows.h] Bugfix: fixed wrong parameter for CreateDIBSection16. Added [GS]etDIBColorTable16, stub for GetBoundsRect16. Partially implemented BITMAP_GetObject16 for DIBs. * [if1632/gdi.spec] [relay32/gdi32.spec] [objects/palette.c] Added some GDI stubs. * [if1632/Makefile.in] [if1632/display.spec] [if1632/mouse.spec] [if1632/keyboard.spec] [if1632/builtin.c] [windows/keyboard.c] Added some stubs for Win16 drivers: KEYBOARD, MOUSE, DISPLAY. * [if1632/wprocs.spec] [msdos/vxd.c] Added some stubs for VxDs: VMM, ConfigMG, TimerAPI. * [msdos/int2f.c] Added some stubs for real-mode network drivers. Sat Sep 26 18:18:18 1998 Marcus Meissner <marcus@jet.franken.de> * [configure.in] Merged in some more of the FreeBSD ports/emulators/wine patches. (Maintainer(s) of this port: You can just submit these patches to Alexandre directly.) * [loader/pe_image.c] Check filesize of image against size derived from header to spot truncated executeables without crashing. * [files/directory.c] Set envvar "COMSPEC". One win32(!!) program crashes without it. * [multimedia/mmio.c] Added mmioSetInfo32. * [include/file.h] Return STD_ERROR_HANDLE for AUX and PRT dos handles. * [loader/module.c] Handle executeables with spaces in their names a bit better in CreateProcess. * [relay32/msvfw32.spec][if1632/msvideo.spec][multimedia/msvideo.c][include/vfw.h] Started on MS Video support (can load Win32 ICMs). * [tools/testrun] A bit smarter use of ps. * [memory/virtual.c] Report PAGE_GUARDed pages as PAGE_PROTECTED (AutoCAD LT R17 fails without that check (since Win95 doesn't know about PAGE_GUARD)). Sat Sep 26 15:04:05 1998 Ove Kaaven <ovek@arcticnet.no> * [include/miscemu.h] [if1632/builtin.c] [loader/task.c] [miscemu/instr.c] [msdos/dpmi.c] [msdos/int21.c] [msdos/interrupts.c] [windows/user.c] INT_[S|G]etHandler was renamed to INT_[S|G]etPMHandler. Added handlers to deal with real-mode interrupts; DOS programs are now able to hook real-mode interrupts. * [loader/dos/module.c] [msdos/dosmem.c] [msdos/int21.c] Moved real-mode interrupt table initialization to msdos/dosmem.c, and made new V86 tasks get a full copy of the existing "system memory" instead of almost empty space. Misc fixes. * [include/dosexe.h] [loader/dos/module.c] [msdos/dpmi.c] [msdos/int2f.c] First shot at letting DOS programs start up DPMI (but DPMI is still disabled for DOS programs, for pkunzip's sake). * [include/debugger.h] [debugger/break.c] [debugger/dbg.y] [debugger/registers.c] [debugger/memory.c] [debugger/info.c] [loader/dos/dosvm.c] First shot at making Wine's debugger work for DOS programs. The -debug flag works, as do "nexti" and "stepi". Sat Sep 26 13:13:13 1998 Juergen Schmied <juergen.schmied@metronet.de> * [dlls/shell32/dataobject.c] New classes IEnumFORMATETC implemented, IDataObject stubs. * [dlls/shell32/*.*][relay32/shell32.spec] Bugfixes. New: ICM_InsertItem(), ILCreateFromPath(). Implemented: ILCloneFirst(). Stubs: ILIsEqual(), ILFindChild(), SHLogILFromFSIL(), PathMatchSpec(), PathIsExe(). Changed: ILGetSize(), _ILIsDesktop(), PathCombine(). * [include/shlobj.h] New SHLGUID's New structures: DVTARGETDEVICE32, STGMEDIUM32, FORMATETC32, CLIPFORMAT32. New interfaces: IEnumFORMATETC, IDataObject, ICommDlgBrowser IDockingWindowFrame, IServiceProvider. * [dlls/shell32/folders.c] Stubs for IShellLink. * [loader/resource.c] Small fixes. * [misc/crtdll.c][relay32/crtdll.spec] New __dllonexit(). * [windows/message.c] SendNotifyMessageA, SendMessageCallBack32A half implemented. * [controls/edit.c] EDIT_WM_SetText set EF_UPDATE flag not for ES_MULTILINE. * [files/file.c] Handling of fileposition fixed. Fri Sep 25 18:13:30 1998 Patrik Stridvall <ps@leissner.se> * [include/windows.h] [include/wintypes.h] [ole/ole2nls.h] [relay32/kernel32.spec] Implemented EnumDateFormats and EnumTimeFormats. Only adds US English support. * [Makefile.in] [configure.in] [dlls/Makefile.in] [dlls/psapi/Makefile.in] [dlls/psapi/psapi_main.c] New files to implement stubs for PSAPI.DLL (NT only). * [relay32/Makefile.in] [relay32/builtin32.c] [relay32/psapi.spec] New spec file for PSAPI.DLL (NT only). * [scheduler/handle.c] HANDLE_GetObjPtr should only interpret the pseudo handles as the current thread or the current process if a thread or a process is requested. * [include/winversion.h] [misc/version.c] Adds the global function VERSION_GetVersion() so functions can have different behavior depending on the -winver flag. * [include/oledlg.h] [ole/oledlg.c] Minor fixes. * [windows/winproc.c] Minor changes. * [include/imm.h] [misc/imm.c] Now returns correct values under both Windows 95 and NT 4.0. Thu Sep 24 22:11:44 1998 Kristian Nielsen <kristian.nielsen@risoe.dk> * [configure.in] [include/acconfig.h] [include/thread.h] [scheduler/sysdeps.c] Autoconfig test for non-reentrant libc. Wed Sep 23 19:52:12 1998 Matthew Becker <mbecker@glasscity.net> * [*/*.c] Miscellaneous documentation updates and debugging output standardizations. * [objects/clipping.c] Added ExtSelectClipRgn. Wed Sep 23 00:03:28 EDT 1998 Pete Ratzlaff <pratzlaff@cfa.harvard.edu> * [include/windows.h] [if1632/user.spec] [relay32/user32.spec] [windows/keyboard.c] Added, marginally implemented, GetKeyboardLayoutName(). Only returns US English keyboard name. Tue Sep 22 16:32:41 1998 Marcel Baur <mbaur@iiic.ethz.ch> * [programs/control/*] New Winelib application. Mon Sep 21 00:29:18 1998 Peter Hunnisett <hunnise@nortel.ca> * [include/dplay.h][multimedia/dplay.c][ole/compobj.c] Added all DirectPlayLobby interfaces and enhanced DirectPlay and DirectPlayLobby support. Still not all that much. Useful enough if you just need to start a program, don't try any real dplay/lobby stuff. * [documentation/status/directplay] Added a very little bit. * [graphics/ddraw.c] - Call to SetWindowLong32A wasn't working because there was no memory set aside when the window class was registered. - Fixed some xlib reference counting and change the behaviour of DirectDrawSurface3_SetPalette to mimic observed behaviour (palette is associated will all backbuffers) - Also stored all palette colour fields and spit back our saved colour fields rather than query X for them. - Added plenty of AddRef and Release traces. - Added Xlib support for using -desktop option. - Fixed Xlib message handling. Messages weren't being passed to the application. Fixes mouse movements in some xlib DDraw games. - Added a few stubs. * [windows/win.c][include/winerror.h] Fixed up some error handling in WIN_SetWindowLong. SetLastError wasn't being used. Could cause problems with 0 return codes. Added new error in winerror (1400). * [AUTHORS] [include/authors.h] Added myself as a Wine author. Sun Sep 20 21:22:44 1998 Alexander Larsson <alla@lysator.liu.se> * [loader/module.c] Changed GetModuleFileName32A so that is returns the long version of the filename. Note that just the name is long, not the directories. Sat Sep 19 20:05:30 1998 Per Ångström <pang@mind.nu> * [controls/menu.c] Made a couple of fixes to make life easier for applications that alter their menus at runtime. * [windows/defdlg.c] Removed the cast of the return value from dialog procedures to a 16-bit bool. The return value needs to retain all its 32 bits, since it is not always a bool, such as when responding to the WM_NCHITTEST message. Fri Sep 18 11:30:38 1998 Sergey Turchanov <turchanov@usa.net> * [loader/resource.c] Fixed very funny bug (though gravely affecting further excecution) with FindResource[Ex]32 functions. * [include/multimon.h] [windows/multimon.c] [relay32/user32.spec] [include/windows.h] [windows/sysmetrics.c] Default implementation for Multimonitor API. * [include/windows.h] [windows/winpos.c] Fixed incorrect declaration (and behaviour) of GetWindowRect32. Wed Sep 16 10:21:15 1998 Gerard Patel <G.Patel@Wanadoo.fr> * [controls/edit.c] Fixed EDIT_EM_GetLine to use correctly length of lines. Tue Sep 15 20:40:16 1998 Eric Kohl <ekohl@abo.rhein-zeitung.de> * [misc/tweak.c][include/tweak.h][controls/menu.c] Replaced the tweak graphic routines by calls to DrawEdge32(). * [misc/tweak.c][include/tweak.h][documentation/win95look] [wine.ini][*/*] Changed "look and feel" selection. Allows Win3.1, Win95 and Win98 (no GUI code implemented) look and feel. * [dlls/comctl32/header.c][include/header.h][include/commctrl.h] Started callback item support and did some minor improvements. * [dlls/comctl32/imagelist.c] Fixed bug in transparent image display. ImageList_GetIcon is still buggy :-( * [dlls/comctl32/toolbar.c] Fixed button drawing (partial hack). * [dlls/comctl32/commctrl.c] Fixed MenuHelp(). * [controls/button.c] Added 3d effect for groupbox. * [windows/msgbox.c] Added font support for message boxes. * [windows/nonclient.c] Fixed window moving bug. * [dlls/comctl32/*.c] Various improvements. * [dlls/comctl32/listview.c][dlls/comctl32/rebar.c] [include/commctrl.h] More messages. * [windows/syscolor.c][include/windows.h] Introduced new Win98 system colors. Tue Sep 15 18:29:45 1998 Wesley Filardo <eightknots@aol.com> * [files/profile.c] Added support in PROFILE_LoadWineIni for -config option * [misc/main.c] [include/options.h] Added -config option. Tue Sep 15 18:22:26 1998 Petter Reinholdtsen <pere@td.org.uit.no> * [documentation/Makefile.in] Make sure directory exists before installing into it. Tue Sep 15 01:47:33 1998 Pablo Saratxaga <pablo.sarachaga@ping.be> * [ole/nls/*] [ole/ole2nls.c] [include/winnls.h] Fixed a few errors and completed some NLS files. Mon Sep 14 01:23:45 1998 Joseph Pranevich <knight@baltimore.wwaves.com> * [include/miscemu.h] [msdos/interrupts.c] Removed a compilation warning, added INT 25 to the list of interrupts callable from DOS applications, added a debug message when unsupported interrupts are used. Sun Sep 13 19:55:22 1998 Lawson Whitney <lawson_whitney@juno.com> * [if1632/relay.c] CallProcEx32W should not reverse arguments. Sun Aug 17 21:18:12 1998 Eric Pouech <eric.pouech@lemel.fr> * [multimedia/midi.c] [multimedia/init.c] [multimedia/mmsys.c] [include/multimedia.h] [include/mmsystem.h] [multimedia/Makefile.in] [multimedia/midipatch.c] [if1632/multimedia.spec] Made MIDI input and output functional on OSS capable systems. * [multimedia/timer.c] Changes to trigger callbacks at the accurate pace even when fake timers are used.
1928 lines
59 KiB
C
1928 lines
59 KiB
C
/*
|
|
* Dialog functions
|
|
*
|
|
* Copyright 1993, 1994, 1996 Alexandre Julliard
|
|
*/
|
|
|
|
#include <ctype.h>
|
|
#include <sys/errno.h>
|
|
#include <limits.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include "windows.h"
|
|
#include "dialog.h"
|
|
#include "drive.h"
|
|
#include "heap.h"
|
|
#include "win.h"
|
|
#include "ldt.h"
|
|
#include "user.h"
|
|
#include "winproc.h"
|
|
#include "message.h"
|
|
#include "sysmetrics.h"
|
|
#include "debug.h"
|
|
|
|
|
|
/* Dialog control information */
|
|
typedef struct
|
|
{
|
|
DWORD style;
|
|
DWORD exStyle;
|
|
DWORD helpId;
|
|
INT16 x;
|
|
INT16 y;
|
|
INT16 cx;
|
|
INT16 cy;
|
|
UINT32 id;
|
|
LPCSTR className;
|
|
LPCSTR windowName;
|
|
LPVOID data;
|
|
} DLG_CONTROL_INFO;
|
|
|
|
/* Dialog template */
|
|
typedef struct
|
|
{
|
|
DWORD style;
|
|
DWORD exStyle;
|
|
DWORD helpId;
|
|
UINT16 nbItems;
|
|
INT16 x;
|
|
INT16 y;
|
|
INT16 cx;
|
|
INT16 cy;
|
|
LPCSTR menuName;
|
|
LPCSTR className;
|
|
LPCSTR caption;
|
|
WORD pointSize;
|
|
WORD weight;
|
|
BOOL32 italic;
|
|
LPCSTR faceName;
|
|
BOOL32 dialogEx;
|
|
} DLG_TEMPLATE;
|
|
|
|
/* Dialog base units */
|
|
static WORD xBaseUnit = 0, yBaseUnit = 0;
|
|
|
|
|
|
/***********************************************************************
|
|
* DIALOG_Init
|
|
*
|
|
* Initialisation of the dialog manager.
|
|
*/
|
|
BOOL32 DIALOG_Init(void)
|
|
{
|
|
TEXTMETRIC16 tm;
|
|
HDC16 hdc;
|
|
|
|
/* Calculate the dialog base units */
|
|
|
|
if (!(hdc = CreateDC16( "DISPLAY", NULL, NULL, NULL ))) return FALSE;
|
|
GetTextMetrics16( hdc, &tm );
|
|
DeleteDC32( hdc );
|
|
xBaseUnit = tm.tmAveCharWidth;
|
|
yBaseUnit = tm.tmHeight;
|
|
|
|
/* Dialog units are based on a proportional system font */
|
|
/* so we adjust them a bit for a fixed font. */
|
|
if (!(tm.tmPitchAndFamily & TMPF_FIXED_PITCH))
|
|
xBaseUnit = xBaseUnit * 5 / 4;
|
|
|
|
TRACE(dialog, "base units = %d,%d\n",
|
|
xBaseUnit, yBaseUnit );
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DIALOG_GetControl16
|
|
*
|
|
* Return the class and text of the control pointed to by ptr,
|
|
* fill the header structure and return a pointer to the next control.
|
|
*/
|
|
static LPCSTR DIALOG_GetControl16( LPCSTR p, DLG_CONTROL_INFO *info )
|
|
{
|
|
static char buffer[10];
|
|
int int_id;
|
|
|
|
info->x = GET_WORD(p); p += sizeof(WORD);
|
|
info->y = GET_WORD(p); p += sizeof(WORD);
|
|
info->cx = GET_WORD(p); p += sizeof(WORD);
|
|
info->cy = GET_WORD(p); p += sizeof(WORD);
|
|
info->id = GET_WORD(p); p += sizeof(WORD);
|
|
info->style = GET_DWORD(p); p += sizeof(DWORD);
|
|
info->exStyle = 0;
|
|
|
|
if (*p & 0x80)
|
|
{
|
|
switch((BYTE)*p)
|
|
{
|
|
case 0x80: strcpy( buffer, "BUTTON" ); break;
|
|
case 0x81: strcpy( buffer, "EDIT" ); break;
|
|
case 0x82: strcpy( buffer, "STATIC" ); break;
|
|
case 0x83: strcpy( buffer, "LISTBOX" ); break;
|
|
case 0x84: strcpy( buffer, "SCROLLBAR" ); break;
|
|
case 0x85: strcpy( buffer, "COMBOBOX" ); break;
|
|
default: buffer[0] = '\0'; break;
|
|
}
|
|
info->className = buffer;
|
|
p++;
|
|
}
|
|
else
|
|
{
|
|
info->className = p;
|
|
p += strlen(p) + 1;
|
|
}
|
|
|
|
int_id = ((BYTE)*p == 0xff);
|
|
if (int_id)
|
|
{
|
|
/* Integer id, not documented (?). Only works for SS_ICON controls */
|
|
info->windowName = (LPCSTR)(UINT32)GET_WORD(p+1);
|
|
p += 3;
|
|
}
|
|
else
|
|
{
|
|
info->windowName = p;
|
|
p += strlen(p) + 1;
|
|
}
|
|
|
|
info->data = (LPVOID)(*p ? p + 1 : NULL); /* FIXME: should be a segptr */
|
|
p += *p + 1;
|
|
|
|
if(int_id)
|
|
TRACE(dialog," %s %04x %d, %d, %d, %d, %d, %08lx, %08lx\n",
|
|
info->className, LOWORD(info->windowName),
|
|
info->id, info->x, info->y, info->cx, info->cy,
|
|
info->style, (DWORD)info->data);
|
|
else
|
|
TRACE(dialog," %s '%s' %d, %d, %d, %d, %d, %08lx, %08lx\n",
|
|
info->className, info->windowName,
|
|
info->id, info->x, info->y, info->cx, info->cy,
|
|
info->style, (DWORD)info->data);
|
|
|
|
return p;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DIALOG_GetControl32
|
|
*
|
|
* Return the class and text of the control pointed to by ptr,
|
|
* fill the header structure and return a pointer to the next control.
|
|
*/
|
|
static const WORD *DIALOG_GetControl32( const WORD *p, DLG_CONTROL_INFO *info,
|
|
BOOL32 dialogEx )
|
|
{
|
|
if (dialogEx)
|
|
{
|
|
info->helpId = GET_DWORD(p); p += 2;
|
|
info->exStyle = GET_DWORD(p); p += 2;
|
|
info->style = GET_DWORD(p); p += 2;
|
|
}
|
|
else
|
|
{
|
|
info->helpId = 0;
|
|
info->style = GET_DWORD(p); p += 2;
|
|
info->exStyle = GET_DWORD(p); p += 2;
|
|
}
|
|
info->x = GET_WORD(p); p++;
|
|
info->y = GET_WORD(p); p++;
|
|
info->cx = GET_WORD(p); p++;
|
|
info->cy = GET_WORD(p); p++;
|
|
|
|
if (dialogEx)
|
|
{
|
|
/* id is a DWORD for DIALOGEX */
|
|
info->id = GET_DWORD(p);
|
|
p += 2;
|
|
}
|
|
else
|
|
{
|
|
info->id = GET_WORD(p);
|
|
p++;
|
|
}
|
|
|
|
if (GET_WORD(p) == 0xffff)
|
|
{
|
|
static const WCHAR class_names[6][10] =
|
|
{
|
|
{ 'B','u','t','t','o','n', }, /* 0x80 */
|
|
{ 'E','d','i','t', }, /* 0x81 */
|
|
{ 'S','t','a','t','i','c', }, /* 0x82 */
|
|
{ 'L','i','s','t','B','o','x', }, /* 0x83 */
|
|
{ 'S','c','r','o','l','l','B','a','r', }, /* 0x84 */
|
|
{ 'C','o','m','b','o','B','o','x', } /* 0x85 */
|
|
};
|
|
WORD id = GET_WORD(p+1);
|
|
if ((id >= 0x80) && (id <= 0x85))
|
|
info->className = (LPCSTR)class_names[id - 0x80];
|
|
else
|
|
{
|
|
info->className = NULL;
|
|
ERR( dialog, "Unknown built-in class id %04x\n", id );
|
|
}
|
|
p += 2;
|
|
}
|
|
else
|
|
{
|
|
info->className = (LPCSTR)p;
|
|
p += lstrlen32W( (LPCWSTR)p ) + 1;
|
|
}
|
|
|
|
if (GET_WORD(p) == 0xffff) /* Is it an integer id? */
|
|
{
|
|
info->windowName = (LPCSTR)(UINT32)GET_WORD(p + 1);
|
|
p += 2;
|
|
}
|
|
else
|
|
{
|
|
info->windowName = (LPCSTR)p;
|
|
p += lstrlen32W( (LPCWSTR)p ) + 1;
|
|
}
|
|
|
|
TRACE(dialog," %s %s %d, %d, %d, %d, %d, %08lx, %08lx, %08lx\n",
|
|
debugstr_w( (LPCWSTR)info->className ),
|
|
debugres_w( (LPCWSTR)info->windowName ),
|
|
info->id, info->x, info->y, info->cx, info->cy,
|
|
info->style, info->exStyle, info->helpId );
|
|
|
|
if (GET_WORD(p))
|
|
{
|
|
if (TRACE_ON(dialog))
|
|
{
|
|
WORD i, count = GET_WORD(p) / sizeof(WORD);
|
|
TRACE(dialog, " BEGIN\n");
|
|
TRACE(dialog, " ");
|
|
for (i = 0; i < count; i++) DUMP( "%04x,", GET_WORD(p+i+1) );
|
|
DUMP("\n");
|
|
TRACE(dialog, " END\n" );
|
|
}
|
|
info->data = (LPVOID)(p + 1);
|
|
p += GET_WORD(p) / sizeof(WORD);
|
|
}
|
|
else info->data = NULL;
|
|
p++;
|
|
|
|
/* Next control is on dword boundary */
|
|
return (const WORD *)((((int)p) + 3) & ~3);
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DIALOG_CreateControls
|
|
*
|
|
* Create the control windows for a dialog.
|
|
*/
|
|
static BOOL32 DIALOG_CreateControls( WND *pWnd, LPCSTR template,
|
|
const DLG_TEMPLATE *dlgTemplate,
|
|
HINSTANCE32 hInst, BOOL32 win32 )
|
|
{
|
|
DIALOGINFO *dlgInfo = (DIALOGINFO *)pWnd->wExtra;
|
|
DLG_CONTROL_INFO info;
|
|
HWND32 hwndCtrl, hwndDefButton = 0;
|
|
INT32 items = dlgTemplate->nbItems;
|
|
|
|
TRACE(dialog, " BEGIN\n" );
|
|
while (items--)
|
|
{
|
|
if (!win32)
|
|
{
|
|
HINSTANCE16 instance;
|
|
template = DIALOG_GetControl16( template, &info );
|
|
if (HIWORD(info.className) && !strcmp( info.className, "EDIT") &&
|
|
((pWnd->dwStyle & DS_LOCALEDIT) != DS_LOCALEDIT))
|
|
{
|
|
if (!dlgInfo->hDialogHeap)
|
|
{
|
|
dlgInfo->hDialogHeap = GlobalAlloc16(GMEM_FIXED, 0x10000);
|
|
if (!dlgInfo->hDialogHeap)
|
|
{
|
|
ERR(dialog, "Insufficient memory to create heap for edit control\n" );
|
|
continue;
|
|
}
|
|
LocalInit(dlgInfo->hDialogHeap, 0, 0xffff);
|
|
}
|
|
instance = dlgInfo->hDialogHeap;
|
|
}
|
|
else instance = (HINSTANCE16)hInst;
|
|
|
|
hwndCtrl = CreateWindowEx16( info.exStyle | WS_EX_NOPARENTNOTIFY,
|
|
info.className, info.windowName,
|
|
info.style | WS_CHILD,
|
|
info.x * dlgInfo->xBaseUnit / 4,
|
|
info.y * dlgInfo->yBaseUnit / 8,
|
|
info.cx * dlgInfo->xBaseUnit / 4,
|
|
info.cy * dlgInfo->yBaseUnit / 8,
|
|
pWnd->hwndSelf, (HMENU16)info.id,
|
|
instance, info.data );
|
|
}
|
|
else
|
|
{
|
|
template = (LPCSTR)DIALOG_GetControl32( (WORD *)template, &info,
|
|
dlgTemplate->dialogEx );
|
|
hwndCtrl = CreateWindowEx32W( info.exStyle | WS_EX_NOPARENTNOTIFY,
|
|
(LPCWSTR)info.className,
|
|
(LPCWSTR)info.windowName,
|
|
info.style | WS_CHILD,
|
|
info.x * dlgInfo->xBaseUnit / 4,
|
|
info.y * dlgInfo->yBaseUnit / 8,
|
|
info.cx * dlgInfo->xBaseUnit / 4,
|
|
info.cy * dlgInfo->yBaseUnit / 8,
|
|
pWnd->hwndSelf, (HMENU32)info.id,
|
|
hInst, info.data );
|
|
}
|
|
if (!hwndCtrl) return FALSE;
|
|
|
|
/* Send initialisation messages to the control */
|
|
if (dlgInfo->hUserFont) SendMessage32A( hwndCtrl, WM_SETFONT,
|
|
(WPARAM32)dlgInfo->hUserFont, 0 );
|
|
if (SendMessage32A(hwndCtrl, WM_GETDLGCODE, 0, 0) & DLGC_DEFPUSHBUTTON)
|
|
{
|
|
/* If there's already a default push-button, set it back */
|
|
/* to normal and use this one instead. */
|
|
if (hwndDefButton)
|
|
SendMessage32A( hwndDefButton, BM_SETSTYLE32,
|
|
BS_PUSHBUTTON,FALSE );
|
|
hwndDefButton = hwndCtrl;
|
|
dlgInfo->idResult = GetWindowWord32( hwndCtrl, GWW_ID );
|
|
}
|
|
}
|
|
TRACE(dialog, " END\n" );
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DIALOG_ParseTemplate16
|
|
*
|
|
* Fill a DLG_TEMPLATE structure from the dialog template, and return
|
|
* a pointer to the first control.
|
|
*/
|
|
static LPCSTR DIALOG_ParseTemplate16( LPCSTR p, DLG_TEMPLATE * result )
|
|
{
|
|
result->style = GET_DWORD(p); p += sizeof(DWORD);
|
|
result->exStyle = 0;
|
|
result->nbItems = *p++;
|
|
result->x = GET_WORD(p); p += sizeof(WORD);
|
|
result->y = GET_WORD(p); p += sizeof(WORD);
|
|
result->cx = GET_WORD(p); p += sizeof(WORD);
|
|
result->cy = GET_WORD(p); p += sizeof(WORD);
|
|
TRACE(dialog, "DIALOG %d, %d, %d, %d\n",
|
|
result->x, result->y, result->cx, result->cy );
|
|
TRACE(dialog, " STYLE %08lx\n", result->style );
|
|
|
|
/* Get the menu name */
|
|
|
|
switch( (BYTE)*p )
|
|
{
|
|
case 0:
|
|
result->menuName = 0;
|
|
p++;
|
|
break;
|
|
case 0xff:
|
|
result->menuName = (LPCSTR)(UINT32)GET_WORD( p + 1 );
|
|
p += 3;
|
|
TRACE(dialog, " MENU %04x\n", LOWORD(result->menuName) );
|
|
break;
|
|
default:
|
|
result->menuName = p;
|
|
TRACE(dialog, " MENU '%s'\n", p );
|
|
p += strlen(p) + 1;
|
|
break;
|
|
}
|
|
|
|
/* Get the class name */
|
|
|
|
if (*p)
|
|
{
|
|
result->className = p;
|
|
TRACE(dialog, " CLASS '%s'\n", result->className );
|
|
}
|
|
else result->className = DIALOG_CLASS_ATOM;
|
|
p += strlen(p) + 1;
|
|
|
|
/* Get the window caption */
|
|
|
|
result->caption = p;
|
|
p += strlen(p) + 1;
|
|
TRACE(dialog, " CAPTION '%s'\n", result->caption );
|
|
|
|
/* Get the font name */
|
|
|
|
if (result->style & DS_SETFONT)
|
|
{
|
|
result->pointSize = GET_WORD(p);
|
|
p += sizeof(WORD);
|
|
result->faceName = p;
|
|
p += strlen(p) + 1;
|
|
TRACE(dialog, " FONT %d,'%s'\n",
|
|
result->pointSize, result->faceName );
|
|
}
|
|
return p;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DIALOG_ParseTemplate32
|
|
*
|
|
* Fill a DLG_TEMPLATE structure from the dialog template, and return
|
|
* a pointer to the first control.
|
|
*/
|
|
static LPCSTR DIALOG_ParseTemplate32( LPCSTR template, DLG_TEMPLATE * result )
|
|
{
|
|
const WORD *p = (const WORD *)template;
|
|
|
|
result->style = GET_DWORD(p); p += 2;
|
|
if (result->style == 0xffff0001) /* DIALOGEX resource */
|
|
{
|
|
result->dialogEx = TRUE;
|
|
result->helpId = GET_DWORD(p); p += 2;
|
|
result->exStyle = GET_DWORD(p); p += 2;
|
|
result->style = GET_DWORD(p); p += 2;
|
|
}
|
|
else
|
|
{
|
|
result->dialogEx = FALSE;
|
|
result->helpId = 0;
|
|
result->exStyle = GET_DWORD(p); p += 2;
|
|
}
|
|
result->nbItems = GET_WORD(p); p++;
|
|
result->x = GET_WORD(p); p++;
|
|
result->y = GET_WORD(p); p++;
|
|
result->cx = GET_WORD(p); p++;
|
|
result->cy = GET_WORD(p); p++;
|
|
TRACE( dialog, "DIALOG%s %d, %d, %d, %d, %ld\n",
|
|
result->dialogEx ? "EX" : "", result->x, result->y,
|
|
result->cx, result->cy, result->helpId );
|
|
TRACE( dialog, " STYLE 0x%08lx\n", result->style );
|
|
TRACE( dialog, " EXSTYLE 0x%08lx\n", result->exStyle );
|
|
|
|
/* Get the menu name */
|
|
|
|
switch(GET_WORD(p))
|
|
{
|
|
case 0x0000:
|
|
result->menuName = NULL;
|
|
p++;
|
|
break;
|
|
case 0xffff:
|
|
result->menuName = (LPCSTR)(UINT32)GET_WORD( p + 1 );
|
|
p += 2;
|
|
TRACE(dialog, " MENU %04x\n", LOWORD(result->menuName) );
|
|
break;
|
|
default:
|
|
result->menuName = (LPCSTR)p;
|
|
TRACE(dialog, " MENU %s\n", debugstr_w( (LPCWSTR)p ));
|
|
p += lstrlen32W( (LPCWSTR)p ) + 1;
|
|
break;
|
|
}
|
|
|
|
/* Get the class name */
|
|
|
|
switch(GET_WORD(p))
|
|
{
|
|
case 0x0000:
|
|
result->className = DIALOG_CLASS_ATOM;
|
|
p++;
|
|
break;
|
|
case 0xffff:
|
|
result->className = (LPCSTR)(UINT32)GET_WORD( p + 1 );
|
|
p += 2;
|
|
TRACE(dialog, " CLASS %04x\n", LOWORD(result->className) );
|
|
break;
|
|
default:
|
|
result->className = (LPCSTR)p;
|
|
TRACE(dialog, " CLASS %s\n", debugstr_w( (LPCWSTR)p ));
|
|
p += lstrlen32W( (LPCWSTR)p ) + 1;
|
|
break;
|
|
}
|
|
|
|
/* Get the window caption */
|
|
|
|
result->caption = (LPCSTR)p;
|
|
p += lstrlen32W( (LPCWSTR)p ) + 1;
|
|
TRACE(dialog, " CAPTION %s\n", debugstr_w( (LPCWSTR)result->caption ) );
|
|
|
|
/* Get the font name */
|
|
|
|
if (result->style & DS_SETFONT)
|
|
{
|
|
result->pointSize = GET_WORD(p);
|
|
p++;
|
|
if (result->dialogEx)
|
|
{
|
|
result->weight = GET_WORD(p); p++;
|
|
result->italic = LOBYTE(GET_WORD(p)); p++;
|
|
}
|
|
else
|
|
{
|
|
result->weight = FW_DONTCARE;
|
|
result->italic = FALSE;
|
|
}
|
|
result->faceName = (LPCSTR)p;
|
|
p += lstrlen32W( (LPCWSTR)p ) + 1;
|
|
TRACE(dialog, " FONT %d, %s, %d, %s\n",
|
|
result->pointSize, debugstr_w( (LPCWSTR)result->faceName ),
|
|
result->weight, result->italic ? "TRUE" : "FALSE" );
|
|
}
|
|
|
|
/* First control is on dword boundary */
|
|
return (LPCSTR)((((int)p) + 3) & ~3);
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DIALOG_CreateIndirect
|
|
*/
|
|
HWND32 DIALOG_CreateIndirect( HINSTANCE32 hInst, LPCSTR dlgTemplate,
|
|
BOOL32 win32Template, HWND32 owner,
|
|
DLGPROC16 dlgProc, LPARAM param,
|
|
WINDOWPROCTYPE procType )
|
|
{
|
|
HMENU16 hMenu = 0;
|
|
HFONT16 hFont = 0;
|
|
HWND32 hwnd;
|
|
RECT32 rect;
|
|
WND * wndPtr;
|
|
DLG_TEMPLATE template;
|
|
DIALOGINFO * dlgInfo;
|
|
WORD xUnit = xBaseUnit;
|
|
WORD yUnit = yBaseUnit;
|
|
|
|
/* Parse dialog template */
|
|
|
|
if (!dlgTemplate) return 0;
|
|
if (win32Template)
|
|
dlgTemplate = DIALOG_ParseTemplate32( dlgTemplate, &template );
|
|
else
|
|
dlgTemplate = DIALOG_ParseTemplate16( dlgTemplate, &template );
|
|
|
|
/* Load menu */
|
|
|
|
if (template.menuName)
|
|
{
|
|
if (!win32Template)
|
|
{
|
|
LPSTR str = SEGPTR_STRDUP( template.menuName );
|
|
hMenu = LoadMenu16( hInst, SEGPTR_GET(str) );
|
|
SEGPTR_FREE( str );
|
|
}
|
|
else hMenu = LoadMenu32W( hInst, (LPCWSTR)template.menuName );
|
|
}
|
|
|
|
/* Create custom font if needed */
|
|
|
|
if (template.style & DS_SETFONT)
|
|
{
|
|
/* The font height must be negative as it is a point size */
|
|
/* (see CreateFont() documentation in the Windows SDK). */
|
|
|
|
if (win32Template)
|
|
hFont = CreateFont32W( -template.pointSize, 0, 0, 0,
|
|
template.weight, template.italic, FALSE,
|
|
FALSE, DEFAULT_CHARSET, 0, 0, PROOF_QUALITY,
|
|
FF_DONTCARE, (LPCWSTR)template.faceName );
|
|
else
|
|
hFont = CreateFont16( -template.pointSize, 0, 0, 0, FW_DONTCARE,
|
|
FALSE, FALSE, FALSE, DEFAULT_CHARSET, 0, 0,
|
|
PROOF_QUALITY, FF_DONTCARE,
|
|
template.faceName );
|
|
if (hFont)
|
|
{
|
|
TEXTMETRIC16 tm;
|
|
HFONT16 oldFont;
|
|
|
|
HDC32 hdc = GetDC32(0);
|
|
oldFont = SelectObject32( hdc, hFont );
|
|
GetTextMetrics16( hdc, &tm );
|
|
SelectObject32( hdc, oldFont );
|
|
ReleaseDC32( 0, hdc );
|
|
xUnit = tm.tmAveCharWidth;
|
|
yUnit = tm.tmHeight;
|
|
if (!(tm.tmPitchAndFamily & TMPF_FIXED_PITCH))
|
|
xBaseUnit = xBaseUnit * 5 / 4; /* See DIALOG_Init() */
|
|
}
|
|
}
|
|
|
|
/* Create dialog main window */
|
|
|
|
rect.left = rect.top = 0;
|
|
rect.right = template.cx * xUnit / 4;
|
|
rect.bottom = template.cy * yUnit / 8;
|
|
if (template.style & DS_MODALFRAME)
|
|
template.exStyle |= WS_EX_DLGMODALFRAME;
|
|
AdjustWindowRectEx32( &rect, template.style,
|
|
hMenu ? TRUE : FALSE , template.exStyle );
|
|
rect.right -= rect.left;
|
|
rect.bottom -= rect.top;
|
|
|
|
if ((INT16)template.x == CW_USEDEFAULT16)
|
|
{
|
|
rect.left = rect.top = (procType == WIN_PROC_16) ? CW_USEDEFAULT16
|
|
: CW_USEDEFAULT32;
|
|
}
|
|
else
|
|
{
|
|
rect.left += template.x * xUnit / 4;
|
|
rect.top += template.y * yUnit / 8;
|
|
if ( !(template.style & WS_CHILD) )
|
|
{
|
|
INT16 dX, dY;
|
|
|
|
if( !(template.style & DS_ABSALIGN) )
|
|
ClientToScreen32( owner, (POINT32 *)&rect );
|
|
|
|
/* try to fit it into the desktop */
|
|
|
|
if( (dX = rect.left + rect.right + SYSMETRICS_CXDLGFRAME
|
|
- SYSMETRICS_CXSCREEN) > 0 ) rect.left -= dX;
|
|
if( (dY = rect.top + rect.bottom + SYSMETRICS_CYDLGFRAME
|
|
- SYSMETRICS_CYSCREEN) > 0 ) rect.top -= dY;
|
|
if( rect.left < 0 ) rect.left = 0;
|
|
if( rect.top < 0 ) rect.top = 0;
|
|
}
|
|
}
|
|
|
|
if (procType == WIN_PROC_16)
|
|
hwnd = CreateWindowEx16(template.exStyle, template.className,
|
|
template.caption, template.style & ~WS_VISIBLE,
|
|
rect.left, rect.top, rect.right, rect.bottom,
|
|
owner, hMenu, hInst, NULL );
|
|
else
|
|
hwnd = CreateWindowEx32W(template.exStyle, (LPCWSTR)template.className,
|
|
(LPCWSTR)template.caption,
|
|
template.style & ~WS_VISIBLE,
|
|
rect.left, rect.top, rect.right, rect.bottom,
|
|
owner, hMenu, hInst, NULL );
|
|
|
|
if (!hwnd)
|
|
{
|
|
if (hFont) DeleteObject32( hFont );
|
|
if (hMenu) DestroyMenu32( hMenu );
|
|
return 0;
|
|
}
|
|
wndPtr = WIN_FindWndPtr( hwnd );
|
|
wndPtr->flags |= WIN_ISDIALOG;
|
|
wndPtr->helpContext = template.helpId;
|
|
|
|
/* Initialise dialog extra data */
|
|
|
|
dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
|
|
WINPROC_SetProc( &dlgInfo->dlgProc, dlgProc, procType, WIN_PROC_WINDOW );
|
|
dlgInfo->hUserFont = hFont;
|
|
dlgInfo->hMenu = hMenu;
|
|
dlgInfo->xBaseUnit = xUnit;
|
|
dlgInfo->yBaseUnit = yUnit;
|
|
dlgInfo->msgResult = 0;
|
|
dlgInfo->idResult = 0;
|
|
dlgInfo->flags = 0;
|
|
dlgInfo->hDialogHeap = 0;
|
|
|
|
if (dlgInfo->hUserFont)
|
|
SendMessage32A( hwnd, WM_SETFONT, (WPARAM32)dlgInfo->hUserFont, 0 );
|
|
|
|
/* Create controls */
|
|
|
|
if (DIALOG_CreateControls( wndPtr, dlgTemplate, &template,
|
|
hInst, win32Template ))
|
|
{
|
|
/* Send initialisation messages and set focus */
|
|
|
|
dlgInfo->hwndFocus = GetNextDlgTabItem32( hwnd, 0, FALSE );
|
|
|
|
if (SendMessage32A( hwnd, WM_INITDIALOG, (WPARAM32)dlgInfo->hwndFocus, param ))
|
|
SetFocus32( dlgInfo->hwndFocus );
|
|
|
|
if (template.style & WS_VISIBLE && !(wndPtr->dwStyle & WS_VISIBLE))
|
|
{
|
|
ShowWindow32( hwnd, SW_SHOWNORMAL ); /* SW_SHOW doesn't always work */
|
|
UpdateWindow32( hwnd );
|
|
}
|
|
return hwnd;
|
|
}
|
|
|
|
if( IsWindow32(hwnd) ) DestroyWindow32( hwnd );
|
|
return 0;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* CreateDialog16 (USER.89)
|
|
*/
|
|
HWND16 WINAPI CreateDialog16( HINSTANCE16 hInst, SEGPTR dlgTemplate,
|
|
HWND16 owner, DLGPROC16 dlgProc )
|
|
{
|
|
return CreateDialogParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* CreateDialogParam16 (USER.241)
|
|
*/
|
|
HWND16 WINAPI CreateDialogParam16( HINSTANCE16 hInst, SEGPTR dlgTemplate,
|
|
HWND16 owner, DLGPROC16 dlgProc,
|
|
LPARAM param )
|
|
{
|
|
HWND16 hwnd = 0;
|
|
HRSRC16 hRsrc;
|
|
HGLOBAL16 hmem;
|
|
LPCVOID data;
|
|
|
|
TRACE(dialog, "%04x,%08lx,%04x,%08lx,%ld\n",
|
|
hInst, (DWORD)dlgTemplate, owner, (DWORD)dlgProc, param );
|
|
|
|
if (!(hRsrc = FindResource16( hInst, dlgTemplate, RT_DIALOG16 ))) return 0;
|
|
if (!(hmem = LoadResource16( hInst, hRsrc ))) return 0;
|
|
if (!(data = LockResource16( hmem ))) hwnd = 0;
|
|
else hwnd = CreateDialogIndirectParam16( hInst, data, owner,
|
|
dlgProc, param );
|
|
FreeResource16( hmem );
|
|
return hwnd;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* CreateDialogParam32A (USER32.73)
|
|
*/
|
|
HWND32 WINAPI CreateDialogParam32A( HINSTANCE32 hInst, LPCSTR name,
|
|
HWND32 owner, DLGPROC32 dlgProc,
|
|
LPARAM param )
|
|
{
|
|
if (HIWORD(name))
|
|
{
|
|
LPWSTR str = HEAP_strdupAtoW( GetProcessHeap(), 0, name );
|
|
HWND32 hwnd = CreateDialogParam32W( hInst, str, owner, dlgProc, param);
|
|
HeapFree( GetProcessHeap(), 0, str );
|
|
return hwnd;
|
|
}
|
|
return CreateDialogParam32W( hInst, (LPCWSTR)name, owner, dlgProc, param );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* CreateDialogParam32W (USER32.74)
|
|
*/
|
|
HWND32 WINAPI CreateDialogParam32W( HINSTANCE32 hInst, LPCWSTR name,
|
|
HWND32 owner, DLGPROC32 dlgProc,
|
|
LPARAM param )
|
|
{
|
|
HANDLE32 hrsrc = FindResource32W( hInst, name, RT_DIALOG32W );
|
|
if (!hrsrc) return 0;
|
|
return CreateDialogIndirectParam32W( hInst,
|
|
(LPVOID)LoadResource32(hInst, hrsrc),
|
|
owner, dlgProc, param );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* CreateDialogIndirect16 (USER.219)
|
|
*/
|
|
HWND16 WINAPI CreateDialogIndirect16( HINSTANCE16 hInst, LPCVOID dlgTemplate,
|
|
HWND16 owner, DLGPROC16 dlgProc )
|
|
{
|
|
return CreateDialogIndirectParam16( hInst, dlgTemplate, owner, dlgProc, 0);
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* CreateDialogIndirectParam16 (USER.242)
|
|
*/
|
|
HWND16 WINAPI CreateDialogIndirectParam16( HINSTANCE16 hInst,
|
|
LPCVOID dlgTemplate,
|
|
HWND16 owner, DLGPROC16 dlgProc,
|
|
LPARAM param )
|
|
{
|
|
return DIALOG_CreateIndirect( hInst, dlgTemplate, FALSE, owner,
|
|
dlgProc, param, WIN_PROC_16 );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* CreateDialogIndirectParam32A (USER32.69)
|
|
*/
|
|
HWND32 WINAPI CreateDialogIndirectParam32A( HINSTANCE32 hInst,
|
|
LPCVOID dlgTemplate,
|
|
HWND32 owner, DLGPROC32 dlgProc,
|
|
LPARAM param )
|
|
{
|
|
return DIALOG_CreateIndirect( hInst, dlgTemplate, TRUE, owner,
|
|
(DLGPROC16)dlgProc, param, WIN_PROC_32A );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* CreateDialogIndirectParam32W (USER32.72)
|
|
*/
|
|
HWND32 WINAPI CreateDialogIndirectParam32W( HINSTANCE32 hInst,
|
|
LPCVOID dlgTemplate,
|
|
HWND32 owner, DLGPROC32 dlgProc,
|
|
LPARAM param )
|
|
{
|
|
return DIALOG_CreateIndirect( hInst, dlgTemplate, TRUE, owner,
|
|
(DLGPROC16)dlgProc, param, WIN_PROC_32W );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DIALOG_DoDialogBox
|
|
*/
|
|
INT32 DIALOG_DoDialogBox( HWND32 hwnd, HWND32 owner )
|
|
{
|
|
WND * wndPtr;
|
|
DIALOGINFO * dlgInfo;
|
|
MSG16 msg;
|
|
INT32 retval;
|
|
|
|
/* Owner must be a top-level window */
|
|
owner = WIN_GetTopParent( owner );
|
|
if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return -1;
|
|
dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
|
|
EnableWindow32( owner, FALSE );
|
|
ShowWindow32( hwnd, SW_SHOW );
|
|
|
|
while (MSG_InternalGetMessage(&msg, hwnd, owner, MSGF_DIALOGBOX, PM_REMOVE,
|
|
!(wndPtr->dwStyle & DS_NOIDLEMSG) ))
|
|
{
|
|
if (!IsDialogMessage16( hwnd, &msg))
|
|
{
|
|
TranslateMessage16( &msg );
|
|
DispatchMessage16( &msg );
|
|
}
|
|
if (dlgInfo->flags & DF_END) break;
|
|
}
|
|
retval = dlgInfo->idResult;
|
|
EnableWindow32( owner, TRUE );
|
|
DestroyWindow32( hwnd );
|
|
return retval;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DialogBox16 (USER.87)
|
|
*/
|
|
INT16 WINAPI DialogBox16( HINSTANCE16 hInst, SEGPTR dlgTemplate,
|
|
HWND16 owner, DLGPROC16 dlgProc )
|
|
{
|
|
return DialogBoxParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DialogBoxParam16 (USER.239)
|
|
*/
|
|
INT16 WINAPI DialogBoxParam16( HINSTANCE16 hInst, SEGPTR template,
|
|
HWND16 owner, DLGPROC16 dlgProc, LPARAM param )
|
|
{
|
|
HWND16 hwnd = CreateDialogParam16( hInst, template, owner, dlgProc, param);
|
|
if (hwnd) return (INT16)DIALOG_DoDialogBox( hwnd, owner );
|
|
return -1;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DialogBoxParam32A (USER32.139)
|
|
*/
|
|
INT32 WINAPI DialogBoxParam32A( HINSTANCE32 hInst, LPCSTR name,
|
|
HWND32 owner, DLGPROC32 dlgProc, LPARAM param )
|
|
{
|
|
HWND32 hwnd = CreateDialogParam32A( hInst, name, owner, dlgProc, param );
|
|
if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
|
|
return -1;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DialogBoxParam32W (USER32.140)
|
|
*/
|
|
INT32 WINAPI DialogBoxParam32W( HINSTANCE32 hInst, LPCWSTR name,
|
|
HWND32 owner, DLGPROC32 dlgProc, LPARAM param )
|
|
{
|
|
HWND32 hwnd = CreateDialogParam32W( hInst, name, owner, dlgProc, param );
|
|
if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
|
|
return -1;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DialogBoxIndirect16 (USER.218)
|
|
*/
|
|
INT16 WINAPI DialogBoxIndirect16( HINSTANCE16 hInst, HANDLE16 dlgTemplate,
|
|
HWND16 owner, DLGPROC16 dlgProc )
|
|
{
|
|
return DialogBoxIndirectParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DialogBoxIndirectParam16 (USER.240)
|
|
*/
|
|
INT16 WINAPI DialogBoxIndirectParam16( HINSTANCE16 hInst, HANDLE16 dlgTemplate,
|
|
HWND16 owner, DLGPROC16 dlgProc,
|
|
LPARAM param )
|
|
{
|
|
HWND16 hwnd;
|
|
LPCVOID ptr;
|
|
|
|
if (!(ptr = GlobalLock16( dlgTemplate ))) return -1;
|
|
hwnd = CreateDialogIndirectParam16( hInst, ptr, owner, dlgProc, param );
|
|
GlobalUnlock16( dlgTemplate );
|
|
if (hwnd) return (INT16)DIALOG_DoDialogBox( hwnd, owner );
|
|
return -1;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DialogBoxIndirectParam32A (USER32.136)
|
|
*/
|
|
INT32 WINAPI DialogBoxIndirectParam32A(HINSTANCE32 hInstance, LPCVOID template,
|
|
HWND32 owner, DLGPROC32 dlgProc,
|
|
LPARAM param )
|
|
{
|
|
HWND32 hwnd = CreateDialogIndirectParam32A( hInstance, template,
|
|
owner, dlgProc, param );
|
|
if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
|
|
return -1;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DialogBoxIndirectParam32W (USER32.138)
|
|
*/
|
|
INT32 WINAPI DialogBoxIndirectParam32W(HINSTANCE32 hInstance, LPCVOID template,
|
|
HWND32 owner, DLGPROC32 dlgProc,
|
|
LPARAM param )
|
|
{
|
|
HWND32 hwnd = CreateDialogIndirectParam32W( hInstance, template,
|
|
owner, dlgProc, param );
|
|
if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
|
|
return -1;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* EndDialog16 (USER32.173)
|
|
*/
|
|
BOOL16 WINAPI EndDialog16( HWND16 hwnd, INT16 retval )
|
|
{
|
|
return EndDialog32( hwnd, retval );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* EndDialog32 (USER.88)
|
|
*/
|
|
BOOL32 WINAPI EndDialog32( HWND32 hwnd, INT32 retval )
|
|
{
|
|
WND * wndPtr = WIN_FindWndPtr( hwnd );
|
|
DIALOGINFO * dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
|
|
|
|
TRACE(dialog, "%04x %d\n", hwnd, retval );
|
|
|
|
if( dlgInfo )
|
|
{
|
|
dlgInfo->idResult = retval;
|
|
dlgInfo->flags |= DF_END;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DIALOG_IsDialogMessage
|
|
*/
|
|
static BOOL32 DIALOG_IsDialogMessage( HWND32 hwnd, HWND32 hwndDlg,
|
|
UINT32 message, WPARAM32 wParam,
|
|
LPARAM lParam, BOOL32 *translate,
|
|
BOOL32 *dispatch )
|
|
{
|
|
INT32 dlgCode;
|
|
|
|
*translate = *dispatch = FALSE;
|
|
|
|
if (message == WM_PAINT)
|
|
{
|
|
/* Apparently, we have to handle this one as well */
|
|
*dispatch = TRUE;
|
|
return TRUE;
|
|
}
|
|
|
|
/* Only the key messages get special processing */
|
|
if ((message != WM_KEYDOWN) &&
|
|
(message != WM_SYSCHAR) &&
|
|
(message != WM_CHAR))
|
|
return FALSE;
|
|
|
|
dlgCode = SendMessage32A( hwnd, WM_GETDLGCODE, 0, 0 );
|
|
if (dlgCode & DLGC_WANTMESSAGE)
|
|
{
|
|
*translate = *dispatch = TRUE;
|
|
return TRUE;
|
|
}
|
|
|
|
switch(message)
|
|
{
|
|
case WM_KEYDOWN:
|
|
if (dlgCode & DLGC_WANTALLKEYS) break;
|
|
switch(wParam)
|
|
{
|
|
case VK_TAB:
|
|
if (!(dlgCode & DLGC_WANTTAB))
|
|
{
|
|
SendMessage32A( hwndDlg, WM_NEXTDLGCTL,
|
|
(GetKeyState32(VK_SHIFT) & 0x8000), 0 );
|
|
return TRUE;
|
|
}
|
|
break;
|
|
|
|
case VK_RIGHT:
|
|
case VK_DOWN:
|
|
if (!(dlgCode & DLGC_WANTARROWS))
|
|
{
|
|
SetFocus32( GetNextDlgGroupItem32( hwndDlg, GetFocus32(),
|
|
FALSE ) );
|
|
return TRUE;
|
|
}
|
|
break;
|
|
|
|
case VK_LEFT:
|
|
case VK_UP:
|
|
if (!(dlgCode & DLGC_WANTARROWS))
|
|
{
|
|
SetFocus32( GetNextDlgGroupItem32( hwndDlg, GetFocus32(),
|
|
TRUE ) );
|
|
return TRUE;
|
|
}
|
|
break;
|
|
|
|
case VK_ESCAPE:
|
|
SendMessage32A( hwndDlg, WM_COMMAND, IDCANCEL,
|
|
(LPARAM)GetDlgItem32( hwndDlg, IDCANCEL ) );
|
|
break;
|
|
|
|
case VK_RETURN:
|
|
{
|
|
DWORD dw = SendMessage16( hwndDlg, DM_GETDEFID, 0, 0 );
|
|
if (HIWORD(dw) == DC_HASDEFID)
|
|
SendMessage32A( hwndDlg, WM_COMMAND,
|
|
MAKEWPARAM( LOWORD(dw), BN_CLICKED ),
|
|
(LPARAM)GetDlgItem32(hwndDlg, LOWORD(dw)));
|
|
else
|
|
SendMessage32A( hwndDlg, WM_COMMAND, IDOK,
|
|
(LPARAM)GetDlgItem32( hwndDlg, IDOK ) );
|
|
}
|
|
break;
|
|
|
|
default:
|
|
*translate = TRUE;
|
|
break;
|
|
}
|
|
break; /* case WM_KEYDOWN */
|
|
|
|
|
|
case WM_CHAR:
|
|
if (dlgCode & (DLGC_WANTALLKEYS | DLGC_WANTCHARS)) break;
|
|
break;
|
|
|
|
case WM_SYSCHAR:
|
|
if (dlgCode & DLGC_WANTALLKEYS) break;
|
|
break;
|
|
}
|
|
|
|
/* If we get here, the message has not been treated specially */
|
|
/* and can be sent to its destination window. */
|
|
*dispatch = TRUE;
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* IsDialogMessage16 (USER.90)
|
|
*/
|
|
BOOL16 WINAPI IsDialogMessage16( HWND16 hwndDlg, LPMSG16 msg )
|
|
{
|
|
BOOL32 ret, translate, dispatch;
|
|
|
|
if ((hwndDlg != msg->hwnd) && !IsChild16( hwndDlg, msg->hwnd ))
|
|
return FALSE;
|
|
|
|
ret = DIALOG_IsDialogMessage( msg->hwnd, hwndDlg, msg->message,
|
|
msg->wParam, msg->lParam,
|
|
&translate, &dispatch );
|
|
if (translate) TranslateMessage16( msg );
|
|
if (dispatch) DispatchMessage16( msg );
|
|
return ret;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* IsDialogMessage32A (USER32.342)
|
|
*/
|
|
BOOL32 WINAPI IsDialogMessage32A( HWND32 hwndDlg, LPMSG32 msg )
|
|
{
|
|
BOOL32 ret, translate, dispatch;
|
|
|
|
if ((hwndDlg != msg->hwnd) && !IsChild32( hwndDlg, msg->hwnd ))
|
|
return FALSE;
|
|
|
|
ret = DIALOG_IsDialogMessage( msg->hwnd, hwndDlg, msg->message,
|
|
msg->wParam, msg->lParam,
|
|
&translate, &dispatch );
|
|
if (translate) TranslateMessage32( msg );
|
|
if (dispatch) DispatchMessage32A( msg );
|
|
return ret;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* IsDialogMessage32W (USER32.343)
|
|
*/
|
|
BOOL32 WINAPI IsDialogMessage32W( HWND32 hwndDlg, LPMSG32 msg )
|
|
{
|
|
BOOL32 ret, translate, dispatch;
|
|
|
|
if ((hwndDlg != msg->hwnd) && !IsChild32( hwndDlg, msg->hwnd ))
|
|
return FALSE;
|
|
|
|
ret = DIALOG_IsDialogMessage( msg->hwnd, hwndDlg, msg->message,
|
|
msg->wParam, msg->lParam,
|
|
&translate, &dispatch );
|
|
if (translate) TranslateMessage32( msg );
|
|
if (dispatch) DispatchMessage32W( msg );
|
|
return ret;
|
|
}
|
|
|
|
|
|
/****************************************************************
|
|
* GetDlgCtrlID16 (USER.277)
|
|
*/
|
|
INT16 WINAPI GetDlgCtrlID16( HWND16 hwnd )
|
|
{
|
|
WND *wndPtr = WIN_FindWndPtr(hwnd);
|
|
if (wndPtr) return wndPtr->wIDmenu;
|
|
else return 0;
|
|
}
|
|
|
|
|
|
/****************************************************************
|
|
* GetDlgCtrlID32 (USER32.234)
|
|
*/
|
|
INT32 WINAPI GetDlgCtrlID32( HWND32 hwnd )
|
|
{
|
|
WND *wndPtr = WIN_FindWndPtr(hwnd);
|
|
if (wndPtr) return wndPtr->wIDmenu;
|
|
else return 0;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* GetDlgItem16 (USER.91)
|
|
*/
|
|
HWND16 WINAPI GetDlgItem16( HWND16 hwndDlg, INT16 id )
|
|
{
|
|
WND *pWnd;
|
|
|
|
if (!(pWnd = WIN_FindWndPtr( hwndDlg ))) return 0;
|
|
for (pWnd = pWnd->child; pWnd; pWnd = pWnd->next)
|
|
if (pWnd->wIDmenu == (UINT16)id) return pWnd->hwndSelf;
|
|
return 0;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* GetDlgItem32 (USER32.235)
|
|
*/
|
|
HWND32 WINAPI GetDlgItem32( HWND32 hwndDlg, INT32 id )
|
|
{
|
|
WND *pWnd;
|
|
|
|
if (!(pWnd = WIN_FindWndPtr( hwndDlg ))) return 0;
|
|
for (pWnd = pWnd->child; pWnd; pWnd = pWnd->next)
|
|
if (pWnd->wIDmenu == (UINT16)id) return pWnd->hwndSelf;
|
|
return 0;
|
|
}
|
|
|
|
|
|
/*******************************************************************
|
|
* SendDlgItemMessage16 (USER.101)
|
|
*/
|
|
LRESULT WINAPI SendDlgItemMessage16( HWND16 hwnd, INT16 id, UINT16 msg,
|
|
WPARAM16 wParam, LPARAM lParam )
|
|
{
|
|
HWND16 hwndCtrl = GetDlgItem16( hwnd, id );
|
|
if (hwndCtrl) return SendMessage16( hwndCtrl, msg, wParam, lParam );
|
|
else return 0;
|
|
}
|
|
|
|
|
|
/*******************************************************************
|
|
* SendDlgItemMessage32A (USER32.452)
|
|
*/
|
|
LRESULT WINAPI SendDlgItemMessage32A( HWND32 hwnd, INT32 id, UINT32 msg,
|
|
WPARAM32 wParam, LPARAM lParam )
|
|
{
|
|
HWND32 hwndCtrl = GetDlgItem32( hwnd, id );
|
|
if (hwndCtrl) return SendMessage32A( hwndCtrl, msg, wParam, lParam );
|
|
else return 0;
|
|
}
|
|
|
|
|
|
/*******************************************************************
|
|
* SendDlgItemMessage32W (USER32.453)
|
|
*/
|
|
LRESULT WINAPI SendDlgItemMessage32W( HWND32 hwnd, INT32 id, UINT32 msg,
|
|
WPARAM32 wParam, LPARAM lParam )
|
|
{
|
|
HWND32 hwndCtrl = GetDlgItem32( hwnd, id );
|
|
if (hwndCtrl) return SendMessage32W( hwndCtrl, msg, wParam, lParam );
|
|
else return 0;
|
|
}
|
|
|
|
|
|
/*******************************************************************
|
|
* SetDlgItemText16 (USER.92)
|
|
*/
|
|
void WINAPI SetDlgItemText16( HWND16 hwnd, INT16 id, SEGPTR lpString )
|
|
{
|
|
SendDlgItemMessage16( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpString );
|
|
}
|
|
|
|
|
|
/*******************************************************************
|
|
* SetDlgItemText32A (USER32.478)
|
|
*/
|
|
void WINAPI SetDlgItemText32A( HWND32 hwnd, INT32 id, LPCSTR lpString )
|
|
{
|
|
SendDlgItemMessage32A( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpString );
|
|
}
|
|
|
|
|
|
/*******************************************************************
|
|
* SetDlgItemText32W (USER32.479)
|
|
*/
|
|
void WINAPI SetDlgItemText32W( HWND32 hwnd, INT32 id, LPCWSTR lpString )
|
|
{
|
|
SendDlgItemMessage32W( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpString );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* GetDlgItemText16 (USER.93)
|
|
*/
|
|
INT16 WINAPI GetDlgItemText16( HWND16 hwnd, INT16 id, SEGPTR str, UINT16 len )
|
|
{
|
|
return (INT16)SendDlgItemMessage16( hwnd, id, WM_GETTEXT,
|
|
len, (LPARAM)str );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* GetDlgItemText32A (USER32.237)
|
|
*/
|
|
INT32 WINAPI GetDlgItemText32A( HWND32 hwnd, INT32 id, LPSTR str, UINT32 len )
|
|
{
|
|
return (INT32)SendDlgItemMessage32A( hwnd, id, WM_GETTEXT,
|
|
len, (LPARAM)str );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* GetDlgItemText32W (USER32.238)
|
|
*/
|
|
INT32 WINAPI GetDlgItemText32W( HWND32 hwnd, INT32 id, LPWSTR str, UINT32 len )
|
|
{
|
|
return (INT32)SendDlgItemMessage32W( hwnd, id, WM_GETTEXT,
|
|
len, (LPARAM)str );
|
|
}
|
|
|
|
|
|
/*******************************************************************
|
|
* SetDlgItemInt16 (USER.94)
|
|
*/
|
|
void WINAPI SetDlgItemInt16( HWND16 hwnd, INT16 id, UINT16 value, BOOL16 fSigned )
|
|
{
|
|
return SetDlgItemInt32( hwnd, (UINT32)(UINT16)id, value, fSigned );
|
|
}
|
|
|
|
|
|
/*******************************************************************
|
|
* SetDlgItemInt32 (USER32.477)
|
|
*/
|
|
void WINAPI SetDlgItemInt32( HWND32 hwnd, INT32 id, UINT32 value,
|
|
BOOL32 fSigned )
|
|
{
|
|
char str[20];
|
|
|
|
if (fSigned) sprintf( str, "%d", (INT32)value );
|
|
else sprintf( str, "%u", value );
|
|
SendDlgItemMessage32A( hwnd, id, WM_SETTEXT, 0, (LPARAM)str );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* GetDlgItemInt16 (USER.95)
|
|
*/
|
|
UINT16 WINAPI GetDlgItemInt16( HWND16 hwnd, INT16 id, BOOL16 *translated,
|
|
BOOL16 fSigned )
|
|
{
|
|
UINT32 result;
|
|
BOOL32 ok;
|
|
|
|
if (translated) *translated = FALSE;
|
|
result = GetDlgItemInt32( hwnd, (UINT32)(UINT16)id, &ok, fSigned );
|
|
if (!ok) return 0;
|
|
if (fSigned)
|
|
{
|
|
if (((INT32)result < -32767) || ((INT32)result > 32767)) return 0;
|
|
}
|
|
else
|
|
{
|
|
if (result > 65535) return 0;
|
|
}
|
|
if (translated) *translated = TRUE;
|
|
return (UINT16)result;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* GetDlgItemInt32 (USER32.236)
|
|
*/
|
|
UINT32 WINAPI GetDlgItemInt32( HWND32 hwnd, INT32 id, BOOL32 *translated,
|
|
BOOL32 fSigned )
|
|
{
|
|
char str[30];
|
|
char * endptr;
|
|
long result = 0;
|
|
|
|
if (translated) *translated = FALSE;
|
|
if (!SendDlgItemMessage32A(hwnd, id, WM_GETTEXT, sizeof(str), (LPARAM)str))
|
|
return 0;
|
|
if (fSigned)
|
|
{
|
|
result = strtol( str, &endptr, 10 );
|
|
if (!endptr || (endptr == str)) /* Conversion was unsuccessful */
|
|
return 0;
|
|
if (((result == LONG_MIN) || (result == LONG_MAX)) && (errno==ERANGE))
|
|
return 0;
|
|
}
|
|
else
|
|
{
|
|
result = strtoul( str, &endptr, 10 );
|
|
if (!endptr || (endptr == str)) /* Conversion was unsuccessful */
|
|
return 0;
|
|
if ((result == ULONG_MAX) && (errno == ERANGE)) return 0;
|
|
}
|
|
if (translated) *translated = TRUE;
|
|
return (UINT32)result;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* CheckDlgButton16 (USER.97)
|
|
*/
|
|
BOOL16 WINAPI CheckDlgButton16( HWND16 hwnd, INT16 id, UINT16 check )
|
|
{
|
|
SendDlgItemMessage32A( hwnd, id, BM_SETCHECK32, check, 0 );
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* CheckDlgButton32 (USER32.45)
|
|
*/
|
|
BOOL32 WINAPI CheckDlgButton32( HWND32 hwnd, INT32 id, UINT32 check )
|
|
{
|
|
SendDlgItemMessage32A( hwnd, id, BM_SETCHECK32, check, 0 );
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* IsDlgButtonChecked16 (USER.98)
|
|
*/
|
|
UINT16 WINAPI IsDlgButtonChecked16( HWND16 hwnd, UINT16 id )
|
|
{
|
|
return (UINT16)SendDlgItemMessage32A( hwnd, id, BM_GETCHECK32, 0, 0 );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* IsDlgButtonChecked32 (USER32.344)
|
|
*/
|
|
UINT32 WINAPI IsDlgButtonChecked32( HWND32 hwnd, UINT32 id )
|
|
{
|
|
return (UINT32)SendDlgItemMessage32A( hwnd, id, BM_GETCHECK32, 0, 0 );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* CheckRadioButton16 (USER.96)
|
|
*/
|
|
BOOL16 WINAPI CheckRadioButton16( HWND16 hwndDlg, UINT16 firstID,
|
|
UINT16 lastID, UINT16 checkID )
|
|
{
|
|
return CheckRadioButton32( hwndDlg, firstID, lastID, checkID );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* CheckRadioButton32 (USER32.48)
|
|
*/
|
|
BOOL32 WINAPI CheckRadioButton32( HWND32 hwndDlg, UINT32 firstID,
|
|
UINT32 lastID, UINT32 checkID )
|
|
{
|
|
WND *pWnd = WIN_FindWndPtr( hwndDlg );
|
|
if (!pWnd) return FALSE;
|
|
|
|
for (pWnd = pWnd->child; pWnd; pWnd = pWnd->next)
|
|
if ((pWnd->wIDmenu == firstID) || (pWnd->wIDmenu == lastID)) break;
|
|
if (!pWnd) return FALSE;
|
|
|
|
if (pWnd->wIDmenu == lastID)
|
|
lastID = firstID; /* Buttons are in reverse order */
|
|
while (pWnd)
|
|
{
|
|
SendMessage32A( pWnd->hwndSelf, BM_SETCHECK32,
|
|
(pWnd->wIDmenu == checkID), 0 );
|
|
if (pWnd->wIDmenu == lastID) break;
|
|
pWnd = pWnd->next;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* GetDialogBaseUnits (USER.243) (USER32.233)
|
|
*/
|
|
DWORD WINAPI GetDialogBaseUnits(void)
|
|
{
|
|
return MAKELONG( xBaseUnit, yBaseUnit );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* MapDialogRect16 (USER.103)
|
|
*/
|
|
void WINAPI MapDialogRect16( HWND16 hwnd, LPRECT16 rect )
|
|
{
|
|
DIALOGINFO * dlgInfo;
|
|
WND * wndPtr = WIN_FindWndPtr( hwnd );
|
|
if (!wndPtr) return;
|
|
dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
|
|
rect->left = (rect->left * dlgInfo->xBaseUnit) / 4;
|
|
rect->right = (rect->right * dlgInfo->xBaseUnit) / 4;
|
|
rect->top = (rect->top * dlgInfo->yBaseUnit) / 8;
|
|
rect->bottom = (rect->bottom * dlgInfo->yBaseUnit) / 8;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* MapDialogRect32 (USER32.382)
|
|
*/
|
|
void WINAPI MapDialogRect32( HWND32 hwnd, LPRECT32 rect )
|
|
{
|
|
DIALOGINFO * dlgInfo;
|
|
WND * wndPtr = WIN_FindWndPtr( hwnd );
|
|
if (!wndPtr) return;
|
|
dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
|
|
rect->left = (rect->left * dlgInfo->xBaseUnit) / 4;
|
|
rect->right = (rect->right * dlgInfo->xBaseUnit) / 4;
|
|
rect->top = (rect->top * dlgInfo->yBaseUnit) / 8;
|
|
rect->bottom = (rect->bottom * dlgInfo->yBaseUnit) / 8;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* GetNextDlgGroupItem16 (USER.227)
|
|
*/
|
|
HWND16 WINAPI GetNextDlgGroupItem16( HWND16 hwndDlg, HWND16 hwndCtrl,
|
|
BOOL16 fPrevious )
|
|
{
|
|
return (HWND16)GetNextDlgGroupItem32( hwndDlg, hwndCtrl, fPrevious );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* GetNextDlgGroupItem32 (USER32.275)
|
|
*/
|
|
HWND32 WINAPI GetNextDlgGroupItem32( HWND32 hwndDlg, HWND32 hwndCtrl,
|
|
BOOL32 fPrevious )
|
|
{
|
|
WND *pWnd, *pWndLast, *pWndCtrl, *pWndDlg;
|
|
|
|
if (!(pWndDlg = WIN_FindWndPtr( hwndDlg ))) return 0;
|
|
if (hwndCtrl)
|
|
{
|
|
if (!(pWndCtrl = WIN_FindWndPtr( hwndCtrl ))) return 0;
|
|
/* Make sure hwndCtrl is a top-level child */
|
|
while ((pWndCtrl->dwStyle & WS_CHILD) && (pWndCtrl->parent != pWndDlg))
|
|
pWndCtrl = pWndCtrl->parent;
|
|
if (pWndCtrl->parent != pWndDlg) return 0;
|
|
}
|
|
else
|
|
{
|
|
/* No ctrl specified -> start from the beginning */
|
|
if (!(pWndCtrl = pWndDlg->child)) return 0;
|
|
if (fPrevious) while (pWndCtrl->next) pWndCtrl = pWndCtrl->next;
|
|
}
|
|
|
|
pWndLast = pWndCtrl;
|
|
pWnd = pWndCtrl->next;
|
|
while (1)
|
|
{
|
|
if (!pWnd || (pWnd->dwStyle & WS_GROUP))
|
|
{
|
|
/* Wrap-around to the beginning of the group */
|
|
WND *pWndStart = pWndDlg->child;
|
|
for (pWnd = pWndStart; pWnd; pWnd = pWnd->next)
|
|
{
|
|
if (pWnd->dwStyle & WS_GROUP) pWndStart = pWnd;
|
|
if (pWnd == pWndCtrl) break;
|
|
}
|
|
pWnd = pWndStart;
|
|
}
|
|
if (pWnd == pWndCtrl) break;
|
|
if ((pWnd->dwStyle & WS_VISIBLE) && !(pWnd->dwStyle & WS_DISABLED))
|
|
{
|
|
pWndLast = pWnd;
|
|
if (!fPrevious) break;
|
|
}
|
|
pWnd = pWnd->next;
|
|
}
|
|
return pWndLast->hwndSelf;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* GetNextDlgTabItem16 (USER.228)
|
|
*/
|
|
HWND16 WINAPI GetNextDlgTabItem16( HWND16 hwndDlg, HWND16 hwndCtrl,
|
|
BOOL16 fPrevious )
|
|
{
|
|
return (HWND16)GetNextDlgTabItem32( hwndDlg, hwndCtrl, fPrevious );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* GetNextDlgTabItem32 (USER32.276)
|
|
*/
|
|
HWND32 WINAPI GetNextDlgTabItem32( HWND32 hwndDlg, HWND32 hwndCtrl,
|
|
BOOL32 fPrevious )
|
|
{
|
|
WND *pWnd, *pWndLast, *pWndCtrl, *pWndDlg;
|
|
|
|
if (!(pWndDlg = WIN_FindWndPtr( hwndDlg ))) return 0;
|
|
if (hwndCtrl)
|
|
{
|
|
if (!(pWndCtrl = WIN_FindWndPtr( hwndCtrl ))) return 0;
|
|
/* Make sure hwndCtrl is a top-level child */
|
|
while ((pWndCtrl->dwStyle & WS_CHILD) && (pWndCtrl->parent != pWndDlg))
|
|
pWndCtrl = pWndCtrl->parent;
|
|
if (pWndCtrl->parent != pWndDlg) return 0;
|
|
}
|
|
else
|
|
{
|
|
/* No ctrl specified -> start from the beginning */
|
|
if (!(pWndCtrl = pWndDlg->child)) return 0;
|
|
if (!fPrevious) while (pWndCtrl->next) pWndCtrl = pWndCtrl->next;
|
|
}
|
|
|
|
pWndLast = pWndCtrl;
|
|
pWnd = pWndCtrl->next;
|
|
while (1)
|
|
{
|
|
if (!pWnd) pWnd = pWndDlg->child;
|
|
if (pWnd == pWndCtrl) break;
|
|
if ((pWnd->dwStyle & WS_TABSTOP) && (pWnd->dwStyle & WS_VISIBLE) &&
|
|
!(pWnd->dwStyle & WS_DISABLED))
|
|
{
|
|
pWndLast = pWnd;
|
|
if (!fPrevious) break;
|
|
}
|
|
pWnd = pWnd->next;
|
|
}
|
|
return pWndLast->hwndSelf;
|
|
}
|
|
|
|
|
|
/**********************************************************************
|
|
* DIALOG_DlgDirSelect
|
|
*
|
|
* Helper function for DlgDirSelect*
|
|
*/
|
|
static BOOL32 DIALOG_DlgDirSelect( HWND32 hwnd, LPSTR str, INT32 len,
|
|
INT32 id, BOOL32 win32, BOOL32 unicode,
|
|
BOOL32 combo )
|
|
{
|
|
char *buffer, *ptr;
|
|
INT32 item, size;
|
|
BOOL32 ret;
|
|
HWND32 listbox = GetDlgItem32( hwnd, id );
|
|
|
|
TRACE(dialog, "%04x '%s' %d\n", hwnd, str, id );
|
|
if (!listbox) return FALSE;
|
|
if (win32)
|
|
{
|
|
item = SendMessage32A(listbox, combo ? CB_GETCURSEL32
|
|
: LB_GETCURSEL32, 0, 0 );
|
|
if (item == LB_ERR) return FALSE;
|
|
size = SendMessage32A(listbox, combo ? CB_GETLBTEXTLEN32
|
|
: LB_GETTEXTLEN32, 0, 0 );
|
|
if (size == LB_ERR) return FALSE;
|
|
}
|
|
else
|
|
{
|
|
item = SendMessage32A(listbox, combo ? CB_GETCURSEL16
|
|
: LB_GETCURSEL16, 0, 0 );
|
|
if (item == LB_ERR) return FALSE;
|
|
size = SendMessage32A(listbox, combo ? CB_GETLBTEXTLEN16
|
|
: LB_GETTEXTLEN16, 0, 0 );
|
|
if (size == LB_ERR) return FALSE;
|
|
}
|
|
|
|
if (!(buffer = SEGPTR_ALLOC( size+1 ))) return FALSE;
|
|
|
|
if (win32)
|
|
SendMessage32A( listbox, combo ? CB_GETLBTEXT32 : LB_GETTEXT32,
|
|
item, (LPARAM)buffer );
|
|
else
|
|
SendMessage16( listbox, combo ? CB_GETLBTEXT16 : LB_GETTEXT16,
|
|
item, (LPARAM)SEGPTR_GET(buffer) );
|
|
|
|
if ((ret = (buffer[0] == '['))) /* drive or directory */
|
|
{
|
|
if (buffer[1] == '-') /* drive */
|
|
{
|
|
buffer[3] = ':';
|
|
buffer[4] = 0;
|
|
ptr = buffer + 2;
|
|
}
|
|
else
|
|
{
|
|
buffer[strlen(buffer)-1] = '\\';
|
|
ptr = buffer + 1;
|
|
}
|
|
}
|
|
else ptr = buffer;
|
|
|
|
if (unicode) lstrcpynAtoW( (LPWSTR)str, ptr, len );
|
|
else lstrcpyn32A( str, ptr, len );
|
|
SEGPTR_FREE( buffer );
|
|
TRACE(dialog, "Returning %d '%s'\n", ret, str );
|
|
return ret;
|
|
}
|
|
|
|
|
|
/**********************************************************************
|
|
* DIALOG_DlgDirList
|
|
*
|
|
* Helper function for DlgDirList*
|
|
*/
|
|
static INT32 DIALOG_DlgDirList( HWND32 hDlg, LPSTR spec, INT32 idLBox,
|
|
INT32 idStatic, UINT32 attrib, BOOL32 combo )
|
|
{
|
|
int drive;
|
|
HWND32 hwnd;
|
|
LPSTR orig_spec = spec;
|
|
|
|
#define SENDMSG(msg,wparam,lparam) \
|
|
((attrib & DDL_POSTMSGS) ? PostMessage32A( hwnd, msg, wparam, lparam ) \
|
|
: SendMessage32A( hwnd, msg, wparam, lparam ))
|
|
|
|
TRACE(dialog, "%04x '%s' %d %d %04x\n",
|
|
hDlg, spec ? spec : "NULL", idLBox, idStatic, attrib );
|
|
|
|
if (spec && spec[0] && (spec[1] == ':'))
|
|
{
|
|
drive = toupper( spec[0] ) - 'A';
|
|
spec += 2;
|
|
if (!DRIVE_SetCurrentDrive( drive )) return FALSE;
|
|
}
|
|
else drive = DRIVE_GetCurrentDrive();
|
|
|
|
/* If the path exists and is a directory, chdir to it */
|
|
if (!spec || !spec[0] || DRIVE_Chdir( drive, spec )) spec = "*.*";
|
|
else
|
|
{
|
|
char *p, *p2;
|
|
p = spec;
|
|
if ((p2 = strrchr( p, '\\' ))) p = p2;
|
|
if ((p2 = strrchr( p, '/' ))) p = p2;
|
|
if (p != spec)
|
|
{
|
|
char sep = *p;
|
|
*p = 0;
|
|
if (!DRIVE_Chdir( drive, spec ))
|
|
{
|
|
*p = sep; /* Restore the original spec */
|
|
return FALSE;
|
|
}
|
|
spec = p + 1;
|
|
}
|
|
}
|
|
|
|
TRACE(dialog, "path=%c:\\%s mask=%s\n",
|
|
'A' + drive, DRIVE_GetDosCwd(drive), spec );
|
|
|
|
if (idLBox && ((hwnd = GetDlgItem32( hDlg, idLBox )) != 0))
|
|
{
|
|
SENDMSG( combo ? CB_RESETCONTENT32 : LB_RESETCONTENT32, 0, 0 );
|
|
if (attrib & DDL_DIRECTORY)
|
|
{
|
|
if (!(attrib & DDL_EXCLUSIVE))
|
|
{
|
|
if (SENDMSG( combo ? CB_DIR32 : LB_DIR32,
|
|
attrib & ~(DDL_DIRECTORY | DDL_DRIVES),
|
|
(LPARAM)spec ) == LB_ERR)
|
|
return FALSE;
|
|
}
|
|
if (SENDMSG( combo ? CB_DIR32 : LB_DIR32,
|
|
(attrib & (DDL_DIRECTORY | DDL_DRIVES)) | DDL_EXCLUSIVE,
|
|
(LPARAM)"*.*" ) == LB_ERR)
|
|
return FALSE;
|
|
}
|
|
else
|
|
{
|
|
if (SENDMSG( combo ? CB_DIR32 : LB_DIR32, attrib,
|
|
(LPARAM)spec ) == LB_ERR)
|
|
return FALSE;
|
|
}
|
|
}
|
|
|
|
if (idStatic && ((hwnd = GetDlgItem32( hDlg, idStatic )) != 0))
|
|
{
|
|
char temp[512];
|
|
int drive = DRIVE_GetCurrentDrive();
|
|
strcpy( temp, "A:\\" );
|
|
temp[0] += drive;
|
|
lstrcpyn32A( temp + 3, DRIVE_GetDosCwd(drive), sizeof(temp)-3 );
|
|
CharLower32A( temp );
|
|
/* Can't use PostMessage() here, because the string is on the stack */
|
|
SetDlgItemText32A( hDlg, idStatic, temp );
|
|
}
|
|
|
|
if (orig_spec && (spec != orig_spec))
|
|
{
|
|
/* Update the original file spec */
|
|
char *p = spec;
|
|
while ((*orig_spec++ = *p++));
|
|
}
|
|
|
|
return TRUE;
|
|
#undef SENDMSG
|
|
}
|
|
|
|
|
|
/**********************************************************************
|
|
* DIALOG_DlgDirListW
|
|
*
|
|
* Helper function for DlgDirList*32W
|
|
*/
|
|
static INT32 DIALOG_DlgDirListW( HWND32 hDlg, LPWSTR spec, INT32 idLBox,
|
|
INT32 idStatic, UINT32 attrib, BOOL32 combo )
|
|
{
|
|
if (spec)
|
|
{
|
|
LPSTR specA = HEAP_strdupWtoA( GetProcessHeap(), 0, spec );
|
|
INT32 ret = DIALOG_DlgDirList( hDlg, specA, idLBox, idStatic,
|
|
attrib, combo );
|
|
lstrcpyAtoW( spec, specA );
|
|
HeapFree( GetProcessHeap(), 0, specA );
|
|
return ret;
|
|
}
|
|
return DIALOG_DlgDirList( hDlg, NULL, idLBox, idStatic, attrib, combo );
|
|
}
|
|
|
|
|
|
/**********************************************************************
|
|
* DlgDirSelect (USER.99)
|
|
*/
|
|
BOOL16 WINAPI DlgDirSelect( HWND16 hwnd, LPSTR str, INT16 id )
|
|
{
|
|
return DlgDirSelectEx16( hwnd, str, 128, id );
|
|
}
|
|
|
|
|
|
/**********************************************************************
|
|
* DlgDirSelectComboBox (USER.194)
|
|
*/
|
|
BOOL16 WINAPI DlgDirSelectComboBox( HWND16 hwnd, LPSTR str, INT16 id )
|
|
{
|
|
return DlgDirSelectComboBoxEx16( hwnd, str, 128, id );
|
|
}
|
|
|
|
|
|
/**********************************************************************
|
|
* DlgDirSelectEx16 (USER.422)
|
|
*/
|
|
BOOL16 WINAPI DlgDirSelectEx16( HWND16 hwnd, LPSTR str, INT16 len, INT16 id )
|
|
{
|
|
return DIALOG_DlgDirSelect( hwnd, str, len, id, FALSE, FALSE, FALSE );
|
|
}
|
|
|
|
|
|
/**********************************************************************
|
|
* DlgDirSelectEx32A (USER32.149)
|
|
*/
|
|
BOOL32 WINAPI DlgDirSelectEx32A( HWND32 hwnd, LPSTR str, INT32 len, INT32 id )
|
|
{
|
|
return DIALOG_DlgDirSelect( hwnd, str, len, id, TRUE, FALSE, FALSE );
|
|
}
|
|
|
|
|
|
/**********************************************************************
|
|
* DlgDirSelectEx32W (USER32.150)
|
|
*/
|
|
BOOL32 WINAPI DlgDirSelectEx32W( HWND32 hwnd, LPWSTR str, INT32 len, INT32 id )
|
|
{
|
|
return DIALOG_DlgDirSelect( hwnd, (LPSTR)str, len, id, TRUE, TRUE, FALSE );
|
|
}
|
|
|
|
|
|
/**********************************************************************
|
|
* DlgDirSelectComboBoxEx16 (USER.423)
|
|
*/
|
|
BOOL16 WINAPI DlgDirSelectComboBoxEx16( HWND16 hwnd, LPSTR str, INT16 len,
|
|
INT16 id )
|
|
{
|
|
return DIALOG_DlgDirSelect( hwnd, str, len, id, FALSE, FALSE, TRUE );
|
|
}
|
|
|
|
|
|
/**********************************************************************
|
|
* DlgDirSelectComboBoxEx32A (USER32.147)
|
|
*/
|
|
BOOL32 WINAPI DlgDirSelectComboBoxEx32A( HWND32 hwnd, LPSTR str, INT32 len,
|
|
INT32 id )
|
|
{
|
|
return DIALOG_DlgDirSelect( hwnd, str, len, id, TRUE, FALSE, TRUE );
|
|
}
|
|
|
|
|
|
/**********************************************************************
|
|
* DlgDirSelectComboBoxEx32W (USER32.148)
|
|
*/
|
|
BOOL32 WINAPI DlgDirSelectComboBoxEx32W( HWND32 hwnd, LPWSTR str, INT32 len,
|
|
INT32 id)
|
|
{
|
|
return DIALOG_DlgDirSelect( hwnd, (LPSTR)str, len, id, TRUE, TRUE, TRUE );
|
|
}
|
|
|
|
|
|
/**********************************************************************
|
|
* DlgDirList16 (USER.100)
|
|
*/
|
|
INT16 WINAPI DlgDirList16( HWND16 hDlg, LPSTR spec, INT16 idLBox,
|
|
INT16 idStatic, UINT16 attrib )
|
|
{
|
|
return DIALOG_DlgDirList( hDlg, spec, idLBox, idStatic, attrib, FALSE );
|
|
}
|
|
|
|
|
|
/**********************************************************************
|
|
* DlgDirList32A (USER32.143)
|
|
*/
|
|
INT32 WINAPI DlgDirList32A( HWND32 hDlg, LPSTR spec, INT32 idLBox,
|
|
INT32 idStatic, UINT32 attrib )
|
|
{
|
|
return DIALOG_DlgDirList( hDlg, spec, idLBox, idStatic, attrib, FALSE );
|
|
}
|
|
|
|
|
|
/**********************************************************************
|
|
* DlgDirList32W (USER32.146)
|
|
*/
|
|
INT32 WINAPI DlgDirList32W( HWND32 hDlg, LPWSTR spec, INT32 idLBox,
|
|
INT32 idStatic, UINT32 attrib )
|
|
{
|
|
return DIALOG_DlgDirListW( hDlg, spec, idLBox, idStatic, attrib, FALSE );
|
|
}
|
|
|
|
|
|
/**********************************************************************
|
|
* DlgDirListComboBox16 (USER.195)
|
|
*/
|
|
INT16 WINAPI DlgDirListComboBox16( HWND16 hDlg, LPSTR spec, INT16 idCBox,
|
|
INT16 idStatic, UINT16 attrib )
|
|
{
|
|
return DIALOG_DlgDirList( hDlg, spec, idCBox, idStatic, attrib, TRUE );
|
|
}
|
|
|
|
|
|
/**********************************************************************
|
|
* DlgDirListComboBox32A (USER32.144)
|
|
*/
|
|
INT32 WINAPI DlgDirListComboBox32A( HWND32 hDlg, LPSTR spec, INT32 idCBox,
|
|
INT32 idStatic, UINT32 attrib )
|
|
{
|
|
return DIALOG_DlgDirList( hDlg, spec, idCBox, idStatic, attrib, TRUE );
|
|
}
|
|
|
|
|
|
/**********************************************************************
|
|
* DlgDirListComboBox32W (USER32.145)
|
|
*/
|
|
INT32 WINAPI DlgDirListComboBox32W( HWND32 hDlg, LPWSTR spec, INT32 idCBox,
|
|
INT32 idStatic, UINT32 attrib )
|
|
{
|
|
return DIALOG_DlgDirListW( hDlg, spec, idCBox, idStatic, attrib, TRUE );
|
|
}
|