Release 0.4.10

Mon Nov 22 13:58:56 1993  David Metcalfe <david@prism.demon.co.uk>

        * [windows/scroll.c]
	Preliminary implementations of ScrollWindow, ScrollDC and
        ScrollWindowEx.

Nov 21, 93 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)

	* [controls/listbox.c]
	Optimization of redraw during 'Add' or 'Insert'.

	* [controls/scroll.c]
	Optimization of WM_PAINT during 'thumbtracking'.

	* [controls/button.c]
	Add of beta implement of 'BS_OWNERDRAW'

	* [controls/static.c]
	Style 'SS_ICON' new supported.

	* [misc/message.c]
	Begin of implemantation of MB_XXX styles.

	* [loader/resource.c]
	Function LoadIcon() : now prepare transparency Bitmap mask.
	Function LoadCursor() : now prepare a 'X pixmapcursor'.
	New function SetCursor() : not finished.
	New function ShowCursor() : not finished.
	New function AccessResource() : stub.

	* [obj/dib.c]
	Function DrawIcon(): deugging phase of icon transparency mask.

	* [loader/library.c]
	new file for news functions LoadLibrary() & FreeLibrary().

	* [sysres.dll]
	Resources only 16bits DLL for System Resources, icons, etc...

Sun Nov 14 14:39:06 1993  julliard@di.epfl.ch (Alexandre Julliard)

	* [include/dialog.h] [windows/dialog.c]
	Simplified dialog template parsing.
	Implemented DialogBoxIndirect().

	* [windows/win.c]
	Fixed bug in CreateWindow() when aborting window creation.
	Modified UpdateWindow() to only update visible windows.
	Implemented IsWindow().

Nov 14, 93 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)

	* [controls/listbox.c]
	Listbox control window : new messages.

	* [controls/combo.c]
	Combo box control window : new messages.

	* [misc/message.c]
	Moved stub MessageBox() to this new file.
	Implemented of a callback, now MessageBox show a window.

	* [loader/resource.c]
	New function DestroyIcon()
	New function DestroyCursor()
	Filled stub LoadIcon()
	Filled stub LoadCursor()
	Bug fixed in FindResourceByName() : missing lseek().

	* [obj/dib.c]
	New function DrawIcon()

	* [windows/win.c]
	New function CloseWindow()
	New function OpenIcon()
	New function IsIconic()
	New Function FindWindow()

Sun Nov 14 08:27:19 1993  Karl Guenter Wuensch (hz225wu@unidui.uni-duisburg.de)

	* [loader/selector.c]
	Wrote AllocCStoDSAlias() and AllocDStoCSAlias()

Sun Nov 14 08:27:19 1993  Bob Amstadt  (bob at amscons)

	* [loader/selector.c]
	Wrote AllocSelector() and PrestoChangoSelector().  YUK!

Sat Nov 13 13:56:42 1993  Bob Amstadt  (bob at amscons)

	* [loader/resource.c]
	Wrote FindResource(), LoadResource(), LockResource(),
	and FreeResource()

	* [include/segmem.h] [loader/selector.c] [loader/signal.h]
	Changed selector allocation method.

Sun Nov 10 08:27:19 1993  Karl Guenter Wuensch (hz225wu@unidui.uni-duisburg.de)

	* [if1632/callback.c if1632/call.S if1632/user.spec] 
	added Catch (KERNEL.55) and Throw (KERNEL.56)
	
Nov 7, 93 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)

	* [controls/scroll.c]
	Scroll bar control window
		Bug resolved : Painting message before scroll visible.

	* [controls/listbox.c]
	Listbox control window
		Destroy cleanup.

	* [controls/combo.c]
	Combo box control window
		Destroy cleanup.

	* [controls/button.c]
		GetCheck Message now return is state.

	* [windows/win.c]
	New function IsWindowVisible()
This commit is contained in:
Alexandre Julliard 1993-11-24 17:08:56 +00:00
parent 0e60778484
commit e399fc3636
51 changed files with 2357 additions and 2136 deletions

123
ChangeLog
View File

@ -1,3 +1,126 @@
Mon Nov 22 13:58:56 1993 David Metcalfe <david@prism.demon.co.uk>
* [windows/scroll.c]
Preliminary implementations of ScrollWindow, ScrollDC and
ScrollWindowEx.
Nov 21, 93 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)
* [controls/listbox.c]
Optimization of redraw during 'Add' or 'Insert'.
* [controls/scroll.c]
Optimization of WM_PAINT during 'thumbtracking'.
* [controls/button.c]
Add of beta implement of 'BS_OWNERDRAW'
* [controls/static.c]
Style 'SS_ICON' new supported.
* [misc/message.c]
Begin of implemantation of MB_XXX styles.
* [loader/resource.c]
Function LoadIcon() : now prepare transparency Bitmap mask.
Function LoadCursor() : now prepare a 'X pixmapcursor'.
New function SetCursor() : not finished.
New function ShowCursor() : not finished.
New function AccessResource() : stub.
* [obj/dib.c]
Function DrawIcon(): deugging phase of icon transparency mask.
* [loader/library.c]
new file for news functions LoadLibrary() & FreeLibrary().
* [sysres.dll]
Resources only 16bits DLL for System Resources, icons, etc...
----------------------------------------------------------------------
Sun Nov 14 14:39:06 1993 julliard@di.epfl.ch (Alexandre Julliard)
* [include/dialog.h] [windows/dialog.c]
Simplified dialog template parsing.
Implemented DialogBoxIndirect().
* [windows/win.c]
Fixed bug in CreateWindow() when aborting window creation.
Modified UpdateWindow() to only update visible windows.
Implemented IsWindow().
Nov 14, 93 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)
* [controls/listbox.c]
Listbox control window : new messages.
* [controls/combo.c]
Combo box control window : new messages.
* [misc/message.c]
Moved stub MessageBox() to this new file.
Implemented of a callback, now MessageBox show a window.
* [loader/resource.c]
New function DestroyIcon()
New function DestroyCursor()
Filled stub LoadIcon()
Filled stub LoadCursor()
Bug fixed in FindResourceByName() : missing lseek().
* [obj/dib.c]
New function DrawIcon()
* [windows/win.c]
New function CloseWindow()
New function OpenIcon()
New function IsIconic()
New Function FindWindow()
Sun Nov 14 08:27:19 1993 Karl Guenter Wuensch (hz225wu@unidui.uni-duisburg.de)
* [loader/selector.c]
Wrote AllocCStoDSAlias() and AllocDStoCSAlias()
Sun Nov 14 08:27:19 1993 Bob Amstadt (bob at amscons)
* [loader/selector.c]
Wrote AllocSelector() and PrestoChangoSelector(). YUK!
Sat Nov 13 13:56:42 1993 Bob Amstadt (bob at amscons)
* [loader/resource.c]
Wrote FindResource(), LoadResource(), LockResource(),
and FreeResource()
* [include/segmem.h] [loader/selector.c] [loader/signal.h]
Changed selector allocation method.
Sun Nov 10 08:27:19 1993 Karl Guenter Wuensch (hz225wu@unidui.uni-duisburg.de)
* [if1632/callback.c if1632/call.S if1632/user.spec]
added Catch (KERNEL.55) and Throw (KERNEL.56)
Nov 7, 93 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)
* [controls/scroll.c]
Scroll bar control window
Bug resolved : Painting message before scroll visible.
* [controls/listbox.c]
Listbox control window
Destroy cleanup.
* [controls/combo.c]
Combo box control window
Destroy cleanup.
* [controls/button.c]
GetCheck Message now return is state.
* [windows/win.c]
New function IsWindowVisible()
Mon Nov 1 14:40:21 1993 julliard@di.epfl.ch (Alexandre Julliard)
* [if1632/user.spec]

View File

@ -1,6 +1,6 @@
######################################################################
# These variables are inherited by the sub-makefiles
DEBUGOPTS=-DDEBUG_RESOURCE
DEBUGOPTS=
COPTS=-O2 -m486
INCLUDE_DIR=include
LDFLAGS=

13
README
View File

@ -31,6 +31,19 @@ For example, to run Windows' solitaire:
Have a nice game of solitaire, but be careful. Emulation isn't perfect.
So, occassionally it will crash.
WHAT'S NEW with version 0.4.10: (see ChangeLog for details)
- Bug fixes
- More scroll bar functions
- More icon and cursor handling
WHAT'S NEW with version 0.4.9: (see ChangeLog for details)
- Bug fixes
- real MessageBox()
- New resource functions
- Icon functions
- Selector manipulation functions
- Catch()/Throw()
WHAT'S NEW with version 0.4.7: (see ChangeLog for details)
- More dialog box functions
- More DOS interrupts

View File

@ -9,6 +9,7 @@ static char Copyright2[] = "Copyright David Metcalfe, 1993";
#include <windows.h>
#include "win.h"
#include "user.h"
LONG ButtonWndProc(HWND hWnd, WORD uMsg, WORD wParam, LONG lParam);
@ -48,6 +49,10 @@ static LONG UB_Paint(HWND hWnd);
static LONG UB_LButtonDown(HWND hWnd, WORD wParam, LONG lParam);
static LONG UB_LButtonUp(HWND hWnd, WORD wParam, LONG lParam);
static LONG UB_KillFocus(HWND hWnd);
static LONG OB_Paint(HWND hWnd);
static LONG OB_LButtonDown(HWND hWnd, WORD wParam, LONG lParam);
static LONG OB_LButtonUp(HWND hWnd, WORD wParam, LONG lParam);
static LONG OB_KillFocus(HWND hWnd);
typedef struct
{
@ -60,7 +65,7 @@ typedef struct
LONG (*getCheckfn)();
} BTNFN;
#define MAX_BTN_TYPE 10
#define MAX_BTN_TYPE 12
static BTNFN btnfn[MAX_BTN_TYPE] =
{
@ -153,7 +158,25 @@ static BTNFN btnfn[MAX_BTN_TYPE] =
(LONG(*)())RB_KillFocus,
(LONG(*)())RB_SetCheck,
(LONG(*)())RB_GetCheck
}
},
{
(LONG(*)())NULL, /* Not defined */
(LONG(*)())NULL,
(LONG(*)())NULL,
(LONG(*)())NULL,
(LONG(*)())NULL,
(LONG(*)())NULL,
(LONG(*)())NULL
},
{
(LONG(*)())OB_Paint, /* BS_OWNERDRAW */
(LONG(*)())OB_LButtonDown,
(LONG(*)())OB_LButtonUp,
(LONG(*)())NULL,
(LONG(*)())OB_KillFocus,
(LONG(*)())NULL,
(LONG(*)())NULL
},
};
@ -239,7 +262,7 @@ LONG ButtonWndProc(HWND hWnd, WORD uMsg, WORD wParam, LONG lParam)
case BM_GETCHECK:
if (btnfn[style].getCheckfn)
(btnfn[style].getCheckfn)(hWnd);
return (btnfn[style].getCheckfn)(hWnd);
break;
default:
@ -954,3 +977,91 @@ static LONG UB_KillFocus(HWND hWnd)
UpdateWindow(hWnd);
}
/**********************************************************************
* Ownerdrawn Button Functions
*/
static LONG OB_Paint(HWND hWnd)
{
PAINTSTRUCT ps;
HDC hDC;
RECT rc;
HANDLE hDis;
LPDRAWITEMSTRUCT lpdis;
WND *wndPtr = WIN_FindWndPtr(hWnd);
hDC = BeginPaint(hWnd, &ps);
GetClientRect(hWnd, &rc);
hDis = USER_HEAP_ALLOC(GMEM_MOVEABLE, sizeof(DRAWITEMSTRUCT));
lpdis = (LPDRAWITEMSTRUCT)USER_HEAP_ADDR(hDis);
lpdis->hDC = hDC;
lpdis->itemID = 0;
CopyRect(&lpdis->rcItem, &rc);
lpdis->CtlID = wndPtr->wIDmenu;
lpdis->CtlType = ODT_BUTTON;
lpdis->itemAction = ODA_DRAWENTIRE;
/* printf("ownerdrawn button WM_DRAWITEM CtrlID=%X\n", lpdis->CtlID);*/
SendMessage(GetParent(hWnd), WM_DRAWITEM, 1, (LPARAM)lpdis);
USER_HEAP_FREE(hDis);
EndPaint(hWnd, &ps);
}
static LONG OB_LButtonDown(HWND hWnd, WORD wParam, LONG lParam)
{
HDC hDC;
RECT rc;
HANDLE hDis;
LPDRAWITEMSTRUCT lpdis;
WND *wndPtr = WIN_FindWndPtr(hWnd);
/* SetFocus(hWnd); */
SetCapture(hWnd);
hDC = GetDC(hWnd);
GetClientRect(hWnd, &rc);
if (PtInRect(&rc, MAKEPOINT(lParam)))
NOTIFY_PARENT(hWnd, BN_CLICKED);
GetClientRect(hWnd, &rc);
hDis = USER_HEAP_ALLOC(GMEM_MOVEABLE, sizeof(DRAWITEMSTRUCT));
lpdis = (LPDRAWITEMSTRUCT)USER_HEAP_ADDR(hDis);
lpdis->hDC = hDC;
lpdis->itemID = 0;
CopyRect(&lpdis->rcItem, &rc);
lpdis->CtlID = wndPtr->wIDmenu;
lpdis->CtlType = ODT_BUTTON;
lpdis->itemAction = ODA_SELECT;
SendMessage(GetParent(hWnd), WM_DRAWITEM, 1, (LPARAM)lpdis);
USER_HEAP_FREE(hDis);
ReleaseDC(hWnd, hDC);
}
static LONG OB_LButtonUp(HWND hWnd, WORD wParam, LONG lParam)
{
HDC hDC;
RECT rc;
HANDLE hDis;
LPDRAWITEMSTRUCT lpdis;
WND *wndPtr = WIN_FindWndPtr(hWnd);
ReleaseCapture();
hDC = GetDC(hWnd);
GetClientRect(hWnd, &rc);
if (PtInRect(&rc, MAKEPOINT(lParam)))
NOTIFY_PARENT(hWnd, BN_CLICKED);
GetClientRect(hWnd, &rc);
hDis = USER_HEAP_ALLOC(GMEM_MOVEABLE, sizeof(DRAWITEMSTRUCT));
lpdis = (LPDRAWITEMSTRUCT)USER_HEAP_ADDR(hDis);
lpdis->hDC = hDC;
lpdis->itemID = 0;
CopyRect(&lpdis->rcItem, &rc);
lpdis->CtlID = wndPtr->wIDmenu;
lpdis->CtlType = ODT_BUTTON;
lpdis->itemAction = ODA_SELECT;
SendMessage(GetParent(hWnd), WM_DRAWITEM, 1, (LPARAM)lpdis);
USER_HEAP_FREE(hDis);
ReleaseDC(hWnd, hDC);
}
static LONG OB_KillFocus(HWND hWnd)
{
InvalidateRect(hWnd, NULL, FALSE);
UpdateWindow(hWnd);
}

View File

@ -74,16 +74,20 @@ LONG COMBOBOX_ComboBoxWndProc( HWND hwnd, WORD message,
WND *wndPtr;
LPHEADCOMBO lphc;
char str[128];
PAINTSTRUCT paintstruct;
static RECT rectsel;
switch(message)
{
case WM_CREATE:
CreateComboStruct(hwnd);
wndPtr = WIN_FindWndPtr(hwnd);
width = wndPtr->rectClient.right - wndPtr->rectClient.left;
height = wndPtr->rectClient.bottom - wndPtr->rectClient.top;
lphc = ComboGetStorageHeader(hwnd);
if (lphc == NULL) return 0;
#ifdef DEBUG_COMBO
printf("Combo WM_CREATE %lX !\n", lphc);
#endif
width = wndPtr->rectClient.right - wndPtr->rectClient.left;
height = wndPtr->rectClient.bottom - wndPtr->rectClient.top;
lphc->hWndDrop = CreateWindow("BUTTON", "",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
width - 16, 0, 16, 16, hwnd, 1, wndPtr->hInstance, 0L);
@ -94,25 +98,23 @@ LONG COMBOBOX_ComboBoxWndProc( HWND hwnd, WORD message,
WS_CHILD | WS_CLIPCHILDREN | WS_BORDER | WS_VSCROLL | LBS_NOTIFY,
wndPtr->rectClient.left, wndPtr->rectClient.top + 16, width, height,
wndPtr->hwndParent, 1, wndPtr->hInstance, (LPSTR)MAKELONG(0, hwnd));
/*
ShowWindow(lphc->hWndLBox, SW_HIDE);
*/
InvalidateRect(lphc->hWndEdit, NULL, TRUE);
UpdateWindow(lphc->hWndEdit);
InvalidateRect(lphc->hWndDrop, NULL, TRUE);
UpdateWindow(lphc->hWndDrop);
#ifdef DEBUG_COMBO
printf("Combo Creation Drop=%X LBox=%X!\n", lphc->hWndDrop, lphc->hWndLBox);
#endif
return 0;
case WM_DESTROY:
lphc = ComboGetStorageHeader(hwnd);
if (lphc == 0) return 0;
DestroyWindow(lphc->hWndDrop);
DestroyWindow(lphc->hWndEdit);
/*
DestroyWindow(lphc->hWndLBox);
*/
free(lphc);
*((LPHEADCOMBO *)&wndPtr->wExtra[1]) = 0;
#ifdef DEBUG_COMBO
printf("Combo WM_DESTROY !\n");
printf("Combo WM_DESTROY %lX !\n", lphc);
#endif
return 0;
@ -128,24 +130,33 @@ LONG COMBOBOX_ComboBoxWndProc( HWND hwnd, WORD message,
lphc->dwState = lphc->dwState ^ CB_SHOWDROPDOWN;
if ((lphc->dwState & CB_SHOWDROPDOWN) == CB_SHOWDROPDOWN) {
ShowWindow(lphc->hWndLBox, SW_SHOW);
/*
SetFocus(lphc->hWndLBox);
*/
}
else {
/*
SetFocus(lphc->hWndEdit);
*/
ShowWindow(lphc->hWndLBox, SW_HIDE);
y = SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L);
if (y != LB_ERR) {
SendMessage(lphc->hWndLBox, LB_GETTEXT, (WORD)y, (LPARAM)str);
SendMessage(lphc->hWndEdit, WM_SETTEXT, (WORD)y, (LPARAM)str);
printf("combo hide\n");
}
}
}
if (LOWORD(lParam) == lphc->hWndLBox) {
switch(HIWORD(lParam))
{
case LBN_SELCHANGE:
lphc->dwState = lphc->dwState ^ CB_SHOWDROPDOWN;
lphc->dwState = lphc->dwState & (CB_SHOWDROPDOWN ^ 0xFFFF);
ShowWindow(lphc->hWndLBox, SW_HIDE);
y = SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L);
if (y != LB_ERR) {
SendMessage(lphc->hWndLBox, LB_GETTEXT, (WORD)y, (LPARAM)str);
SendMessage(lphc->hWndEdit, WM_SETTEXT, (WORD)y, (LPARAM)str);
}
SendMessage(GetParent(hwnd), WM_COMMAND, wndPtr->wIDmenu,
MAKELONG(hwnd, CBN_SELCHANGE));
break;
@ -165,6 +176,8 @@ LONG COMBOBOX_ComboBoxWndProc( HWND hwnd, WORD message,
case WM_CTLCOLOR:
return(SendMessage(GetParent(hwnd), WM_CTLCOLOR, wParam, lParam));
case WM_PAINT:
BeginPaint( hwnd, &paintstruct );
EndPaint( hwnd, &paintstruct );
lphc = ComboGetStorageHeader(hwnd);
InvalidateRect(lphc->hWndEdit, NULL, TRUE);
UpdateWindow(lphc->hWndEdit);
@ -175,17 +188,6 @@ LONG COMBOBOX_ComboBoxWndProc( HWND hwnd, WORD message,
UpdateWindow(lphc->hWndLBox);
}
break;
case WM_MOUSEMOVE:
if ((wParam & MK_LBUTTON) != 0) {
y = HIWORD(lParam);
if (y < 4) {
lphc = ComboGetStorageHeader(hwnd);
}
GetClientRect(hwnd, &rect);
if (y > (rect.bottom - 4)) {
lphc = ComboGetStorageHeader(hwnd);
}
}
case CB_ADDSTRING:
#ifdef DEBUG_COMBO
printf("CB_ADDSTRING '%s' !\n", (LPSTR)lParam);
@ -196,6 +198,10 @@ LONG COMBOBOX_ComboBoxWndProc( HWND hwnd, WORD message,
printf("CB_GETLBTEXT #%u !\n", wParam);
lphc = ComboGetStorageHeader(hwnd);
return(SendMessage(lphc->hWndLBox, LB_GETTEXT, wParam, lParam));
case CB_GETLBTEXTLEN:
printf("CB_GETLBTEXTLEN !\n");
lphc = ComboGetStorageHeader(hwnd);
return(SendMessage(lphc->hWndLBox, LB_GETTEXTLEN, wParam, lParam));
case CB_INSERTSTRING:
printf("CB_INSERTSTRING '%s' !\n", (LPSTR)lParam);
lphc = ComboGetStorageHeader(hwnd);
@ -210,17 +216,65 @@ LONG COMBOBOX_ComboBoxWndProc( HWND hwnd, WORD message,
return(SendMessage(lphc->hWndLBox, LB_RESETCONTENT, 0, 0L));
case CB_DIR:
printf("ComboBox CB_DIR !\n");
lphc = ComboGetStorageHeader(hwnd);
return(SendMessage(lphc->hWndLBox, LB_DIR, wParam, lParam));
case CB_FINDSTRING:
lphc = ComboGetStorageHeader(hwnd);
return(SendMessage(lphc->hWndLBox, LB_FINDSTRING, wParam, lParam));
case CB_GETCOUNT:
lphc = ComboGetStorageHeader(hwnd);
return(SendMessage(lphc->hWndLBox, LB_GETCOUNT, 0, 0L));
case CB_GETCURSEL:
printf("ComboBox CB_GETCURSEL !\n");
return(SendMessage(lphc->hWndLBox, LB_GETCOUNT, 0, 0L));
lphc = ComboGetStorageHeader(hwnd);
return(SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L));
case CB_SETCURSEL:
printf("ComboBox CB_SETCURSEL wParam=%x !\n", wParam);
return(SendMessage(lphc->hWndLBox, LB_GETCOUNT, wParam, 0L));
printf("ComboBox CB_SETCURSEL wParam=%X !\n", wParam);
lphc = ComboGetStorageHeader(hwnd);
return(SendMessage(lphc->hWndLBox, LB_SETCURSEL, wParam, 0L));
case CB_GETEDITSEL:
printf("ComboBox CB_GETEDITSEL !\n");
lphc = ComboGetStorageHeader(hwnd);
/* return(SendMessage(lphc->hWndEdit, EM_GETSEL, 0, 0L)); */
break;
case CB_SETEDITSEL:
printf("ComboBox CB_SETEDITSEL lParam=%lX !\n", lParam);
lphc = ComboGetStorageHeader(hwnd);
/* return(SendMessage(lphc->hWndEdit, EM_SETSEL, 0, lParam)); */
break;
case CB_SELECTSTRING:
printf("ComboBox CB_SELECTSTRING !\n");
lphc = ComboGetStorageHeader(hwnd);
break;
case CB_SHOWDROPDOWN:
printf("ComboBox CB_SHOWDROPDOWN !\n");
lphc = ComboGetStorageHeader(hwnd);
lphc->dwState = lphc->dwState | CB_SHOWDROPDOWN;
if (wParam != 0) {
ShowWindow(lphc->hWndLBox, SW_SHOW);
}
else {
lphc->dwState = lphc->dwState ^ CB_SHOWDROPDOWN;
ShowWindow(lphc->hWndLBox, SW_HIDE);
SendMessage(GetParent(hwnd), WM_COMMAND, wndPtr->wIDmenu,
MAKELONG(hwnd, CBN_DROPDOWN));
}
break;
case CB_GETITEMDATA:
printf("ComboBox CB_GETITEMDATA wParam=%X !\n", wParam);
lphc = ComboGetStorageHeader(hwnd);
return(SendMessage(lphc->hWndLBox, LB_GETITEMDATA, wParam, 0L));
break;
case CB_SETITEMDATA:
printf("ComboBox CB_SETITEMDATA wParam=%X lParam=%lX !\n", wParam, lParam);
lphc = ComboGetStorageHeader(hwnd);
return(SendMessage(lphc->hWndLBox, LB_SETITEMDATA, wParam, lParam));
break;
case CB_LIMITTEXT:
printf("ComboBox CB_LIMITTEXT !\n");
lphc = ComboGetStorageHeader(hwnd);
/* return(SendMessage(lphc->hWndEdit, EM_LIMITTEXT, wParam, 0L)); */
break;
default:
return DefWindowProc( hwnd, message, wParam, lParam );
@ -235,6 +289,10 @@ LPHEADCOMBO ComboGetStorageHeader(HWND hwnd)
WND *wndPtr;
LPHEADCOMBO lphc;
wndPtr = WIN_FindWndPtr(hwnd);
if (wndPtr == 0) {
printf("Bad Window handle on ComboBox !\n");
return 0;
}
lphc = *((LPHEADCOMBO *)&wndPtr->wExtra[1]);
return lphc;
}
@ -246,6 +304,10 @@ int CreateComboStruct(HWND hwnd)
WND *wndPtr;
LPHEADCOMBO lphc;
wndPtr = WIN_FindWndPtr(hwnd);
if (wndPtr == 0) {
printf("Bad Window handle on ComboBox !\n");
return 0;
}
lphc = (LPHEADCOMBO)malloc(sizeof(HEADCOMBO));
*((LPHEADCOMBO *)&wndPtr->wExtra[1]) = lphc;
lphc->dwState = 0;

View File

@ -107,6 +107,9 @@ LONG LISTBOX_ListBoxWndProc( HWND hwnd, WORD message,
case WM_CREATE:
CreateListBoxStruct(hwnd);
lphl = ListBoxGetWindowAndStorage(hwnd, &wndPtr);
#ifdef DEBUG_LISTBOX
printf("ListBox WM_CREATE %lX !\n", lphl);
#endif
createStruct = (CREATESTRUCT *)lParam;
if (HIWORD(createStruct->lpCreateParams) != 0)
lphl->hWndLogicParent = (HWND)HIWORD(createStruct->lpCreateParams);
@ -122,10 +125,14 @@ LONG LISTBOX_ListBoxWndProc( HWND hwnd, WORD message,
return 0;
case WM_DESTROY:
lphl = ListBoxGetStorageHeader(hwnd);
if (lphl == 0) return 0;
ListBoxResetContent(hwnd);
DestroyWindow(lphl->hWndScroll);
free(lphl);
printf("ListBox WM_DESTROY !\n");
*((LPHEADLIST *)&wndPtr->wExtra[1]) = 0;
#ifdef DEBUG_LISTBOX
printf("ListBox WM_DESTROY %lX !\n", lphl);
#endif
return 0;
case WM_VSCROLL:
@ -164,6 +171,10 @@ LONG LISTBOX_ListBoxWndProc( HWND hwnd, WORD message,
return 0;
case WM_LBUTTONDOWN:
/*
SetFocus(hwnd);
*/
SetCapture(hwnd);
lphl = ListBoxGetStorageHeader(hwnd);
if (lphl == NULL) return 0;
lphl->PrevSelected = lphl->ItemSelected;
@ -174,6 +185,7 @@ LONG LISTBOX_ListBoxWndProc( HWND hwnd, WORD message,
UpdateWindow(hwnd);
return 0;
case WM_LBUTTONUP:
ReleaseCapture();
lphl = ListBoxGetWindowAndStorage(hwnd, &wndPtr);
if (lphl == NULL) return 0;
if (lphl->PrevSelected != lphl->ItemSelected)
@ -248,8 +260,10 @@ LONG LISTBOX_ListBoxWndProc( HWND hwnd, WORD message,
case LB_DIR:
printf("ListBox LB_DIR !\n");
wRet = ListBoxDirectory(hwnd, wParam, (LPSTR)lParam);
if (IsWindowVisible(hwnd)) {
InvalidateRect(hwnd, NULL, TRUE);
UpdateWindow(hwnd);
}
return wRet;
case LB_ADDSTRING:
wRet = ListBoxAddString(hwnd, (LPSTR)lParam);
@ -315,30 +329,38 @@ LONG LISTBOX_ListBoxWndProc( HWND hwnd, WORD message,
printf("ListBox LB_SETCURSEL wParam=%x !\n", wParam);
#endif
wRet = ListBoxSetCurSel(hwnd, wParam);
if (IsWindowVisible(hwnd)) {
InvalidateRect(hwnd, NULL, TRUE);
UpdateWindow(hwnd);
}
return wRet;
case LB_SETSEL:
printf("ListBox LB_SETSEL wParam=%x lParam=%lX !\n", wParam, lParam);
wRet = ListBoxSetSel(hwnd, wParam);
if (IsWindowVisible(hwnd)) {
InvalidateRect(hwnd, NULL, TRUE);
UpdateWindow(hwnd);
}
return wRet;
case LB_SETTOPINDEX:
printf("ListBox LB_SETTOPINDEX wParam=%x !\n", wParam);
lphl = ListBoxGetStorageHeader(hwnd);
lphl->FirstVisible = wParam;
SetScrollPos(lphl->hWndScroll, WM_VSCROLL, lphl->FirstVisible, TRUE);
if (IsWindowVisible(hwnd)) {
InvalidateRect(hwnd, NULL, TRUE);
UpdateWindow(hwnd);
}
break;
case LB_SETITEMHEIGHT:
#ifdef DEBUG_LISTBOX
printf("ListBox LB_SETITEMHEIGHT wParam=%x lParam=%lX !\n", wParam, lParam);
#endif
wRet = ListBoxSetItemHeight(hwnd, wParam, lParam);
if (IsWindowVisible(hwnd)) {
InvalidateRect(hwnd, NULL, TRUE);
UpdateWindow(hwnd);
}
return wRet;
default:
@ -381,6 +403,10 @@ void StdDrawListBox(HWND hwnd)
char C[128];
h = 0;
hdc = BeginPaint( hwnd, &ps );
if (!IsWindowVisible(hwnd)) {
EndPaint( hwnd, &ps );
return;
}
GetClientRect(hwnd, &rect);
lphl = ListBoxGetStorageHeader(hwnd);
if (lphl == NULL) goto EndOfPaint;
@ -425,7 +451,6 @@ void OwnerDrawListBox(HWND hwnd)
{
LPHEADLIST lphl;
LPLISTSTRUCT lpls;
HANDLE hTemp;
PAINTSTRUCT ps;
HBRUSH hBrush;
HWND hWndParent;
@ -435,6 +460,10 @@ void OwnerDrawListBox(HWND hwnd)
char C[128];
h = 0;
hdc = BeginPaint( hwnd, &ps );
if (!IsWindowVisible(hwnd)) {
EndPaint( hwnd, &ps );
return;
}
GetClientRect(hwnd, &rect);
lphl = ListBoxGetStorageHeader(hwnd);
if (lphl == NULL) goto EndOfPaint;
@ -465,11 +494,9 @@ void OwnerDrawListBox(HWND hwnd)
lpls->dis.rcItem.right, lpls->dis.rcItem.bottom);
printf("LBOX WM_DRAWITEM Parent=%X &dis=%lX CtlID=%u !\n",
hWndParent, (LONG)&lpls->dis, lpls->dis.CtlID);
#endif
printf("LBOX WM_DRAWITEM '%s' !\n", lpls->dis.itemData);
#endif
SendMessage(lphl->hWndLogicParent, WM_DRAWITEM, i, (LPARAM)&lpls->dis);
GlobalUnlock(hTemp);
GlobalFree(hTemp);
if (lpls->dis.itemState != 0) {
InvertRect(hdc, &lpls->dis.rcItem);
}
@ -575,7 +602,8 @@ int ListBoxAddString(HWND hwnd, LPSTR newstr)
lplsnew->dis.itemID = lphl->ItemsCount;
lplsnew->dis.itemData = (DWORD)newstr;
lplsnew->hData = hTemp;
SetScrollRange(lphl->hWndScroll, WM_VSCROLL, 1, lphl->ItemsCount, TRUE);
SetScrollRange(lphl->hWndScroll, WM_VSCROLL, 1, lphl->ItemsCount,
(lphl->FirstVisible != 1));
if (lphl->FirstVisible >= (lphl->ItemsCount - lphl->ItemsVisible)) {
InvalidateRect(hwnd, NULL, TRUE);
UpdateWindow(hwnd);
@ -625,7 +653,8 @@ int ListBoxInsertString(HWND hwnd, UINT uIndex, LPSTR newstr)
lplsnew->dis.itemID = lphl->ItemsCount;
lplsnew->dis.itemData = (DWORD)newstr;
lplsnew->hData = hTemp;
SetScrollRange(lphl->hWndScroll, WM_VSCROLL, 1, lphl->ItemsCount, TRUE);
SetScrollRange(lphl->hWndScroll, WM_VSCROLL, 1, lphl->ItemsCount,
(lphl->FirstVisible != 1));
if (((lphl->ItemsCount - lphl->FirstVisible) == lphl->ItemsVisible) &&
(lphl->ItemsVisible != 0))
ShowWindow(lphl->hWndScroll, SW_NORMAL);
@ -768,10 +797,10 @@ int ListBoxSetCurSel(HWND hwnd, WORD wIndex)
lphl = ListBoxGetWindowAndStorage(hwnd, &wndPtr);
if (lphl == NULL) return LB_ERR;
lphl->ItemSelected = LB_ERR;
if (wIndex < 1 || wIndex > lphl->ItemsCount) return LB_ERR;
if (wIndex < 0 || wIndex >= lphl->ItemsCount) return LB_ERR;
lpls = lphl->lpFirst;
if (lpls == NULL) return LB_ERR;
for(i = 1; i <= lphl->ItemsCount; i++) {
for(i = 0; i < lphl->ItemsCount; i++) {
lpls2 = lpls;
lpls = (LPLISTSTRUCT)lpls->lpNext;
if (i == wIndex)
@ -797,10 +826,10 @@ int ListBoxSetSel(HWND hwnd, WORD wIndex)
UINT i;
lphl = ListBoxGetStorageHeader(hwnd);
if (lphl == NULL) return LB_ERR;
if (wIndex < 1 || wIndex > lphl->ItemsCount) return LB_ERR;
if (wIndex < 0 || wIndex >= lphl->ItemsCount) return LB_ERR;
lpls = lphl->lpFirst;
if (lpls == NULL) return LB_ERR;
for(i = 1; i <= lphl->ItemsCount; i++) {
for(i = 0; i < lphl->ItemsCount; i++) {
lpls2 = lpls;
lpls = (LPLISTSTRUCT)lpls->lpNext;
if (i == wIndex) {

View File

@ -86,11 +86,15 @@ LONG SCROLLBAR_ScrollBarWndProc( HWND hwnd, WORD message,
#endif
return 0;
case WM_DESTROY:
lphs = ScrollBarGetStorageHeader(hwnd);
lphs = ScrollBarGetWindowAndStorage(hwnd, &wndPtr);
if (lphs == 0) return 0;
#ifdef DEBUG_SCROLL
printf("ScrollBar WM_DESTROY %lX !\n", lphs);
#endif
DestroyWindow(lphs->hWndUp);
DestroyWindow(lphs->hWndDown);
free(lphs);
printf("ScrollBar WM_DESTROY !\n");
*((LPHEADSCROLL *)&wndPtr->wExtra[1]) = 0;
return 0;
case WM_COMMAND:
@ -105,10 +109,17 @@ LONG SCROLLBAR_ScrollBarWndProc( HWND hwnd, WORD message,
if (LOWORD(lParam) == lphs->hWndDown)
SendMessage(wndPtr->hwndParent, lphs->Direction,
SB_LINEDOWN, MAKELONG(0, hwnd));
/*
SetFocus(hwnd);
*/
return 0;
case WM_LBUTTONDOWN:
lphs = ScrollBarGetWindowAndStorage(hwnd, &wndPtr);
/*
SetFocus(hwnd);
*/
SetCapture(hwnd);
GetClientRect(hwnd, &rect);
if (lphs->Direction == WM_VSCROLL) {
y = HIWORD(lParam);
@ -152,7 +163,9 @@ LONG SCROLLBAR_ScrollBarWndProc( HWND hwnd, WORD message,
}
break;
case WM_LBUTTONUP:
lphs = ScrollBarGetStorageHeader(hwnd);
lphs->ThumbActive = FALSE;
ReleaseCapture();
break;
case WM_KEYDOWN:
@ -192,6 +205,10 @@ LPHEADSCROLL ScrollBarGetWindowAndStorage(HWND hwnd, WND **wndPtr)
WND *Ptr;
LPHEADSCROLL lphs;
*(wndPtr) = Ptr = WIN_FindWndPtr(hwnd);
if (Ptr == 0) {
printf("Bad Window handle on ScrollBar !\n");
return 0;
}
lphs = *((LPHEADSCROLL *)&Ptr->wExtra[1]);
return lphs;
}
@ -202,6 +219,10 @@ LPHEADSCROLL ScrollBarGetStorageHeader(HWND hwnd)
WND *wndPtr;
LPHEADSCROLL lphs;
wndPtr = WIN_FindWndPtr(hwnd);
if (wndPtr == 0) {
printf("Bad Window handle on ScrollBar !\n");
return 0;
}
lphs = *((LPHEADSCROLL *)&wndPtr->wExtra[1]);
return lphs;
}
@ -217,6 +238,10 @@ void StdDrawScrollBar(HWND hwnd)
UINT i, w, h, siz;
char C[128];
hdc = BeginPaint( hwnd, &ps );
if (!IsWindowVisible(hwnd)) {
EndPaint( hwnd, &ps );
return;
}
hBrush = SendMessage(GetParent(hwnd), WM_CTLCOLOR, (WORD)hdc,
MAKELONG(hwnd, CTLCOLOR_SCROLLBAR));
if (hBrush == (HBRUSH)NULL) hBrush = GetStockObject(LTGRAY_BRUSH);
@ -235,24 +260,24 @@ void StdDrawScrollBar(HWND hwnd)
}
FillRect(hdc, &rect, hBrush);
if (lphs->Direction == WM_VSCROLL)
SetRect(&rect, 0, lphs->CurPix + w,
w, lphs->CurPix + (w << 1));
SetRect(&rect, 0, lphs->CurPix + w, w, lphs->CurPix + (w << 1));
else
SetRect(&rect, lphs->CurPix + h,
0, lphs->CurPix + (h << 1), h);
SetRect(&rect, lphs->CurPix + h, 0, lphs->CurPix + (h << 1), h);
FrameRect(hdc, &rect, GetStockObject(BLACK_BRUSH));
InflateRect(&rect, -1, -1);
FillRect(hdc, &rect, GetStockObject(LTGRAY_BRUSH));
DrawReliefRect(hdc, rect, 2, 0);
InflateRect(&rect, -3, -3);
DrawReliefRect(hdc, rect, 1, 1);
EndOfPaint:
EndPaint( hwnd, &ps );
if (!lphs->ThumbActive) {
InvalidateRect(lphs->hWndUp, NULL, TRUE);
UpdateWindow(lphs->hWndUp);
InvalidateRect(lphs->hWndDown, NULL, TRUE);
UpdateWindow(lphs->hWndDown);
}
EndOfPaint:
EndPaint( hwnd, &ps );
}
@ -264,16 +289,22 @@ int CreateScrollBarStruct(HWND hwnd)
LPHEADSCROLL lphs;
wndPtr = WIN_FindWndPtr(hwnd);
lphs = (LPHEADSCROLL)malloc(sizeof(HEADSCROLL));
if (lphs == 0) {
printf("Bad Memory Alloc on ScrollBar !\n");
return 0;
}
#ifdef DEBUG_SCROLL
printf("CreateScrollBarStruct %lX !\n", lphs);
#endif
*((LPHEADSCROLL *)&wndPtr->wExtra[1]) = lphs;
lphs->ThumbActive;
lphs->ThumbActive = FALSE;
lphs->MinVal = 0;
lphs->MaxVal = 100;
lphs->CurVal = 0;
lphs->CurPix = 0;
width = wndPtr->rectClient.right - wndPtr->rectClient.left;
height = wndPtr->rectClient.bottom - wndPtr->rectClient.top;
lphs = ScrollBarGetStorageHeader(hwnd);
if (lphs == NULL) return 0;
if (width <= height)
{
lphs->MaxPix = height - 3 * width;
@ -308,7 +339,7 @@ int GetScrollPos(HWND hwnd, int nBar)
{
LPHEADSCROLL lphs;
lphs = ScrollBarGetStorageHeader(hwnd);
if (lphs == NULL) return;
if (lphs == NULL) return 0;
return lphs->CurVal;
}
@ -330,7 +361,7 @@ int SetScrollPos(HWND hwnd, int nBar, int nPos, BOOL bRedraw)
int nRet;
LPHEADSCROLL lphs;
lphs = ScrollBarGetStorageHeader(hwnd);
if (lphs == NULL) return;
if (lphs == NULL) return 0;
nRet = lphs->CurVal;
lphs->CurVal = (short)nPos;
if (lphs->MaxVal != lphs->MinVal)
@ -343,7 +374,7 @@ int SetScrollPos(HWND hwnd, int nBar, int nPos, BOOL bRedraw)
printf("SetScrollPos min=%d max=%d\n",
lphs->MinVal, lphs->MaxVal);
#endif
if (bRedraw) {
if ((bRedraw) && (IsWindowVisible(hwnd))) {
InvalidateRect(hwnd, NULL, TRUE);
UpdateWindow(hwnd);
}
@ -367,7 +398,7 @@ void SetScrollRange(HWND hwnd, int nBar, int MinPos, int MaxPos, BOOL bRedraw)
#ifdef DEBUG_SCROLL
printf("SetScrollRange min=%d max=%d\n", lphs->MinVal, lphs->MaxVal);
#endif
if (bRedraw) {
if ((bRedraw) && (IsWindowVisible(hwnd))) {
InvalidateRect(hwnd, NULL, TRUE);
UpdateWindow(hwnd);
}

View File

@ -16,6 +16,8 @@ LONG StaticWndProc(HWND hWnd, WORD uMsg, WORD wParam, LONG lParam);
static LONG PaintTextfn(HWND hwnd);
static LONG PaintRectfn(HWND hwnd);
static LONG PaintFramefn(HWND hwnd);
static LONG PaintIconfn(HWND hwnd);
static COLORREF color_windowframe, color_background, color_window,
color_windowtext;
@ -37,7 +39,7 @@ static STATICFN staticfn[MAX_STATIC_TYPE] =
{ (LONG(*)())PaintTextfn }, /* SS_LEFT */
{ (LONG(*)())PaintTextfn }, /* SS_CENTER */
{ (LONG(*)())PaintTextfn }, /* SS_RIGHT */
{ (LONG(*)())NULL }, /* SS_ICON */
{ (LONG(*)())PaintIconfn }, /* SS_ICON */
{ (LONG(*)())PaintRectfn }, /* SS_BLACKRECT */
{ (LONG(*)())PaintRectfn }, /* SS_GRAYRECT */
{ (LONG(*)())PaintRectfn }, /* SS_WHITERECT */
@ -65,16 +67,21 @@ LONG StaticWndProc(HWND hWnd, WORD uMsg, WORD wParam, LONG lParam)
break;
case WM_CREATE:
if (style < 0L || style >= (LONG)DIM(staticfn))
if (style < 0L || style >= (LONG)DIM(staticfn)) {
lResult = -1L;
else
{
break;
}
/* initialise colours */
color_windowframe = GetSysColor(COLOR_WINDOWFRAME);
color_background = GetSysColor(COLOR_BACKGROUND);
color_window = GetSysColor(COLOR_WINDOW);
color_windowtext = GetSysColor(COLOR_WINDOWTEXT);
lResult = 0L;
if (style == SS_ICON) {
/*
SetWindowPos(hWnd, (HWND)NULL, 0, 0, 32, 32,
SWP_NOZORDER | SWP_NOMOVE);
*/
}
break;
@ -259,6 +266,35 @@ static LONG PaintFramefn(HWND hwnd)
}
static LONG PaintIconfn(HWND hwnd)
{
WND *wndPtr;
PAINTSTRUCT ps;
RECT rc;
HDC hdc;
LPSTR textPtr;
HICON hIcon;
wndPtr = WIN_FindWndPtr(hwnd);
hdc = BeginPaint(hwnd, &ps);
GetClientRect(hwnd, &rc);
FillRect(hdc, &rc, GetStockObject(WHITE_BRUSH));
textPtr = (LPSTR)USER_HEAP_ADDR(wndPtr->hText);
printf("SS_ICON : textPtr='%s' / left=%d top=%d right=%d bottom=%d \n",
textPtr, rc.left, rc.top, rc.right, rc.bottom);
/*
SetWindowPos(hwnd, (HWND)NULL, 0, 0, 32, 32,
SWP_NOZORDER | SWP_NOMOVE);
GetClientRect(hwnd, &rc);
printf("SS_ICON : textPtr='%s' / left=%d top=%d right=%d bottom=%d \n",
textPtr, rc.left, rc.top, rc.right, rc.bottom);
*/
hIcon = LoadIcon(wndPtr->hInstance, textPtr);
DrawIcon(hdc, rc.left, rc.top, hIcon);
EndPaint(hwnd, &ps);
GlobalUnlock(hwnd);
}

View File

@ -15,11 +15,12 @@ return_value:
/**********************************************************************
* Places to keep info about the current 32-bit stack frame.
*/
saved_esp:
.globl _IF1632_Saved32_esp,_IF1632_Saved32_ebp,_IF1632_Saved32_ss
_IF1632_Saved32_esp:
.long 0
saved_ebp:
_IF1632_Saved32_ebp:
.long 0
saved_ss:
_IF1632_Saved32_ss:
.word 0
/**********************************************************************
@ -64,9 +65,9 @@ _CallToInit16:
* Save our registers
*/
pushal
pushl saved_esp
pushl saved_ebp
pushw saved_ss
pushl _IF1632_Saved32_esp
pushl _IF1632_Saved32_ebp
pushw _IF1632_Saved32_ss
/*
* Get target address.
@ -78,9 +79,9 @@ _CallToInit16:
/*
* Put stack registers where we can get them after stack switch.
*/
movw %ss,saved_ss
movl %esp,saved_esp
movl %ebp,saved_ebp
movw %ss,_IF1632_Saved32_ss
movl %esp,_IF1632_Saved32_esp
movl %ebp,_IF1632_Saved32_ebp
/*
* Load initial registers
@ -130,16 +131,16 @@ _CallToInit16:
movw %ax,%fs
movw %ax,%gs
popl %eax
movw saved_ss,%ss
movl saved_esp,%esp
movl saved_ebp,%ebp
movw _IF1632_Saved32_ss,%ss
movl _IF1632_Saved32_esp,%esp
movl _IF1632_Saved32_ebp,%ebp
/*
* Restore registers, but do not destroy return value.
*/
popw saved_ss
popl saved_ebp
popl saved_esp
popw _IF1632_Saved32_ss
popl _IF1632_Saved32_ebp
popl _IF1632_Saved32_esp
movl %eax,return_value
popal
movl return_value,%eax
@ -173,13 +174,13 @@ _CallTo16:
/*
* Switch to 16-bit stack
*/
pushl saved_esp
pushl saved_ebp
pushw saved_ss
pushl _IF1632_Saved32_esp
pushl _IF1632_Saved32_ebp
pushw _IF1632_Saved32_ss
movw %ss,saved_ss
movl %esp,saved_esp
movl %ebp,saved_ebp
movw %ss,_IF1632_Saved32_ss
movl %esp,_IF1632_Saved32_esp
movl %ebp,_IF1632_Saved32_ebp
movw _IF1632_Saved16_ss,%ss
movl _IF1632_Saved16_esp,%esp
@ -215,13 +216,13 @@ _CallTo16:
movl %esp,_IF1632_Saved16_esp
movl %ebp,_IF1632_Saved16_ebp
movw saved_ss,%ss
movl saved_esp,%esp
movl saved_ebp,%ebp
movw _IF1632_Saved32_ss,%ss
movl _IF1632_Saved32_esp,%esp
movl _IF1632_Saved32_ebp,%ebp
popw saved_ss
popl saved_ebp
popl saved_esp
popw _IF1632_Saved32_ss
popl _IF1632_Saved32_ebp
popl _IF1632_Saved32_esp
movl %eax,return_value
movw return_value+2,%dx
@ -276,9 +277,9 @@ _CallTo32:
movl %esp,_IF1632_Saved16_esp
movl %ebp,_IF1632_Saved16_ebp
movw saved_ss,%ss
movl saved_esp,%esp
movl saved_ebp,%ebp
movw _IF1632_Saved32_ss,%ss
movl _IF1632_Saved32_esp,%esp
movl _IF1632_Saved32_ebp,%ebp
/*
* Call entry point

View File

@ -5,10 +5,16 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
#include "callback.h"
#include "wine.h"
#include "segmem.h"
#include <setjmp.h>
extern unsigned short SelectorOwners[];
extern unsigned short IF1632_Saved16_ss;
extern unsigned long IF1632_Saved16_ebp;
extern unsigned long IF1632_Saved16_esp;
extern unsigned short IF1632_Saved32_ss;
extern unsigned long IF1632_Saved32_ebp;
extern unsigned long IF1632_Saved32_esp;
extern struct segment_descriptor_s *MakeProcThunks;
struct thunk_s
@ -169,3 +175,77 @@ void CallLineDDAProc(FARPROC func, short xPos, short yPos, long lParam)
(*func)(xPos, yPos, lParam);
}
}
/* ------------------------------------------------------------------------ */
/*
* The following functions realize the Catch/Throw functionality.
* My thought is to use the setjmp, longjmp combination to do the
* major part of this one. All I have to remember, in addition to
* whatever the jmp_buf contains, is the contents of the 16-bit
* sp, bp and ss. I do this by storing them in the structure passed
* to me by the 16-bit program (including my own jmp_buf...).
* Hopefully there isn't any program that modifies the contents!
* Bad thing: I have to save part of the stack, since this will
* get reused on the next call after my return, leaving it in an
* undefined state.
*/
#define STACK_DEPTH_16 28
struct special_buffer {
jmp_buf buffer;
long regs [6];
char stack_part [STACK_DEPTH_16];
} *sb;
int Catch (LPCATCHBUF cbuf)
{
WORD retval;
jmp_buf *tmp_jmp;
char *stack16 = (char *) (((unsigned int)IF1632_Saved16_ss << 16) +
(IF1632_Saved16_esp & 0xffff));
sb = malloc (sizeof (struct special_buffer));
sb -> regs [0] = IF1632_Saved16_esp;
sb -> regs [1] = IF1632_Saved16_ebp;
sb -> regs [2] = IF1632_Saved16_ss & 0xffff;
sb -> regs [3] = IF1632_Saved32_esp;
sb -> regs [4] = IF1632_Saved32_ebp;
sb -> regs [5] = IF1632_Saved32_ss & 0xffff;
memcpy (sb -> stack_part, stack16, STACK_DEPTH_16);
tmp_jmp = &sb -> buffer;
*((struct special_buffer **)cbuf) = sb;
if ((retval = setjmp (*tmp_jmp)))
{
IF1632_Saved16_esp = sb -> regs [0];
IF1632_Saved16_ebp = sb -> regs [1];
IF1632_Saved16_ss = sb -> regs [2] & 0xffff;
IF1632_Saved32_esp = sb -> regs [3];
IF1632_Saved32_ebp = sb -> regs [4];
IF1632_Saved32_ss = sb -> regs [5] & 0xffff;
stack16 = (char *) (((unsigned int)IF1632_Saved16_ss << 16) +
(IF1632_Saved16_esp & 0xffff));
memcpy (stack16, sb -> stack_part, STACK_DEPTH_16);
#ifdef DEBUG_CATCH
printf ("Been thrown here: %d, retval = %d\n", sb, retval);
#endif
free ((void *) sb);
return (retval);
} else {
#ifdef DEBUG_CATCH
printf ("Will somtime get thrown here: %d\n", sb);
#endif
return (retval);
}
}
void Throw (LPCATCHBUF cbuf, int val)
{
sb = *((struct special_buffer **)cbuf);
#ifdef DEBUG_CATCH
printf ("Throwing to: %d\n", sb);
#endif
longjmp (sb -> buffer, val);
}

View File

@ -32,11 +32,14 @@ length 415
50 pascal GetProcAddress(word ptr) GetProcAddress(1 2)
51 pascal MakeProcInstance(ptr word) CALLBACK_MakeProcInstance(1 2)
52 pascal FreeProcInstance(ptr) FreeProcInstance(1)
55 pascal Catch(ptr) Catch (1)
56 pascal Throw(ptr word) Throw(1 2)
59 pascal WriteProfileString(ptr ptr ptr) WriteProfileString(1 2 3)
60 pascal FindResource(word ptr ptr) FindResource(1 2 3)
61 pascal LoadResource(word word) LoadResource(1 2)
62 pascal LockResource(word) LockResource(1)
63 pascal FreeResource(word) FreeResource(1)
64 pascal AccessResource(word word) AccessResource(1 2)
74 pascal OpenFile(ptr ptr word) KERNEL_OpenFile(1 2 3)
81 pascal _lclose(word) KERNEL__lclose(1)
82 pascal _lread(word ptr word) KERNEL__lread(1 2 3)
@ -48,6 +51,8 @@ length 415
91 register InitTask(word word word word word
word word word word word)
KERNEL_InitTask()
95 pascal LoadLibrary(ptr) LoadLibrary(1)
96 pascal FreeLibrary(word) FreeLibrary(1)
102 register DOS3Call(word word word word word
word word word word word)
KERNEL_DOS3Call()
@ -67,6 +72,11 @@ length 415
163 pascal GlobalLRUOldest(word) ReturnArg(1)
164 pascal GlobalLRUNewest(word) ReturnArg(1)
166 pascal WinExec(ptr word) WinExec(1 2)
170 pascal AllocCStoDSAlias(word) AllocDStoCSAlias(1)
171 pascal AllocDStoCSAlias(word) AllocDStoCSAlias(1)
175 pascal AllocSelector(word) AllocSelector(1)
176 pascal FreeSelector(word) FreeSelector(1)
177 pascal PrestoChangoSelector(word word) PrestoChangoSelector(1 2)
178 equate __WINFLAGS 0x413
184 return GlobalDOSAlloc 4 0
185 return GlobalDOSFree 2 0

View File

@ -166,8 +166,15 @@ DLLRelay(unsigned int func_num, unsigned int seg_off)
break;
case DLL_ARGTYPE_LONG:
ip = (int *) ((char *) arg_ptr + offset);
arg_table[i] = *ip;
break;
case DLL_ARGTYPE_FARPTR:
ip = (int *) ((char *) arg_ptr + offset);
if (*ip & 0xffff0000)
arg_table[i] = SAFEMAKEPTR((unsigned) *ip >> 16, *ip);
else
arg_table[i] = *ip;
break;
}

View File

@ -15,6 +15,8 @@ length 540
15 pascal GetCurrentTime() GetTickCount()
18 pascal SetCapture(word) SetCapture(1)
19 pascal ReleaseCapture() ReleaseCapture()
20 pascal SetDoubleClickTime(word) SetDoubleClickTime(1)
21 pascal GetDoubleClickTime() GetDoubleClickTime()
22 pascal SetFocus(word) SetFocus(1)
23 pascal GetFocus() GetFocus()
31 pascal IsIconic(word) IsIconic(1)
@ -28,16 +30,24 @@ length 540
41 pascal CreateWindow(ptr ptr long s_word s_word s_word s_word word word word ptr)
CreateWindow(1 2 3 4 5 6 7 8 9 10 11)
42 pascal ShowWindow(word word) ShowWindow(1 2)
43 pascal CloseWindow(word) CloseWindow(1)
44 pascal OpenIcon(word) OpenIcon(1)
46 pascal GetParent(word) GetParent(1)
47 pascal IsWindow(word) IsWindow(1)
48 pascal IsChild(word word) IsChild(1 2)
49 pascal IsWindowVisible(word) IsWindowVisible(1)
50 pascal FindWindow(ptr ptr) FindWindow(1 2)
53 pascal DestroyWindow(word) DestroyWindow(1)
56 pascal MoveWindow(word word word word word word)
MoveWindow(1 2 3 4 5 6)
57 pascal RegisterClass(ptr) RegisterClass(1)
61 pascal ScrollWindow(word s_word s_word ptr ptr) ScrollWindow(1 2 3 4 5)
62 pascal SetScrollPos(word word word word) SetScrollPos(1 2 3 4)
64 pascal SetScrollRange(word word word word word) SetScrollRange(1 2 3 4 5)
66 pascal GetDC(word) GetDC(1)
68 pascal ReleaseDC(word word) ReleaseDC(1 2)
69 pascal SetCursor(word word) SetCursor(1 2)
71 pascal ShowCursor(word word) ShowCursor(1 2)
72 pascal SetRect(ptr s_word s_word s_word s_word) SetRect(1 2 3 4 5)
73 pascal SetRectEmpty(ptr) SetRectEmpty(1)
74 pascal CopyRect(ptr ptr) CopyRect(1 2)
@ -50,6 +60,7 @@ length 540
81 pascal FillRect(word ptr word) FillRect(1 2 3)
82 pascal InvertRect(word ptr) InvertRect(1 2)
83 pascal FrameRect(word ptr word) FrameRect(1 2 3)
84 pascal DrawIcon(word s_word s_word word) DrawIcon(1 2 3 4)
85 pascal DrawText(word ptr s_word ptr word) DrawText(1 2 3 4 5)
87 pascal DialogBox(word ptr word ptr) DialogBox(1 2 3 4)
88 pascal EndDialog(word s_word) EndDialog(1 2)
@ -109,8 +120,11 @@ length 540
181 pascal SetSysColors(word ptr ptr) SetSysColors(1 2 3)
182 pascal KillSystemTimer(word word) KillSystemTimer(1 2)
190 pascal GetUpdateRect(word ptr word) GetUpdateRect(1 2 3)
218 pascal DialogBoxIndirect(word word word ptr) DialogBoxIndirect(1 2 3 4)
219 pascal CreateDialogIndirect(word ptr word ptr)
CreateDialogIndirect(1 2 3 4)
221 pascal ScrollDC(word s_word s_word ptr ptr word ptr)
ScrollDC(1 2 3 4 5 6 7)
227 pascal GetNextDlgGroupItem(word word word) GetNextDlgGroupItem(1 2 3)
228 pascal GetNextDlgTabItem(word word word) GetNextDlgTabItem(1 2 3)
229 pascal GetTopWindow(word) GetTopWindow(1)
@ -118,6 +132,9 @@ length 540
232 pascal SetWindowPos(word word word word word word word)
SetWindowPos(1 2 3 4 5 6 7)
237 pascal GetUpdateRgn(word word word) GetUpdateRgn(1 2 3)
239 pascal DialogBoxParam(word ptr word ptr long) DialogBoxParam(1 2 3 4 5)
240 pascal DialogBoxIndirectParam(word word word ptr long)
DialogBoxIndirectParam(1 2 3 4 5)
241 pascal CreateDialogParam(word ptr word ptr long)
CreateDialogParam(1 2 3 4 5)
242 pascal CreateDialogIndirectParam(word ptr word ptr long)
@ -128,6 +145,8 @@ length 540
277 pascal GetDlgCtrlID(word) GetDlgCtrlID(1)
286 pascal GetDesktopWindow() GetDesktopWindow()
288 pascal GetMessageExtraInfo() GetMessageExtraInfo()
319 pascal ScrollWindowEx(word s_word s_word ptr ptr word ptr word)
ScrollWindowEx(1 2 3 4 5 6 7 8)
324 pascal FillWindow(word word word word) FillWindow(1 2 3 4)
325 pascal PaintRect(word word word word ptr) PaintRect(1 2 3 4 5)
334 pascal GetQueueStatus(word) GetQueueStatus(1)
@ -149,6 +168,8 @@ length 540
452 pascal CreateWindowEx(long ptr ptr long s_word s_word s_word s_word
word word word ptr)
CreateWindowEx(1 2 3 4 5 6 7 8 9 10 11 12)
457 pascal DestroyIcon(word) DestroyIcon(1)
458 pascal DestroyCursor(word) DestroyCursor(1)
471 pascal lstrcmpi(ptr ptr) lstrcmpi(1 2)
472 pascal AnsiNext(ptr) AnsiNext(1 )
473 pascal AnsiPrev(ptr ptr) AnsiPrev(1 2)

27
include/cursor.h Normal file
View File

@ -0,0 +1,27 @@
/*
* structure definitions for CURSOR
*
* Copyright Martin Ayotte, 1993
*
*/
typedef struct {
BYTE Width;
BYTE Reserved1;
BYTE Height;
BYTE Reserved2;
WORD curXHotspot;
WORD curYHotspot;
DWORD curDIBSize;
DWORD curDIBOffset;
} CURSORDESCRIP;
typedef struct {
CURSORDESCRIP descriptor;
HBITMAP hBitmap;
Display *display;
Pixmap pixshape;
Pixmap pixmask;
Cursor xcursor;
} CURSORALLOC;

View File

@ -54,15 +54,6 @@ typedef struct
} DLGCONTROLHEADER;
/* Dialog control data */
typedef struct
{
DLGCONTROLHEADER * header;
LPSTR class;
LPSTR text;
} DLGCONTROL;
/* Dialog template */
typedef struct
{
@ -72,7 +63,6 @@ typedef struct
LPSTR caption;
WORD pointSize;
LPSTR faceName;
DLGCONTROL * controls;
} DLGTEMPLATE;

26
include/icon.h Normal file
View File

@ -0,0 +1,26 @@
/*
* structure definitions for ICON
*
* Copyright Martin Ayotte, 1993
*
*/
typedef struct {
BYTE Width;
BYTE Height;
BYTE ColorCount;
BYTE Reserved1;
WORD Reserved2;
WORD Reserved3;
DWORD icoDIBSize;
DWORD icoDIBOffset;
} ICONDESCRIP;
typedef struct {
ICONDESCRIP descriptor;
HBITMAP hBitmap;
HBITMAP hBitMask;
} ICONALLOC;

View File

@ -6,6 +6,19 @@
#ifndef SEGMEM_H
#define SEGMEM_H
/*
* Array to track selector allocation.
*/
#define MAX_SELECTORS 512
#define SELECTOR_ISFREE 0x8000
#define SELECTOR_INDEXMASK 0x0fff
extern unsigned short SelectorMap[MAX_SELECTORS];
#define SAFEMAKEPTR(s, o) \
(((int) SelectorMap[SelectorMap[(s) >> 3] & SELECTOR_INDEXMASK] << 19) \
| 0x70000 | ((o) & 0xffff))
/*
* Structure to hold info about each selector we create.
*/

View File

@ -66,6 +66,14 @@ typedef int *LPCATCHBUF;
#define MAKELONG(low, high) ((LONG)(((WORD)(low)) | (((DWORD)((WORD)(high))) << 16)))
#ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
/*
typedef long LONG;
typedef WORD HANDLE;
@ -136,6 +144,8 @@ typedef struct {
LPSTR lpszClassName __attribute__ ((packed));
} WNDCLASS, *LPWNDCLASS;
typedef LONG (* WNDPROC)() __attribute__ ((packed));
#define CS_VREDRAW 0x0001
#define CS_HREDRAW 0x0002
#define CS_KEYCVTWINDOW 0x0004
@ -230,6 +240,15 @@ typedef struct {
#define DLGC_STATIC 0x0100
#define DLGC_BUTTON 0x2000
/* Standard dialog button IDs */
#define IDOK 1
#define IDCANCEL 2
#define IDABORT 3
#define IDRETRY 4
#define IDIGNORE 5
#define IDYES 6
#define IDNO 7
typedef struct { short x, y; } POINT;
typedef POINT *PPOINT;
@ -735,17 +754,17 @@ typedef struct { BYTE rgbtBlue, rgbtGreen, rgbtRed; } RGBTRIPLE;
typedef struct tagBITMAPINFOHEADER
{
unsigned long biSize;
unsigned long biWidth;
unsigned long biHeight;
unsigned short biPlanes;
unsigned short biBitCount;
unsigned long biCompression;
unsigned long biSizeImage;
unsigned long biXPelsPerMeter;
unsigned long biYPelsPerMeter;
unsigned long biClrUsed;
unsigned long biClrImportant;
DWORD biSize;
DWORD biWidth;
DWORD biHeight;
WORD biPlanes;
WORD biBitCount;
DWORD biCompression;
DWORD biSizeImage;
DWORD biXPelsPerMeter;
DWORD biYPelsPerMeter;
DWORD biClrUsed;
DWORD biClrImportant;
} BITMAPINFOHEADER;
typedef BITMAPINFOHEADER * LPBITMAPINFOHEADER;
@ -1021,8 +1040,34 @@ enum { SW_HIDE, SW_SHOWNORMAL, SW_NORMAL, SW_SHOWMINIMIZED, SW_SHOWMAXIMIZED,
#define GCW_HBRBACKGROUND (-10)
#endif
#define MB_OK 0
#define MB_ICONINFORMATION 0x0040
#define MB_OK 0x0000
#define MB_OKCANCEL 0x0001
#define MB_ABORTRETRYIGNORE 0x0002
#define MB_YESNOCANCEL 0x0003
#define MB_YESNO 0x0004
#define MB_RETRYCANCEL 0x0005
#define MB_TYPEMASK 0x000F
#define MB_ICONHAND 0x0010
#define MB_ICONQUESTION 0x0020
#define MB_ICONEXCLAMATION 0x0030
#define MB_ICONASTERISK 0x0040
#define MB_ICONMASK 0x00F0
#define MB_ICONINFORMATION MB_ICONASTERISK
#define MB_ICONSTOP MB_ICONHAND
#define MB_DEFBUTTON1 0x0000
#define MB_DEFBUTTON2 0x0100
#define MB_DEFBUTTON3 0x0200
#define MB_DEFMASK 0x0F00
#define MB_APPLMODAL 0x0000
#define MB_SYSTEMMODAL 0x1000
#define MB_TASKMODAL 0x2000
#define MB_NOFOCUS 0x8000
#define DT_TOP 0
#define DT_LEFT 0
@ -1079,6 +1124,11 @@ enum { SW_HIDE, SW_SHOWNORMAL, SW_NORMAL, SW_SHOWMINIMIZED, SW_SHOWMAXIMIZED,
#define WS_EX_ACCEPTFILES 0x00000010L
#define WS_EX_TRANSPARENT 0x00000020L
/* Window scrolling */
#define SW_SCROLLCHILDREN 0x0001
#define SW_INVALIDATE 0x0002
#define SW_ERASE 0x0003
/* Button control styles */
#define BS_PUSHBUTTON 0x00000000L
#define BS_DEFPUSHBUTTON 0x00000001L
@ -1319,6 +1369,70 @@ enum { SW_HIDE, SW_SHOWNORMAL, SW_NORMAL, SW_SHOWMINIMIZED, SW_SHOWMAXIMIZED,
#define ODS_CHECKED 0x0008
#define ODS_FOCUS 0x0010
/* Edit control styles */
#define ES_LEFT 0x00000000L
#define ES_CENTER 0x00000001L
#define ES_RIGHT 0x00000002L
#define ES_MULTILINE 0x00000004L
#define ES_UPPERCASE 0x00000008L
#define ES_LOWERCASE 0x00000010L
#define ES_PASSWORD 0x00000020L
#define ES_AUTOVSCROLL 0x00000040L
#define ES_AUTOHSCROLL 0x00000080L
#define ES_NOHISESEL 0x00000100L
#define ES_OEMCONVERT 0x00000400L
#define ES_READONLY 0x00000800L
#define ES_WANTRETURN 0x00001000L
/* Edit control messages */
#define EM_GETSEL (WM_USER+0)
#define EM_SETSEL (WM_USER+1)
#define EM_GETRECT (WM_USER+2)
#define EM_SETRECT (WM_USER+3)
#define EM_SETRECTNP (WM_USER+4)
#define EM_LINESCROLL (WM_USER+6)
#define EM_GETMODIFY (WM_USER+8)
#define EM_SETMODIFY (WM_USER+9)
#define EM_GETLINECOUNT (WM_USER+10)
#define EM_LINEINDEX (WM_USER+11)
#define EM_SETHANDLE (WM_USER+12)
#define EM_GETHANDLE (WM_USER+13)
#define EM_LINELENGTH (WM_USER+17)
#define EM_REPLACESEL (WM_USER+18)
#define EM_GETLINE (WM_USER+20)
#define EM_LIMITTEXT (WM_USER+21)
#define EM_CANUNDO (WM_USER+22)
#define EM_UNDO (WM_USER+23)
#define EM_FMTLINES (WM_USER+24)
#define EM_LINEFROMCHAR (WM_USER+25)
#define EM_SETTABSTOPS (WM_USER+27)
#define EM_SETPASSWORDCHAR (WM_USER+28)
#define EM_EMPTYUNDOBUFFER (WM_USER+29)
#define EM_GETFIRSTVISIBLELINE (WM_USER+30)
#define EM_SETREADONLY (WM_USER+31)
#define EM_SETWORDBREAKPROC (WM_USER+32)
#define EM_GETWORDBREAKPROC (WM_USER+33)
#define EM_GETPASSWORDCHAR (WM_USER+34)
typedef int (CALLBACK *EDITWORDBREAKPROC)(LPSTR lpch, int ichCurrent,
int cch, int code);
/* EDITWORDBREAKPROC code values */
#define WB_LEFT 0
#define WB_RIGHT 1
#define WB_ISDELIMITER 2
/* Edit control notification codes */
#define EN_SETFOCUS 0x0100
#define EN_KILLFOCUS 0x0200
#define EN_CHANGE 0x0300
#define EN_UPDATE 0x0400
#define EN_ERRSPACE 0x0500
#define EN_MAXTEXT 0x0501
#define EN_HSCROLL 0x0601
#define EN_VSCROLL 0x0602
#define WM_DRAWITEM 0x002B
typedef struct tagDRAWITEMSTRUCT
@ -1485,12 +1599,12 @@ Fb(int,_lopen,LPSTR,a,int,b)
Fa(int,lstrlen,LPCSTR,a)
Fa(LONG,DispatchMessage,LPMSG,msg)
Fa(void,UpdateWindow,HWND,a)
Fa(ATOM,AddAtom,LPSTR,a)
Fa(ATOM,AddAtom,LPCSTR,a)
Fa(ATOM,DeleteAtom,ATOM,a)
Fa(ATOM,FindAtom,LPSTR,a)
Fa(ATOM,GlobalAddAtom,LPSTR,a)
Fa(ATOM,FindAtom,LPCSTR,a)
Fa(ATOM,GlobalAddAtom,LPCSTR,a)
Fa(ATOM,GlobalDeleteAtom,ATOM,a)
Fa(ATOM,GlobalFindAtom,LPSTR,a)
Fa(ATOM,GlobalFindAtom,LPCSTR,a)
Fa(BOOL,DeleteDC,HDC,a)
Fa(BOOL,DeleteMetaFile,HANDLE,a)
Fa(BOOL,DeleteObject,HANDLE,a)
@ -1504,7 +1618,7 @@ Fa(BOOL,FreeResource,HANDLE,a)
Fa(BOOL,GlobalUnWire,HANDLE,a)
Fa(BOOL,GlobalUnfix,HANDLE,a)
Fa(BOOL,GlobalUnlock,HANDLE,a)
Fa(BOOL,InitAtomTable,int,a)
Fa(BOOL,InitAtomTable,WORD,a)
Fa(BOOL,IsClipboardFormatAvailable,WORD,a)
Fa(BOOL,IsIconic,HWND,a)
Fa(BOOL,IsRectEmpty,LPRECT,a)
@ -1858,10 +1972,10 @@ Fc(LONG,GetBitmapBits,HBITMAP,a,LONG,b,LPSTR,c)
Fc(LONG,SetBitmapBits,HBITMAP,a,LONG,b,LPSTR,c)
Fc(LONG,SetClassLong,HWND,a,short,b,LONG,c)
Fc(LONG,SetWindowLong,HWND,a,short,b,LONG,c)
Fc(WORD,GetAtomName,ATOM,a,LPSTR,b,int,c)
Fc(WORD,GetAtomName,ATOM,a,LPSTR,b,short,c)
Fc(WORD,GetMenuState,HMENU,a,WORD,b,WORD,c)
Fc(WORD,GetProfileInt,LPSTR,a,LPSTR,b,int,c)
Fc(WORD,GlobalGetAtomName,ATOM,a,LPSTR,b,int,c)
Fc(WORD,GlobalGetAtomName,ATOM,a,LPSTR,b,short,c)
Fc(WORD,SetClassWord,HWND,a,short,b,WORD,c)
Fc(WORD,SetWindowWord,HWND,a,short,b,WORD,c)
Fb(WORD,SetBkMode,HDC,a,WORD,b)
@ -1911,7 +2025,7 @@ Fd(BOOL,PostMessage,HWND,a,WORD,b,WORD,c,LONG,d)
Fd(LONG,SendMessage,HWND,a,WORD,b,WORD,c,LONG,d)
Fd(BOOL,GetMessage,LPMSG,msg,HWND,b,WORD,c,WORD,d)
Fd(BOOL,GetTextExtentPoint,HDC,a,LPSTR,b,short,c,LPSIZE,d)
Fd(BOOL,DrawIcon,HDC,a,int,b,int,c,HICON,d)
Fd(BOOL,DrawIcon,HDC,a,short,b,short,c,HICON,d)
Fd(BOOL,EnumMetaFile,HDC,a,LOCALHANDLE,b,FARPROC,c,BYTE FAR*,d)
Fd(BOOL,FloodFill,HDC,a,int,b,int,c,DWORD,d)
Fd(BOOL,GetCharWidth,HDC,a,WORD,b,WORD,c,LPINT,d)
@ -1986,7 +2100,7 @@ Fe(HWND,CreateDialogParam,HANDLE,a,LPCSTR,b,HWND,c,FARPROC,d,LPARAM,e)
Fe(LONG,DefFrameProc,HWND,a,HWND,b,WORD,c,WORD,d,LONG,e)
Fe(LONG,SendDlgItemMessage,HWND,a,WORD,b,WORD,c,WORD,d,LONG,e)
Fe(int,DialogBoxIndirectParam,HANDLE,a,HANDLE,b,HWND,c,FARPROC,d,LONG,e)
Fe(int,DialogBoxParam,HANDLE,a,LPSTR,b,HWND,c,FARPROC,d,LONG,e)
Fe(int,DialogBoxParam,HANDLE,a,LPCSTR,b,HWND,c,FARPROC,d,LONG,e)
Fe(int,DlgDirList,HWND,a,LPSTR,b,int,c,int,d,WORD,e)
Fe(int,DlgDirListComboBox,HWND,a,LPSTR,b,int,c,int,d,WORD,e)
Fe(int,Escape,HDC,a,int,b,int,c,LPSTR,d,LPSTR,e)
@ -1999,7 +2113,7 @@ Fe(int,IntersectVisRect,HDC,a,short,b,short,c,short,d,short,e)
Fe(int,SetVoiceAccent,int,a,int,b,int,c,int,d,int,e)
Fe(int,ToAscii,WORD,wVirtKey,WORD,wScanCode,LPSTR,lpKeyState,LPVOID,lpChar,WORD,wFlags)
Fe(void,PaintRect,HWND,a,HWND,b,HDC,c,HBRUSH,d,LPRECT,e)
Fe(void,ScrollWindow,HWND,a,int,b,int,c,LPRECT,d,LPRECT,e)
Fe(void,ScrollWindow,HWND,a,short,b,short,c,LPRECT,d,LPRECT,e)
Fe(void,SetRect,LPRECT,a,short,b,short,c,short,d,short,e)
Fe(void,SetRectRgn,HRGN,a,short,b,short,c,short,d,short,e)
Fe(void,SetScrollRange,HWND,a,int,b,int,c,int,d,BOOL,e)
@ -2012,7 +2126,7 @@ Ff(void,MoveWindow,HWND,a,short,b,short,c,short,d,short,e,BOOL,f)
Ff(BOOL,ScaleViewportExtEx,HDC,a,short,b,short,c,short,d,short,e,LPSIZE,f)
Ff(BOOL,ScaleWindowExtEx,HDC,a,short,b,short,c,short,d,short,e,LPSIZE,f)
Fg(BOOL,RoundRect,HDC,a,short,b,short,c,short,d,short,e,short,f,short,g)
Fg(BOOL,ScrollDC,HDC,a,int,b,int,c,LPRECT,d,LPRECT,e,HRGN,f,LPRECT,g)
Fg(BOOL,ScrollDC,HDC,a,short,b,short,c,LPRECT,d,LPRECT,e,HRGN,f,LPRECT,g)
Fg(BOOL,TrackPopupMenu,HMENU,a,WORD,b,int,c,int,d,int,e,HWND,f,LPRECT,g)
Fg(HCURSOR,CreateCursor,HANDLE,a,int,b,int,c,int,d,int,e,LPSTR,f,LPSTR,g)
Fg(HICON,CreateIcon,HANDLE,a,int,b,int,c,BYTE,d,BYTE,e,LPSTR,f,LPSTR,g)
@ -2022,6 +2136,7 @@ Fg(void,SetWindowPos,HWND,a,HWND,b,short,c,short,d,short,e,short,f,WORD,g)
Fh(BOOL,ExtTextOut,HDC,a,int,b,int,c,WORD,d,LPRECT,e,LPSTR,f,WORD,g,LPINT,h)
Fh(HANDLE,DeferWindowPos,HANDLE,hWinPosInfo,HWND,hWnd,HWND,hWndInsertAfter,int,x,int,y,int,cx,int,cy,WORD,wFlags)
Fh(LONG,TabbedTextOut,HDC,a,int,b,int,c,LPSTR,d,int,e,int,f,LPINT,g,int,h)
Fh(int,ScrollWindowEx,HWND,a,short,b,short,c,LPRECT,d,LPRECT,e,HRGN,f,LPRECT,g,WORD,h)
Fi(BOOL,Arc,HDC,a,int,xLeft,int,yTop,int,xRight,int,yBottom,int,xStart,int,yStart,int,xEnd,int,yEnd)
Fi(BOOL,Chord,HDC,a,int,xLeft,int,yTop,int,xRight,int,yBottom,int,xStart,int,yStart,int,xEnd,int,yEnd)
Fi(BOOL,BitBlt,HDC,a,short,b,short,c,short,d,short,e,HDC,f,short,g,short,h,DWORD,i)

View File

@ -1,7 +1,7 @@
CFLAGS=$(COPTS) $(DEBUGOPTS) -I../include
OBJS=dump.o files.o ldt.o ldtlib.o resource.o selector.o signal.o int1a.o \
int21.o wine.o
int21.o wine.o library.o
default: loader.o

View File

@ -66,6 +66,7 @@ FindFileInPath(char *buffer, int buflen, char *rootname,
strncpy(buffer, dirname, buflen);
strncat(buffer, "/", buflen - strlen(buffer));
strncat(buffer, f->d_name, buflen - strlen(buffer));
closedir(d);
return buffer;
}
}

View File

@ -665,6 +665,7 @@ void GetFileDateTime(struct sigcontext_struct *context)
struct stat filestat;
struct tm *now;
dirname = (char *) pointer(DS,DX);
ParseDOSFileName(unixname, dirname, &drive);
{
@ -872,7 +873,7 @@ int do_int21(struct sigcontext_struct * context){
case 0x12: /* FIND NEXT MATCHING FILE USING FCB */
case 0x13: /* DELETE FILE USING FCB */
case 0x14: /* SEQUENTIAL READ FROM FCB FILE */
case 0x15: /* SEQUENTIAL WRITE TO FCB FILE
case 0x15: /* SEQUENTIAL WRITE TO FCB FILE */
case 0x16: /* CREATE OR TRUNCATE FILE USING FCB */
case 0x17: /* RENAME FILE USING FCB */
case 0x1a: /* SET DISK TRANSFER AREA ADDRESS */
@ -888,7 +889,7 @@ int do_int21(struct sigcontext_struct * context){
case 0x2e: /* SET VERIFY FLAG */
break;
case 0x18: /* NULL FUNCTIONS FOR CP/M COMPATIBILITY *
case 0x18: /* NULL FUNCTIONS FOR CP/M COMPATIBILITY */
case 0x1d:
case 0x1e:
case 0x20:

37
loader/library.c Normal file
View File

@ -0,0 +1,37 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include "prototypes.h"
#include "windows.h"
#include "win.h"
#include "gdi.h"
#include "wine.h"
/**********************************************************************
* LoadLibrary [KERNEL.95]
*/
HANDLE LoadLibrary(LPSTR libname)
{
HANDLE hRet;
printf("LoadLibrary '%s'\n", libname);
hRet = LoadImage(libname, NULL);
printf("after LoadLibrary hRet=%04X\n", hRet);
return hRet;
}
/**********************************************************************
* FreeLibrary [KERNEL.96]
*/
void FreeLibrary(HANDLE hLib)
{
printf("FreeLibrary(%04X);\n", hLib);
if (hLib != (HANDLE)NULL) GlobalFree(hLib);
}

View File

@ -1,6 +1,7 @@
static char RCSId[] = "$Id: resource.c,v 1.4 1993/07/04 04:04:21 root Exp root $";
static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
#include <X11/Intrinsic.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
@ -8,16 +9,32 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
#include <fcntl.h>
#include <unistd.h>
#include "prototypes.h"
#include "neexe.h"
#include "windows.h"
#include "win.h"
#include "gdi.h"
#include "wine.h"
#include "icon.h"
#include "cursor.h"
#define MIN(a,b) ((a) < (b) ? (a) : (b))
typedef struct resource_s
{
struct resource_s *next;
HANDLE info_mem;
int size_shift;
struct resource_nameinfo_s nameinfo;
HANDLE rsc_mem;
} RESOURCE;
static int ResourceFd = -1;
static HANDLE ResourceInst = 0;
static struct w_files *ResourceFileInfo = NULL;
static RESOURCE *Top = NULL;
static HCURSOR hActiveCursor;
extern HINSTANCE hSysRes;
HANDLE RSC_LoadResource(int instance, char *rsc_name, int type, int *image_size_ret);
/**********************************************************************
@ -227,6 +244,11 @@ FindResourceByName(struct resource_nameinfo_s *result_p,
printf("FindResourceByName (%s) bad typeinfo size !\n", resource_name);
return -1;
}
#ifdef DEBUG_RESOURCE
printf("FindResourceByName typeinfo.type_id=%d type_id=%d\n",
typeinfo.type_id, type_id);
#endif
if (typeinfo.type_id == 0) break;
if (typeinfo.type_id == type_id || type_id == -1)
{
for (i = 0; i < typeinfo.count; i++)
@ -248,6 +270,10 @@ FindResourceByName(struct resource_nameinfo_s *result_p,
read(ResourceFd, name, nbytes);
lseek(ResourceFd, old_pos, SEEK_SET);
name[nbytes] = '\0';
#ifdef DEBUG_RESOURCE
printf("FindResourceByName type_id=%d name='%s' resource_name='%s'\n",
typeinfo.type_id, name, resource_name);
#endif
if (strcasecmp(name, resource_name) == 0)
{
memcpy(result_p, &nameinfo, sizeof(nameinfo));
@ -255,31 +281,289 @@ FindResourceByName(struct resource_nameinfo_s *result_p,
}
}
}
else {
lseek(ResourceFd, (typeinfo.count * sizeof(nameinfo)), SEEK_CUR);
}
}
printf("FindResourceByName (%s) typeinfo.type_id = 0 !\n", resource_name);
return -1;
}
/**********************************************************************
* LoadIcon
* LoadIcon [USER.174]
*/
HICON
LoadIcon(HANDLE instance, LPSTR icon_name)
HICON LoadIcon(HANDLE instance, LPSTR icon_name)
{
fprintf(stderr,"LoadIcon: (%d),%d\n",instance,icon_name);
HICON hIcon;
HANDLE rsc_mem;
WORD *lp;
ICONDESCRIP *lpicodesc;
ICONALLOC *lpico;
int width, height;
BITMAPINFO *bmi;
BITMAPINFOHEADER *bih;
RGBQUAD *rgbq;
HBITMAP hBitMap;
HDC hMemDC;
HDC hMemDC2;
HDC hdc;
int i, j, image_size;
#ifdef DEBUG_RESOURCE
printf("LoadIcon: instance = %04x, name = %08x\n",
instance, icon_name);
#endif
if (instance == (HANDLE)NULL) instance = hSysRes;
if (!(hdc = GetDC(GetDesktopWindow()))) return 0;
rsc_mem = RSC_LoadResource(instance, icon_name, NE_RSCTYPE_GROUP_ICON,
&image_size);
if (rsc_mem == (HANDLE)NULL) {
printf("LoadIcon / Icon %04X not Found !\n", icon_name);
return 0;
}
lp = (WORD *)GlobalLock(rsc_mem);
if (lp == NULL) {
GlobalFree(rsc_mem);
return 0;
}
lpicodesc = (ICONDESCRIP *)(lp + 3);
hIcon = GlobalAlloc(GMEM_MOVEABLE, sizeof(ICONALLOC) + 1024);
if (hIcon == (HICON)NULL) {
GlobalFree(rsc_mem);
return 0;
}
printf("LoadIcon Alloc hIcon=%X\n", hIcon);
lpico = (ICONALLOC *)GlobalLock(hIcon);
lpico->descriptor = *lpicodesc;
width = lpicodesc->Width;
height = lpicodesc->Height;
GlobalUnlock(rsc_mem);
GlobalFree(rsc_mem);
rsc_mem = RSC_LoadResource(instance,
MAKEINTRESOURCE(lpicodesc->icoDIBOffset),
NE_RSCTYPE_ICON, &image_size);
if (rsc_mem == (HANDLE)NULL) {
printf("LoadIcon / Icon %04X Bitmaps not Found !\n", icon_name);
return 0;
}
lp = (WORD *)GlobalLock(rsc_mem);
if (lp == NULL) {
GlobalFree(rsc_mem);
return 0;
}
bmi = (BITMAPINFO *)lp;
bih = (BITMAPINFOHEADER *)lp;
rgbq = &bmi->bmiColors[0];
bih->biHeight = bih->biHeight / 2;
/*
printf("LoadIcon / image_size=%d width=%d height=%d bih->biBitCount=%d bih->biSizeImage=%ld\n",
image_size, width, height, bih->biBitCount, bih->biSizeImage);
*/
if (bih->biSize == sizeof(BITMAPINFOHEADER))
lpico->hBitmap = ConvertInfoBitmap(hdc, (BITMAPINFO *)bih);
else
lpico->hBitmap = 0;
bih->biBitCount = 1;
bih->biClrUsed = bih->biClrImportant = 2;
rgbq[0].rgbBlue = 0xFF;
rgbq[0].rgbGreen = 0xFF;
rgbq[0].rgbRed = 0xFF;
rgbq[0].rgbReserved = 0x00;
rgbq[1].rgbBlue = 0x00;
rgbq[1].rgbGreen = 0x00;
rgbq[1].rgbRed = 0x00;
rgbq[1].rgbReserved = 0x00;
lpico->hBitMask = CreateDIBitmap(hdc, bih, CBM_INIT,
(LPSTR)lp + bih->biSizeImage - sizeof(BITMAPINFOHEADER) / 2 - 4,
(BITMAPINFO *)bih, DIB_RGB_COLORS );
GlobalUnlock(rsc_mem);
GlobalFree(rsc_mem);
hMemDC = CreateCompatibleDC(hdc);
hMemDC2 = CreateCompatibleDC(hdc);
SelectObject(hMemDC, lpico->hBitmap);
SelectObject(hMemDC2, lpico->hBitMask);
BitBlt(hMemDC, 0, 0, bih->biWidth, bih->biHeight, hMemDC2, 0, 0, SRCINVERT);
DeleteDC(hMemDC);
DeleteDC(hMemDC2);
ReleaseDC(0, hdc);
return hIcon;
}
/**********************************************************************
* DestroyIcon [USER.457]
*/
BOOL DestroyIcon(HICON hIcon)
{
ICONALLOC *lpico;
if (hIcon == (HICON)NULL) return FALSE;
lpico = (ICONALLOC *)GlobalLock(hIcon);
if (lpico->hBitmap != (HBITMAP)NULL) DeleteObject(lpico->hBitmap);
GlobalFree(hIcon);
return TRUE;
}
/**********************************************************************
* LoadCursor [USER.173]
*/
HCURSOR LoadCursor(HANDLE instance, LPSTR cursor_name)
{
XColor bkcolor;
XColor fgcolor;
HCURSOR hCursor;
HANDLE rsc_mem;
WORD *lp;
CURSORDESCRIP *lpcurdesc;
CURSORALLOC *lpcur;
BITMAP BitMap;
HBITMAP hBitMap;
HDC hMemDC;
HDC hdc;
int i, j, image_size;
#ifdef DEBUG_RESOURCE
printf("LoadCursor: instance = %04x, name = %08x\n",
instance, cursor_name);
#endif
if (!(hdc = GetDC(GetDesktopWindow()))) return 0;
if (instance == (HANDLE)NULL) instance = hSysRes;
rsc_mem = RSC_LoadResource(instance, cursor_name, NE_RSCTYPE_GROUP_CURSOR,
&image_size);
if (rsc_mem == (HANDLE)NULL) {
printf("LoadCursor / Cursor %08X not Found !\n", cursor_name);
return 0;
}
lp = (WORD *)GlobalLock(rsc_mem);
if (lp == NULL) {
GlobalFree(rsc_mem);
return 0;
}
lpcurdesc = (CURSORDESCRIP *)(lp + 3);
#ifdef DEBUG_CURSOR
printf("LoadCursor / image_size=%d\n", image_size);
printf("LoadCursor / curReserved=%X\n", *lp);
printf("LoadCursor / curResourceType=%X\n", *(lp + 1));
printf("LoadCursor / curResourceCount=%X\n", *(lp + 2));
printf("LoadCursor / cursor Width=%d\n", (int)lpcurdesc->Width);
printf("LoadCursor / cursor Height=%d\n", (int)lpcurdesc->Height);
printf("LoadCursor / cursor curXHotspot=%d\n", (int)lpcurdesc->curXHotspot);
printf("LoadCursor / cursor curYHotspot=%d\n", (int)lpcurdesc->curYHotspot);
printf("LoadCursor / cursor curDIBSize=%lX\n", (DWORD)lpcurdesc->curDIBSize);
printf("LoadCursor / cursor curDIBOffset=%lX\n", (DWORD)lpcurdesc->curDIBOffset);
#endif
hCursor = GlobalAlloc(GMEM_MOVEABLE, sizeof(CURSORALLOC) + 1024L);
if (hCursor == (HCURSOR)NULL) {
GlobalFree(rsc_mem);
return 0;
}
printf("LoadCursor Alloc hCursor=%X\n", hCursor);
lpcur = (CURSORALLOC *)GlobalLock(hCursor);
lpcur->descriptor = *lpcurdesc;
GlobalUnlock(rsc_mem);
GlobalFree(rsc_mem);
rsc_mem = RSC_LoadResource(instance,
MAKEINTRESOURCE(lpcurdesc->curDIBOffset),
NE_RSCTYPE_CURSOR, &image_size);
if (rsc_mem == (HANDLE)NULL) {
printf("LoadCursor / Cursor %08X Bitmap not Found !\n", cursor_name);
return 0;
}
lp = (WORD *)GlobalLock(rsc_mem);
if (lp == NULL) {
GlobalFree(rsc_mem);
return 0;
}
lp += 2;
for (j = 0; j < 16; j++)
printf("%04X ", *(lp + j));
if (*lp == sizeof(BITMAPINFOHEADER))
lpcur->hBitmap = ConvertInfoBitmap(hdc, (BITMAPINFO *)lp);
else
lpcur->hBitmap = 0;
lp += sizeof(BITMAP);
for (i = 0; i < 81; i++) {
char temp = *((char *)lp + 162 + i);
*((char *)lp + 162 + i) = *((char *)lp + 324 - i);
*((char *)lp + 324 - i) = temp;
}
printf("LoadCursor / before XCreatePixmapFromBitmapData !\n");
lpcur->pixshape = XCreatePixmapFromBitmapData(
XT_display, DefaultRootWindow(XT_display),
((char *)lp + 211), 32, 32,
/*
lpcurdesc->Width / 2, lpcurdesc->Height / 4,
*/
WhitePixel(XT_display, DefaultScreen(XT_display)),
BlackPixel(XT_display, DefaultScreen(XT_display)), 1);
lpcur->pixmask = lpcur->pixshape;
bkcolor.pixel = WhitePixel(XT_display, DefaultScreen(XT_display));
fgcolor.pixel = BlackPixel(XT_display, DefaultScreen(XT_display));
printf("LoadCursor / before XCreatePixmapCursor !\n");
lpcur->xcursor = XCreatePixmapCursor(XT_display,
lpcur->pixshape, lpcur->pixmask,
&fgcolor, &bkcolor, lpcur->descriptor.curXHotspot,
lpcur->descriptor.curYHotspot);
ReleaseDC(0, hdc);
GlobalUnlock(rsc_mem);
GlobalFree(rsc_mem);
return hCursor;
}
/**********************************************************************
* DestroyCursor [USER.458]
*/
BOOL DestroyCursor(HCURSOR hCursor)
{
CURSORALLOC *lpcur;
if (hCursor == (HCURSOR)NULL) return FALSE;
lpcur = (CURSORALLOC *)GlobalLock(hCursor);
if (lpcur->hBitmap != (HBITMAP)NULL) DeleteObject(lpcur->hBitmap);
GlobalUnlock(hCursor);
GlobalFree(hCursor);
return TRUE;
}
/**********************************************************************
* SetCursor [USER.69]
*/
HCURSOR SetCursor(HCURSOR hCursor)
{
HDC hDC;
HDC hMemDC;
BITMAP bm;
CURSORALLOC *lpcur;
HCURSOR hOldCursor;
#ifdef DEBUG_CURSOR
printf("SetCursor / hCursor=%04X !\n", hCursor);
#endif
if (hCursor == (HCURSOR)NULL) return FALSE;
lpcur = (CURSORALLOC *)GlobalLock(hCursor);
hOldCursor = hActiveCursor;
printf("SetCursor / before XDefineCursor !\n");
XDefineCursor(XT_display, DefaultRootWindow(XT_display), lpcur->xcursor);
GlobalUnlock(hCursor);
hActiveCursor = hCursor;
return hOldCursor;
}
/**********************************************************************
* ShowCursor [USER.71]
*/
int ShowCursor(BOOL bShow)
{
if (bShow) {
}
return 0;
}
/**********************************************************************
* LoadCursor
*/
HCURSOR
LoadCursor(HANDLE instance, LPSTR cursor_name)
{
fprintf(stderr,"LoadCursor: (%d),%d\n",instance,cursor_name);
return 0;
}
/**********************************************************************
* LoadAccelerators
@ -296,8 +580,43 @@ LoadAccelerators(HANDLE instance, LPSTR lpTableName)
*/
HANDLE FindResource(HANDLE instance, LPSTR resource_name, LPSTR type_name)
{
fprintf(stderr,"FindResource: (%d),%d\n",instance, resource_name, type_name);
RESOURCE *r;
HANDLE rh;
if (instance == 0)
return 0;
if (OpenResourceFile(instance) < 0)
return 0;
rh = GlobalAlloc(GMEM_MOVEABLE, sizeof(*r));
if (rh == 0)
return 0;
r = (RESOURCE *)GlobalLock(rh);
r->next = Top;
Top = r;
r->info_mem = rh;
r->rsc_mem = 0;
if (((int) resource_name & 0xffff0000) == 0)
{
r->size_shift = FindResourceByNumber(&r->nameinfo, type_name,
(int) resource_name | 0x8000);
}
else
{
r->size_shift = FindResourceByName(&r->nameinfo, type_name,
resource_name);
}
if (r->size_shift == -1)
{
GlobalFree(rh);
return 0;
}
return rh;
}
/**********************************************************************
@ -305,8 +624,36 @@ HANDLE FindResource(HANDLE instance, LPSTR resource_name, LPSTR type_name)
*/
HANDLE LoadResource(HANDLE instance, HANDLE hResInfo)
{
fprintf(stderr,"LoadResource: (%d),%d\n",instance, hResInfo);
return ;
RESOURCE *r;
int image_size;
void *image;
HANDLE h;
if (instance == 0)
return 0;
if (OpenResourceFile(instance) < 0)
return 0;
r = (RESOURCE *)GlobalLock(hResInfo);
if (r == NULL)
return 0;
image_size = r->nameinfo.length << r->size_shift;
h = r->rsc_mem = GlobalAlloc(GMEM_MOVEABLE, image_size);
image = GlobalLock(h);
if (image == NULL || read(ResourceFd, image, image_size) != image_size)
{
GlobalFree(h);
GlobalUnlock(hResInfo);
return 0;
}
GlobalUnlock(h);
GlobalUnlock(hResInfo);
return h;
}
/**********************************************************************
@ -314,18 +661,50 @@ HANDLE LoadResource(HANDLE instance, HANDLE hResInfo)
*/
LPSTR LockResource(HANDLE hResData)
{
fprintf(stderr,"LockResource: %d\n", hResData);
return ;
return GlobalLock(hResData);
}
/**********************************************************************
* FreeResource [KERNEL.63]
*/
BOOL FreeResource(HANDLE hResData)
HANDLE FreeResource(HANDLE hResData)
{
fprintf(stderr,"FreeResource: %d\n", hResData);
return ;
RESOURCE *r, *rp;
for (r = rp = Top; r != NULL; r = r->next)
{
if (r->info_mem == hResData)
{
if (rp != NULL)
rp->next = r->next;
else
Top = r->next;
GlobalFree(r->rsc_mem);
GlobalFree(r->info_mem);
return 0;
}
}
return hResData;
}
/**********************************************************************
* AccessResource [KERNEL.64]
*/
int AccessResource(HANDLE instance, HANDLE hResInfo)
{
int resfile;
#ifdef DEBUG_RESOURCE
printf("AccessResource(%04X, %04X);\n", instance, hResInfo);
#endif
/*
resfile = OpenResourceFile(instance);
return resfile;
*/
return - 1;
}
/**********************************************************************
@ -365,9 +744,10 @@ RSC_LoadResource(int instance, char *rsc_name, int type, int *image_size_ret)
{
size_shift = FindResourceByName(&nameinfo, type, rsc_name);
}
if (size_shift == -1)
if (size_shift == -1) {
printf("RSC_LoadResource / Resource '%X' not Found !\n", rsc_name);
return 0;
}
/*
* Read resource.
*/
@ -406,15 +786,15 @@ LoadString(HANDLE instance, WORD resource_id, LPSTR buffer, int buflen)
instance, resource_id, buffer, buflen);
#endif
hmem = RSC_LoadResource(instance, (char *) (resource_id >> 4),
hmem = RSC_LoadResource(instance, (char *) ((resource_id >> 4) + 1),
NE_RSCTYPE_STRING, &rsc_size);
if (hmem == 0)
return 0;
p = GlobalLock(hmem);
string_num = resource_id & 0x000f;
for (i = 0; i < resource_id; i++)
p += *p;
for (i = 0; i < string_num; i++)
p += *p + 1;
i = MIN(buflen - 1, *p);
memcpy(buffer, p + 1, i);
@ -445,7 +825,6 @@ LoadBitmap(HANDLE instance, LPSTR bmp_name)
{
HBITMAP hbitmap;
HANDLE rsc_mem;
GDIOBJHDR * ptr;
HDC hdc;
long *lp;
int image_size;
@ -454,11 +833,20 @@ LoadBitmap(HANDLE instance, LPSTR bmp_name)
printf("LoadBitmap: instance = %04x, name = %08x\n",
instance, bmp_name);
#endif
printf("LoadBitmap: instance = %04x, name = %08x\n",
instance, bmp_name);
if (!(hdc = GetDC( 0 ))) return 0;
if (instance == (HANDLE)NULL) instance = hSysRes;
if (!(hdc = GetDC(GetDesktopWindow()))) return 0;
printf("before RSC_Load\n");
rsc_mem = RSC_LoadResource(instance, bmp_name, NE_RSCTYPE_BITMAP,
&image_size);
if (rsc_mem == (HANDLE)NULL) {
printf("LoadBitmap / BitMap %04X not Found !\n", bmp_name);
return 0;
}
printf("before GlobalLock\n");
lp = (long *) GlobalLock(rsc_mem);
if (lp == NULL)
{
@ -470,7 +858,7 @@ LoadBitmap(HANDLE instance, LPSTR bmp_name)
else if (*lp == sizeof(BITMAPINFOHEADER))
hbitmap = ConvertInfoBitmap( hdc, (BITMAPINFO *) lp );
else hbitmap = 0;
printf("LoadBitmap %04X\n", hbitmap);
GlobalFree(rsc_mem);
ReleaseDC( 0, hdc );
return hbitmap;

View File

@ -38,44 +38,253 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
#define UTEXTSEL 0x1f
#endif
#define MAX_SELECTORS 512
static struct segment_descriptor_s * EnvironmentSelector = NULL;
static struct segment_descriptor_s * PSP_Selector = NULL;
struct segment_descriptor_s * MakeProcThunks = NULL;
unsigned short PSPSelector;
unsigned char ran_out = 0;
unsigned short SelectorOwners[MAX_SELECTORS];
unsigned short SelectorMap[MAX_SELECTORS];
unsigned short SelectorLimits[MAX_SELECTORS];
unsigned char SelectorTypes[MAX_SELECTORS];
int LastUsedSelector = FIRST_SELECTOR - 1;
#ifdef DEV_ZERO
static FILE *zfile = NULL;
#endif
static int next_unused_selector = FIRST_SELECTOR;
extern void KERNEL_Ordinal_102();
extern void UNIXLIB_Ordinal_0();
extern char **Argv;
extern int Argc;
/**********************************************************************
* GetNextSegment
* FindUnusedSelector
*/
int
FindUnusedSelector(void)
{
int i;
for (i = LastUsedSelector + 1; i != LastUsedSelector; i++)
{
if (i >= MAX_SELECTORS)
i = FIRST_SELECTOR;
if (!SelectorMap[i])
break;
}
if (i == LastUsedSelector)
return 0;
LastUsedSelector = i;
return i;
}
/**********************************************************************
* AllocSelector
*
* This is very bad!!! This function is implemented for Windows
* compatibility only. Do not call this from the emulation library.
*/
unsigned int
AllocSelector(unsigned int old_selector)
{
int i_new, i_old;
long base;
i_new = FindUnusedSelector();
if (old_selector)
{
i_old = (old_selector >> 3);
SelectorMap[i_new] = i_old;
base = SAFEMAKEPTR(old_selector, 0);
if (set_ldt_entry(i_new, base,
SelectorLimits[i_old], 0,
SelectorTypes[i_old], 0, 0) < 0)
{
return 0;
}
SelectorLimits[i_new] = SelectorLimits[i_old];
SelectorTypes[i_new] = SelectorTypes[i_old];
SelectorMap[i_new] = SelectorMap[i_old];
}
else
{
SelectorMap[i_new] = i_new;
}
return i_new;
}
/**********************************************************************
* PrestoChangoSelector
*
* This is very bad!!! This function is implemented for Windows
* compatibility only. Do not call this from the emulation library.
*/
unsigned int PrestoChangoSelector(unsigned src_selector, unsigned dst_selector)
{
long dst_base, src_base;
char *p;
int src_idx, dst_idx;
int alias_count;
int i;
src_idx = (SelectorMap[src_selector >> 3]);
dst_idx = dst_selector >> 3;
src_base = (src_idx << 19) | 0x70000;
dst_base = (dst_idx << 19) | 0x70000;
alias_count = 0;
for (i = FIRST_SELECTOR; i < MAX_SELECTORS; i++)
if (SelectorMap[i] == src_idx)
alias_count++;
if (SelectorTypes[src_idx] == MODIFY_LDT_CONTENTS_DATA
|| alias_count > 1 || src_idx == dst_idx)
{
if (SelectorTypes[src_idx] == MODIFY_LDT_CONTENTS_DATA)
SelectorTypes[dst_idx] = MODIFY_LDT_CONTENTS_CODE;
else
SelectorTypes[dst_idx] = MODIFY_LDT_CONTENTS_DATA;
SelectorMap[dst_idx] = SelectorMap[src_idx];
SelectorLimits[dst_idx] = SelectorLimits[src_idx];
if (set_ldt_entry(dst_idx, src_base,
SelectorLimits[dst_idx], 0,
SelectorTypes[dst_idx], 0, 0) < 0)
{
return 0;
}
}
else
{
/*
* We're changing an unaliased code segment into a data
* segment. The SAFEST (but ugliest) way to deal with
* this is to map the new segment and copy all the contents.
*/
SelectorTypes[dst_idx] = MODIFY_LDT_CONTENTS_DATA;
SelectorMap[dst_idx] = SelectorMap[src_idx];
SelectorLimits[dst_idx] = SelectorLimits[src_idx];
#ifdef DEV_ZERO
if (zfile == NULL)
zfile = fopen("/dev/zero","r");
p = (void *) mmap((char *) dst_base,
((SelectorLimits[dst_idx] + PAGE_SIZE)
& ~(PAGE_SIZE - 1)),
PROT_EXEC | PROT_READ | PROT_WRITE,
MAP_FIXED | MAP_PRIVATE, fileno(zfile), 0);
#else
p = (void *) mmap((char *) dst_base,
((SelectorLimits[dst_idx] + PAGE_SIZE)
& ~(PAGE_SIZE - 1)),
PROT_EXEC | PROT_READ | PROT_WRITE,
MAP_FIXED | MAP_PRIVATE | MAP_ANON, -1, 0);
#endif
if (p == NULL)
return 0;
memcpy((void *) dst_base, (void *) src_base,
SelectorLimits[dst_idx] + 1);
if (set_ldt_entry(src_idx, dst_base,
SelectorLimits[dst_idx], 0,
SelectorTypes[dst_idx], 0, 0) < 0)
{
return 0;
}
if (set_ldt_entry(dst_idx, dst_base,
SelectorLimits[dst_idx], 0,
SelectorTypes[dst_idx], 0, 0) < 0)
{
return 0;
}
}
return (dst_idx << 3) | 0x0007;
}
/**********************************************************************
* AllocCStoDSAlias
*/
AllocDStoCSAlias(unsigned int ds_selector)
{
unsigned int cs_selector;
if (ds_selector == 0)
return 0;
cs_selector = AllocSelector(0);
return PrestoChangoSelector(ds_selector, cs_selector);
}
/**********************************************************************
* FreeSelector
*/
unsigned int FreeSelector(unsigned int sel)
{
int sel_idx;
int alias_count;
int i;
sel_idx = SelectorMap[sel >> 3];
if (sel_idx != (sel >> 3))
{
SelectorMap[sel >> 3] = 0;
return 0;
}
alias_count = 0;
for (i = FIRST_SELECTOR; i < MAX_SELECTORS; i++)
if (SelectorMap[i] == sel_idx)
alias_count++;
if (alias_count == 1)
{
munmap((char *) (sel << 16),
((SelectorLimits[sel_idx] + PAGE_SIZE) & ~(PAGE_SIZE - 1)));
SelectorMap[sel >> 3] = 0;
}
return 0;
}
/**********************************************************************
* CreateNewSegment
*/
struct segment_descriptor_s *
GetNextSegment(unsigned int flags, unsigned int limit)
CreateNewSegment(int code_flag, int read_only, int length)
{
struct segment_descriptor_s *selectors, *s;
int sel_idx;
#ifdef DEV_ZERO
FILE *zfile;
#endif
struct segment_descriptor_s *s;
int contents;
int i;
sel_idx = next_unused_selector++;
i = FindUnusedSelector();
/*
* Fill in selector info.
*/
s = malloc(sizeof(*s));
if (code_flag)
{
contents = MODIFY_LDT_CONTENTS_CODE;
s->flags = 0;
}
else
{
contents = MODIFY_LDT_CONTENTS_DATA;
s->flags = NE_SEGFLAGS_DATA;
s->selector = (sel_idx << 3) | 0x0007;
s->length = limit;
}
s->selector = (i << 3) | 0x0007;
s->length = length;
#ifdef DEV_ZERO
if (zfile == NULL)
zfile = fopen("/dev/zero","r");
s->base_addr = (void *) mmap((char *) (s->selector << 16),
((s->length + PAGE_SIZE - 1) &
@ -83,7 +292,6 @@ GetNextSegment(unsigned int flags, unsigned int limit)
PROT_EXEC | PROT_READ | PROT_WRITE,
MAP_FIXED | MAP_PRIVATE, fileno(zfile), 0);
fclose(zfile);
#else
s->base_addr = (void *) mmap((char *) (s->selector << 16),
((s->length + PAGE_SIZE - 1) &
@ -93,18 +301,30 @@ GetNextSegment(unsigned int flags, unsigned int limit)
#endif
if (set_ldt_entry(sel_idx, (unsigned long) s->base_addr,
if (set_ldt_entry(i, (unsigned long) s->base_addr,
(s->length - 1) & 0xffff, 0,
MODIFY_LDT_CONTENTS_DATA, 0, 0) < 0)
contents, read_only, 0) < 0)
{
next_unused_selector--;
free(s);
return NULL;
}
SelectorMap[i] = (unsigned short) i;
SelectorLimits[i] = s->length - 1;
SelectorTypes[i] = contents;
return s;
}
/**********************************************************************
* GetNextSegment
*/
struct segment_descriptor_s *
GetNextSegment(unsigned int flags, unsigned int limit)
{
return CreateNewSegment(0, 0, limit);
}
/**********************************************************************
* GetEntryPointFromOrdinal
*/
@ -275,37 +495,14 @@ GetDOSEnvironment()
* CreateEnvironment
*/
static struct segment_descriptor_s *
#ifdef DEV_ZERO
CreateEnvironment(FILE *zfile)
#else
CreateEnvironment(void)
#endif
{
char *p;
int sel_idx;
struct segment_descriptor_s * s;
s = (struct segment_descriptor_s *)
malloc(sizeof(struct segment_descriptor_s));
sel_idx = next_unused_selector++;
/*
* Create memory to hold environment.
*/
s->flags = NE_SEGFLAGS_DATA;
s->selector = (sel_idx << 3) | 0x0007;
s->length = PAGE_SIZE;
#ifdef DEV_ZERO
s->base_addr = (void *) mmap((char *) (s->selector << 16),
PAGE_SIZE,
PROT_EXEC | PROT_READ | PROT_WRITE,
MAP_FIXED | MAP_PRIVATE, fileno(zfile), 0);
#else
s->base_addr = (void *) mmap((char *) (s->selector << 16),
PAGE_SIZE,
PROT_EXEC | PROT_READ | PROT_WRITE,
MAP_FIXED | MAP_PRIVATE | MAP_ANON, -1, 0);
#endif
s = CreateNewSegment(0, 0, PAGE_SIZE);
if (s == NULL)
return NULL;
/*
* Fill environment with meaningless babble.
@ -318,63 +515,6 @@ CreateEnvironment(void)
*p++ = 0;
strcpy(p, "C:\\TEST.EXE");
/*
* Create entry in LDT for this segment.
*/
if (set_ldt_entry(sel_idx, (unsigned long) s->base_addr,
(s->length - 1) & 0xffff, 0,
MODIFY_LDT_CONTENTS_DATA, 0, 0) < 0)
{
myerror("Could not create LDT entry for environment");
}
return s;
}
/**********************************************************************
* CreateThunks
*/
static struct segment_descriptor_s *
#ifdef DEV_ZERO
CreateThunks(FILE *zfile)
#else
CreateThunks(void)
#endif
{
int sel_idx;
struct segment_descriptor_s * s;
s = (struct segment_descriptor_s *)
malloc(sizeof(struct segment_descriptor_s));
sel_idx = next_unused_selector++;
/*
* Create memory to hold environment.
*/
s->flags = 0;
s->selector = (sel_idx << 3) | 0x0007;
s->length = 0x10000;
#ifdef DEV_ZERO
s->base_addr = (void *) mmap((char *) (s->selector << 16),
s->length,
PROT_EXEC | PROT_READ | PROT_WRITE,
MAP_FIXED | MAP_PRIVATE, fileno(zfile), 0);
#else
s->base_addr = (void *) mmap((char *) (s->selector << 16),
s->length,
PROT_EXEC | PROT_READ | PROT_WRITE,
MAP_FIXED | MAP_PRIVATE | MAP_ANON, -1, 0);
#endif
/*
* Create entry in LDT for this segment.
*/
if (set_ldt_entry(sel_idx, (unsigned long) s->base_addr,
(s->length - 1) & 0xffff, 0,
MODIFY_LDT_CONTENTS_CODE, 0, 0) < 0)
{
myerror("Could not create LDT entry for thunks");
}
return s;
}
@ -382,40 +522,15 @@ CreateThunks(void)
* CreatePSP
*/
static struct segment_descriptor_s *
#ifdef DEV_ZERO
CreatePSP(FILE *zfile)
#else
CreatePSP(void)
#endif
{
struct dos_psp_s *psp;
unsigned short *usp;
int sel_idx;
struct segment_descriptor_s * s;
char *p1, *p2;
int i;
s = (struct segment_descriptor_s *)
malloc(sizeof(struct segment_descriptor_s));
sel_idx = next_unused_selector++;
/*
* Create memory to hold PSP.
*/
s->flags = NE_SEGFLAGS_DATA;
s->selector = (sel_idx << 3) | 0x0007;
s->length = PAGE_SIZE;
#ifdef DEV_ZERO
s->base_addr = (void *) mmap((char *) (s->selector << 16),
PAGE_SIZE,
PROT_EXEC | PROT_READ | PROT_WRITE,
MAP_FIXED | MAP_PRIVATE, fileno(zfile), 0);
#else
s->base_addr = (void *) mmap((char *) (s->selector << 16),
PAGE_SIZE,
PROT_EXEC | PROT_READ | PROT_WRITE,
MAP_FIXED | MAP_PRIVATE | MAP_ANON, -1, 0);
#endif
s = CreateNewSegment(0, 0, PAGE_SIZE);
/*
* Fill PSP
@ -451,15 +566,6 @@ CreatePSP(void)
*p1 = '\0';
psp->pspCommandTailCount = strlen(psp->pspCommandTail);
/*
* Create entry in LDT for this segment.
*/
if (set_ldt_entry(sel_idx, (unsigned long) s->base_addr,
(s->length - 1) & 0xffff, 0,
MODIFY_LDT_CONTENTS_DATA, 0, 0) < 0)
{
myerror("Could not create LDT entry for PSP");
}
return s;
}
@ -472,15 +578,12 @@ CreateSelectors(struct w_files * wpnt)
int fd = wpnt->fd;
struct ne_segment_table_entry_s *seg_table = wpnt->seg_table;
struct ne_header_s *ne_header = wpnt->ne_header;
struct segment_descriptor_s *selectors, *s;
unsigned short *sp;
struct segment_descriptor_s *selectors, *s, *stmp;
unsigned short auto_data_sel;
int contents, read_only;
int SelectorTableLength;
int i;
int status;
#ifdef DEV_ZERO
FILE * zfile;
#endif
int old_length, file_image_length;
/*
@ -495,24 +598,12 @@ CreateSelectors(struct w_files * wpnt)
* Step through the segment table in the exe header.
*/
s = selectors;
#ifdef DEV_ZERO
zfile = fopen("/dev/zero","r");
#endif
for (i = 0; i < ne_header->n_segment_tab; i++, s++)
{
#ifdef DEBUG_SEGMENT
printf(" %2d: OFFSET %04.4x, LENGTH %04.4x, ",
i + 1, seg_table[i].seg_data_offset,
seg_table[i].seg_data_length);
printf("FLAGS %04.4x, MIN ALLOC %04.4x\n",
seg_table[i].seg_flags, seg_table[i].min_alloc);
#endif
/*
* Store the flags in our table.
*/
s->flags = seg_table[i].seg_flags;
s->selector = ((next_unused_selector + i) << 3) | 0x0007;
/*
* Is there an image for this segment in the file?
@ -570,19 +661,12 @@ CreateSelectors(struct w_files * wpnt)
if (s->flags & NE_SEGFLAGS_EXECUTEONLY)
read_only = 1;
}
#ifdef DEV_ZERO
s->base_addr =
(void *) mmap((char *) (s->selector << 16),
(s->length + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1),
PROT_EXEC | PROT_READ | PROT_WRITE,
MAP_FIXED | MAP_PRIVATE, fileno(zfile), 0);
#else
s->base_addr =
(void *) mmap((char *) (s->selector << 16),
(s->length + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1),
PROT_EXEC | PROT_READ | PROT_WRITE,
MAP_FIXED | MAP_PRIVATE | MAP_ANON, -1, 0);
#endif
stmp = CreateNewSegment(!(s->flags & NE_SEGFLAGS_DATA), read_only,
s->length);
s->base_addr = stmp->base_addr;
s->selector = stmp->selector;
if (seg_table[i].seg_data_offset != 0)
{
/*
@ -593,56 +677,28 @@ CreateSelectors(struct w_files * wpnt)
if(read(fd, s->base_addr, file_image_length) != file_image_length)
myerror("Unable to read segment from file");
}
/*
* Create entry in LDT for this segment.
*/
if (set_ldt_entry(s->selector >> 3, (unsigned long) s->base_addr,
(s->length - 1) & 0xffff, 0,
contents, read_only, 0) < 0)
{
free(selectors);
fprintf(stderr,"Ran out of ldt entries.\n");
ran_out++;
return NULL;
}
#ifdef DEBUG_SEGMENT
printf(" SELECTOR %04.4x, %s\n",
s->selector,
contents == MODIFY_LDT_CONTENTS_CODE ? "CODE" : "DATA");
#endif
/*
* If this is the automatic data segment, then we must initialize
* the local heap.
*/
if (i + 1 == ne_header->auto_data_seg)
{
auto_data_sel = s->selector;
HEAP_LocalInit(s->base_addr + old_length,
ne_header->local_heap_length);
}
}
sp = &SelectorOwners[next_unused_selector];
for (i = 0; i < ne_header->n_segment_tab; i++)
*sp++ = (((next_unused_selector + ne_header->auto_data_seg - 1) << 3)
| 0x0007);
next_unused_selector += ne_header->n_segment_tab;
s = selectors;
for (i = 0; i < ne_header->n_segment_tab; i++, s++)
SelectorOwners[s->selector >> 3] = auto_data_sel;
if(!EnvironmentSelector) {
#ifdef DEV_ZERO
EnvironmentSelector = CreateEnvironment(zfile);
PSP_Selector = CreatePSP(zfile);
MakeProcThunks = CreateThunks(zfile);
#else
EnvironmentSelector = CreateEnvironment();
PSP_Selector = CreatePSP();
MakeProcThunks = CreateThunks();
#endif
MakeProcThunks = CreateNewSegment(1, 0, 0x10000);
};
#ifdef DEV_ZERO
fclose(zfile);
#endif
return selectors;
}

View File

@ -10,7 +10,8 @@
#include <linux/sched.h>
#include <asm/system.h>
#endif
#include <wine.h>
#include "wine.h"
#include "segmem.h"
char * cstack[4096];
struct sigaction segv_act;
@ -64,7 +65,7 @@ static void win_fault(int signal, int code, struct sigcontext *scp){
/* Now take a look at the actual instruction where the program
bombed */
instr = (char *) ((scp->sc_cs << 16) | (scp->sc_eip & 0xffff));
instr = (char *) SAFEMAKEPTR(scp->sc_cs, scp->sc_eip);
if(*instr != 0xcd) {
fprintf(stderr,

View File

@ -38,11 +38,13 @@ int Argc;
struct mz_header_s *CurrentMZHeader;
struct ne_header_s *CurrentNEHeader;
int CurrentNEFile;
HINSTANCE hSysRes;
static char *dllExtensions[] = { "dll", "exe", NULL };
static char *exeExtensions[] = { "exe", NULL };
static char *WinePath = NULL;
/**********************************************************************
* DebugPrintString
*/
@ -99,7 +101,7 @@ GetFileInfo(unsigned short instance)
* LoadImage
* Load one NE format executable into memory
*/
LoadImage(char * filename, char * modulename)
HINSTANCE LoadImage(char * filename, char * modulename)
{
unsigned int read_size;
int i;
@ -236,6 +238,7 @@ LoadImage(char * filename, char * modulename)
fprintf(stderr,"Unable to load:%s\n", buff);
}
return(wpnt->hinstance);
}
@ -278,6 +281,7 @@ _WinMain(int argc, char **argv)
}
LoadImage(exe_path, NULL);
hSysRes = LoadImage("sysres.dll", NULL);
if(ran_out) exit(1);
#ifdef DEBUG

View File

@ -555,7 +555,7 @@ GlobalReAlloc(unsigned int block, unsigned int new_size, unsigned int flags)
* reallocate the block. If this fails, call GlobalAlloc() to get
* a new block.
*/
if (g->sequence = 0)
if (g->sequence == 0)
{
MDESC **free_list;
void *p;

View File

@ -1,7 +1,7 @@
CFLAGS=$(COPTS) $(DEBUGOPTS) -I$(INCLUDE_DIR)
OBJS=dos.o kernel.o user.o xt.o rect.o file.o sound.o emulate.o \
keyboard.o profile.o lstr.o exec.o
keyboard.o profile.o lstr.o exec.o message.o
default: misc.o

View File

@ -41,7 +41,7 @@ WORD WinExec(LPSTR lpCmdLine, WORD nCmdShow)
}
switch(fork()) {
case -1:
printf("Can'k 'fork' process !\n");
printf("Can't 'fork' process !\n");
break;
case 0:
printf("New process started !\n");
@ -68,7 +68,7 @@ BOOL WinHelp(HWND hWnd, LPSTR lpHelpFile, WORD wCommand, DWORD dwData)
printf("WinHelp(%s, %u, %lu)\n", lpHelpFile, wCommand, dwData);
switch(fork()) {
case -1:
printf("Can'k 'fork' process !\n");
printf("Can't 'fork' process !\n");
break;
case 0:
printf("New process started !\n");

264
misc/message.c Normal file
View File

@ -0,0 +1,264 @@
/*
* 'Wine' MessageBox function handling
*
* Copyright 1993 Martin Ayotte
*/
static char Copyright[] = "Copyright Martin Ayotte, 1993";
#include "windows.h"
#include "heap.h"
#include "win.h"
typedef struct tagMSGBOX {
LPSTR Title;
LPSTR Str;
WORD wType;
WORD wRetVal;
BOOL ActiveFlg;
HWND hWndYes;
HWND hWndNo;
HWND hWndCancel;
HICON hIcon;
} MSGBOX;
typedef MSGBOX FAR* LPMSGBOX;
LONG SystemMessageBoxProc(HWND hwnd, WORD message, WORD wParam, LONG lParam);
/**************************************************************************
* MessageBox [USER.1]
*/
int MessageBox( HWND hWnd, LPSTR str, LPSTR title, WORD type )
{
HWND hDlg;
WND *wndPtr;
WNDCLASS wndClass;
MSG msg;
MSGBOX mb;
wndPtr = WIN_FindWndPtr(hWnd);
printf( "MessageBox: '%s'\n", str );
wndClass.style = CS_HREDRAW | CS_VREDRAW ;
wndClass.lpfnWndProc = (WNDPROC)SystemMessageBoxProc;
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 0;
wndClass.hInstance = wndPtr->hInstance;
wndClass.hIcon = (HICON)NULL;
wndClass.hCursor = LoadCursor((HANDLE)NULL, IDC_ARROW);
wndClass.hbrBackground = GetStockObject(WHITE_BRUSH);
wndClass.lpszMenuName = NULL;
wndClass.lpszClassName = "MESSAGEBOX";
if (!RegisterClass(&wndClass)) return 0;
memset(&mb, 0, sizeof(MSGBOX));
mb.Title = title;
mb.Str = str;
mb.wType = type;
mb.ActiveFlg = TRUE;
hDlg = CreateWindow("MESSAGEBOX", title,
WS_POPUP | WS_DLGFRAME | WS_VISIBLE, 100, 150, 320, 120,
(HWND)NULL, (HMENU)NULL, wndPtr->hInstance, (LPSTR)&mb);
if (hDlg == 0) return 0;
while(TRUE) {
if (!mb.ActiveFlg) break;
if (!GetMessage(&msg, (HWND)NULL, 0, 0)) break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
printf( "after MessageBox !\n");
if (!UnregisterClass("MESSAGEBOX", wndPtr->hInstance)) return 0;
return(mb.wRetVal);
}
LPMSGBOX MsgBoxGetStorageHeader(HWND hwnd)
{
WND *wndPtr;
LPMSGBOX lpmb;
wndPtr = WIN_FindWndPtr(hwnd);
if (wndPtr == 0) {
printf("Bad Window handle on MessageBox !\n");
return 0;
}
lpmb = *((LPMSGBOX *)&wndPtr->wExtra[1]);
return lpmb;
}
LONG SystemMessageBoxProc(HWND hWnd, WORD message, WORD wParam, LONG lParam)
{
WND *wndPtr;
CREATESTRUCT *createStruct;
PAINTSTRUCT ps;
HDC hDC;
RECT rect;
LPMSGBOX lpmb;
LPMSGBOX lpmbInit;
BITMAP bm;
HBITMAP hBitMap;
HDC hMemDC;
HICON hIcon;
HINSTANCE hInst2;
int x;
switch(message) {
case WM_CREATE:
wndPtr = WIN_FindWndPtr(hWnd);
createStruct = (CREATESTRUCT *)lParam;
lpmbInit = (LPMSGBOX)createStruct->lpCreateParams;
if (lpmbInit == 0) break;
*((LPMSGBOX *)&wndPtr->wExtra[1]) = lpmbInit;
lpmb = MsgBoxGetStorageHeader(hWnd);
GetClientRect(hWnd, &rect);
switch(lpmb->wType & MB_TYPEMASK) {
case MB_OK :
lpmb->hWndYes = CreateWindow("BUTTON", "&Ok",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
rect.right / 2 - 70, rect.bottom - 25,
60, 18, hWnd, 1, wndPtr->hInstance, 0L);
break;
case MB_OKCANCEL :
lpmb->hWndYes = CreateWindow("BUTTON", "&Ok",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
rect.right / 2 - 70, rect.bottom - 25,
60, 18, hWnd, 1, wndPtr->hInstance, 0L);
lpmb->hWndCancel = CreateWindow("BUTTON", "&Cancel",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
rect.right / 2 + 10, rect.bottom - 25,
60, 18, hWnd, 2, wndPtr->hInstance, 0L);
break;
case MB_ABORTRETRYIGNORE :
lpmb->hWndYes = CreateWindow("BUTTON", "&Retry",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
rect.right / 2 - 70, rect.bottom - 25,
60, 18, hWnd, 1, wndPtr->hInstance, 0L);
lpmb->hWndNo = CreateWindow("BUTTON", "&Ignore",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
rect.right / 2 + 10, rect.bottom - 25,
60, 18, hWnd, 2, wndPtr->hInstance, 0L);
lpmb->hWndCancel = CreateWindow("BUTTON", "&Abort",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
rect.right / 2 + 80, rect.bottom - 25,
60, 18, hWnd, 3, wndPtr->hInstance, 0L);
break;
case MB_YESNO :
lpmb->hWndYes = CreateWindow("BUTTON", "&Yes",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
rect.right / 2 - 70, rect.bottom - 25,
60, 18, hWnd, 1, wndPtr->hInstance, 0L);
lpmb->hWndNo = CreateWindow("BUTTON", "&No",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
rect.right / 2 + 10, rect.bottom - 25,
60, 18, hWnd, 2, wndPtr->hInstance, 0L);
break;
}
switch(lpmb->wType & MB_ICONMASK) {
case MB_ICONEXCLAMATION:
printf("MsgBox LoadIcon Exclamation !\n");
lpmb->hIcon = LoadIcon((HINSTANCE)NULL, IDI_EXCLAMATION);
break;
case MB_ICONQUESTION:
printf("MsgBox LoadIcon Question !\n");
lpmb->hIcon = LoadIcon((HINSTANCE)NULL, IDI_QUESTION);
break;
case MB_ICONASTERISK:
printf("MsgBox LoadIcon Asterisk !\n");
lpmb->hIcon = LoadIcon((HINSTANCE)NULL, IDI_ASTERISK);
break;
case MB_ICONHAND:
printf("MsgBox LoadIcon Hand !\n");
lpmb->hIcon = LoadIcon((HINSTANCE)NULL, IDI_HAND);
break;
}
break;
case WM_PAINT:
lpmb = MsgBoxGetStorageHeader(hWnd);
GetClientRect(hWnd, &rect);
hDC = BeginPaint(hWnd, &ps);
if (lpmb->hIcon) DrawIcon(hDC, 30, 20, lpmb->hIcon);
TextOut(hDC, rect.right / 2, 15,
lpmb->Title, strlen(lpmb->Title));
TextOut(hDC, rect.right / 2, 30,
lpmb->Str, strlen(lpmb->Str));
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
printf("MessageBox WM_DESTROY !\n");
ReleaseCapture();
lpmb = MsgBoxGetStorageHeader(hWnd);
lpmb->ActiveFlg = FALSE;
if (lpmb->hIcon) DestroyIcon(lpmb->hIcon);
if (lpmb->hWndYes) DestroyWindow(lpmb->hWndYes);
if (lpmb->hWndNo) DestroyWindow(lpmb->hWndNo);
if (lpmb->hWndCancel) DestroyWindow(lpmb->hWndCancel);
break;
case WM_COMMAND:
lpmb = MsgBoxGetStorageHeader(hWnd);
switch(wParam) {
case 1:
lpmb->wRetVal = IDOK;
break;
case 2:
wndPtr = WIN_FindWndPtr(hWnd);
hDC = GetDC(hWnd);
/*
for (x = 1; x < 50; x++) {
hBitMap = LoadBitmap(wndPtr->hInstance, MAKEINTRESOURCE(x));
GetObject(hBitMap, sizeof(BITMAP), (LPSTR)&bm);
hMemDC = CreateCompatibleDC(hDC);
SelectObject(hMemDC, hBitMap);
printf(" bm.bmWidth=%d bm.bmHeight=%d\n",
bm.bmWidth, bm.bmHeight);
BitBlt(hDC, x * 20, 30, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
DeleteDC(hMemDC);
}
*/
hBitMap = LoadBitmap((HINSTANCE)NULL, "SMILE");
GetObject(hBitMap, sizeof(BITMAP), (LPSTR)&bm);
printf("bm.bmWidth=%d bm.bmHeight=%d\n",
bm.bmWidth, bm.bmHeight);
hMemDC = CreateCompatibleDC(hDC);
SelectObject(hMemDC, hBitMap);
BitBlt(hDC, 100, 30, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
DeleteDC(hMemDC);
ReleaseDC(hWnd, hDC);
lpmb->wRetVal = IDCANCEL;
/*
SetWindowPos(lpmb->hWndNo, (HWND)NULL, 20, 20, 0, 0,
SWP_NOSIZE | SWP_NOZORDER);
*/
return 0;
break;
case 3:
hDC = GetDC(hWnd);
hInst2 = LoadImage("ev3lite.exe", NULL);
hIcon = LoadIcon(hInst2, "EV3LITE");
DrawIcon(hDC, 20, 20, hIcon);
DestroyIcon(hIcon);
hInst2 = LoadImage("sysres.dll", NULL);
hIcon = LoadIcon(hInst2, "WINEICON");
DrawIcon(hDC, 60, 20, hIcon);
DestroyIcon(hIcon);
hIcon = LoadIcon((HINSTANCE)NULL, IDI_EXCLAMATION);
DrawIcon(hDC, 1000, 20, hIcon);
DestroyIcon(hIcon);
ReleaseDC(hWnd, hDC);
lpmb->wRetVal = IDIGNORE;
return(0);
break;
default:
return(0);
}
CloseWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam );
}
return(0);
}

View File

@ -53,11 +53,6 @@ void main(int argc, char **argv)
*/
int MessageBox( HWND hwnd, LPSTR str, LPSTR title, WORD type )
{
printf( "MessageBox: '%s'\n", str );
}
void MessageBeep( WORD i )
{
XBell(XT_display, 100);
@ -102,12 +97,6 @@ void AdjustWindowRect( LPRECT rect, DWORD style, BOOL menu )
}
BOOL IsIconic( HWND hwnd )
{
printf( "IsIconic: returning FALSE\n" );
return FALSE;
}
HMENU CreateMenu() { return 0; }
BOOL AppendMenu( HMENU hmenu, WORD flags, WORD id, LPSTR text ) { return TRUE;}

View File

@ -19,7 +19,7 @@ extern Screen * XT_screen;
* We try to use a private color map if possible, because Windows programs
* assume that palette(0) == Black and palette(max-1) == White.
*/
#define USE_PRIVATE_MAP
#undef USE_PRIVATE_MAP
Colormap COLOR_WinColormap = 0;

View File

@ -6,9 +6,11 @@
static char Copyright[] = "Copyright Alexandre Julliard, 1993";
#include <stdio.h>
#include <stdlib.h>
#include "gdi.h"
#include "icon.h"
extern XImage * BITMAP_BmpToImage( BITMAP *, void * );
@ -201,3 +203,45 @@ HBITMAP CreateDIBitmap( HDC hdc, BITMAPINFOHEADER * header, DWORD init,
bits, data, coloruse );
return handle;
}
/***********************************************************************
* DrawIcon (USER.84)
*/
BOOL DrawIcon(HDC hDC, short x, short y, HICON hIcon)
{
ICONALLOC *lpico;
BITMAP bm;
HBITMAP hBitTemp;
HDC hMemDC;
HDC hMemDC2;
#ifdef DEBUG_ICON
printf("DrawIcon(%04X, %d, %d, %04X) \n", hDC, x, y, hIcon);
#endif
if (hIcon == (HICON)NULL) return FALSE;
lpico = (ICONALLOC *)GlobalLock(hIcon);
GetObject(lpico->hBitmap, sizeof(BITMAP), (LPSTR)&bm);
#ifdef DEBUG_ICON
printf("DrawIcon / x=%d y=%d\n", x, y);
printf("DrawIcon / icon Width=%d\n", (int)lpico->descriptor.Width);
printf("DrawIcon / icon Height=%d\n", (int)lpico->descriptor.Height);
printf("DrawIcon / icon ColorCount=%d\n", (int)lpico->descriptor.ColorCount);
printf("DrawIcon / icon icoDIBSize=%lX\n", (DWORD)lpico->descriptor.icoDIBSize);
printf("DrawIcon / icon icoDIBOffset=%lX\n", (DWORD)lpico->descriptor.icoDIBOffset);
printf("DrawIcon / bitmap bmWidth=%d bmHeight=%d\n", bm.bmWidth, bm.bmHeight);
#endif
hMemDC = CreateCompatibleDC(hDC);
#ifdef DEBUG_ICON
SelectObject(hMemDC, lpico->hBitmap);
BitBlt(hDC, x, y, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
SelectObject(hMemDC, lpico->hBitMask);
BitBlt(hDC, x, y + bm.bmHeight, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
#else
SelectObject(hMemDC, lpico->hBitMask);
BitBlt(hDC, x, y, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCAND);
SelectObject(hMemDC, lpico->hBitmap);
BitBlt(hDC, x, y, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCPAINT);
#endif
DeleteDC(hMemDC);
return TRUE;
}

BIN
sysres.dll Executable file

Binary file not shown.

View File

@ -1,146 +0,0 @@
/*------------------------------------------
BTNLOOK.C -- Button Look Program
------------------------------------------*/
#include <windows.h>
#include <stdio.h>
struct
{
long style;
char *text;
}
button[] =
{
BS_PUSHBUTTON, "PUSHBUTTON",
BS_DEFPUSHBUTTON, "DEFPUSHBUTTON",
BS_CHECKBOX, "CHECKBOX",
BS_AUTOCHECKBOX, "AUTOCHECKBOX",
BS_RADIOBUTTON, "RADIOBUTTON",
BS_3STATE, "3STATE",
BS_AUTO3STATE, "AUTO3STATE",
BS_GROUPBOX, "GROUPBOX",
BS_USERBUTTON, "USERBUTTON",
BS_AUTORADIOBUTTON, "AUTORADIOBUTTON"
};
#define NUM (sizeof button / sizeof button[0])
long FAR PASCAL _export WndProc(HWND, WORD, WORD, LONG);
int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance,
LPSTR lpszCmdParam, int nCmdShow)
{
static char szAppName[] = "BtnLook";
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
if (!hPrevInstance)
{
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szAppName;
RegisterClass(&wndclass);
}
hwnd = CreateWindow(szAppName, "Button Look",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInstance, NULL);
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
long FAR PASCAL _export WndProc(HWND hwnd, WORD message, WORD wParam, LONG lParam)
{
static char szPrm[] = "wParam LOWORD(lParam) HIWORD(lParam)",
szTop[] = "Control ID Window Handle Notification",
szUnd[] = "__________ _____________ ____________",
szFormat[] = " %5u %4X %5u",
szBuffer[50];
static HWND hwndButton[NUM];
static RECT rect;
static int cxChar, cyChar;
HDC hdc;
PAINTSTRUCT ps;
int i;
TEXTMETRIC tm;
switch (message)
{
case WM_CREATE:
hdc = GetDC(hwnd);
SelectObject(hdc, GetStockObject(SYSTEM_FIXED_FONT));
GetTextMetrics(hdc, &tm);
cxChar = tm.tmAveCharWidth;
cyChar = tm.tmHeight + tm.tmExternalLeading;
ReleaseDC(hwnd, hdc);
for (i = 0; i < NUM; i++)
hwndButton[i] = CreateWindow("button", button[i].text,
WS_CHILD | WS_VISIBLE | button[i].style,
cxChar, cyChar * (1 + 2 * i),
20 * cxChar, 7 * cyChar / 4,
hwnd, i,
((LPCREATESTRUCT) lParam)->hInstance, NULL);
return 0;
case WM_SIZE:
rect.left = 24 * cxChar;
rect.top = 3 * cyChar;
rect.right = LOWORD(lParam);
rect.bottom = HIWORD(lParam);
return 0;
case WM_PAINT:
InvalidateRect(hwnd, &rect, TRUE);
hdc = BeginPaint(hwnd, &ps);
SelectObject(hdc, GetStockObject(SYSTEM_FIXED_FONT));
SetBkMode(hdc, TRANSPARENT);
TextOut(hdc, 24 * cxChar, 1 * cyChar, szPrm, sizeof szPrm - 1);
TextOut(hdc, 24 * cxChar, 2 * cyChar, szTop, sizeof szTop - 1);
TextOut(hdc, 24 * cxChar, 2 * cyChar, szUnd, sizeof szUnd - 1);
EndPaint(hwnd, &ps);
return 0;
case WM_COMMAND:
/* ScrollWindow(hwnd, 0, -cyChar, &rect, &rect); */
hdc = GetDC(hwnd);
SelectObject(hdc, GetStockObject(SYSTEM_FIXED_FONT));
TextOut(hdc, 24 * cxChar, cyChar * 5, /* (rect.bottom / cyChar - 1), */
szBuffer, sprintf(szBuffer, szFormat, wParam,
LOWORD(lParam), HIWORD(lParam)));
ReleaseDC(hwnd, hdc);
ValidateRect(hwnd, NULL);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}

Binary file not shown.

View File

@ -1,442 +0,0 @@
/**********************************************************************
* Copyright (c) 1991 by TRG ELECTRONIK *
* *
* widget.C *
* widget Inventory Controler PART # 1 *
* *
**********************************************************************/
#include <WINDOWS.H>
#include "STDIO.h"
#include "STDLIB.h"
#include "STDARG.h"
#include "STRING.H"
#include "widget.H"
#include "widget.VAR"
#include "widget.P"
#define NoREF(a) a=a
WORD wPlayDiskID;
HWND hWndBut;
HWND hWndChk;
HWND hWndRadio;
HWND hWndLBox;
HWND hWndScrol;
HWND hWndScro2;
HWND hWndStat;
HWND hWndEdit;
HWND hWndCBox;
int x, y;
/**********************************************************************/
int PASCAL WinMain(HANDLE hInstance,HANDLE hPrevInstance,
LPSTR lpszCmdLine,int nCmdShow)
{
WNDCLASS wndClass;
MSG msg;
HWND hWnd;
HDC hDC;
char C[40];
int X;
NoREF(lpszCmdLine);
if ( !hPrevInstance )
{
wndClass.style = CS_HREDRAW | CS_VREDRAW ;
wndClass.lpfnWndProc = (WNDPROC)WndProc;
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 0;
wndClass.hInstance = hInstance;
wndClass.hIcon = LoadIcon(hInstance,(LPSTR)"ICON_1");
wndClass.hCursor = LoadCursor(NULL, IDC_ARROW );
wndClass.hbrBackground = GetStockObject(WHITE_BRUSH );
wndClass.lpszMenuName = szAppName;
wndClass.lpszClassName = szAppName;
if (!RegisterClass(&wndClass))
return FALSE;
}
hWnd = CreateWindow(szAppName, "widget test program",
WS_POPUP | WS_BORDER | WS_VISIBLE, 50, 50,
400, 400, NULL, NULL, hInstance, NULL);
hWndMain = hWnd;
hInst = hInstance;
hDCMain = GetDC(hWndMain);
InitWidgets();
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg );
DispatchMessage(&msg );
}
ReleaseDC(hWndMain, hDC);
return(0);
}
void InitWidgets()
{
hWndBut = CreateWindow("BUTTON", "Button #1",
WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | BS_PUSHBUTTON,
230, 40, 80, 30, hWndMain, 1001, hInst, NULL);
hWndScrol = CreateWindow("SCROLLBAR", "Scroll #1",
WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SBS_VERT,
200, 140, 15, 100, hWndMain, 1004, hInst, NULL);
hWndScro2 = CreateWindow("SCROLLBAR", "Scroll #2",
WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SBS_HORZ,
50, 140, 100, 15, hWndMain, 1005, hInst, NULL);
x = y = 25;
SetVertScroll(NULL, hWndScrol, 25, 0, 50);
SetScrollRange(hWndScro2, SB_CTL, 0, 50, TRUE);
SetScrollPos(hWndScro2, SB_CTL, 25, TRUE);
hWndLBox = CreateWindow("LISTBOX", "",
WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | LBS_NOTIFY,
230, 160, 150, 100, hWndMain, 1004, hInst, NULL);
SendMessage(hWndLBox, LB_ADDSTRING, 0, (LPARAM)"ListBox item #1");
}
long FAR PASCAL WndProc(HWND hWnd, unsigned Message, WORD wParam, LONG lParam)
{
int ShiftState;
char C[80];
ShiftState = GetKeyState(VK_SHIFT);
switch(Message)
{
case WM_COMMAND:
if (LOWORD(lParam) != 0)
{
sprintf(C, "MAIN WM_COMMAND wParam=%X lParam=%lX !!!", wParam, lParam);
TextOut(hDCMain, 25, 280, C, strlen(C));
}
break;
case WM_KEYDOWN:
sprintf(C, "WM_KEYDOWN !!!");
TextOut(hDCMain, 25, 40, C, strlen(C));
KeyDown(hWnd, Message, wParam);
break;
case WM_CHAR:
sprintf(C, "WM_CHAR !!!");
TextOut(hDCMain, 25, 50, C, strlen(C));
break;
case WM_LBUTTONDOWN:
break;
case WM_LBUTTONUP:
break;
case WM_RBUTTONDOWN:
break;
case WM_RBUTTONUP:
break;
case WM_MOUSEMOVE:
break;
case WM_VSCROLL:
sprintf(C, "WM_VSCROLL %X %X %lX !!!", Message, wParam, lParam);
TextOut(hDCMain, 25, 370, C, strlen(C));
Do_Dlg_VertScroll(hWnd, wParam, lParam, &y, 0, 50);
break;
case WM_HSCROLL:
sprintf(C, "WM_HSCROLL %X %X %lX !!!", Message, wParam, lParam);
TextOut(hDCMain, 25, 370, C, strlen(C));
Do_Dlg_HorzScroll(hWnd, wParam, lParam, &x, 0, 50);
break;
case WM_PAINT:
DoPaint(hWnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, Message, wParam, lParam);
}
return(0);
}
BOOL KeyDown(HWND hWnd, unsigned Message, WORD wParam)
{
WORD wRet;
UINT uRet;
DWORD dwRet;
char C[128];
char C2[64];
NoREF(hWnd);
NoREF(Message);
sprintf(C, "KeyDown %x !!!", wParam);
TextOut(hDCMain, 25, 100, C, strlen(C));
switch (wParam)
{
case VK_HOME: /* 'HOME' KEY */
break;
case VK_LEFT: /* 'LEFT' CURSOR KEY */
break;
case VK_RIGHT: /* 'RIGHT' CURSOR KEY */
break;
case VK_UP: /* 'UP' CURSOR KEY */
break;
case VK_DOWN: /* 'DOWN' CURSOR KEY */
break;
case VK_PRIOR: /* 'PGUP' CURSOR KEY */
break;
case VK_NEXT: /* 'PGDN' CURSOR KEY */
break;
case '1':
break;
case '2':
break;
case '3':
break;
case '4':
break;
case '5':
break;
case 'A':
break;
case 'B':
break;
case 'C':
break;
case 'D':
break;
case 'E':
break;
case 'F':
break;
case 'G':
break;
case 'H':
WinHelp(hWndMain, "toto.hlp", HELP_INDEX, 0L);
break;
case 'J':
WinExec("/D:/wine/widget.exe arg1 arg2 arg3 arg4 arg5 arg6", SW_NORMAL);
break;
case 'K':
break;
case 'Q':
hWndStat = CreateWindow("STATIC", "Static #1",
WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_SIMPLE,
230, 20, 80, 20, hWndMain, 1000, hInst, NULL);
break;
case 'W':
hWndChk = CreateWindow("BUTTON", "CheckBox #1",
WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | BS_CHECKBOX,
230, 90, 120, 20, hWndMain, 1002, hInst, NULL);
break;
case 'R':
hWndRadio = CreateWindow("BUTTON", "RadioBut #1",
WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | BS_RADIOBUTTON,
230, 120, 120, 20, hWndMain, 1003, hInst, NULL);
SendMessage(hWndRadio, BM_SETCHECK, 0, 0L);
break;
case 'T':
SendMessage(hWndLBox, LB_ADDSTRING, 0, (LPARAM)"ListBox Single item");
break;
case 'Y':
SendMessage(hWndLBox, LB_ADDSTRING, 0, (LPARAM)"ListBox item #2");
SendMessage(hWndLBox, LB_ADDSTRING, 0, (LPARAM)"ListBox item #3");
SendMessage(hWndLBox, LB_ADDSTRING, 0, (LPARAM)"ListBox item #4");
SendMessage(hWndLBox, LB_ADDSTRING, 0, (LPARAM)"ListBox item #5");
SendMessage(hWndLBox, LB_ADDSTRING, 0, (LPARAM)"ListBox item #6");
SendMessage(hWndLBox, LB_SETCURSEL, 3, 0L);
SendMessage(hWndLBox, LB_INSERTSTRING, 5, (LPARAM)"Item between 5 & 6");
wRet = SendMessage(hWndLBox, LB_FINDSTRING, -1, (LPARAM)"Item between 5 & 6");
sprintf(C, "LB_FINDSTRING returned #%u ", wRet);
TextOut(hDCMain, 25, 300, C, strlen(C));
wRet = SendMessage(hWndLBox, LB_GETCURSEL, 0, 0L);
sprintf(C, "LB_GETCURSEL returned #%u ", wRet);
TextOut(hDCMain, 25, 320, C, strlen(C));
break;
case 'U':
SendMessage(hWndLBox, LB_DELETESTRING, 3, 0L);
break;
case 'I':
SendMessage(hWndLBox, LB_RESETCONTENT, 0, 0L);
break;
case 'O':
C2[0] = '\0';
SendMessage(hWndLBox, LB_GETTEXT, 2, (DWORD)C2);
sprintf(C, "LB_GETTEXT returned '%s' ", C2);
TextOut(hDCMain, 25, 320, C, strlen(C));
break;
case 'P':
SendMessage(hWndLBox, LB_DIR, 0, (DWORD)"*.*");
break;
case 'Z':
ShowWindow(hWndScrol, SW_HIDE);
break;
case 'X':
ShowWindow(hWndScrol, SW_SHOW);
break;
case 'V':
hWndCBox = CreateWindow("COMBOBOX", "Combo #1",
WS_CHILD | WS_VISIBLE | WS_BORDER | CBS_DROPDOWNLIST,
230, 270, 150, 100, hWndMain, 1006, hInst, NULL);
SendMessage(hWndCBox, CB_ADDSTRING, 0, (LPARAM)"ComboBox item #1");
SendMessage(hWndCBox, CB_ADDSTRING, 0, (LPARAM)"ComboBox item #2");
break;
case 'N':
hWndCBox = CreateWindow("COMBOBOX", "Combo #2",
WS_CHILD | WS_VISIBLE | WS_BORDER | CBS_DROPDOWN,
30, 270, 150, 100, hWndMain, 1007, hInst, NULL);
SendMessage(hWndCBox, CB_ADDSTRING, 0, (LPARAM)"ComboBox item #1");
SendMessage(hWndCBox, CB_ADDSTRING, 0, (LPARAM)"ComboBox item #2");
break;
case VK_F10: /* 'F10' FUNCTION KEY */
break;
case VK_F11: /* 'F11' FUNCTION KEY */
break;
}
return(TRUE);
}
void DoPaint(HWND hWnd)
{
HDC hDC;
RECT rect;
PAINTSTRUCT ps;
char C[80];
GetClientRect(hWnd, &rect);
hDC = BeginPaint(hWnd, &ps);
FillRect(hDC, &rect, GetStockObject(GRAY_BRUSH));
InflateRect(&rect, -3, -3);
FrameRect(hDC, &rect, GetStockObject(BLACK_BRUSH));
InflateRect(&rect, -10, -10);
FillRect(hDC, &rect, GetStockObject(WHITE_BRUSH));
sprintf(C, "Wine Testing !!!");
TextOut(hDC, 25, 25, C, strlen(C));
ReleaseDC(hWnd,hDC);
EndPaint(hWnd,&ps);
}
/**********************************************************************/
void SetVertScroll(int hDlg, int hWndSCROLL, int VAL, int MIN, int MAX)
{
char C[12];
SetScrollRange(hWndSCROLL, SB_CTL, -MAX, -MIN, FALSE);
SetScrollPos(hWndSCROLL, SB_CTL, -VAL, TRUE);
itoa(VAL, C, 10);
//SetDlgItemText(hDlg, (IDDTXT1 + GetDlgCtrlID(hWndSCROLL) - IDDSCROLL1), C);
}
void SetHorzScroll(int hDlg, int hWndSCROLL, int VAL, int MIN, int MAX)
{
char C[12];
SetScrollRange(hWndSCROLL, SB_CTL, MAX, MIN, FALSE);
SetScrollPos(hWndSCROLL, SB_CTL, VAL, TRUE);
itoa(VAL, C, 10);
//SetDlgItemText(hDlg, (IDDTXT1 + GetDlgCtrlID(hWndSCROLL) - IDDSCROLL1), C);
}
void Do_Dlg_VertScroll(HWND hDlg, WORD wParam, DWORD lParam, int *V, int MIN, int MAX)
{
char C[12];
int VAL;
int VAL2;
int Step = 100;
if (MAX < 1000) Step = 10;
if (MAX < 100) Step = MAX / 10;
VAL = *(V);
VAL2 = VAL;
switch (wParam)
{
case SB_LINEUP:
VAL++;
break;
case SB_LINEDOWN:
VAL--;
break;
case SB_PAGEUP:
VAL += Step;
break;
case SB_PAGEDOWN:
VAL -= Step;
break;
case SB_THUMBTRACK:
case SB_THUMBPOSITION:
VAL = -(LOWORD(lParam));
break;
}
if (VAL > MAX) VAL = MAX;
if (VAL < MIN) VAL = MIN;
if (VAL != VAL2)
{
SetScrollPos(HIWORD(lParam), SB_CTL, -VAL, TRUE);
ltoa(VAL, C, 10);
// SetDlgItemText(hDlg, (IDDTXT1 + GetDlgCtrlID(HIWORD(lParam)) - IDDSCROLL1), C);
}
*(V) = VAL;
}
void Do_Dlg_HorzScroll(HWND hDlg, WORD wParam, DWORD lParam, int *V, int MIN, int MAX)
{
char C[12];
int VAL;
int VAL2;
int Step = 100;
if (MAX < 1000) Step = 10;
if (MAX < 100) Step = MAX / 10;
VAL = *(V);
VAL2 = VAL;
switch (wParam)
{
case SB_LINEUP:
VAL--;
break;
case SB_LINEDOWN:
VAL++;
break;
case SB_PAGEUP:
VAL -= Step;
break;
case SB_PAGEDOWN:
VAL += Step;
break;
case SB_THUMBTRACK:
case SB_THUMBPOSITION:
VAL = (LOWORD(lParam));
break;
}
if (VAL > MAX) VAL = MAX;
if (VAL < MIN) VAL = MIN;
if (VAL != VAL2)
{
SetScrollPos(HIWORD(lParam), SB_CTL, VAL, TRUE);
ltoa(VAL, C, 10);
// SetDlgItemText(hDlg, (IDDTXT1 + GetDlgCtrlID(HIWORD(lParam)) - IDDSCROLL1), C);
}
*(V) = VAL;
}
/**********************************************************************/


View File

@ -1,23 +0,0 @@
;**********************************************************************
;* Copyright (c) 1991 by TRG ELECTRONIK *
;**********************************************************************
NAME WineTest
DESCRIPTION 'Drink Inventry Controler'
STUB 'WINSTUB.EXE'
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE MULTIPLE
EXETYPE WINDOWS
SEGMENTS
DRINK_TEXT PRELOAD MOVEABLE DISCARDABLE
HEAPSIZE 20000
STACKSIZE 8192
EXPORTS WndProc @1
About_Proc @3


View File

@ -1,250 +0,0 @@
/**********************************************************************
* Copyright (c) 1991 by TRG ELECTRONIK *
**********************************************************************/
#define szAppName "widgetClass"
#define IDNULL -1
#define IDSCLOSE 20
#define IDSOKCLOSE 21
#define IDSSAVE 22
#define IDSOKSAVE 23
#define IDINFO 24
#define IDSAVE 25
#define IDDELETE 26
#define IDNEW 27
#define IDBUSER 30
#define IDBUSER1 31
#define IDBUSER2 32
#define IDBUSER3 33
#define IDBUSER4 34
#define IDBUSER5 35
#define IDBUSER6 36
#define IDBUSER7 37
#define IDBUSER8 38
#define IDBUSER9 39
#define IDDJOBNAME 50
#define IDDPRINTER 51
#define IDSETUP 60
#define IDI_MKSICON 99
/******************************************/
#define MID_NEW 100
#define MID_OPEN 101
#define MID_SAVE 102
#define MID_SAVEAS 103
#define MID_PRINT 104
#define MID_PRSETUP 105
#define MID_STATUS 106
#define MID_QUIT 107
#define MID_CUT 121
#define MID_COPY 122
#define MID_PASTE 123
#define MID_CLEAR 124
#define MID_COPYTO 125
#define MID_PASTEFROM 126
#define MID_NEWPROD 140
#define MID_NEWBEER 141
#define MID_USERCFG 142
#define MID_POREGIE 151
#define MID_POBIERE 152
#define MID_DAYSTOCK 153
#define MID_RESERVE 154
#define MID_COCKSALE 155
#define MID_DRYSALE 156
#define MID_COMPILE 157
#define MID_RECETTES 158
#define MID_HD 159
#define MID_TESTPRN 160
#define MID_INFODSK 161
#define MID_SHARP 162
#define MID_PASSWORD 163
/******************************************/
#define IDDTEXT 200
#define IDDTXT1 201
#define IDDTXT2 202
#define IDDTXT3 203
#define IDDTXT4 204
#define IDDTXT5 205
#define IDDTXT6 206
#define IDDTXT7 207
#define IDDTXT8 208
#define IDDTXT9 209
#define IDDTXT10 210
#define IDDTXT11 211
#define IDDTXT12 212
#define IDDTXT13 213
#define IDDTXT14 214
#define IDDTXT15 215
#define IDDTXT16 216
#define IDDTXT17 217
#define IDDTXT18 218
#define IDDTXT19 219
#define IDDBUTTON1 220
#define IDDBUTTON2 221
#define IDDBUTTON3 222
#define IDDBUTTON4 223
#define IDDBUTTON5 224
#define IDDBUTTON6 225
#define IDDBUTTON7 226
#define IDDBUTTON8 227
#define IDDBUTTON9 228
#define IDDBUTTON10 229
#define IDDCHKBOX1 240
#define IDDCHKBOX2 241
#define IDDCHKBOX3 242
#define IDDCHKBOX4 243
#define IDDCHKBOX5 244
#define IDDCHKBOX6 245
#define IDDCHKBOX7 246
#define IDDCHKBOX8 247
#define IDDCHKBOX9 248
#define IDDCHKBOX10 249
#define IDDSCROLL1 250
#define IDDSCROLL2 251
#define IDDSCROLL3 252
#define IDDSCROLL4 253
#define IDDSCROLL5 254
#define IDDSCROLL6 255
#define IDDSCROLL7 256
#define IDDSCROLL8 257
#define IDDSTR1 2000
#define IDDSTR2 2001
#define IDDSTR3 2002
#define IDDSTR4 2003
#define IDDSTR5 2004
#define IDDSTR6 2005
#define IDDSTR7 2006
#define IDDSTR8 2007
#define IDDSTR9 2008
#define IDDSTR10 2009
#define IDDSTR11 2010
#define IDDSTR12 2011
#define IDDSTR13 2012
#define IDDSTR14 2013
#define IDDSTR15 2014
#define IDDSTR16 2015
#define IDDSTR17 2016
#define IDDSTR18 2017
#define IDDSTR19 2018
#define IDDSTR20 2019
#define IDDSTR21 2020
#define IDDSTR22 2021
#define IDDSTR23 2022
#define IDDSTR24 2023
#define IDDSTR25 2024
#define IDDSTR26 2025
#define IDDSTR27 2026
#define IDDSTR28 2027
#define IDDSTR29 2028
#define IDDSTR30 2029
#define IDDSTR31 2030
#define IDDSTR32 2031
#define IDDSTR33 2032
#define IDDSTR34 2033
#define IDDSTR35 2034
#define IDDSTR36 2035
#define IDDSTR37 2036
#define IDDSTR38 2037
#define IDDSTR39 2038
#define IDDSTR40 2039
#define IDDSTR41 2040
#define IDDSTR42 2041
#define IDDSTR43 2042
#define IDDSTR44 2043
#define IDDSTR45 2044
#define IDDSTR46 2045
#define IDDSTR47 2046
#define IDDSTR48 2047
#define IDDSTR49 2048
#define IDDSTR50 2049
#define IDDSTR51 2050
#define IDDSTR52 2051
#define IDDSTR53 2052
#define IDDSTR54 2053
#define IDDSTR55 2054
#define IDDSTR56 2055
#define IDDSTR57 2056
#define IDDSTR58 2057
#define IDDSTR59 2058
#define IDDSTR60 2059
#define IDDSTR61 2060
#define IDDSTR62 2061
#define IDDSTR63 2062
#define IDDSTR64 2063
#define IDDSTR65 2064
#define IDDSTR66 2065
#define IDDSTR67 2066
#define IDDSTR68 2067
#define IDDSTR69 2068
#define IDDSTR70 2069
/******************************************/
#define IDDDEFAULTS 1001
#define IDDCHECKBOX 1002
#define IDDNULL 1003
#define IDDRBLEFT 1004
#define IDDRBRIGHT 1005
#define IDDRBCENTER 1006
#define IDDLISTBOX 1007
#define IDDSBH 1008
#define IDDSBV 1009
/******************************************/
#define ABOUT_Dlg 2001
#define NEW_Dlg 2002
#define OPEN_Dlg 2003
#define SAVE_Dlg 2004
#define SAVEAS_Dlg 2005
#define PRINT_Dlg 2006
#define ABORT_Dlg 2007
#define PRSETUP_Dlg 2008
#define QUIT_Dlg 2009
#define GETOBJ_Dlg 2020
#define NEWPROD_Dlg 2021
#define NEWBEER_Dlg 2022
#define USERCFG_Dlg 2023
#define POREGIE_Dlg 2024
#define POBIERE_Dlg 2025
#define PASSWORD_Dlg 2026
#define TVQ_Dlg 2027
#define LTEXTOK_Dlg 2070
/******************************************/
#define RED 0x000000FF
#define GREEN 0x0000FF00
#define BLUE 0x00FF0000
#define CYAN 0x00FFFF00
#define MAGENTA 0x00FF00FF
#define BLACK 0x00000000
#define WHITE 0x00FFFFFF
#define GRAY 0x00808080
#define LTGRAY 0x00C0C0C0
#define DKGRAY 0x00404040


Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 766 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 766 B

View File

@ -1,78 +0,0 @@
/**********************************************************************
* Copyright (c) 1991 by TRG ELECTRONIK *
* *
* widget.RC *
* widget RESSOURCES *
* *
**********************************************************************/
#include <\BC\INCLUDE\WINDOWS.H>
#include "widget.H"
#define TABGRP WS_TABSTOP | WS_GROUP
#define LBSTYLES WS_VSCROLL | WS_BORDER | WS_VISIBLE | LBS_SORT | TABGRP
#define HSCROLL WS_VISIBLE | SBS_HORZ | SBS_TOPALIGN | TABGRP
#define VSCROLL WS_VISIBLE | SBS_VERT | SBS_LEFTALIGN | TABGRP
#define BLACKRECT SS_BLACKRECT | WS_VISIBLE | WS_GROUP
#define WHITEFRAME SS_WHITEFRAME | WS_VISIBLE | WS_GROUP
ICON_1 ICON widget.ICO
ICON_2 ICON widget.IC2
ICON_3 ICON widget.IC3
MENU_1 MENU
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&New", MID_NEW
MENUITEM "&Open", MID_OPEN
MENUITEM "&Save", MID_SAVE
MENUITEM "Save &As", MID_SAVEAS
MENUITEM SEPARATOR
MENUITEM "&Quit!", MID_QUIT
END
END
ABOUT_Dlg DIALOG 100, 100, 154, 75
STYLE WS_POPUP | WS_DLGFRAME
BEGIN
ICON "widget" -1, 9, 23, 0, 0
ICON "DKICON2" -1, 30, 23, 0, 0
ICON "DKICON3" -1, 50, 23, 0, 0
CTEXT "About widget Inventory Controler" -1, 0, 14,154, 8
CTEXT "Version 0.50" -1, 30, 34, 94, 8
CTEXT "Copyright © 1991, TRG Electronik" -1, 0, 47,154, 9
DEFPUSHBUTTON "Ok" IDOK, 61, 59, 32, 14, WS_GROUP
END
LTEXTOK_Dlg DIALOG 100, 100, 300, 120
STYLE WS_POPUP | WS_DLGFRAME
BEGIN
LTEXT "", IDDTXT1, 20, 15,118, 12
LTEXT "", IDDTXT2, 20, 30,118, 25
LTEXT "", IDDTXT3, 20, 45,118, 35
LTEXT "", IDDTXT3, 20, 60,118, 35
DEFPUSHBUTTON "OK", IDOK, 150, 85, 40, 14, TABGRP
END
STRINGTABLE
BEGIN
IDDSTR1, "Wine Test Program"
IDDSTR2, ""
IDDSTR3, ""
IDDSTR4, ""
IDDSTR5, ""
IDDSTR6, ""
IDDSTR7, ""
IDDSTR8, ""
IDDSTR9, ""
IDDSTR10, ""
END


View File

@ -1,649 +0,0 @@
/**********************************************************************
* Copyright (c) 1991 by TRG ELECTRONIK *
* *
* widget.C *
* widget Inventory Controler PART # 1 *
* *
**********************************************************************/
#include <WINDOWS.H>
#include "STDIO.h"
#include "STDLIB.h"
#include "STDARG.h"
#include "STRING.H"
#include "widget.H"
#include "widget.VAR"
#include "widget.P"
#define NoREF(a) a=a
HWND hWndBut;
HWND hWndChk;
HWND hWndRadio;
HWND hWndLBox;
HWND hWndLBox2;
HWND hWndLBox3;
HWND hWndLBox4;
HWND hWndScrol;
HWND hWndScro2;
HWND hWndScro3;
HWND hWndStat;
HWND hWndEdit;
HWND hWndCBox;
int x, y;
HBRUSH hREDBrush;
HBRUSH hGREENBrush;
HBRUSH hBLUEBrush;
HBRUSH hGRAYBrush;
HBITMAP hBitMap;
HBITMAP hBitMap2;
HBITMAP hBitMap3;
BITMAP BitMap;
/**********************************************************************/
int PASCAL WinMain(HANDLE hInstance,HANDLE hPrevInstance,
LPSTR lpszCmdLine,int nCmdShow)
{
WNDCLASS wndClass;
MSG msg;
HWND hWnd;
HDC hDC;
char C[40];
int X;
NoREF(lpszCmdLine);
if ( !hPrevInstance )
{
wndClass.style = CS_HREDRAW | CS_VREDRAW ;
wndClass.lpfnWndProc = (WNDPROC)WndProc;
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 0;
wndClass.hInstance = hInstance;
wndClass.hIcon = LoadIcon(hInstance,(LPSTR)"ICON_1");
wndClass.hCursor = LoadCursor(NULL, IDC_ARROW );
wndClass.hbrBackground = GetStockObject(WHITE_BRUSH );
wndClass.lpszMenuName = szAppName;
wndClass.lpszClassName = szAppName;
if (!RegisterClass(&wndClass))
return FALSE;
}
hWnd = CreateWindow(szAppName, "widget test program",
WS_POPUP | WS_CAPTION | WS_BORDER | WS_VISIBLE, 50, 50,
400, 500, NULL, NULL, hInstance, NULL);
hWndMain = hWnd;
hInst = hInstance;
hDCMain = GetDC(hWndMain);
hREDBrush = CreateSOLIDBrush(0x000000FF);
hGREENBrush = CreateSOLIDBrush(0x00007F00);
hBLUEBrush = CreateSOLIDBrush(0x00FF0000);
hGRAYBrush = CreateSOLIDBrush(0x00C0C0C0);
InitWidgets();
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg );
DispatchMessage(&msg );
}
DeleteObject(hREDBrush);
DeleteObject(hGREENBrush);
DeleteObject(hBLUEBrush);
DeleteObject(hGRAYBrush);
if (hBitMap != NULL) DeleteObject(hBitMap);
if (hBitMap2 != NULL) DeleteObject(hBitMap2);
if (hBitMap3 != NULL) DeleteObject(hBitMap3);
ReleaseDC(hWndMain, hDC);
return(0);
}
void InitWidgets()
{
hWndBut = CreateWindow("BUTTON", "Button #1",
WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | BS_PUSHBUTTON,
230, 40, 80, 30, hWndMain, 1001, hInst, NULL);
hWndScrol = CreateWindow("SCROLLBAR", "Scroll #1",
WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SBS_VERT,
200, 150, 15, 100, hWndMain, 1004, hInst, NULL);
hWndScro2 = CreateWindow("SCROLLBAR", "Scroll #2",
WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SBS_HORZ,
50, 150, 100, 15, hWndMain, 1005, hInst, NULL);
hWndScro3 = CreateWindow("SCROLLBAR", "Scroll #3",
WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SBS_SIZEBOX,
50, 180, 25, 25, hWndMain, 1006, hInst, NULL);
x = y = 25;
SetVertScroll(NULL, hWndScrol, 25, 0, 50);
SetScrollRange(hWndScro2, SB_CTL, 0, 50, TRUE);
SetScrollPos(hWndScro2, SB_CTL, 25, TRUE);
hWndLBox = CreateWindow("LISTBOX", "",
WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | LBS_NOTIFY,
230, 160, 150, 100, hWndMain, 1004, hInst, NULL);
SendMessage(hWndLBox, LB_ADDSTRING, 0, (LPARAM)"ListBox item #1");
hWndStat = CreateWindow("STATIC", "Static #1",
WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_LEFT,
30, 120, 150, 20, hWndMain, 1011, hInst, NULL);
SendMessage(hWndStat, WM_SETTEXT, 0, (LPARAM)"Static Left Text");
hWndCBox = CreateWindow("COMBOBOX", "Combo #1",
WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_BORDER | CBS_DROPDOWNLIST,
230, 270, 150, 100, hWndMain, 1060, hInst, NULL);
SendMessage(hWndCBox, CB_ADDSTRING, 0, (LPARAM)"ComboBox item #1");
SendMessage(hWndCBox, CB_ADDSTRING, 0, (LPARAM)"ComboBox item #2");
SendMessage(hWndCBox, CB_ADDSTRING, 0, (LPARAM)"ComboBox item #3");
SendMessage(hWndCBox, CB_ADDSTRING, 0, (LPARAM)"ComboBox item #4");
SendMessage(hWndCBox, CB_ADDSTRING, 0, (LPARAM)"ComboBox item #5");
SendMessage(hWndCBox, CB_ADDSTRING, 0, (LPARAM)"ComboBox item #6");
}
long FAR PASCAL WndProc(HWND hWnd, unsigned Message, WORD wParam, LONG lParam)
{
int ShiftState;
LPDRAWITEMSTRUCT dis;
HDC hMemDC;
HBRUSH hBrush;
char C[128];
ShiftState = GetKeyState(VK_SHIFT);
switch(Message)
{
case WM_COMMAND:
if (LOWORD(lParam) != 0)
{
sprintf(C, "MAIN WM_COMMAND wParam=%X lParam=%lX !!!", wParam, lParam);
TextOut(hDCMain, 25, 280, C, strlen(C));
}
break;
case WM_KEYDOWN:
sprintf(C, "WM_KEYDOWN !!!");
TextOut(hDCMain, 25, 40, C, strlen(C));
KeyDown(hWnd, Message, wParam);
break;
case WM_CHAR:
sprintf(C, "WM_CHAR !!!");
TextOut(hDCMain, 25, 50, C, strlen(C));
break;
case WM_CTLCOLOR:
switch(HIWORD(lParam))
{
case CTLCOLOR_SCROLLBAR:
return(hBLUEBrush);
case CTLCOLOR_LISTBOX:
SetBkColor((HDC)wParam, 0x00C0C000);
SetTextColor((HDC)wParam, 0x00FF0000);
return(hGREENBrush);
case CTLCOLOR_STATIC:
SetBkColor((HDC)wParam, 0x00C0C0C0);
SetTextColor((HDC)wParam, 0x0000FFFF);
return(hREDBrush);
}
return((HBRUSH)NULL);
case WM_LBUTTONDOWN:
break;
case WM_LBUTTONUP:
break;
case WM_RBUTTONDOWN:
break;
case WM_RBUTTONUP:
break;
case WM_MOUSEMOVE:
break;
case WM_VSCROLL:
sprintf(C, "WM_VSCROLL %X %lX !!!", wParam, lParam);
TextOut(hDCMain, 25, 380, C, strlen(C));
Do_Dlg_VertScroll(hWnd, wParam, lParam, &y, 0, 50);
break;
case WM_HSCROLL:
sprintf(C, "WM_HSCROLL %X %lX !!!", wParam, lParam);
TextOut(hDCMain, 25, 380, C, strlen(C));
Do_Dlg_HorzScroll(hWnd, wParam, lParam, &x, 0, 50);
break;
case WM_DRAWITEM:
sprintf(C, "WM_DRAWITEM %X %lX !!!", wParam, lParam);
TextOut(hDCMain, 25, 380, C, strlen(C));
if (lParam == 0L) break;
if (wParam == 0) break;
dis = (LPDRAWITEMSTRUCT)lParam;
if ((dis->CtlType == ODT_LISTBOX) && (dis->CtlID == 1062)) {
hBrush = SelectObject(dis->hDC, GetStockObject(LTGRAY_BRUSH));
SelectObject(dis->hDC, hBrush);
FillRect(dis->hDC, &dis->rcItem, hBrush);
sprintf(C, "Item #%X", dis->itemID);
if (dis->itemData == NULL) break;
TextOut(dis->hDC, dis->rcItem.left,
dis->rcItem.top, C, strlen(C));
}
if ((dis->CtlType == ODT_LISTBOX) && (dis->CtlID == 1063)) {
hBrush = SelectObject(dis->hDC, GetStockObject(LTGRAY_BRUSH));
SelectObject(dis->hDC, hBrush);
FillRect(dis->hDC, &dis->rcItem, hBrush);
if (dis->itemData == NULL) break;
TextOut(dis->hDC, dis->rcItem.left, dis->rcItem.top,
(LPSTR)dis->itemData, lstrlen((LPSTR)dis->itemData));
}
if ((dis->CtlType == ODT_LISTBOX) && (dis->CtlID == 1064)) {
hBrush = SelectObject(dis->hDC, GetStockObject(LTGRAY_BRUSH));
SelectObject(dis->hDC, hBrush);
FillRect(dis->hDC, &dis->rcItem, hBrush);
hMemDC = CreateCompatibleDC(dis->hDC);
SelectObject(hMemDC,hBitMap);
BitBlt(dis->hDC, dis->rcItem.left, dis->rcItem.top,
BitMap.bmWidth, BitMap.bmHeight, hMemDC, 0, 0, SRCCOPY);
DeleteDC(hMemDC);
sprintf(C, "Item #%X", dis->itemID);
TextOut(dis->hDC, dis->rcItem.left + BitMap.bmWidth,
dis->rcItem.top, C, strlen(C));
// if (dis->itemData == NULL) break;
// TextOut(dis->hDC, dis->rcItem.left + BitMap.bmWidth,
// dis->rcItem.top, (LPSTR)dis->itemData,
// lstrlen((LPSTR)dis->itemData));
}
break;
case WM_PAINT:
DoPaint(hWnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, Message, wParam, lParam);
}
return(0);
}
BOOL KeyDown(HWND hWnd, unsigned Message, WORD wParam)
{
WORD wRet;
UINT uRet;
DWORD dwRet;
HDC hMemDC;
char C[128];
char C2[64];
NoREF(hWnd);
NoREF(Message);
sprintf(C, "KeyDown %x !!!", wParam);
TextOut(hDCMain, 25, 100, C, strlen(C));
switch (wParam)
{
case VK_HOME: /* 'HOME' KEY */
break;
case VK_LEFT: /* 'LEFT' CURSOR KEY */
break;
case VK_RIGHT: /* 'RIGHT' CURSOR KEY */
break;
case VK_UP: /* 'UP' CURSOR KEY */
break;
case VK_DOWN: /* 'DOWN' CURSOR KEY */
break;
case VK_PRIOR: /* 'PGUP' CURSOR KEY */
break;
case VK_NEXT: /* 'PGDN' CURSOR KEY */
break;
case '1':
break;
case '2':
hWndStat = CreateWindow("STATIC", "Static #2",
WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_CENTER,
30, 150, 150, 20, hWndMain, 1012, hInst, NULL);
SendMessage(hWndStat, WM_SETTEXT, 0, (LPARAM)"Static Center Text");
break;
case '3':
hWndStat = CreateWindow("STATIC", "Static #3",
WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT,
30, 180, 150, 20, hWndMain, 1013, hInst, NULL);
SendMessage(hWndStat, WM_SETTEXT, 0, (LPARAM)"Static Right Text");
break;
case '4':
hWndStat = CreateWindow("STATIC", "Static #4",
WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_SIMPLE,
30, 210, 150, 20, hWndMain, 1014, hInst, NULL);
SendMessage(hWndStat, WM_SETTEXT, 0, (LPARAM)"SS_SIMPLE");
break;
case '5':
hWndStat = CreateWindow("STATIC", "Static #5",
WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_GRAYRECT,
30, 240, 150, 20, hWndMain, 1015, hInst, NULL);
SendMessage(hWndStat, WM_SETTEXT, 0, (LPARAM)"SS_GRAYRECT");
break;
case 'A':
hWndStat = CreateWindow("STATIC", "Static #6",
WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_BLACKRECT,
30, 240, 150, 20, hWndMain, 1016, hInst, NULL);
SendMessage(hWndStat, WM_SETTEXT, 0, (LPARAM)"SS_BLACKRECT");
break;
case 'C':
if (hBitMap2 == NULL) {
hBitMap2 = LoadBitmap(hInst, "LBICON");
GetObject(hBitMap2, sizeof(BITMAP), (LPSTR)&BitMap);
}
hMemDC = CreateCompatibleDC(hDCMain);
SelectObject(hMemDC, hBitMap2);
BitBlt(hDCMain, 10, 10, BitMap.bmWidth,
BitMap.bmHeight, hMemDC, 0, 0, SRCCOPY);
DeleteDC(hMemDC);
sprintf(C, "DrawBitmap");
TextOut(hDCMain, 25, 320, C, strlen(C));
break;
case 'D':
if (hBitMap3 == NULL) {
hBitMap3 = LoadBitmap(hInst, MAKEINTRESOURCE(3333));
GetObject(hBitMap3, sizeof(BITMAP), (LPSTR)&BitMap);
}
hMemDC = CreateCompatibleDC(hDCMain);
SelectObject(hMemDC, hBitMap3);
BitBlt(hDCMain, 80, 10, BitMap.bmWidth,
BitMap.bmHeight, hMemDC, 0, 0, SRCCOPY);
DeleteDC(hMemDC);
sprintf(C, "DrawBitmap");
TextOut(hDCMain, 25, 320, C, strlen(C));
break;
case 'F':
MoveWindow(hWnd, 10, 10, 500, 600, TRUE);
break;
case 'G':
MoveWindow(hWndBut, 20, 20, 100, 20, TRUE);
break;
case 'H':
WinHelp(hWndMain, "toto.hlp", HELP_INDEX, 0L);
break;
case 'J':
WinExec("/D:/wine/widget.exe arg1 arg2 arg3 arg4 arg5 arg6", SW_NORMAL);
break;
case 'K':
break;
case 'Q':
hWndChk = CreateWindow("BUTTON", "CheckBox #1",
WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | BS_CHECKBOX,
30, 300, 120, 20, hWndMain, 1020, hInst, NULL);
break;
case 'W':
wRet = SendMessage(hWndChk , BM_GETCHECK, 0, 0L);
SendMessage(hWndChk , BM_SETCHECK, wRet, 0L);
break;
case 'E':
break;
case 'R':
hWndRadio = CreateWindow("BUTTON", "RadioBut #1",
WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | BS_RADIOBUTTON,
230, 120, 120, 20, hWndMain, 1003, hInst, NULL);
SendMessage(hWndRadio, BM_SETCHECK, TRUE, 0L);
break;
case 'T':
SendMessage(hWndLBox, LB_ADDSTRING, 0, (LPARAM)"ListBox Single item");
break;
case 'Y':
SendMessage(hWndLBox, LB_ADDSTRING, 0, (LPARAM)"ListBox item #2");
SendMessage(hWndLBox, LB_ADDSTRING, 0, (LPARAM)"ListBox item #3");
SendMessage(hWndLBox, LB_ADDSTRING, 0, (LPARAM)"ListBox item #4");
SendMessage(hWndLBox, LB_ADDSTRING, 0, (LPARAM)"ListBox item #5");
SendMessage(hWndLBox, LB_ADDSTRING, 0, (LPARAM)"ListBox item #6");
SendMessage(hWndLBox, LB_SETCURSEL, 3, 0L);
SendMessage(hWndLBox, LB_INSERTSTRING, 5, (LPARAM)"Item between 5 & 6");
wRet = SendMessage(hWndLBox, LB_FINDSTRING, -1, (LPARAM)"Item between 5 & 6");
sprintf(C, "LB_FINDSTRING returned #%u ", wRet);
TextOut(hDCMain, 25, 300, C, strlen(C));
wRet = SendMessage(hWndLBox, LB_GETCURSEL, 0, 0L);
sprintf(C, "LB_GETCURSEL returned #%u ", wRet);
TextOut(hDCMain, 25, 320, C, strlen(C));
break;
case 'U':
wRet = SendMessage(hWndLBox, LB_GETCURSEL, 0, 0L);
SendMessage(hWndLBox, LB_DELETESTRING, wRet, 0L);
SendMessage(hWndLBox, LB_SETCURSEL, wRet, 0L);
break;
case 'I':
SendMessage(hWndLBox, LB_RESETCONTENT, 0, 0L);
break;
case 'O':
C2[0] = '\0';
wRet = SendMessage(hWndLBox, LB_GETCURSEL, 0, 0L);
SendMessage(hWndLBox, LB_GETTEXT, wRet, (DWORD)C2);
sprintf(C, "LB_GETTEXT #%d returned '%s' ", wRet, C2);
TextOut(hDCMain, 25, 320, C, strlen(C));
break;
case 'P':
SendMessage(hWndLBox, LB_DIR, 0, (DWORD)"*.*");
break;
case 'Z':
ShowWindow(hWndScrol, SW_HIDE);
break;
case 'X':
ShowWindow(hWndScrol, SW_SHOW);
break;
case 'V':
MoveWindow(hWndScrol, 120, 150, 15, 60, TRUE);
break;
case 'B':
hWndCBox = CreateWindow("COMBOBOX", "Combo #2",
WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_BORDER | CBS_DROPDOWN,
30, 270, 150, 100, hWndMain, 1061, hInst, NULL);
SendMessage(hWndCBox, CB_ADDSTRING, 0, (LPARAM)"ComboBox item #1");
SendMessage(hWndCBox, CB_ADDSTRING, 0, (LPARAM)"ComboBox item #2");
SendMessage(hWndCBox, CB_DIR, 0, (DWORD)"*.*");
break;
case 'N':
hWndLBox2 = CreateWindow("LISTBOX", "", WS_CHILD | WS_VISIBLE |
WS_BORDER | WS_VSCROLL | LBS_OWNERDRAWVARIABLE | LBS_NOTIFY,
// WS_BORDER | WS_VSCROLL | LBS_OWNERDRAWVARIABLE | LBS_HASSTRINGS | LBS_NOTIFY,
30, 300, 150, 60, hWndMain, 1062, hInst, NULL);
SendMessage(hWndLBox2, LB_ADDSTRING, 0, (LPARAM)"DRAWFIXED #1");
SendMessage(hWndLBox2, LB_ADDSTRING, 0, (LPARAM)"DRAWFIXED #2");
SendMessage(hWndLBox2, LB_ADDSTRING, 0, (LPARAM)"DRAWFIXED #3");
SendMessage(hWndLBox2, LB_ADDSTRING, 0, (LPARAM)"DRAWFIXED #4");
SendMessage(hWndLBox2, LB_ADDSTRING, 0, (LPARAM)"DRAWFIXED #5");
SendMessage(hWndLBox2, LB_ADDSTRING, 0, (LPARAM)"DRAWFIXED #6");
break;
case 'M':
hWndLBox3 = CreateWindow("LISTBOX", "", WS_CHILD | WS_VISIBLE |
WS_BORDER | WS_VSCROLL | LBS_OWNERDRAWVARIABLE | LBS_NOTIFY,
// WS_BORDER | WS_VSCROLL | LBS_OWNERDRAWVARIABLE | LBS_HASSTRINGS | LBS_NOTIFY,
230, 300, 150, 60, hWndMain, 1063, hInst, NULL);
SendMessage(hWndLBox3, LB_ADDSTRING, 0, (LPARAM)"DRAWVARIABLE #1");
SendMessage(hWndLBox3, LB_ADDSTRING, 0, (LPARAM)"DRAWVARIABLE #2");
SendMessage(hWndLBox3, LB_ADDSTRING, 0, (LPARAM)"DRAWVARIABLE #3");
SendMessage(hWndLBox3, LB_ADDSTRING, 0, (LPARAM)"DRAWVARIABLE #4");
SendMessage(hWndLBox3, LB_ADDSTRING, 0, (LPARAM)"DRAWVARIABLE #5");
SendMessage(hWndLBox3, LB_ADDSTRING, 0, (LPARAM)"DRAWVARIABLE #6");
SendMessage(hWndLBox3, LB_ADDSTRING, 0, (LPARAM)"DRAWVARIABLE #7");
SendMessage(hWndLBox3, LB_SETITEMHEIGHT, 1, 10L);
SendMessage(hWndLBox3, LB_SETITEMHEIGHT, 2, 20L);
SendMessage(hWndLBox3, LB_SETITEMHEIGHT, 3, 30L);
SendMessage(hWndLBox3, LB_SETITEMHEIGHT, 4, 40L);
SendMessage(hWndLBox3, LB_SETITEMHEIGHT, 5, 50L);
break;
case 'L':
hBitMap = LoadBitmap(hInst, MAKEINTRESOURCE(3333));
GetObject(hBitMap, sizeof(BITMAP), (LPSTR)&BitMap);
hWndLBox4 = CreateWindow("LISTBOX", "", WS_CHILD | WS_VISIBLE |
WS_BORDER | WS_VSCROLL | LBS_OWNERDRAWVARIABLE | LBS_HASSTRINGS | LBS_NOTIFY,
230, 380, 150, 60, hWndMain, 1064, hInst, NULL);
SendMessage(hWndLBox4, LB_ADDSTRING, 0, (LPARAM)"DRAWVARIABLE #1");
SendMessage(hWndLBox4, LB_ADDSTRING, 0, (LPARAM)"DRAWVARIABLE #2");
SendMessage(hWndLBox4, LB_ADDSTRING, 0, (LPARAM)"DRAWVARIABLE #3");
SendMessage(hWndLBox4, LB_ADDSTRING, 0, (LPARAM)"DRAWVARIABLE #4");
SendMessage(hWndLBox4, LB_ADDSTRING, 0, (LPARAM)"DRAWVARIABLE #5");
SendMessage(hWndLBox4, LB_ADDSTRING, 0, (LPARAM)"DRAWVARIABLE #6");
SendMessage(hWndLBox4, LB_SETITEMHEIGHT, 1, 10L);
SendMessage(hWndLBox4, LB_SETITEMHEIGHT, 2, 20L);
SendMessage(hWndLBox4, LB_SETITEMHEIGHT, 3, 30L);
SendMessage(hWndLBox4, LB_SETITEMHEIGHT, 4, 40L);
SendMessage(hWndLBox4, LB_SETITEMHEIGHT, 5, 50L);
break;
case VK_F10: /* 'F10' FUNCTION KEY */
break;
case VK_F11: /* 'F11' FUNCTION KEY */
break;
}
return(TRUE);
}
void DoPaint(HWND hWnd)
{
HDC hDC;
RECT rect;
PAINTSTRUCT ps;
char C[80];
GetClientRect(hWnd, &rect);
hDC = BeginPaint(hWnd, &ps);
FillRect(hDC, &rect, GetStockObject(GRAY_BRUSH));
InflateRect(&rect, -3, -3);
FrameRect(hDC, &rect, GetStockObject(BLACK_BRUSH));
InflateRect(&rect, -10, -10);
FillRect(hDC, &rect, GetStockObject(WHITE_BRUSH));
sprintf(C, "Wine Testing !!!");
TextOut(hDC, 25, 25, C, strlen(C));
ReleaseDC(hWnd,hDC);
EndPaint(hWnd,&ps);
}
HBRUSH CreateLTGRAYBrush()
{
return(CreateSOLIDBrush(0x00C0C0C0));
}
HBRUSH CreateSOLIDBrush(COLORREF Color)
{
LOGBRUSH logGRAYBrush;
logGRAYBrush.lbStyle = BS_SOLID;
logGRAYBrush.lbColor = Color;
logGRAYBrush.lbHatch = NULL;
return(CreateBrushIndirect(&logGRAYBrush));
}
/**********************************************************************/
void SetVertScroll(int hDlg, int hWndSCROLL, int VAL, int MIN, int MAX)
{
char C[12];
SetScrollRange(hWndSCROLL, SB_CTL, -MAX, -MIN, FALSE);
SetScrollPos(hWndSCROLL, SB_CTL, -VAL, TRUE);
itoa(VAL, C, 10);
//SetDlgItemText(hDlg, (IDDTXT1 + GetDlgCtrlID(hWndSCROLL) - IDDSCROLL1), C);
}
void SetHorzScroll(int hDlg, int hWndSCROLL, int VAL, int MIN, int MAX)
{
char C[12];
SetScrollRange(hWndSCROLL, SB_CTL, MAX, MIN, FALSE);
SetScrollPos(hWndSCROLL, SB_CTL, VAL, TRUE);
itoa(VAL, C, 10);
//SetDlgItemText(hDlg, (IDDTXT1 + GetDlgCtrlID(hWndSCROLL) - IDDSCROLL1), C);
}
void Do_Dlg_VertScroll(HWND hDlg, WORD wParam, DWORD lParam, int *V, int MIN, int MAX)
{
char C[12];
int VAL;
int VAL2;
int Step = 100;
if (MAX < 1000) Step = 10;
if (MAX < 100) Step = MAX / 10;
VAL = *(V);
VAL2 = VAL;
switch (wParam)
{
case SB_LINEUP:
VAL++;
break;
case SB_LINEDOWN:
VAL--;
break;
case SB_PAGEUP:
VAL += Step;
break;
case SB_PAGEDOWN:
VAL -= Step;
break;
case SB_THUMBTRACK:
case SB_THUMBPOSITION:
VAL = -(LOWORD(lParam));
break;
}
if (VAL > MAX) VAL = MAX;
if (VAL < MIN) VAL = MIN;
if (VAL != VAL2)
{
SetScrollPos(HIWORD(lParam), SB_CTL, -VAL, TRUE);
ltoa(VAL, C, 10);
// SetDlgItemText(hDlg, (IDDTXT1 + GetDlgCtrlID(HIWORD(lParam)) - IDDSCROLL1), C);
}
*(V) = VAL;
}
void Do_Dlg_HorzScroll(HWND hDlg, WORD wParam, DWORD lParam, int *V, int MIN, int MAX)
{
char C[12];
int VAL;
int VAL2;
int Step = 100;
if (MAX < 1000) Step = 10;
if (MAX < 100) Step = MAX / 10;
VAL = *(V);
VAL2 = VAL;
switch (wParam)
{
case SB_LINEUP:
VAL--;
break;
case SB_LINEDOWN:
VAL++;
break;
case SB_PAGEUP:
VAL -= Step;
break;
case SB_PAGEDOWN:
VAL += Step;
break;
case SB_THUMBTRACK:
case SB_THUMBPOSITION:
VAL = (LOWORD(lParam));
break;
}
if (VAL > MAX) VAL = MAX;
if (VAL < MIN) VAL = MIN;
if (VAL != VAL2)
{
SetScrollPos(HIWORD(lParam), SB_CTL, VAL, TRUE);
ltoa(VAL, C, 10);
// SetDlgItemText(hDlg, (IDDTXT1 + GetDlgCtrlID(HIWORD(lParam)) - IDDSCROLL1), C);
}
*(V) = VAL;
}
/**********************************************************************/


Binary file not shown.

Binary file not shown.

View File

@ -2,7 +2,7 @@ CFLAGS=$(COPTS) $(DEBUGOPTS) -I$(INCLUDE_DIR)
OBJS=class.o dc.o dce.o event.o message.o win.o timer.o graphics.o \
clipping.o mapping.o painting.o keyboard.o utility.o syscolor.o \
defwnd.o defdlg.o dialog.o focus.o
defwnd.o defdlg.o dialog.o focus.o scroll.o
default: windows.o

View File

@ -6,10 +6,9 @@
static char Copyright[] = "Copyright Alexandre Julliard, 1993";
#include <stdlib.h>
#include "windows.h"
#include "dialog.h"
#include "prototypes.h"
#include "win.h"
@ -29,7 +28,7 @@ BOOL DIALOG_Init()
/* Calculate the dialog base units */
if (!(hdc = GetDC( 0 ))) return FALSE;
if (!(hdc = GetDC(GetDesktopWindow()))) return FALSE;
GetTextMetrics( hdc, &tm );
ReleaseDC( 0, hdc );
xBaseUnit = tm.tmAveCharWidth;
@ -79,15 +78,17 @@ static DLGCONTROLHEADER * DIALOG_GetControl( DLGCONTROLHEADER * ptr,
/***********************************************************************
* DIALOG_ParseTemplate
*
* Fill a DLGTEMPLATE structure from the dialog template.
* Fill a DLGTEMPLATE structure from the dialog template, and return
* a pointer to the first control.
*/
static void DIALOG_ParseTemplate( LPCSTR template, DLGTEMPLATE * result )
static DLGCONTROLHEADER * DIALOG_ParseTemplate( LPCSTR template,
DLGTEMPLATE * result )
{
int i;
unsigned char * p = (unsigned char *)template;
result->header = (DLGTEMPLATEHEADER *)p;
p += 13;
result->menuName = p;
if (*p == 0xff) p += 3;
else p += strlen(p) + 1;
@ -104,18 +105,8 @@ static void DIALOG_ParseTemplate( LPCSTR template, DLGTEMPLATE * result )
result->pointSize = *(WORD *)p; p += sizeof(WORD);
result->faceName = p; p += strlen(p) + 1;
}
result->controls = NULL;
if (!result->header->nbItems) return;
result->controls = (DLGCONTROL *) malloc( result->header->nbItems * sizeof(DLGCONTROL) );
if (!result->controls) return;
for (i = 0; i < result->header->nbItems; i++)
{
result->controls[i].header = (DLGCONTROLHEADER *)p;
p = (char *)DIALOG_GetControl( result->controls[i].header,
&result->controls[i].class,
&result->controls[i].text );
}
return (DLGCONTROLHEADER *)p;
}
@ -125,9 +116,6 @@ static void DIALOG_ParseTemplate( LPCSTR template, DLGTEMPLATE * result )
#ifdef DEBUG_DIALOG
static void DIALOG_DisplayTemplate( DLGTEMPLATE * result )
{
int i;
DLGCONTROL * ctrl = result->controls;
printf( "DIALOG %d, %d, %d, %d\n", result->header->x, result->header->y,
result->header->cx, result->header->cy );
printf( " STYLE %08x\n", result->header->style );
@ -138,18 +126,6 @@ static void DIALOG_DisplayTemplate( DLGTEMPLATE * result )
else printf( " MENU '%s'\n", result->menuName );
if (result->header->style & DS_SETFONT)
printf( " FONT %d,'%s'\n", result->pointSize, result->faceName );
printf( " BEGIN\n" );
for (i = 0; i < result->header->nbItems; i++, ctrl++)
{
printf( " %s '%s' %d, %d, %d, %d, %d, %08x\n",
ctrl->class, ctrl->text, ctrl->header->id,
ctrl->header->x, ctrl->header->y, ctrl->header->cx,
ctrl->header->cy, ctrl->header->style );
}
printf( " END\n" );
}
#endif /* DEBUG_DIALOG */
@ -187,7 +163,7 @@ HWND CreateDialogParam( HINSTANCE hInst, LPCSTR dlgTemplate,
else hwnd = CreateDialogIndirectParam(hInst, data, owner, dlgProc, param);
FreeResource( hmem );
#else
hmem = RSC_LoadResource( hInst, dlgTemplate, 0x8005, &size );
hmem = RSC_LoadResource( hInst, dlgTemplate, NE_RSCTYPE_DIALOG, &size );
data = (LPCSTR) GlobalLock( hmem );
hwnd = CreateDialogIndirectParam( hInst, data, owner, dlgProc, param );
GlobalFree( hmem );
@ -212,31 +188,39 @@ HWND CreateDialogIndirect( HINSTANCE hInst, LPCSTR dlgTemplate,
HWND CreateDialogIndirectParam( HINSTANCE hInst, LPCSTR dlgTemplate,
HWND owner, FARPROC dlgProc, LPARAM param )
{
HMENU hMenu = 0;
HMENU hMenu;
HFONT hFont = 0;
HWND hwnd;
WND * wndPtr;
int i;
DLGTEMPLATE template;
DLGCONTROLHEADER * header;
DIALOGINFO * dlgInfo;
WORD xUnit = xBaseUnit;
WORD yUnit = yBaseUnit;
if (!dlgTemplate) return 0;
DIALOG_ParseTemplate( dlgTemplate, &template );
/* Parse dialog template */
if (!dlgTemplate) return 0;
header = DIALOG_ParseTemplate( dlgTemplate, &template );
#ifdef DEBUG_DIALOG
DIALOG_DisplayTemplate( &template );
#endif
/* Load menu */
if (template.menuName[0])
switch (template.menuName[0])
{
if (template.menuName[0] != 0xff)
hMenu = LoadMenu( hInst, template.menuName );
else
case 0x00:
hMenu = 0;
break;
case 0xff:
hMenu = LoadMenu( hInst, MAKEINTRESOURCE( template.menuName[1] +
256*template.menuName[2] ));
break;
default:
hMenu = LoadMenu( hInst, template.menuName );
break;
}
/* Create custom font if needed */
@ -252,7 +236,7 @@ HWND CreateDialogIndirectParam( HINSTANCE hInst, LPCSTR dlgTemplate,
HFONT oldFont;
HDC hdc;
hdc = GetDC( 0 );
hdc = GetDC(GetDesktopWindow());
oldFont = SelectObject( hdc, hFont );
GetTextMetrics( hdc, &tm );
SelectObject( hdc, oldFont );
@ -265,7 +249,7 @@ HWND CreateDialogIndirectParam( HINSTANCE hInst, LPCSTR dlgTemplate,
/* Create dialog main window */
hwnd = CreateWindow( template.className, template.caption,
template.header->style & ~WS_VISIBLE,
template.header->style,
template.header->x * xUnit / 4,
template.header->y * yUnit / 8,
template.header->cx * xUnit / 4,
@ -276,28 +260,43 @@ HWND CreateDialogIndirectParam( HINSTANCE hInst, LPCSTR dlgTemplate,
{
if (hFont) DeleteObject( hFont );
if (hMenu) DestroyMenu( hMenu );
if (template.controls) free( template.controls );
return 0;
}
/* Create control windows */
if (hwnd && template.header->nbItems)
{
int i;
DLGCONTROL * ctrl = template.controls;
for (i = 0; i < template.header->nbItems; i++, ctrl++)
#ifdef DEBUG_DIALOG
printf( " BEGIN\n" );
#endif
for (i = 0; i < template.header->nbItems; i++)
{
DLGCONTROLHEADER * next_header;
LPSTR class, text;
next_header = DIALOG_GetControl( header, &class, &text );
#ifdef DEBUG_DIALOG
printf( " %s '%s' %d, %d, %d, %d, %d, %08x\n",
class, text, header->id, header->x, header->y, header->cx,
header->cy, header->style );
#endif
if ((strcmp(class, "STATIC") == 0) & ((header->style & SS_ICON) == SS_ICON)) {
header->cx = 32;
header->cy = 32;
}
header->style |= WS_CHILD;
CreateWindowEx( WS_EX_NOPARENTNOTIFY,
ctrl->class, ctrl->text, ctrl->header->style,
ctrl->header->x * xUnit / 4,
ctrl->header->y * yUnit / 8,
ctrl->header->cx * xUnit / 4,
ctrl->header->cy * yUnit / 8,
hwnd, ctrl->header->id, hInst, NULL );
}
class, text, header->style,
header->x * xUnit / 4, header->y * yUnit / 8,
header->cx * xUnit / 4, header->cy * yUnit / 8,
hwnd, header->id, hInst, NULL );
header = next_header;
}
#ifdef DEBUG_DIALOG
printf( " END\n" );
#endif
/* Initialise dialog extra data */
wndPtr = WIN_FindWndPtr( hwnd );
@ -318,35 +317,24 @@ HWND CreateDialogIndirectParam( HINSTANCE hInst, LPCSTR dlgTemplate,
if (SendMessage( hwnd, WM_INITDIALOG, dlgInfo->hwndFocus, param ))
SetFocus( dlgInfo->hwndFocus );
/* Display dialog */
if (template.header->style & WS_VISIBLE) ShowWindow( hwnd, SW_SHOW );
if (template.controls) free( template.controls );
return hwnd;
}
/***********************************************************************
* DialogBox (USER.87)
* DIALOG_DoDialogBox
*/
int DialogBox( HINSTANCE hInst, LPCSTR dlgTemplate,
HWND owner, FARPROC dlgProc )
static int DIALOG_DoDialogBox( HWND hwnd )
{
HWND hwnd;
WND * wndPtr;
DIALOGINFO * dlgInfo;
MSG msg;
int retval;
#ifdef DEBUG_DIALOG
printf( "DialogBox: %d,'%s',%d,%p\n", hInst, dlgTemplate, owner, dlgProc );
#endif
hwnd = CreateDialog( hInst, dlgTemplate, owner, dlgProc );
if (!hwnd) return -1;
wndPtr = WIN_FindWndPtr( hwnd );
if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return -1;
dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
ShowWindow( hwnd, SW_SHOW );
while (GetMessage (&msg, 0, 0, 0))
{
if (!IsDialogMessage( hwnd, &msg))
@ -362,6 +350,61 @@ int DialogBox( HINSTANCE hInst, LPCSTR dlgTemplate,
}
/***********************************************************************
* DialogBox (USER.87)
*/
int DialogBox( HINSTANCE hInst, LPCSTR dlgTemplate,
HWND owner, FARPROC dlgProc )
{
return DialogBoxParam( hInst, dlgTemplate, owner, dlgProc, 0 );
}
/***********************************************************************
* DialogBoxParam (USER.239)
*/
int DialogBoxParam( HINSTANCE hInst, LPCSTR dlgTemplate,
HWND owner, FARPROC dlgProc, LPARAM param )
{
HWND hwnd;
#ifdef DEBUG_DIALOG
printf( "DialogBoxParam: %d,'%s',%d,%p,%d\n",
hInst, dlgTemplate, owner, dlgProc, param );
#endif
hwnd = CreateDialogParam( hInst, dlgTemplate, owner, dlgProc, param );
if (hwnd) return DIALOG_DoDialogBox( hwnd );
return -1;
}
/***********************************************************************
* DialogBoxIndirect (USER.218)
*/
int DialogBoxIndirect( HINSTANCE hInst, HANDLE dlgTemplate,
HWND owner, FARPROC dlgProc )
{
return DialogBoxIndirectParam( hInst, dlgTemplate, owner, dlgProc, 0 );
}
/***********************************************************************
* DialogBoxIndirectParam (USER.240)
*/
int DialogBoxIndirectParam( HINSTANCE hInst, HANDLE dlgTemplate,
HWND owner, FARPROC dlgProc, LPARAM param )
{
HWND hwnd;
LPCSTR ptr;
if (!(ptr = GlobalLock( dlgTemplate ))) return -1;
hwnd = CreateDialogIndirectParam( hInst, ptr, owner, dlgProc, param );
GlobalUnlock( dlgTemplate );
if (hwnd) return DIALOG_DoDialogBox( hwnd );
return -1;
}
/***********************************************************************
* EndDialog (USER.88)
*/

View File

@ -16,8 +16,7 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993";
#define NB_BUTTONS 3 /* Windows can handle 3 buttons */
#define DBLCLICK_TIME 300 /* Max. time for a double click (milliseconds) */
static WORD dblclick_time = 300; /* Max. time for a double click (milliseconds) */
/* Event handlers */
static void EVENT_expose();
@ -191,7 +190,7 @@ static void EVENT_mouse_button( Widget w, int hwnd, XButtonEvent *event,
{ /* Check if double-click */
prevTime = lastClickTime[buttonNum];
lastClickTime[buttonNum] = event->time;
if (event->time - prevTime < DBLCLICK_TIME)
if (event->time - prevTime < dblclick_time)
{
WND * wndPtr;
CLASS * classPtr;
@ -329,3 +328,24 @@ void ReleaseCapture()
captureWnd = 0;
}
/**********************************************************************
* SetDoubleClickTime (USER.20)
*/
void SetDoubleClickTime (WORD interval)
{
if (interval == 0)
dblclick_time = 500;
else
dblclick_time = interval;
}
/**********************************************************************
* GetDoubleClickTime (USER.21)
*/
WORD GetDoubleClickTime ()
{
return ((WORD)dblclick_time);
}

171
windows/scroll.c Normal file
View File

@ -0,0 +1,171 @@
/*
* Scroll windows and DCs
*
* Copyright David W. Metcalfe, 1993
*
*/
static char Copyright[] = "Copyright David W. Metcalfe, 1993";
#include <stdlib.h>
#include "windows.h"
#include "gdi.h"
static int RgnType;
/*************************************************************************
* ScrollWindow (USER.61)
*/
void ScrollWindow(HWND hwnd, short dx, short dy, LPRECT rect, LPRECT clipRect)
{
HDC hdc;
HRGN hrgnUpdate;
RECT rc, cliprc;
#ifdef DEBUG_SCROLL
printf("ScrollWindow: dx=%d, dy=%d, rect=%d,%d,%d,%d\n", dx, dy,
rect->left, rect->top, rect->right, rect->bottom);
#endif
hdc = GetDC(hwnd);
if (rect == NULL)
GetWindowRect(hwnd, &rc);
else
CopyRect(&rc, rect);
if (clipRect == NULL)
GetWindowRect(hwnd, &cliprc);
else
CopyRect(&cliprc, clipRect);
hrgnUpdate = CreateRectRgn(0, 0, 0, 0);
ScrollDC(hdc, dx, dy, &rc, &cliprc, hrgnUpdate, NULL);
InvalidateRgn(hwnd, hrgnUpdate, TRUE);
ReleaseDC(hwnd, hdc);
}
/*************************************************************************
* ScrollDC (USER.221)
*/
BOOL ScrollDC(HDC hdc, short dx, short dy, LPRECT rc, LPRECT cliprc,
HRGN hrgnUpdate, LPRECT rcUpdate)
{
HRGN hrgnClip, hrgn1, hrgn2;
POINT src, dest;
short width, height;
DC *dc = (DC *)GDI_GetObjPtr(hdc, DC_MAGIC);
#ifdef DEBUG_SCROLL
printf("ScrollDC: dx=%d, dy=%d, rc=%d,%d,%d,%d\n", dx, dy,
rc->left, rc->top, rc->right, rc->bottom);
#endif
if (rc == NULL)
return;
if (cliprc)
{
hrgnClip = CreateRectRgnIndirect(cliprc);
SelectClipRgn(hdc, hrgnClip);
}
if (dx > 0)
{
src.x = XDPTOLP(dc, rc->left);
dest.x = XDPTOLP(dc, rc->left + abs(dx));
}
else
{
src.x = XDPTOLP(dc, rc->left + abs(dx));
dest.x = XDPTOLP(dc, rc->left);
}
if (dy > 0)
{
src.y = YDPTOLP(dc, rc->top);
dest.y = YDPTOLP(dc, rc->top + abs(dy));
}
else
{
src.y = YDPTOLP(dc, rc->top + abs(dy));
dest.y = YDPTOLP(dc, rc->top);
}
width = rc->right - rc->left - abs(dx);
height = rc->bottom - rc->top - abs(dy);
if (!BitBlt(hdc, dest.x, dest.y, width, height, hdc, src.x, src.y,
SRCCOPY))
return;
if (hrgnUpdate)
{
if (dx > 0)
hrgn1 = CreateRectRgn(rc->left, rc->top, rc->left+dx, rc->bottom);
else if (dx < 0)
hrgn1 = CreateRectRgn(rc->right+dx, rc->top, rc->right,
rc->bottom);
else
hrgn1 = CreateRectRgn(0, 0, 0, 0);
if (dy > 0)
hrgn2 = CreateRectRgn(rc->left, rc->top, rc->right, rc->top+dy);
else if (dy < 0)
hrgn2 = CreateRectRgn(rc->left, rc->bottom+dy, rc->right,
rc->bottom);
else
hrgn2 = CreateRectRgn(0, 0, 0, 0);
RgnType = CombineRgn(hrgnUpdate, hrgn1, hrgn2, RGN_OR);
}
if (rcUpdate)
{
SelectClipRgn(hdc, hrgnUpdate);
GetClipBox(hdc, rcUpdate);
}
}
/*************************************************************************
* ScrollWindowEx (USER.319)
*/
int ScrollWindowEx(HWND hwnd, short dx, short dy, LPRECT rect, LPRECT clipRect,
HRGN hrgnUpdate, LPRECT rcUpdate, WORD flags)
{
HDC hdc;
RECT rc, cliprc;
#ifdef DEBUG_SCROLL
printf("ScrollWindowEx: dx=%d, dy=%d, rect=%d,%d,%d,%d\n", dx, dy,
rect->left, rect->top, rect->right, rect->bottom);
#endif
hdc = GetDC(hwnd);
if (rect == NULL)
GetWindowRect(hwnd, &rc);
else
CopyRect(&rc, rect);
if (clipRect == NULL)
GetWindowRect(hwnd, &cliprc);
else
CopyRect(&cliprc, clipRect);
ScrollDC(hdc, dx, dy, &rc, &cliprc, hrgnUpdate, rcUpdate);
if (flags | SW_INVALIDATE)
{
InvalidateRgn(hwnd, hrgnUpdate, FALSE);
if (flags | SW_ERASE)
SendMessage(hwnd, WM_ERASEBKGND, (WORD)hdc, (LONG)NULL);
}
ReleaseDC(hwnd, hdc);
return RgnType;
}

View File

@ -52,9 +52,11 @@ HWND WIN_FindWinToRepaint( HWND hwnd )
WND * wndPtr;
if (!hwnd) hwnd = firstWindow;
while (hwnd)
for ( ; hwnd != 0; hwnd = wndPtr->hwndNext )
{
if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
if (!wndPtr || !wndPtr->winWidget) continue;
if (!XtIsRealized( wndPtr->winWidget )) continue;
if (wndPtr->hrgnUpdate) return hwnd;
if (wndPtr->hwndChild)
{
@ -62,7 +64,6 @@ HWND WIN_FindWinToRepaint( HWND hwnd )
if ((child = WIN_FindWinToRepaint( wndPtr->hwndChild )))
return child;
}
hwnd = wndPtr->hwndNext;
}
return 0;
}
@ -122,8 +123,8 @@ HWND CreateWindowEx( DWORD exStyle, LPSTR className, LPSTR windowName,
if (y == CW_USEDEFAULT) y = 0;
if (width == CW_USEDEFAULT) width = 600;
if (height == CW_USEDEFAULT) height = 400;
if (!width) width = 1;
if (!height) height = 1;
if (width == 0) width = 1;
if (height == 0) height = 1;
/* Find the parent and class */
@ -135,9 +136,10 @@ HWND CreateWindowEx( DWORD exStyle, LPSTR className, LPSTR windowName,
}
else if (style & WS_CHILD) return 0; /* WS_CHILD needs a parent */
if (!(class = CLASS_FindClassByName( className, &classPtr )))
if (!(class = CLASS_FindClassByName( className, &classPtr ))) {
printf("CreateWindow BAD CLASSNAME '%s' !\n", className);
return 0;
}
/* Create the window structure */
hwnd = USER_HEAP_ALLOC(GMEM_MOVEABLE, sizeof(WND)+classPtr->wc.cbWndExtra);
@ -250,6 +252,8 @@ HWND CreateWindowEx( DWORD exStyle, LPSTR className, LPSTR windowName,
formWidgetClass,
wndPtr->shellWidget,
NULL );
/* wndPtr->winWidget = wndPtr->compositeWidget; */
wndPtr->winWidget = wndPtr->shellWidget;
if (wndPtr->wIDmenu == 0)
{
wndPtr->menuBarPtr =
@ -322,8 +326,13 @@ WinCreated:
if (wmcreate == -1)
{
/* Abort window creation */
if (parent) parentPtr->hwndChild = wndPtr->hwndNext;
else firstWindow = wndPtr->hwndNext;
if (wndPtr->shellWidget) XtDestroyWidget( wndPtr->shellWidget );
else XtDestroyWidget( wndPtr->winWidget );
if (wndPtr->hdc) DeleteDC( wndPtr->hdc );
classPtr->cWindows--;
USER_HEAP_FREE( hwnd );
return 0;
}
@ -446,28 +455,32 @@ BOOL ShowWindow( HWND hwnd, int cmd )
XtNwidth, &width,
XtNheight, &height,
NULL );
SendMessage( hwnd, WM_SIZE, SIZE_RESTORED,
(width & 0xffff) | (height << 16) );
SendMessage( hwnd, WM_SHOWWINDOW, TRUE, 0 );
/*
printf("ShowWindow(%X, %X); !\n", hwnd, cmd);
*/
switch(cmd)
{
case SW_HIDE:
XtSetMappedWhenManaged(wndPtr->winWidget, FALSE);
wndPtr->dwStyle &= (WS_VISIBLE ^ 0xFFFFFFFL);
SendMessage( hwnd, WM_SHOWWINDOW, FALSE, 0 );
break;
case SW_SHOWNA:
case SW_SHOWMINNOACTIVE:
case SW_SHOWNOACTIVATE:
case SW_SHOWMINIMIZED:
case SW_MINIMIZE:
wndPtr->dwStyle |= WS_ICONIC;
goto WINVisible;
case SW_SHOWNA:
case SW_SHOWNOACTIVATE:
case SW_MAXIMIZE:
case SW_SHOWMAXIMIZED:
case SW_SHOWMINIMIZED:
case SW_SHOW:
case SW_NORMAL:
case SW_SHOWNORMAL:
wndPtr->dwStyle &= (WS_ICONIC ^ 0xFFFFFFFL);
WINVisible:
XtSetMappedWhenManaged(wndPtr->winWidget, TRUE);
wndPtr->dwStyle |= WS_VISIBLE;
SendMessage( hwnd, WM_SIZE, SIZE_RESTORED,
(width & 0xffff) | (height << 16) );
SendMessage( hwnd, WM_SHOWWINDOW, TRUE, 0 );
break;
default:
break;
@ -477,6 +490,42 @@ BOOL ShowWindow( HWND hwnd, int cmd )
}
/***********************************************************************
* CloseWindow (USER.43)
*/
void CloseWindow(HWND hWnd)
{
WND * wndPtr = WIN_FindWndPtr(hWnd);
if (wndPtr->dwStyle & WS_CHILD) return;
ShowWindow(hWnd, SW_MINIMIZE);
PostMessage(hWnd, WM_CLOSE, 0, 0L);
}
/***********************************************************************
* OpenIcon (USER.44)
*/
BOOL OpenIcon(HWND hWnd)
{
WND * wndPtr = WIN_FindWndPtr(hWnd);
if (!IsIconic(hWnd)) return FALSE;
ShowWindow(hWnd, SW_SHOWNORMAL);
return(TRUE);
}
/***********************************************************************
* FindWindow (USER.50)
*/
HWND FindWindow(LPSTR ClassMatch, LPSTR TitleMatch)
{
return((HWND)NULL);
}
/***********************************************************************
* MoveWindow (USER.56)
*/
@ -508,7 +557,9 @@ void MoveWindow(HWND hWnd, short x, short y, short w, short h, BOOL bRepaint)
void UpdateWindow( HWND hwnd )
{
if (GetUpdateRect( hwnd, NULL, FALSE ))
SendMessage( hwnd, WM_PAINT, 0, 0 );
{
if (IsWindowVisible( hwnd )) SendMessage( hwnd, WM_PAINT, 0, 0 );
}
}
/**********************************************************************
@ -578,17 +629,17 @@ void SetWindowPos(HWND hWnd, HWND hWndInsertAfter, short x, short y, short w, sh
WND * wndPtr = WIN_FindWndPtr( hWnd );
if (wndPtr)
{
if ((wFlag & SWP_NOMOVE) == 0) {
if ((wFlag & SWP_NOMOVE) != SWP_NOMOVE) {
wndPtr->rectClient.left = x;
wndPtr->rectClient.top = y;
XtVaSetValues(wndPtr->winWidget, XtNx, x, XtNy, y, NULL );
}
if ((wFlag & SWP_NOSIZE) == 0) {
if ((wFlag & SWP_NOSIZE) != SWP_NOSIZE) {
wndPtr->rectClient.right = x + w;
wndPtr->rectClient.bottom = y + h;
XtVaSetValues(wndPtr->winWidget, XtNwidth, w, XtNheight, h, NULL );
}
if ((wFlag & SWP_NOREDRAW) == 0) {
if ((wFlag & SWP_NOREDRAW) != SWP_NOREDRAW) {
InvalidateRect(hWnd, NULL, TRUE);
UpdateWindow(hWnd);
}
@ -597,8 +648,10 @@ void SetWindowPos(HWND hWnd, HWND hWndInsertAfter, short x, short y, short w, sh
if ((wFlag & SWP_SHOWWINDOW) == SWP_SHOWWINDOW)
ShowWindow(hWnd, SW_SHOW);
/*
if ((wFlag & SWP_NOACTIVATE) == 0)
if ((wFlag & SWP_NOACTIVATE) != SWP_NOACTIVATE)
SetActiveWindow(hWnd);
if ((wFlag & SWP_NOZORDER) != SWP_NOZORDER)
{ }
*/
printf("SetWindowPos(%X, %X, %d, %d, %d, %d, %X); !\n",
hWnd, hWndInsertAfter, x, y, w, h, wFlag);
@ -695,16 +748,21 @@ LONG SetWindowLong( HWND hwnd, short offset, LONG newval )
}
/*****************************************************************
* GetParent (USER.46)
/***********************************************************************
* IsIconic (USER.31)
*/
HWND GetParent(HWND hwnd)
BOOL IsIconic(HWND hWnd)
{
WND *wndPtr = WIN_FindWndPtr(hwnd);
return wndPtr->hwndParent;
WND * wndPtr;
if (hWnd == 0) return(FALSE);
wndPtr = WIN_FindWndPtr(hWnd);
if (wndPtr == 0) return(FALSE);
if (wndPtr->dwStyle & WS_ICONIC) return(TRUE);
return(FALSE);
}
/*******************************************************************
* GetWindowText (USER.36)
*/
@ -732,6 +790,26 @@ int GetWindowTextLength(HWND hwnd)
}
/*******************************************************************
* IsWindow (USER.47)
*/
BOOL IsWindow( HWND hwnd )
{
WND * wndPtr = WIN_FindWndPtr( hwnd );
return (wndPtr->dwMagic == WND_MAGIC);
}
/*****************************************************************
* GetParent (USER.46)
*/
HWND GetParent(HWND hwnd)
{
WND *wndPtr = WIN_FindWndPtr(hwnd);
return wndPtr->hwndParent;
}
/*******************************************************************
* IsChild (USER.48)
*/
@ -755,6 +833,23 @@ BOOL IsChild( HWND parent, HWND child )
}
/***********************************************************************
* IsWindowVisible (USER.49)
*/
BOOL IsWindowVisible(HWND hWnd)
{
WND * wndPtr;
if (hWnd == 0) return(FALSE);
wndPtr = WIN_FindWndPtr(hWnd);
if (wndPtr == 0) return(FALSE);
if (wndPtr->dwStyle & WS_VISIBLE) {
if (XtIsRealized(wndPtr->winWidget)) return(TRUE);
}
return(FALSE);
}
/*******************************************************************
* GetTopWindow (USER.229)
*/