Release 960506
Mon May 6 12:56:26 1996 Alexandre Julliard <julliard@lrc.epfl.ch>
* [DEVELOPERS-HINTS]
Added paragraph on naming conventions for Win16/Win32/Winelib.
* [controls/menu.c]
Create a default system menu that is the same for all windows
instead of making a copy every time.
* [include/wintypes.h]
Added WINELIB_NAME and DECL_WINELIB_TYPE macros.
Added xx16 and xx32 definitions for most types. General clean-up.
* [memory/global.c] [memory/local.c] [*/*]
Renamed Global and Local heap functions to xxx16. Added all xxx32
versions of the same functions.
* [memory/selector.c]
Mask out lower bits of selector in FreeSelector().
* [misc/lstr.c]
Fixed wvsprintf().
* [windows/class.c]
Changed the class structure to make Win32 support easier.
* [windows/defwnd.c]
Added handling of WM_INITMENUPOPUP for system menu to gray out
invalid options.
* [windows/winpos.c]
Bug fix: the WINDOSPOS structure pointer in WM_NCCALCSIZE must be
a SEGPTR.
Sun May 5 03:51:26 1996 Huw D. M. Davies <h.davies1@physics.oxford.ac.uk>
* [memory/local.c]
Implementation of moveable and (rudimentary) support for
discardable local memory, plus several bug fixes.
Sat May 4 18:33:35 1996 Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>
* [include/windows.h] [windows/win.c] [if1632/user.spec]
FindWindowEx() implemented (someone reported it was missing
for FrameMaker 4.1).
* [if1632/kernel32.spec] [if1632/user32.spec] [win32/memory.c]
[win32/resource.c]
Misc small stubs/small functions which bring win95 binaries
further down the road. (IsBadCodePtr, LocalReAlloc,GetCursorPos)
Small fix in WIN32_LoadAcceleratorsA.
Fri May 3 19:43:12 1996 Frans van Dorsselaer <dorssel@rulhm1.LeidenUniv.nl>
* [controls/edit.c] [controls/EDIT.TODO]
Changed / fixed some types and typecasts.
Fixed the scrollbar reset after WM_SETHANDLE / WM_SETTEXT.
Added heap initialization in WM_CREATE.
Fri May 3 19:30:02 1996 Greg Kreider <kreider@natlab.research.philips.com>
* [controls/combo.c] [controls/listbox.c]
Pass WM_[HV]SCROLL to listbox, but not combo.
Don't try to redraw non-existant scroll bars (changes dwStyle flags).
Combo box gets border.
Combo box includes button (otherwise button won't trigger dropdown).
Proper border around RectButton.
Check size consistancy of combo, listbox, and button after resizing
or before painting. These routines still aren't completely correct.
Localize size checks in separate routines.
Listboxes are white.
Thu May 2 19:21:23 1996 Albrecht Kleine <kleine@ak.sax.de>
* [controls/combo.c][include/commdlg.h][include/commdlg.c]
[resources/sysres_De.rc][resources/sysres_En.rc]
Introduced ChooseFont dialog, but needed some patches in
handling of comboboxes with edit controls.
Tue Apr 30 00:33:27 1996 Ulrich Schmid <uschmid@mail.hh.provi.de>
* [programs/winhelp/*]
Added a help viewer and a simple `.hlp' to `.sgml' converter.
Mon Apr 29 14:17:57 1996 Tristan Tarrant <tst@sthinc.demon.co.uk>
* [resources/sysres_*.rc] [misc/shell.c]
Modified size of "About" dialog boxes.
Sat Apr 27 18:10:11 Martin von Loewis <loewis@informatik.hu-berlin.de>
* [if1632/Makefile.in][loader/builtin.c]
crtdll.spec, ntdll.spec, wsock32.spec: new files.
* [loader/pe_image.c]
Fix error message if import by ordinal failed.
diff --git a/controls/EDIT.TODO b/controls/EDIT.TODO
index 99b4270..7bacadf 100644
--- a/controls/EDIT.TODO
+++ b/controls/EDIT.TODO
@@ -98,6 +98,8 @@
- The clipboard is broken. Whenever things go wrong with
cut/copy/paste, it is probably the clipboard that messes up things,
not edit.c.
+- Turning on WordWrap with Notepad leaves part of the horizontal
+ scrollbar visible (problem with WM_ERASEBKGND ???).
I am still very actively changing things. Especially I am working
diff --git a/controls/combo.c b/controls/combo.c
index 5a616ce..d2dc819 100644
--- a/controls/combo.c
+++ b/controls/combo.c
@@ -8,6 +8,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -32,9 +33,24 @@
* I hope no programs rely on the implementation of combos.
*/
+ /*
+ * May 2nd: I added 3 "work arounds" (#1,#2,#3) to make combos
+ * with EDIT work. (We need that for ChooseFont dialog.)
+ * Perhaps we have to rewrite something more.
+ * I have prepared some more stuff, but it doesn't
+ * contain here, because it's not ready ;-)
+ *
+ * If you're writing on combo.c, please mail to me.
+ *
+ * Albrecht Kleine <kleine@ak.sax.de>
+ */
+
#define CBLMM_EDGE 4 /* distance inside box which is same as moving mouse
outside box, to trigger scrolling of CBL */
+static BOOL CBCheckSize(HWND hwnd);
+static BOOL CBLCheckSize(HWND hwnd);
+
static HBITMAP hComboBit = 0;
static WORD CBitHeight, CBitWidth;
@@ -70,14 +86,17 @@
lphc->hWndLBox = 0;
lphc->dwState = 0;
lphc->LastSel = -1;
- lphc->dwStyle = style;
+ lphc->dwStyle = style;
lphc->DropDownVisible = FALSE;
return TRUE;
}
void ComboUpdateWindow(HWND hwnd, LPHEADLIST lphl, LPHEADCOMBO lphc, BOOL repaint)
{
- SetScrollRange(lphc->hWndLBox, SB_VERT, 0, ListMaxFirstVisible(lphl), TRUE);
+ WND *wndPtr = WIN_FindWndPtr(hwnd);
+
+ if (wndPtr->dwStyle & WS_VSCROLL)
+ SetScrollRange(lphc->hWndLBox,SB_VERT,0,ListMaxFirstVisible(lphl),TRUE);
if (repaint && lphl->bRedrawFlag) {
InvalidateRect(hwnd, NULL, TRUE);
}
@@ -93,7 +112,7 @@
if (!hComboBit) COMBO_Init();
createStruct = (CREATESTRUCT *)PTR_SEG_TO_LIN(lParam);
- createStruct->style &= ~(WS_VSCROLL | WS_HSCROLL);
+ createStruct->style |= WS_BORDER;
SetWindowLong(hwnd, GWL_STYLE, createStruct->style);
dprintf_combo(stddeb,"ComboBox WM_NCCREATE!\n");
@@ -111,10 +130,12 @@
LONG style = 0;
LONG cstyle = GetWindowLong(hwnd,GWL_STYLE);
RECT rect,lboxrect;
+ WND* wndPtr = WIN_FindWndPtr(hwnd);
char className[] = "COMBOLBOX"; /* Hack so that class names are > 0x10000 */
char editName[] = "EDIT";
/* translate combo into listbox styles */
+ cstyle |= WS_BORDER;
if (cstyle & CBS_OWNERDRAWFIXED) style |= LBS_OWNERDRAWFIXED;
if (cstyle & CBS_OWNERDRAWVARIABLE) style |= LBS_OWNERDRAWVARIABLE;
if (cstyle & CBS_SORT) style |= LBS_SORT;
@@ -122,19 +143,22 @@
style |= LBS_NOTIFY;
CreateListBoxStruct(hwnd, ODT_COMBOBOX, style, GetParent(hwnd));
CreateComboStruct(hwnd,cstyle);
+
lphl = ComboGetListHeader(hwnd);
lphc = ComboGetStorageHeader(hwnd);
GetClientRect(hwnd,&rect);
GetWindowRect(hwnd,&lboxrect);
+
/* FIXME: combos with edit controls are broken. */
switch(cstyle & 3) {
case CBS_SIMPLE: /* edit control, list always visible */
dprintf_combo(stddeb,"CBS_SIMPLE\n");
SetRectEmpty(&lphc->RectButton);
+ lboxrect=rect; /* work around #1 */
lphc->LBoxTop = lphl->StdItemHeight;
- lphc->hWndEdit = CreateWindow(MAKE_SEGPTR(editName), (SEGPTR)0,
- WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | SS_LEFT,
+ lphc->hWndEdit = CreateWindow16(MAKE_SEGPTR(editName), (SEGPTR)0,
+ WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | SS_LEFT | WS_BORDER,
0, 0, rect.right, lphl->StdItemHeight,
hwnd, (HMENU)1, WIN_GetWindowInstance(hwnd), 0L);
break;
@@ -147,7 +171,7 @@
SetWindowPos(hwnd, 0, 0, 0, rect.right - rect.left + 2*SYSMETRICS_CXBORDER,
lphl->StdItemHeight + 2*SYSMETRICS_CYBORDER,
SWP_NOMOVE | SWP_NOZORDER);
- lphc->hWndEdit = CreateWindow(MAKE_SEGPTR(editName), (SEGPTR)0,
+ lphc->hWndEdit = CreateWindow16(MAKE_SEGPTR(editName), (SEGPTR)0,
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | SS_LEFT,
0, 0, lphc->RectButton.left, lphl->StdItemHeight,
hwnd, (HMENU)1, WIN_GetWindowInstance(hwnd), 0L);
@@ -158,8 +182,9 @@
lphc->RectButton.left = lphc->RectButton.right - 6 - CBitWidth;
lphc->RectButton.bottom = lphc->RectButton.top + lphl->StdItemHeight;
lphc->LBoxTop = lphl->StdItemHeight;
- SetWindowPos(hwnd, 0, 0, 0, rect.right - rect.left + 2*SYSMETRICS_CXBORDER,
- lphl->StdItemHeight + 2*SYSMETRICS_CYBORDER,
+
+ SetWindowPos(hwnd, 0, 0, 0, rect.right,
+ lphl->StdItemHeight + 2*SYSMETRICS_CYBORDER,
SWP_NOMOVE | SWP_NOZORDER);
break;
}
@@ -167,16 +192,45 @@
/* FIXME: WinSight says these should be CHILD windows with the TOPMOST flag
* set. Wine doesn't support TOPMOST, and simply setting the WS_CHILD
* flag doesn't work. */
- lphc->hWndLBox = CreateWindow(MAKE_SEGPTR(className), (SEGPTR)0,
- WS_POPUP | WS_BORDER | WS_VSCROLL,
+ if ((cstyle & 3)==CBS_SIMPLE) /* work around #2 */
+ {
+ lphc->hWndLBox = CreateWindow16(MAKE_SEGPTR(className), (SEGPTR)0,
+ WS_BORDER | WS_CHILD | WS_VISIBLE |
+ ((cstyle & WS_HSCROLL)? WS_HSCROLL : 0) |
+ ((cstyle & WS_VSCROLL)? WS_VSCROLL : 0),
+ lboxrect.left +8 , lboxrect.top,
+ lboxrect.right - lboxrect.left - 8,
+ lboxrect.bottom - lboxrect.top,
+ hwnd,0, WIN_GetWindowInstance(hwnd),
+ (SEGPTR)hwnd );
+ }
+ else
+ {
+ lphc->hWndLBox = CreateWindow16(MAKE_SEGPTR(className), (SEGPTR)0,
+ WS_POPUP | WS_BORDER |
+ ((cstyle & WS_HSCROLL)? WS_HSCROLL : 0) |
+ ((cstyle & WS_VSCROLL)? WS_VSCROLL : 0),
lboxrect.left, lboxrect.top,
lboxrect.right - lboxrect.left,
lboxrect.bottom - lboxrect.top,
0, 0, WIN_GetWindowInstance(hwnd),
(SEGPTR)hwnd );
- ShowWindow(lphc->hWndLBox, SW_HIDE);
- dprintf_combo(stddeb,"Combo Creation LBox=%04x\n", lphc->hWndLBox);
- return 0;
+ ShowWindow(lphc->hWndLBox, SW_HIDE);
+ }
+ wndPtr->dwStyle &= ~(WS_VSCROLL | WS_HSCROLL);
+
+ dprintf_combo( stddeb, "Combo Creation hwnd=%04x LBox=%04x\n",
+ hwnd, lphc->hWndLBox);
+ dprintf_combo( stddeb, " lbox %d,%d-%d,%d button %d,%d-%d,%d\n",
+ lboxrect.left, lboxrect.top, lboxrect.right, lboxrect.bottom,
+ lphc->RectButton.left, lphc->RectButton.top,
+ lphc->RectButton.right, lphc->RectButton.bottom );
+ dprintf_combo( stddeb, " client %d,%d-%d,%d window %d,%d-%d,%d\n",
+ wndPtr->rectClient.left, wndPtr->rectClient.top,
+ wndPtr->rectClient.right, wndPtr->rectClient.bottom,
+ wndPtr->rectWindow.left, wndPtr->rectWindow.top,
+ wndPtr->rectWindow.right, wndPtr->rectWindow.bottom );
+ return 0;
}
/***********************************************************************
@@ -205,14 +259,12 @@
HFONT hOldFont;
HDC hdc;
RECT rect;
- int height;
hdc = BeginPaint(hwnd, &ps);
-
- if (hComboBit != 0) {
+ if (hComboBit != 0 && !IsRectEmpty(&lphc->RectButton)) { /* work around #3 */
GRAPH_DrawReliefRect(hdc, &lphc->RectButton, 2, 2, FALSE);
GRAPH_DrawBitmap(hdc, hComboBit,
- lphc->RectButton.left + 3,lphc->RectButton.top + 2,
+ lphc->RectButton.left + 2,lphc->RectButton.top + 2,
0, 0, CBitWidth, CBitHeight );
}
if (!IsWindowVisible(hwnd) || !lphl->bRedrawFlag
@@ -234,12 +286,12 @@
if (hBrush == 0) hBrush = GetStockObject(WHITE_BRUSH);
GetClientRect(hwnd, &rect);
+
+ CBCheckSize(hwnd);
rect.right -= (lphc->RectButton.right - lphc->RectButton.left);
lpls = ListBoxGetItem(lphl,lphl->ItemFocused);
if (lpls != NULL) {
- height = lpls->mis.itemHeight;
- rect.bottom = rect.top + height;
FillRect(hdc, &rect, hBrush);
ListBoxDrawItem (hwnd, lphl, hdc, lpls, &rect, ODA_DRAWENTIRE, 0);
if (GetFocus() == hwnd)
@@ -389,7 +441,6 @@
wRet = ListBoxInsertString(lphl, wParam, (LPSTR)PTR_SEG_TO_LIN(lParam));
else
wRet = ListBoxInsertString(lphl, wParam, (LPSTR)lParam);
-
ComboUpdateWindow(hwnd, lphl, lphc, TRUE);
return wRet;
}
@@ -593,6 +644,59 @@
/***********************************************************************
+ * CBCheckSize
+ */
+static BOOL CBCheckSize(HWND hwnd)
+{
+ LPHEADCOMBO lphc = ComboGetStorageHeader(hwnd);
+ LPHEADLIST lphl = ComboGetListHeader(hwnd);
+ LONG cstyle = GetWindowLong(hwnd,GWL_STYLE);
+ RECT cRect,wRect;
+
+ /* TODO - The size of combo's and their listboxes is still broken */
+
+ if (lphc->hWndLBox == 0) return FALSE;
+
+ GetClientRect(hwnd,&cRect);
+ GetWindowRect(hwnd,&wRect);
+
+ dprintf_vxd(stddeb,"CBCheckSize: cRect %d,%d-%d,%d wRect %d,%d-%d,%d\n",
+ cRect.left,cRect.top,cRect.right,cRect.bottom,
+ wRect.left,wRect.top,wRect.right,wRect.bottom);
+
+ if ((cRect.bottom - cRect.top) >
+ (lphl->StdItemHeight + 2*SYSMETRICS_CYBORDER)) {
+ SetWindowPos(hwnd, 0, 0, 0,
+ cRect.right-cRect.left,
+ lphl->StdItemHeight+2*SYSMETRICS_CYBORDER,
+ SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE );
+ GetClientRect(hwnd,&cRect);
+ GetWindowRect(hwnd,&wRect);
+ }
+
+ switch (cstyle & 3) {
+ case CBS_SIMPLE:
+ break;
+ case CBS_DROPDOWN:
+ case CBS_DROPDOWNLIST:
+ lphc->RectButton.right = cRect.right;
+ lphc->RectButton.left = cRect.right - 2*SYSMETRICS_CXBORDER - 4
+ - CBitWidth;
+ lphc->RectButton.top = cRect.top;
+ lphc->RectButton.bottom = cRect.bottom;
+ break;
+ default:
+ fprintf(stderr,"CBCheckSize: style %lx not recognized!\n",cstyle);
+ return FALSE;
+ }
+
+ CBLCheckSize(hwnd);
+
+ return TRUE;
+}
+
+
+/***********************************************************************
* ComboWndProc
*/
LRESULT ComboBoxWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
@@ -610,6 +714,7 @@
case WM_LBUTTONDOWN: return CBLButtonDown(hwnd, wParam, lParam);
case WM_SETFOCUS: return CBSetFocus(hwnd, wParam, lParam);
case WM_KILLFOCUS: return CBKillFocus(hwnd, wParam, lParam);
+ case WM_SIZE: return CBCheckSize(hwnd);
case CB_RESETCONTENT: return CBResetContent(hwnd, wParam, lParam);
case CB_DIR: return CBDir(hwnd, wParam, lParam);
case CB_ADDSTRING: return CBAddString(hwnd, wParam, lParam);
@@ -736,6 +841,7 @@
PAINTSTRUCT ps;
HBRUSH hBrush;
HFONT hOldFont;
+ WND * wndPtr = WIN_FindWndPtr(hwnd);
HWND combohwnd = CLBoxGetCombo(hwnd);
HDC hdc;
RECT rect;
@@ -750,17 +856,12 @@
}
hOldFont = SelectObject(hdc, lphl->hFont);
-#ifdef WINELIB32
- hBrush = SendMessage(lphl->hParent, WM_CTLCOLORLISTBOX, hdc, hwnd);
-#else
- hBrush = SendMessage(lphl->hParent, WM_CTLCOLOR, hdc,
- MAKELONG(hwnd, CTLCOLOR_LISTBOX));
-#endif
-
- if (hBrush == 0) hBrush = GetStockObject(WHITE_BRUSH);
+ /* listboxes should be white */
+ hBrush = GetStockObject(WHITE_BRUSH);
GetClientRect(hwnd, &rect);
FillRect(hdc, &rect, hBrush);
+ CBLCheckSize(hwnd);
lpls = lphl->lpFirst;
@@ -797,7 +898,10 @@
lpls = lpls->lpNext;
}
- SetScrollRange(hwnd, SB_VERT, 0, ListMaxFirstVisible(lphl), TRUE);
+
+ if (wndPtr->dwStyle & WS_VSCROLL)
+ SetScrollRange(hwnd, SB_VERT, 0, ListMaxFirstVisible(lphl), TRUE);
+
SelectObject(hdc,hOldFont);
EndPaint( hwnd, &ps );
return 0;
@@ -967,6 +1071,57 @@
return 0;
}
+
+/***********************************************************************
+ * CBLCheckSize
+ */
+static BOOL CBLCheckSize(HWND hwnd)
+{
+ LPHEADCOMBO lphc = ComboGetStorageHeader(hwnd);
+ LPHEADLIST lphl = ComboGetListHeader(hwnd);
+ LPLISTSTRUCT lpls;
+ HWND hWndLBox;
+ RECT cRect,wRect,lRect,lwRect;
+ int totheight;
+ char className[80];
+
+ GetClassName(hwnd,className,80);
+ fflush(stddeb);
+ if (strncmp(className,"COMBOBOX",8)) return FALSE;
+ if ((hWndLBox = lphc->hWndLBox) == 0) return FALSE;
+ dprintf_vxd(stddeb,"CBLCheckSize headers hw %04x lb %04x name %s\n",
+ hwnd,hWndLBox,className);
+
+ GetClientRect(hwnd,&cRect);
+ GetWindowRect(hwnd,&wRect);
+ GetClientRect(hWndLBox,&lRect);
+ GetWindowRect(hWndLBox,&lwRect);
+
+ dprintf_vxd(stddeb,"CBLCheckSize: init cRect %d,%d-%d,%d wRect %d,%d-%d,%d\n",
+ cRect.left,cRect.top,cRect.right,cRect.bottom,
+ wRect.left,wRect.top,wRect.right,wRect.bottom);
+ dprintf_vxd(stddeb," lRect %d,%d-%d,%d lwRect %d,%d-%d,%d\n",
+ lRect.left,lRect.top,lRect.right,lRect.bottom,
+ lwRect.left,lwRect.top,lwRect.right,lwRect.bottom);
+ fflush(stddeb);
+
+ totheight = 0;
+ for (lpls=lphl->lpFirst; lpls != NULL; lpls=lpls->lpNext)
+ totheight += lpls->mis.itemHeight;
+
+ /* TODO: This isn't really what windows does */
+ if (lRect.bottom-lRect.top < 3*lphl->StdItemHeight) {
+ dprintf_vxd(stddeb," Changing; totHeight %d StdItemHght %d\n",
+ totheight,lphl->StdItemHeight);
+ SetWindowPos(hWndLBox, 0, lRect.left, lRect.top,
+ lwRect.right-lwRect.left, totheight+2*SYSMETRICS_CYBORDER,
+ SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE );
+ }
+
+ return TRUE;
+}
+
+
/***********************************************************************
* ComboLBoxWndProc
*/
@@ -984,6 +1139,7 @@
case WM_LBUTTONUP: return CBLLButtonUp(hwnd, wParam, lParam);
case WM_MOUSEMOVE: return CBLMouseMove(hwnd, wParam, lParam);
case WM_VSCROLL: return CBLVScroll(hwnd, wParam, lParam);
+ case WM_SIZE: return CBLCheckSize(hwnd);
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
diff --git a/controls/edit.c b/controls/edit.c
index 296365c..d55c954 100644
--- a/controls/edit.c
+++ b/controls/edit.c
@@ -48,7 +48,7 @@
typedef struct
{
UINT TextWidth; /* width of the widest line in pixels */
- HLOCAL hBuf;
+ HLOCAL16 hBuf;
char *text;
HFONT hFont;
LINEDEF *LineDefs;
@@ -64,7 +64,7 @@
UINT SelStart; /* offset of selection start, == SelEnd if no selection */
UINT SelEnd; /* offset of selection end == current caret position */
UINT NumTabStops;
- LPINT TabStops;
+ LPINT16 TabStops;
EDITWORDBREAKPROC WordBreakProc;
char PasswordChar;
} EDITSTATE;
@@ -858,7 +858,7 @@
RECT rcWnd;
RECT rcLine;
RECT rcUpdate;
- UINT line;
+ UINT l;
if (end == start )
return;
@@ -894,10 +894,10 @@
&rcLine);
if (IntersectRect(&rcUpdate, &rcWnd, &rcLine))
InvalidateRect(wndPtr->hwndSelf, &rcUpdate, FALSE);
- for (line = sl + 1 ; line < el ; line++) {
- EDIT_GetLineRect(wndPtr, line, 0,
+ for (l = sl + 1 ; l < el ; l++) {
+ EDIT_GetLineRect(wndPtr, l, 0,
(UINT)EDIT_EM_LineLength(wndPtr,
- (UINT)EDIT_EM_LineIndex(wndPtr, line, 0L), 0L),
+ (UINT)EDIT_EM_LineIndex(wndPtr, l, 0L), 0L),
&rcLine);
if (IntersectRect(&rcUpdate, &rcWnd, &rcLine))
InvalidateRect(wndPtr->hwndSelf, &rcUpdate, FALSE);
@@ -1262,7 +1262,7 @@
UINT ret;
char *text;
UINT li;
- INT xoff;
+ UINT xoff;
if (!count)
return 0;
@@ -1318,7 +1318,7 @@
{
const char *str = (char *)lParam;
int strl = strlen(str);
- int tl = EDIT_WM_GetTextLength(wndPtr, 0, 0L);
+ UINT tl = (UINT)EDIT_WM_GetTextLength(wndPtr, 0, 0L);
UINT s = LOWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
UINT e = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
int i;
@@ -1365,24 +1365,24 @@
static void EDIT_ScrollIntoView(WND *wndPtr)
{
UINT e = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
- int l = EDIT_EM_LineFromChar(wndPtr, e, 0L);
- int lineindex = EDIT_EM_LineIndex(wndPtr, l, 0L);
- int firstvis = (int)EDIT_EM_GetFirstVisibleLine(wndPtr, 0, 0L);
- int vislinecount = EDIT_GetVisibleLineCount(wndPtr);
- int wndwidth = EDIT_GetWndWidth(wndPtr);
- int charwidth = EDIT_GetAveCharWidth(wndPtr);
- int x = EDIT_WndXFromCol(wndPtr, l, e - lineindex);
+ UINT l = (UINT)EDIT_EM_LineFromChar(wndPtr, e, 0L);
+ UINT li = (UINT)EDIT_EM_LineIndex(wndPtr, l, 0L);
+ UINT fv = (UINT)EDIT_EM_GetFirstVisibleLine(wndPtr, 0, 0L);
+ UINT vlc = EDIT_GetVisibleLineCount(wndPtr);
+ UINT ww = EDIT_GetWndWidth(wndPtr);
+ UINT cw = EDIT_GetAveCharWidth(wndPtr);
+ INT x = EDIT_WndXFromCol(wndPtr, l, e - li);
int dy = 0;
int dx = 0;
- if (l >= firstvis + vislinecount)
- dy = l - vislinecount + 1 - firstvis;
- if (l < firstvis)
- dy = l - firstvis;
+ if (l >= fv + vlc)
+ dy = l - vlc + 1 - fv;
+ if (l < fv)
+ dy = l - fv;
if (x < 0)
- dx = x - wndwidth / HSCROLL_FRACTION / charwidth * charwidth;
- if (x > wndwidth)
- dx = x - (HSCROLL_FRACTION - 1) * wndwidth / HSCROLL_FRACTION / charwidth * charwidth;
+ dx = x - ww / HSCROLL_FRACTION / cw * cw;
+ if (x > ww)
+ dx = x - (HSCROLL_FRACTION - 1) * ww / HSCROLL_FRACTION / cw * cw;
if (dy || dx) {
EDIT_EM_LineScroll(wndPtr, 0, MAKELPARAM(dy, dx));
if (dy)
@@ -1404,24 +1404,24 @@
{
EDITSTATE *es = EDITSTATEPTR(wndPtr);
char *text = EDIT_GetPointer(wndPtr);
- int ret;
+ INT ret;
HDC hdc;
HFONT hFont;
HFONT oldFont = 0;
- int linecount = (int)EDIT_EM_GetLineCount(wndPtr, 0, 0L);
- int lineindex = EDIT_EM_LineIndex(wndPtr, line, 0L);
- int linelength = EDIT_EM_LineLength(wndPtr, lineindex, 0L);
- int xoffset = EDIT_GetXOffset(wndPtr);
+ UINT lc = (UINT)EDIT_EM_GetLineCount(wndPtr, 0, 0L);
+ UINT li = (UINT)EDIT_EM_LineIndex(wndPtr, line, 0L);
+ UINT ll = (UINT)EDIT_EM_LineLength(wndPtr, li, 0L);
+ UINT xoff = EDIT_GetXOffset(wndPtr);
hdc = GetDC(wndPtr->hwndSelf);
hFont = (HFONT)EDIT_WM_GetFont(wndPtr, 0, 0L);
if (hFont)
oldFont = SelectObject(hdc, hFont);
- line = MAX(0, MIN(line, linecount - 1));
- col = MAX(0, MIN(col, linelength));
+ line = MAX(0, MIN(line, lc - 1));
+ col = MIN(col, ll);
ret = LOWORD(GetTabbedTextExtent(hdc,
- text + lineindex, col,
- es->NumTabStops, es->TabStops)) - xoffset;
+ text + li, col,
+ es->NumTabStops, es->TabStops)) - xoff;
if (hFont)
SelectObject(hdc, oldFont);
ReleaseDC(wndPtr->hwndSelf, hdc);
@@ -1438,10 +1438,10 @@
*/
static INT EDIT_WndYFromLine(WND *wndPtr, UINT line)
{
- int firstvis = (int)EDIT_EM_GetFirstVisibleLine(wndPtr, 0, 0L);
- int lineheight = EDIT_GetLineHeight(wndPtr);
+ UINT fv = (UINT)EDIT_EM_GetFirstVisibleLine(wndPtr, 0, 0L);
+ UINT lh = EDIT_GetLineHeight(wndPtr);
- return (line - firstvis) * lineheight;
+ return (line - fv) * lh;
}
@@ -1458,7 +1458,7 @@
*/
static INT EDIT_WordBreakProc(char *s, INT index, INT count, INT action)
{
- int ret = 0;
+ INT ret = 0;
dprintf_edit(stddeb, "edit: EDIT_WordBreakProc: s=%p, index=%d"
", count=%d, action=%d\n", s, index, count, action);
@@ -1582,17 +1582,17 @@
char *src;
char *dst;
UINT len;
- int i;
- int linecount = (int)EDIT_EM_GetLineCount(wndPtr, 0, 0L);
+ UINT i;
+ UINT lc = (UINT)EDIT_EM_GetLineCount(wndPtr, 0, 0L);
if (!IsMultiLine(wndPtr))
wParam = 0;
- if ((UINT)wParam >= linecount)
+ if ((UINT)wParam >= lc)
return 0L;
text = EDIT_GetPointer(wndPtr);
- src = text + EDIT_EM_LineIndex(wndPtr, wParam, 0L);
+ src = text + (UINT)EDIT_EM_LineIndex(wndPtr, wParam, 0L);
dst = (char *)PTR_SEG_TO_LIN(lParam);
- len = MIN(*(WORD *)dst, EDIT_EM_LineLength(wndPtr, wParam, 0L));
+ len = MIN(*(WORD *)dst, (UINT)EDIT_EM_LineLength(wndPtr, wParam, 0L));
for (i = 0 ; i < len ; i++) {
*dst = *src;
src++;
@@ -1669,7 +1669,7 @@
*
* EM_GETTHUMB
*
- * undocumented: is this right ?
+ * FIXME: undocumented: is this right ?
*
*/
static LRESULT EDIT_EM_GetThumb(WND *wndPtr, WPARAM wParam, LPARAM lParam)
@@ -1723,14 +1723,14 @@
*/
static LRESULT EDIT_EM_LineFromChar(WND *wndPtr, WPARAM wParam, LPARAM lParam)
{
- int l;
+ UINT l;
if (!IsMultiLine(wndPtr))
return 0L;
if ((INT)wParam == -1)
wParam = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
- l = (int)EDIT_EM_GetLineCount(wndPtr, 0, 0L) - 1;
- while (EDIT_EM_LineIndex(wndPtr, l, 0L) > (UINT)wParam)
+ l = (UINT)EDIT_EM_GetLineCount(wndPtr, 0, 0L) - 1;
+ while ((UINT)EDIT_EM_LineIndex(wndPtr, l, 0L) > (UINT)wParam)
l--;
return (LRESULT)l;
}
@@ -1745,16 +1745,17 @@
{
EDITSTATE *es = EDITSTATEPTR(wndPtr);
UINT e;
- int l;
+ UINT l;
+ UINT lc = (UINT)EDIT_EM_GetLineCount(wndPtr, 0, 0L);
if ((INT)wParam == -1) {
e = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
- l = (int)EDIT_EM_GetLineCount(wndPtr, 0, 0L) - 1;
+ l = lc - 1;
while (es->LineDefs[l].offset > e)
l--;
return (LRESULT)es->LineDefs[l].offset;
}
- if ((UINT)wParam >= es->LineCount)
+ if ((UINT)wParam >= lc)
return -1L;
return (LRESULT)es->LineDefs[(UINT)wParam].offset;
}
@@ -1768,21 +1769,21 @@
static LRESULT EDIT_EM_LineLength(WND *wndPtr, WPARAM wParam, LPARAM lParam)
{
EDITSTATE *es = EDITSTATEPTR(wndPtr);
- UINT selstart;
- UINT selend;
- int startline;
- int endline;
+ UINT s;
+ UINT e;
+ UINT sl;
+ UINT el;
if (!IsMultiLine(wndPtr))
return (LRESULT)es->LineDefs[0].length;
if ((INT)wParam == -1) {
- selstart = LOWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
- selend = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
- startline = EDIT_EM_LineFromChar(wndPtr, selstart, 0L);
- endline = EDIT_EM_LineFromChar(wndPtr, selend, 0L);
- return (LRESULT)(selstart - es->LineDefs[startline].offset +
- es->LineDefs[endline].offset +
- es->LineDefs[endline].length - selend);
+ s = LOWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
+ e = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
+ sl = (UINT)EDIT_EM_LineFromChar(wndPtr, s, 0L);
+ el = (UINT)EDIT_EM_LineFromChar(wndPtr, e, 0L);
+ return (LRESULT)(s - es->LineDefs[sl].offset +
+ es->LineDefs[el].offset +
+ es->LineDefs[el].length - e);
}
return (LRESULT)es->LineDefs[(UINT)EDIT_EM_LineFromChar(wndPtr, wParam, 0L)].length;
}
@@ -1796,28 +1797,24 @@
static LRESULT EDIT_EM_LineScroll(WND *wndPtr, WPARAM wParam, LPARAM lParam)
{
EDITSTATE *es = EDITSTATEPTR(wndPtr);
- int linecount = (int)EDIT_EM_GetLineCount(wndPtr, 0, 0L);
- int firstvis = (int)EDIT_EM_GetFirstVisibleLine(wndPtr, 0, 0L);
- int newfirstvis = firstvis + (INT)LOWORD(lParam);
- int xoffset = EDIT_GetXOffset(wndPtr);
- int newxoffset = xoffset + (INT)HIWORD(lParam);
- int textwidth = EDIT_GetTextWidth(wndPtr);
- int dx;
- int dy;
+ UINT lc = (UINT)EDIT_EM_GetLineCount(wndPtr, 0, 0L);
+ UINT fv = (UINT)EDIT_EM_GetFirstVisibleLine(wndPtr, 0, 0L);
+ UINT nfv = MAX(0, fv + (INT)LOWORD(lParam));
+ UINT xoff = EDIT_GetXOffset(wndPtr);
+ UINT nxoff = MAX(0, xoff + (INT)HIWORD(lParam));
+ UINT tw = EDIT_GetTextWidth(wndPtr);
+ INT dx;
+ INT dy;
POINT pos;
HRGN hRgn;
- if (newfirstvis < 0)
- newfirstvis = 0;
- if (newfirstvis >= linecount)
- newfirstvis = linecount - 1;
+ if (nfv >= lc)
+ nfv = lc - 1;
- if (newxoffset < 0)
- newxoffset = 0;
- if (newxoffset >= textwidth)
- newxoffset = textwidth;
- dx = xoffset - newxoffset;
- dy = EDIT_WndYFromLine(wndPtr, firstvis) - EDIT_WndYFromLine(wndPtr, newfirstvis);
+ if (nxoff >= tw)
+ nxoff = tw;
+ dx = xoff - nxoff;
+ dy = EDIT_WndYFromLine(wndPtr, fv) - EDIT_WndYFromLine(wndPtr, nfv);
if (dx || dy) {
if (wndPtr->hwndSelf == GetFocus())
HideCaret(wndPtr->hwndSelf);
@@ -1830,8 +1827,8 @@
DeleteObject(hRgn);
ScrollWindow(wndPtr->hwndSelf, dx, dy, NULL, NULL);
}
- es->FirstVisibleLine = newfirstvis;
- es->XOffset = newxoffset;
+ es->FirstVisibleLine = nfv;
+ es->XOffset = nxoff;
if (IsVScrollBar(wndPtr))
SetScrollPos(wndPtr->hwndSelf, SB_VERT,
EDIT_WM_VScroll(wndPtr, EM_GETTHUMB, 0L), TRUE);
@@ -1888,7 +1885,7 @@
/*
* old buffer is freed by caller
*/
- es->hBuf = (HLOCAL)wParam;
+ es->hBuf = (HLOCAL16)wParam;
es->BufSize = LOCAL_Size(wndPtr->hInstance, es->hBuf) - 1;
es->LineCount = 0;
es->FirstVisibleLine = 0;
@@ -1898,6 +1895,7 @@
EDIT_BuildLineDefs(wndPtr);
if (EDIT_GetRedraw(wndPtr))
InvalidateRect(wndPtr->hwndSelf, NULL, TRUE);
+ EDIT_ScrollIntoView(wndPtr);
}
return 0L;
}
@@ -1982,9 +1980,9 @@
UINT ne = HIWORD(lParam);
UINT s = LOWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
UINT e = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
- int el;
- int elineindex;
- int tl = EDIT_WM_GetTextLength(wndPtr, 0, 0L);
+ UINT el;
+ UINT eli;
+ UINT tl = (UINT)EDIT_WM_GetTextLength(wndPtr, 0, 0L);
if ((INT)ns == -1) {
ns = e;
@@ -1997,9 +1995,9 @@
es->SelStart = ns;
es->SelEnd = ne;
if (wndPtr->hwndSelf == GetFocus()) {
- el = EDIT_EM_LineFromChar(wndPtr, ne, 0L);
- elineindex = EDIT_EM_LineIndex(wndPtr, el, 0L);
- SetCaretPos(EDIT_WndXFromCol(wndPtr, el, ne - elineindex),
+ el = (UINT)EDIT_EM_LineFromChar(wndPtr, ne, 0L);
+ eli = (UINT)EDIT_EM_LineIndex(wndPtr, el, 0L);
+ SetCaretPos(EDIT_WndXFromCol(wndPtr, el, ne - eli),
EDIT_WndYFromLine(wndPtr, el));
}
if (!wParam)
@@ -2038,9 +2036,9 @@
if (!wParam)
es->TabStops = NULL;
else {
- es->TabStops = (LPINT)xmalloc(wParam * sizeof(unsigned short));
- memcpy(es->TabStops, (LPINT)PTR_SEG_TO_LIN(lParam),
- (UINT)wParam * sizeof(INT));
+ es->TabStops = (LPINT16)xmalloc(wParam * sizeof(INT16));
+ memcpy(es->TabStops, (LPINT16)PTR_SEG_TO_LIN(lParam),
+ (UINT)wParam * sizeof(INT16));
}
return 1L;
}
@@ -2158,14 +2156,14 @@
if (e == s)
return -1L;
ORDER_UINT(s, e);
- hdst = GlobalAlloc(GMEM_MOVEABLE, (DWORD)(e - s + 1));
- dst = GlobalLock(hdst);
+ hdst = GlobalAlloc16(GMEM_MOVEABLE, (DWORD)(e - s + 1));
+ dst = GlobalLock16(hdst);
text = EDIT_GetPointer(wndPtr);
src = text + s;
for (i = 0 ; i < e - s ; i++)
*dst++ = *src++;
*dst = '\0';
- GlobalUnlock(hdst);
+ GlobalUnlock16(hdst);
OpenClipboard(wndPtr->hwndSelf);
EmptyClipboard();
SetClipboardData(CF_TEXT, hdst);
@@ -2208,8 +2206,15 @@
es->BufLimit = BUFLIMIT_SINGLE;
es->PasswordChar = (cs->style & ES_PASSWORD) ? '*' : '\0';
}
+ if (!LOCAL_HeapSize(wndPtr->hInstance)) {
+ if (!LocalInit(wndPtr->hInstance, 0, GlobalSize(wndPtr->hInstance))) {
+ fprintf(stderr, "edit: WM_CREATE: could not initialize local heap\n");
+ return -1L;
+ }
+ dprintf_edit(stddeb, "edit: WM_CREATE: local heap initialized\n");
+ }
if (!(es->hBuf = LOCAL_Alloc(wndPtr->hInstance, LMEM_MOVEABLE, es->BufSize + 1))) {
- fprintf(stderr, "edit: WM_CREATE: unable to heap buffer, please report !\n");
+ fprintf(stderr, "edit: WM_CREATE: unable to allocate buffer\n");
return -1L;
}
es->BufSize = LOCAL_Size(wndPtr->hInstance, es->hBuf) - 1;
@@ -2348,11 +2353,9 @@
*/
static LRESULT EDIT_WM_GetTextLength(WND *wndPtr, WPARAM wParam, LPARAM lParam)
{
- LRESULT ret;
char *text = EDIT_GetPointer(wndPtr);
- ret = (LRESULT)strlen(text);
- return ret;
+ return (LRESULT)strlen(text);
}
@@ -2365,43 +2368,43 @@
*/
static LRESULT EDIT_WM_HScroll(WND *wndPtr, WPARAM wParam, LPARAM lParam)
{
- int wndwidth = EDIT_GetWndWidth(wndPtr);
- int textwidth = EDIT_GetTextWidth(wndPtr);
- int charwidth = EDIT_GetAveCharWidth(wndPtr);
- int xoffset = EDIT_GetXOffset(wndPtr);
- int dx = 0;
+ UINT ww = EDIT_GetWndWidth(wndPtr);
+ UINT tw = EDIT_GetTextWidth(wndPtr);
+ UINT cw = EDIT_GetAveCharWidth(wndPtr);
+ UINT xoff = EDIT_GetXOffset(wndPtr);
+ INT dx = 0;
BOOL not = TRUE;
LRESULT ret = 0L;
switch (wParam) {
case SB_LINELEFT:
- dx = -charwidth;
+ dx = -cw;
break;
case SB_LINERIGHT:
- dx = charwidth;
+ dx = cw;
break;
case SB_PAGELEFT:
- dx = -wndwidth / HSCROLL_FRACTION / charwidth * charwidth;
+ dx = -ww / HSCROLL_FRACTION / cw * cw;
break;
case SB_PAGERIGHT:
- dx = wndwidth / HSCROLL_FRACTION / charwidth * charwidth;
+ dx = ww / HSCROLL_FRACTION / cw * cw;
break;
case SB_LEFT:
- dx = -xoffset;
+ dx = -xoff;
break;
case SB_RIGHT:
- dx = textwidth - xoffset;
+ dx = tw - xoff;
break;
case SB_THUMBTRACK:
/*
* not = FALSE;
*/
case SB_THUMBPOSITION:
- dx = LOWORD(lParam) * textwidth / 100 - xoffset;
+ dx = LOWORD(lParam) * tw / 100 - xoff;
break;
/* The next two are undocumented ! */
case EM_GETTHUMB:
- ret = textwidth ? MAKELONG(xoffset * 100 / textwidth, 0) : 0;
+ ret = tw ? MAKELONG(xoff * 100 / tw, 0) : 0;
break;
case EM_LINESCROLL:
dx = LOWORD(lParam);
@@ -2539,11 +2542,11 @@
*/
static LRESULT EDIT_WM_LButtonDblClk(WND *wndPtr, WPARAM wParam, LPARAM lParam)
{
- int s;
+ UINT s;
UINT e = HIWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
- UINT l = EDIT_EM_LineFromChar(wndPtr, e, 0L);
- int li = EDIT_EM_LineIndex(wndPtr, l, 0L);
- int ll = EDIT_EM_LineLength(wndPtr, e, 0L);
+ UINT l = (UINT)EDIT_EM_LineFromChar(wndPtr, e, 0L);
+ UINT li = (UINT)EDIT_EM_LineIndex(wndPtr, l, 0L);
+ UINT ll = (UINT)EDIT_EM_LineLength(wndPtr, e, 0L);
char *text = EDIT_GetPointer(wndPtr);
s = li + EDIT_CallWordBreakProc(wndPtr, text + li, e - li, ll, WB_LEFT);
@@ -2575,7 +2578,7 @@
l = MIN(fv + vlc - 1, MAX(fv, l));
x = MIN(EDIT_GetWndWidth(wndPtr), MAX(0, x));
c = EDIT_ColFromWndX(wndPtr, l, x);
- li = EDIT_EM_LineIndex(wndPtr, l, 0L);
+ li = (UINT)EDIT_EM_LineIndex(wndPtr, l, 0L);
e = li + c;
if (GetKeyState(VK_SHIFT) & 0x8000)
s = LOWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
@@ -2625,7 +2628,7 @@
x = MIN(EDIT_GetWndWidth(wndPtr), MAX(0, x));
c = EDIT_ColFromWndX(wndPtr, l, x);
s = LOWORD(EDIT_EM_GetSel(wndPtr, 0, 0L));
- li = EDIT_EM_LineIndex(wndPtr, l, 0L);
+ li = (UINT)EDIT_EM_LineIndex(wndPtr, l, 0L);
EDIT_EM_SetSel(wndPtr, 1, MAKELPARAM(s, li + c));
}
return 0L;
@@ -2639,10 +2642,11 @@
*/
static LRESULT EDIT_WM_Paint(WND *wndPtr, WPARAM wParam, LPARAM lParam)
{
- EDITSTATE *es = EDITSTATEPTR(wndPtr);
PAINTSTRUCT ps;
- int i;
- int firstvis = (int)EDIT_EM_GetFirstVisibleLine(wndPtr, 0, 0L);
+ UINT i;
+ UINT fv = (UINT)EDIT_EM_GetFirstVisibleLine(wndPtr, 0, 0L);
+ UINT vlc = EDIT_GetVisibleLineCount(wndPtr);
+ UINT lc = (UINT)EDIT_EM_GetLineCount(wndPtr, 0, 0L);
HDC hdc;
HFONT hFont;
HFONT oldFont = 0;
@@ -2663,7 +2667,7 @@
if (!IsWindowEnabled(wndPtr->hwndSelf))
SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT));
GetClipBox(hdc, &rcRgn);
- for (i = firstvis ; i <= MIN(firstvis + EDIT_GetVisibleLineCount(wndPtr), firstvis + es->LineCount - 1) ; i++ ) {
+ for (i = fv ; i <= MIN(fv + vlc, fv + lc - 1) ; i++ ) {
EDIT_GetLineRect(wndPtr, i, 0, -1, &rcLine);
if (IntersectRect(&rc, &rcRgn, &rcLine))
EDIT_PaintLine(wndPtr, hdc, i, rev);
@@ -2687,9 +2691,9 @@
OpenClipboard(wndPtr->hwndSelf);
if ((hsrc = GetClipboardData(CF_TEXT))) {
- src = (char *)GlobalLock(hsrc);
+ src = (char *)GlobalLock16(hsrc);
EDIT_ReplaceSel(wndPtr, 0, (LPARAM)src);
- GlobalUnlock(hsrc);
+ GlobalUnlock16(hsrc);
}
CloseClipboard();
return -1L;
@@ -2749,7 +2753,7 @@
if (es->hFont)
oldFont = SelectObject(hdc, es->hFont);
GetTextMetrics(hdc, &tm);
- es->LineHeight = HIWORD(GetTextExtent(hdc, "", 0));
+ es->LineHeight = HIWORD(GetTextExtent(hdc, "X", 1));
es->AveCharWidth = tm.tmAveCharWidth;
if (es->hFont)
SelectObject(hdc, oldFont);
@@ -2794,6 +2798,7 @@
EDIT_EM_ReplaceSel(wndPtr, 0, lParam);
EDIT_EM_EmptyUndoBuffer(wndPtr, 0, 0L);
EDIT_EM_SetModify(wndPtr, TRUE, 0L);
+ EDIT_ScrollIntoView(wndPtr);
return 0L;
}
@@ -2825,10 +2830,10 @@
*/
static LRESULT EDIT_WM_VScroll(WND *wndPtr, WPARAM wParam, LPARAM lParam)
{
- int linecount = (int)EDIT_EM_GetLineCount(wndPtr, 0, 0L);
- int firstvis = (int)EDIT_EM_GetFirstVisibleLine(wndPtr, 0, 0L);
- int vislinecount = EDIT_GetVisibleLineCount(wndPtr);
- int dy = 0;
+ UINT lc = (UINT)EDIT_EM_GetLineCount(wndPtr, 0, 0L);
+ UINT fv = (UINT)EDIT_EM_GetFirstVisibleLine(wndPtr, 0, 0L);
+ UINT vlc = EDIT_GetVisibleLineCount(wndPtr);
+ INT dy = 0;
BOOL not = TRUE;
LRESULT ret = 0L;
@@ -2840,27 +2845,27 @@
dy = 1;
break;
case SB_PAGEUP:
- dy = -vislinecount;
+ dy = -vlc;
break;
case SB_PAGEDOWN:
- dy = vislinecount;
+ dy = vlc;
break;
case SB_TOP:
- dy = -firstvis;
+ dy = -fv;
break;
case SB_BOTTOM:
- dy = linecount - 1 - firstvis;
+ dy = lc - 1 - fv;
break;
case SB_THUMBTRACK:
/*
* not = FALSE;
*/
case SB_THUMBPOSITION:
- dy = LOWORD(lParam) * (linecount - 1) / 100 - firstvis;
+ dy = LOWORD(lParam) * (lc - 1) / 100 - fv;
break;
/* The next two are undocumented ! */
case EM_GETTHUMB:
- ret = (linecount > 1) ? MAKELONG(firstvis * 100 / (linecount - 1), 0) : 0L;
+ ret = (lc > 1) ? MAKELONG(fv * 100 / (lc - 1), 0) : 0L;
break;
case EM_LINESCROLL:
dy = LOWORD(lParam);
diff --git a/controls/listbox.c b/controls/listbox.c
index dbec947..b6d31c0 100644
--- a/controls/listbox.c
+++ b/controls/listbox.c
@@ -130,14 +130,9 @@
lphl->hDrawItemStruct = 0;
}
-#if 0
- HeapHandle = GlobalAlloc(GMEM_FIXED, LIST_HEAP_SIZE);
- HeapBase = GlobalLock(HeapHandle);
- HEAP_Init(&lphl->Heap, HeapBase, LIST_HEAP_SIZE);
-#endif
/* WINELIBS list boxes do not operate on local heaps */
#ifndef WINELIB
- lphl->HeapSel = GlobalAlloc(GMEM_FIXED,LIST_HEAP_SIZE);
+ lphl->HeapSel = GlobalAlloc16(GMEM_FIXED,LIST_HEAP_SIZE);
LocalInit( lphl->HeapSel, 0, LIST_HEAP_SIZE-1);
#else
lphl->HeapSel = 0;
@@ -150,7 +145,7 @@
USER_HEAP_FREE(lphl->hDrawItemStruct);
/* XXX need to free lphl->Heap */
- GlobalFree(lphl->HeapSel);
+ GlobalFree16(lphl->HeapSel);
free(lphl);
}
@@ -184,11 +179,14 @@
void ListBoxUpdateWindow(HWND hwnd, LPHEADLIST lphl, BOOL repaint)
{
- SetScrollRange(hwnd, SB_VERT, 0, ListMaxFirstVisible(lphl), TRUE);
- if (lphl->ItemsPerColumn != 0) {
+ WND *wndPtr = WIN_FindWndPtr(hwnd);
+
+ if (wndPtr->dwStyle & WS_VSCROLL)
+ SetScrollRange(hwnd, SB_VERT, 0, ListMaxFirstVisible(lphl), TRUE);
+ if ((wndPtr->dwStyle & WS_HSCROLL) && (lphl->ItemsPerColumn != 0))
SetScrollRange(hwnd, SB_HORZ, 1, lphl->ItemsVisible /
lphl->ItemsPerColumn + 1, TRUE);
- }
+
if (repaint && lphl->bRedrawFlag) {
InvalidateRect(hwnd, NULL, TRUE);
}
@@ -328,7 +326,8 @@
SendMessage(lphl->hParent, WM_MEASUREITEM, 0, (LPARAM)USER_HEAP_SEG_ADDR(hTemp));
if (lphl->dwStyle & LBS_OWNERDRAWFIXED) {
- lphl->StdItemHeight = lpmeasure->itemHeight;
+ if (lpmeasure->itemHeight > lphl->StdItemHeight)
+ lphl->StdItemHeight = lpmeasure->itemHeight;
lpls->mis.itemHeight = lpmeasure->itemHeight;
}
@@ -356,6 +355,7 @@
}
+
int ListBoxInsertString(LPHEADLIST lphl, UINT uIndex, LPCSTR newstr)
{
LPLISTSTRUCT *lppls, lplsnew, lpls;
@@ -393,7 +393,7 @@
hStr = LIST_HEAP_ALLOC(lphl, LMEM_MOVEABLE, strlen(newstr) + 1);
str = (LPSTR)LIST_HEAP_ADDR(lphl, hStr);
if (str == NULL) return LB_ERRSPACE;
- strcpy(str, newstr);
+ strcpy(str, newstr);
lplsnew->itemText = str;
/* I'm not so sure about the next one */
lplsnew->mis.itemData = 0;
@@ -783,8 +783,10 @@
GetClientRect(hwnd,&rect);
lphl->ColumnsWidth = rect.right - rect.left;
- SetScrollRange(hwnd, SB_VERT, 0, ListMaxFirstVisible(lphl), TRUE);
- SetScrollRange(hwnd, SB_HORZ, 1, 1, TRUE);
+ if (dwStyle & WS_VSCROLL)
+ SetScrollRange(hwnd, SB_VERT, 0, ListMaxFirstVisible(lphl), TRUE);
+ if (dwStyle & WS_HSCROLL)
+ SetScrollRange(hwnd, SB_HORZ, 1, 1, TRUE);
return 0;
}
@@ -1307,7 +1309,6 @@
RECT rect, paintRect, scratchRect;
int i, top, height, maxwidth, ipc;
-
top = 0;
if (!IsWindowVisible(hwnd) || !lphl->bRedrawFlag) {
diff --git a/controls/menu.c b/controls/menu.c
index eecb575..20f4e06 100644
--- a/controls/menu.c
+++ b/controls/menu.c
@@ -62,9 +62,12 @@
((DWORD)MAKELONG( (WORD)(item)->hText, (item)->xTab ))
extern void NC_DrawSysButton(HWND hwnd, HDC hdc, BOOL down); /* nonclient.c */
+static HMENU MENU_CopySysMenu(void);
static HBITMAP hStdCheck = 0;
static HBITMAP hStdMnArrow = 0;
+static HMENU MENU_DefSysMenu = 0; /* Default system menu */
+
/* we _can_ use global popup window because there's no way 2 menues can
* be tracked at the same time.
@@ -95,11 +98,27 @@
arrow_bitmap_width = bm.bmWidth;
arrow_bitmap_height = bm.bmHeight;
+ if (!(MENU_DefSysMenu = MENU_CopySysMenu()))
+ {
+ fprintf( stderr, "Unable to create default system menu\n" );
+ return FALSE;
+ }
return TRUE;
}
/***********************************************************************
+ * MENU_GetDefSysMenu
+ *
+ * Return the default system menu.
+ */
+HMENU MENU_GetDefSysMenu(void)
+{
+ return MENU_DefSysMenu;
+}
+
+
+/***********************************************************************
* MENU_HasSysMenu
*
* Check whether the window owning the menu bar has a system menu.
@@ -124,7 +143,7 @@
POPUPMENU *menu;
if (!(handle = SYSRES_LoadResource( SYSRES_MENU_SYSMENU ))) return 0;
- hMenu = LoadMenuIndirect( WIN16_GlobalLock( handle ) );
+ hMenu = LoadMenuIndirect( WIN16_GlobalLock16( handle ) );
SYSRES_FreeResource( handle );
if (!hMenu)
{
@@ -246,7 +265,7 @@
int i;
LONG menuchar;
- if (!IsMenu( hmenu )) hmenu = GetSystemMenu( hwndOwner, FALSE);
+ if (!IsMenu( hmenu )) hmenu = WIN_FindWndPtr(hwndOwner)->hSysMenu;
if (!hmenu) return -1;
menu = (POPUPMENU *) USER_HEAP_LIN_ADDR( hmenu );
@@ -692,7 +711,7 @@
{
/* This is supposed to be called when popup is hidden */
- TDB* task = (TDB*)GlobalLock(hTask);
+ TDB* task = (TDB*)GlobalLock16(hTask);
if( !task ) return 0;
@@ -730,7 +749,7 @@
if (!pTopPWnd)
{
- pTopPWnd = WIN_FindWndPtr(CreateWindow( POPUPMENU_CLASS_ATOM, (SEGPTR)0,
+ pTopPWnd = WIN_FindWndPtr(CreateWindow16( POPUPMENU_CLASS_ATOM, (SEGPTR)0,
WS_POPUP | WS_BORDER, x, y,
menu->Width + 2*SYSMETRICS_CXBORDER,
menu->Height + 2*SYSMETRICS_CYBORDER,
@@ -742,7 +761,7 @@
if( uSubPWndLevel )
{
/* create new window for the submenu */
- HWND hWnd = CreateWindow( POPUPMENU_CLASS_ATOM, (SEGPTR)0,
+ HWND hWnd = CreateWindow16( POPUPMENU_CLASS_ATOM, (SEGPTR)0,
WS_POPUP | WS_BORDER, x, y,
menu->Width + 2*SYSMETRICS_CXBORDER,
menu->Height + 2*SYSMETRICS_CYBORDER,
@@ -818,12 +837,12 @@
#ifdef WINELIB32
/* FIX: LostInfo */
SendMessage( hwndOwner, WM_MENUSELECT,
- MAKEWPARAM( (DWORD)GetSystemMenu( lppop->hWnd, FALSE ),
+ MAKEWPARAM( WIN_FindWndPtr(lppop->hWnd)->hSysMenu,
lppop->wFlags | MF_MOUSESELECT ),
(LPARAM)hmenu );
#else
SendMessage( hwndOwner, WM_MENUSELECT,
- GetSystemMenu( lppop->hWnd, FALSE ),
+ WIN_FindWndPtr(lppop->hWnd)->hSysMenu,
MAKELONG( lppop->wFlags | MF_MOUSESELECT, hmenu ) );
#endif
}
@@ -1111,7 +1130,7 @@
menu = (POPUPMENU *) USER_HEAP_LIN_ADDR( hmenu );
if (menu->FocusedItem == NO_SELECTED_ITEM) return 0;
else if (menu->FocusedItem == SYSMENU_SELECTED)
- return GetSystemMenu( menu->hWnd, FALSE );
+ return WIN_FindWndPtr(menu->hWnd)->hSysMenu;
item = ((MENUITEM *)USER_HEAP_LIN_ADDR(menu->hItems)) + menu->FocusedItem;
if (!(item->item_flags & MF_POPUP) || !(item->item_flags & MF_MOUSESELECT))
@@ -1135,7 +1154,7 @@
if (menu->FocusedItem == NO_SELECTED_ITEM) return;
if (menu->FocusedItem == SYSMENU_SELECTED)
{
- hsubmenu = GetSystemMenu( menu->hWnd, FALSE );
+ hsubmenu = WIN_FindWndPtr(menu->hWnd)->hSysMenu;
}
else
{
@@ -1345,7 +1364,7 @@
{
if (!MENU_IsInSysMenu( menu, pt )) return FALSE;
id = SYSMENU_SELECTED;
- hsubmenu = GetSystemMenu( menu->hWnd, FALSE );
+ hsubmenu = WIN_FindWndPtr(menu->hWnd)->hSysMenu;
}
if (menu->FocusedItem != id) return FALSE;
@@ -1498,7 +1517,7 @@
HWND hwnd, LPRECT lprect )
{
MSG *msg;
- HLOCAL hMsg;
+ HLOCAL16 hMsg;
POPUPMENU *menu;
HMENU hmenuCurrent = hmenu;
BOOL fClosed = FALSE, fRemove;
@@ -2219,7 +2238,10 @@
{
LPPOPUPMENU lppop;
dprintf_menu(stddeb,"DestroyMenu (%04x) !\n", hMenu);
+
if (hMenu == 0) return FALSE;
+ /* Silently ignore attempts to destroy default system menu */
+ if (hMenu == MENU_DefSysMenu) return TRUE;
lppop = (LPPOPUPMENU) USER_HEAP_LIN_ADDR(hMenu);
if (!lppop || (lppop->wMagic != MENU_MAGIC)) return FALSE;
lppop->wMagic = 0; /* Mark it as destroyed */
@@ -2252,6 +2274,11 @@
WND *wndPtr = WIN_FindWndPtr( hWnd );
if (!wndPtr) return 0;
+ if (!wndPtr->hSysMenu || (wndPtr->hSysMenu == MENU_DefSysMenu))
+ {
+ wndPtr->hSysMenu = MENU_CopySysMenu();
+ return wndPtr->hSysMenu;
+ }
if (!bRevert) return wndPtr->hSysMenu;
if (wndPtr->hSysMenu) DestroyMenu(wndPtr->hSysMenu);
wndPtr->hSysMenu = MENU_CopySysMenu();
@@ -2267,7 +2294,8 @@
WND *wndPtr;
if (!(wndPtr = WIN_FindWndPtr(hwnd))) return FALSE;
- if (wndPtr->hSysMenu) DestroyMenu( wndPtr->hSysMenu );
+ if (wndPtr->hSysMenu && (wndPtr->hSysMenu != MENU_DefSysMenu))
+ DestroyMenu( wndPtr->hSysMenu );
wndPtr->hSysMenu = hMenu;
return TRUE;
}
diff --git a/controls/scroll.c b/controls/scroll.c
index 27323a6..e0e7617 100644
--- a/controls/scroll.c
+++ b/controls/scroll.c
@@ -956,7 +956,7 @@
/*************************************************************************
* GetScrollRange (USER.65)
*/
-void GetScrollRange(HWND hwnd, int nBar, LPINT lpMin, LPINT lpMax)
+void GetScrollRange(HWND hwnd, int nBar, LPINT16 lpMin, LPINT16 lpMax)
{
SCROLLINFO *infoPtr;
diff --git a/controls/static.c b/controls/static.c
index 9f470b5..9b88116 100644
--- a/controls/static.c
+++ b/controls/static.c
@@ -58,10 +58,10 @@
infoPtr->hIcon = hicon;
if (hicon)
{
- CURSORICONINFO *info = (CURSORICONINFO *) GlobalLock( hicon );
+ CURSORICONINFO *info = (CURSORICONINFO *) GlobalLock16( hicon );
SetWindowPos( wndPtr->hwndSelf, 0, 0, 0, info->nWidth, info->nHeight,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
- GlobalUnlock( hicon );
+ GlobalUnlock16( hicon );
}
return prevIcon;
}
diff --git a/controls/widgets.c b/controls/widgets.c
index e541835..1f737bc 100644
--- a/controls/widgets.c
+++ b/controls/widgets.c
@@ -15,7 +15,7 @@
#include "module.h"
#include "stackframe.h"
-static WNDCLASS WIDGETS_BuiltinClasses[] =
+static WNDCLASS16 WIDGETS_BuiltinClasses[] =
{
{ CS_GLOBALCLASS | CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW | CS_PARENTDC,
(WNDPROC)"ButtonWndProc", 0, sizeof(BUTTONINFO),
@@ -61,7 +61,7 @@
{
int i;
char name[20];
- WNDCLASS *class = WIDGETS_BuiltinClasses;
+ WNDCLASS16 *class = WIDGETS_BuiltinClasses;
for (i = 0; i < NB_BUILTIN_CLASSES; i++, class++)
{
@@ -69,7 +69,7 @@
class->lpszClassName = MAKE_SEGPTR(name);
class->hCursor = LoadCursor( 0, IDC_ARROW );
class->lpfnWndProc = MODULE_GetWndProcEntry16( (char *)class->lpfnWndProc );
- if (!RegisterClass( class )) return FALSE;
+ if (!RegisterClass16( class )) return FALSE;
}
return TRUE;
}