示例#1
0
BOOL WINAPI
ShowWindow(HWND hwnd, int nCmdShow)
{
	if(!hwnd)
		return FALSE;
	
	/* fix: send show msg*/

	switch(nCmdShow) {
	case SW_HIDE:
		if (!(hwnd->style & WS_VISIBLE))
			return FALSE;
		MwHideWindow(hwnd, TRUE, TRUE);
		hwnd->style &= ~WS_VISIBLE;
		return TRUE;

	case SW_MAXIMIZE:
		if (!(hwnd->style & WS_MAXIMIZE)) {
			RECT rc;

			hwnd->restorerc = hwnd->winrect;
			SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, 0);
			MoveWindow(hwnd, rc.top, rc.left, rc.right - rc.left,
					rc.bottom - rc.top, TRUE);
			hwnd->style |= WS_MAXIMIZE;
		}
		break;
	case SW_RESTORE:
	case SW_SHOWDEFAULT:
		if(hwnd->style & WS_MAXIMIZE) {
			RECT rc = hwnd->restorerc;
			MoveWindow(hwnd, rc.left, rc.top,
				rc.right-rc.left, rc.bottom-rc.top,
				TRUE);
			hwnd->style &= ~WS_MAXIMIZE;
		}
		break;
	default:
		if (hwnd->style & WS_VISIBLE)
			return FALSE;
	}
	hwnd->style |= WS_VISIBLE;
	MwShowWindow(hwnd, TRUE);
	return TRUE;
}
示例#2
0
/*
 * Map the window to possibly make it and its children visible on the screen.
 * This is a recursive routine which decrements the unmapcount values for
 * this window and all of its children, and causes exposure events for
 * those windows which become visible.
 */
void
MwShowWindow(HWND hwnd, BOOL bSendMsg)
{
	HWND	wp = hwnd;

	if (wp == rootwp)
		return;

	++mwpaintNC;		/* experimental NC paint handling*/

	if (wp->unmapcount)
		wp->unmapcount--;

	if (wp->unmapcount == 0) {
		SendMessage(wp, WM_SHOWWINDOW, TRUE, 0L);
		MwCheckMouseWindow();
		MwCheckCursor();
	}

	/*
	 * If the window just became visible,
	 * then draw its border, clear it to the background color, and
	 * generate an exposure event.
	 */
	if (wp->unmapcount == 0) {
		/*MwDrawBorder(wp);*/
		MwClearWindow(wp, 0, 0, wp->winrect.right - wp->winrect.left,
			wp->winrect.bottom - wp->winrect.top, TRUE);
	}

	/*
	 * Do the same thing for the children.
	 */
	for (wp = wp->children; wp; wp = wp->siblings)
		MwShowWindow(wp, bSendMsg);
}
示例#3
0
BOOL WINAPI
ShowWindow(HWND hwnd, int nCmdShow)
{
	if(!hwnd)
		return FALSE;
	
	/* fix: send show msg*/

	switch(nCmdShow) {
	case SW_HIDE:
		if (!(hwnd->style & WS_VISIBLE))
			return FALSE;
		MwHideWindow(hwnd, TRUE, TRUE);
		hwnd->style &= ~WS_VISIBLE;
		break;

	default:
		if (hwnd->style & WS_VISIBLE)
			return FALSE;
		hwnd->style |= WS_VISIBLE;
		MwShowWindow(hwnd, TRUE);
	}
	return TRUE;
}
示例#4
0
HWND WINAPI
CreateWindowEx(DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWindowName,
	DWORD dwStyle, int x, int y, int nWidth, int nHeight,
	HWND hwndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam)
{
	HWND		pwp;		/* parent window */
	HWND		wp;		/* new window */
	HWND		hwndOwner;
	PWNDCLASS	pClass;
	CREATESTRUCT	cs;
	int			titLen;
	static int	nextx = 20;
	static int	nexty = 20;
	
	/* WARNING: All modification made here should be reported 
	   on MwInitialize for the rootwp window */

	pClass = MwFindClassByName(lpClassName);
	if(!pClass)
		return NULL;

	if(x == CW_USEDEFAULT || y == CW_USEDEFAULT) {
		x = nextx;
		nextx += 10;
		y = nexty;
		nexty += 10;
		if(nextx > 200)
			nextx = nexty = 20;
	}
	if(nWidth == CW_USEDEFAULT || nHeight == CW_USEDEFAULT) {
		nWidth = 250;
		nHeight = 250;
	}

	if(hwndParent == NULL) {
		if(dwStyle & WS_CHILD)
			return NULL;
		pwp = rootwp;
	} else
		pwp = hwndParent;

	/* WS_POPUP z-order parent is the root window (passed parent is owner)*/
	if(dwStyle & WS_POPUP)
		pwp = rootwp;		/* force clip to root, not z-parent*/

	/* window owner is NULL for child windows, else it's the passed parent*/
	if(dwStyle & WS_CHILD)
		hwndOwner = NULL;
	else hwndOwner = hwndParent;

	wp = (HWND)GdItemAlloc(sizeof(struct hwnd) - 1 + pClass->cbWndExtra);
	if(!wp)
		return NULL;

	/* force all clipping on by default*/
	dwStyle |= WS_CLIPSIBLINGS | WS_CLIPCHILDREN;

	wp->pClass = pClass;
	wp->lpfnWndProc = pClass->lpfnWndProc;
	wp->style = dwStyle;
	wp->exstyle = dwExStyle;
	wp->parent = pwp;
	wp->owner = hwndOwner;
	wp->children = NULL;
	wp->siblings = pwp->children;
	pwp->children = wp;
	wp->next = listwp;
	listwp = wp;
	wp->winrect.left = pwp->clirect.left + x;
	wp->winrect.top = pwp->clirect.top + y;
	wp->winrect.right = wp->winrect.left + nWidth;
	wp->winrect.bottom = wp->winrect.top + nHeight;
	wp->cursor = pwp->cursor;
	wp->cursor->usecount++;
	wp->unmapcount = pwp->unmapcount + 1;
	wp->id = (int)hMenu;
	wp->gotPaintMsg = PAINT_PAINTED;

	titLen = 0;
	if (lpWindowName != NULL)
		titLen = strlen(lpWindowName);
	if (titLen < 64) titLen = 64; /* old mw compatibility */
	wp->szTitle = (LPTSTR)malloc(titLen + 1);
	if (wp->szTitle == NULL) {
		free(wp);
		return NULL;
	}
	if (lpWindowName != NULL)
		strcpy(wp->szTitle, lpWindowName);
	else
		wp->szTitle[0] = '\0';

#if UPDATEREGIONS
	wp->update = GdAllocRegion();
#endif
	wp->nextrabytes = pClass->cbWndExtra;
	wp->hInstance = hInstance;
	wp->nEraseBkGnd = 1;
	wp->paintBrush = NULL;
	wp->paintPen = NULL;

	/* calculate client area*/
	MwCalcClientRect(wp);

	cs.lpCreateParams = lpParam;
	cs.hInstance = hInstance;
	cs.hMenu = hMenu;
	cs.hwndParent = hwndParent;
	cs.cy = nHeight;
	cs.cx = nWidth;
	cs.y = y;
	cs.x = x;
	cs.style = dwStyle;
	cs.lpszName = lpWindowName;
	cs.lpszClass = lpClassName;
	cs.dwExStyle = dwExStyle;

	if(SendMessage(wp, WM_CREATE, 0, (LPARAM)(LPSTR)&cs) == -1) {
		MwDestroyWindow(wp, FALSE);
		return NULL;
	}

	/* send SIZE and MOVE msgs*/
	MwSendSizeMove(wp, TRUE, TRUE);

	if(wp->style & WS_VISIBLE) {
		MwShowWindow(wp, TRUE);
		SetFocus(wp);
	}

	return wp;
}
示例#5
0
BOOL
SetWindowPos(HWND hwnd, HWND hwndInsertAfter, int x, int y, int cx, int cy,
	UINT fuFlags)
{
	int		hidden;
	BOOL		bMove, bSize, bZorder;
	MWCOORD		offx = 0, offy = 0;	/* = 0 for bad gcc warning*/
	WINDOWPOS	winpos;

	if(!hwnd || hwnd == rootwp || cx < 0 || cy < 0)
		return FALSE;

	/* FIXME SWP_NOACTIVATE*/

	if((fuFlags & SWP_SHOWWINDOW))
		return ShowWindow(hwnd, SW_SHOW);

	if((fuFlags & SWP_HIDEWINDOW))
		return ShowWindow(hwnd, SW_HIDE);

	/* move is relative to parent's client rect for child windows*/
	if(hwnd->style & WS_CHILD) {
		x += hwnd->parent->clirect.left;
		y += hwnd->parent->clirect.top;
	} else {
		x += hwnd->parent->winrect.left;
		y += hwnd->parent->winrect.top;
	}

	bMove = !(fuFlags & SWP_NOMOVE) &&
			(hwnd->winrect.left != x || hwnd->winrect.top != y);
	bSize = !(fuFlags & SWP_NOSIZE) &&
			((hwnd->winrect.right - hwnd->winrect.left) != cx ||
		 	(hwnd->winrect.bottom - hwnd->winrect.top) != cy);
	bZorder = !(fuFlags & SWP_NOZORDER);
	if(!bMove && !bSize && !bZorder)
		return TRUE;

	/* could optimize to not require redraw when possible*/
	hidden = hwnd->unmapcount || (fuFlags & SWP_NOREDRAW);

	if(bZorder) {
		switch((int)hwndInsertAfter) {
		case (int)HWND_TOP:
			MwRaiseWindow(hwnd);
			break;
		case (int)HWND_BOTTOM:
			MwLowerWindow(hwnd);
			break;
		default:
			/* FIXME for non top/bottom zorder*/
			break;
		}
	} else {
		if(!hidden)
			MwHideWindow(hwnd, FALSE, FALSE);
	}

	if(bMove) {
		offx = x - hwnd->winrect.left;
		offy = y - hwnd->winrect.top;
	}
	if(bMove || bSize) {
		hwnd->winrect.left = x;
		hwnd->winrect.top = y;
		hwnd->winrect.right = x + cx;
		hwnd->winrect.bottom = y + cy;
	}
	if(bMove)
		MwOffsetChildren(hwnd, offx, offy);

	if(bMove || bSize) {
		MwCalcClientRect(hwnd);

		/* send windowposchanged message*/
		/* FIXME: move WM_MOVE, WM_SIZE to defwndproc*/
		winpos.hwnd = hwnd;
		winpos.hwndInsertAfter = hwndInsertAfter;
		winpos.x = x;
		winpos.y = y;
		winpos.cx = cx;
		winpos.cy = cy;
		winpos.flags = fuFlags;
		SendMessage(hwnd, WM_WINDOWPOSCHANGED, 0, (LPARAM)&winpos);

		MwSendSizeMove(hwnd, bSize, bMove);
	}

	++mwpaintSerial;	/* increment paint serial # for alphablending*/
	++mwpaintNC;		/* increment paint serial # for NC painting*/
	hwnd->nEraseBkGnd++;
	if(!bZorder && !hidden)
		MwShowWindow(hwnd, FALSE);

	return TRUE;
}