www.pudn.com > windowmanager.rar > wintern.h, change:2005-05-09,size:14784b

/* wintern.h*/ 
 * Copyright (c) 1999 Greg Haerr <greg@censoft.com> 
 * Microwindows internal routines header file 
#ifndef __WINTERN_H 
#define __WINTERN_H 
#include <string.h> 
#define VXWORKS	0 
#define UNIX 0	 
#define DOS_DJGPP	0  
#define strcmpi	strcasecmp 
#elif (VXWORKS) 
int strcmpi(const char *s1, const char *s2); 
#ifdef __PACIFIC__ 
#define strcmpi		stricmp 
extern int stricmp_a(const char *s1, const char *s2); 
#define stricmp		stricmp_a 
#define DBLCLICKSPEED	750		/* mouse dblclik speed msecs (was 450)*/ 
/* gotPaintMsg values*/ 
#define PAINT_PAINTED		0	/* WM_PAINT msg has been processed*/ 
#define PAINT_NEEDSPAINT	1	/* WM_PAINT seen, paint when can*/ 
#define PAINT_DELAYPAINT	2	/* WM_PAINT seen,paint after user move*/ 
/* non-win32 api access for microwin*/ 
BOOL		MwSetDesktopWallpaper(PMWIMAGEHDR pImage); 
void		MwRegisterFdInput(HWND hwnd,int fd); 
void		MwUnregisterFdInput(HWND hwnd,int fd); 
void		MwRegisterFdOutput(HWND hwnd,int fd); 
void		MwUnregisterFdOutput(HWND hwnd,int fd); 
void		MwRegisterFdExcept(HWND hwnd,int fd); 
void		MwUnregisterFdExcept(HWND hwnd,int fd); 
/* internal routines*/ 
/* winuser.c*/ 
PWNDCLASS 	MwFindClassByName(LPCSTR lpClassName); 
void		MwDestroyWindow(HWND hwnd,BOOL bSendMsg); 
HWND		MwGetTopWindow(HWND hwnd); 
void		MwCalcClientRect(HWND hwnd); 
void		MwSendSizeMove(HWND hwnd, BOOL bSize, BOOL bMove); 
void		MwSetCursor(HWND wp, PMWCURSOR pcursor); 
HWND		MwAutoLostFocus(HWND hwnd); 
BOOL		MwSetForegroundWindow(HWND hwnd); 
/* wingdi.c*/ 
#define MwIsClientDC(port)	(((port)->flags & DCX_WINDOW) == 0) 
#define MwIsMemDC(port)		((port)->devFlags == PSF_MEMORY) 
void		MwPaintNCArea(HWND hwnd); 
HWND		MwPrepareDC(HDC hdc); 
void		MwSetClipWindow(HDC hdc); 
/* winsbar.c*/ 
void		MwAdjustNCScrollbars(HWND hwnd); 
void		MwPaintNCScrollbars(HWND hwnd, HDC hdc); 
void		MwHandleNCMessageScrollbar(HWND hwnd, UINT msg, WPARAM hitcode, 
			LPARAM lParam); 
/* winexpos.c*/ 
void		MwRedrawScreen(INT screen); 
void		MwHideWindow(HWND hwnd,BOOL bChangeFocus,BOOL bSendMsg); 
void		MwShowWindow(HWND hwnd,BOOL bSendMsg); 
void		MwRaiseWindow(HWND hwnd); 
void		MwLowerWindow(HWND hwnd); 
BOOL		MwCheckOverlap(HWND topwp, HWND botwp); 
void		MwClearWindow(HWND wp,SHORT x,SHORT y,SHORT width,SHORT height,BOOL exposeflag); 
BOOL		MwExposeArea(HWND wp, SHORT rootx,SHORT rooty,SHORT width,SHORT height); 
/* winevent.c*/ 
BOOL		MwCheckMouseEvent(void); 
BOOL		MwCheckKeyboardEvent(void); 
BOOL		CheckKeyboardEvent(void); 
BOOL		CheckMouseEvent(void); 
void 		MwHandleMouseStatus(MWCOORD newx, MWCOORD newy, int newbuttons); 
void		MwTranslateMouseMessage(HWND hwnd,UINT msg,int hittest); 
void		MwDeliverMouseEvent(int buttons, int changebuttons,	MWKEYMOD modifiers); 
void		MwDeliverMouseEventEx(int buttons, int changebuttons, MWKEYMOD modifiers); 
void		MwDeliverKeyboardEvent(MWKEY keyvalue, MWKEYMOD modifiers, 
			MWSCANCODE scancode, BOOL pressed); 
void		MwDeliverExposureEvent(HWND wp, MWCOORD x, MWCOORD y, 
			MWCOORD width,MWCOORD height); 
void		MwUnionUpdateRegion(HWND wp, MWCOORD x, MWCOORD y, 
			MWCOORD width,MWCOORD height, BOOL bUnion); 
void		MwMoveCursor(MWCOORD x, MWCOORD y); 
void		MwCheckCursor(void); 
HWND		MwFindVisibleWindow(MWCOORD x, MWCOORD y); 
void		MwCheckMouseWindow(void); 
int		strzcpy(char *dst,const char *src,int dstsiz); 
void  RegisterMainWindow(HWND hMainWindow); 
/* winmain.c*/ 
int		MwOpen(void); 
void	MwClose(void); 
void	MwSelect(void); 
int		MwInitialize(void); 
void	MwTerminate(void); 
#define VTSWITCH	0	//added by liuyudong for warnning 
/* temp framebuffer vt switch stuff at upper level 
 * this should be handled at the lower level, just like vgalib does. 
void MwInitVt(void); 
int  MwCurrentVt(void); 
int  MwCheckVtChange(void); 
void MwRedrawVt(int t); 
void MwExitVt(void); 
extern int mwvterm; 
#endif /* VTSWITCH*/ 
BOOL IsValidWindow(HWND hwnd); 
typedef INT							STATUS; 
typedef struct tagQMSG              *PQMSG; 
//typedef struct tagWND               *PWND; 
typedef struct tagQ                 *PQ; 
typedef struct tagTHREADINFO        *PTHREADINFO; 
typedef unsigned long				*ULONG_PTR; 
typedef long						*LONG_PTR; 
typedef struct tagSMS				*PSMS; 
#define STATUS_SUCCESS				0 
typedef struct tagMLIST { 
    PQMSG pqmsgRead; 
    PQMSG pqmsgWriteLast; 
    DWORD cMsgs; 
 * Message Queue structure. 
#define  PWND HWND 
typedef struct tagQ { 
	MLIST       mlInput;            // raw mouse and key message list. 
    PWND        spwndCapture; 
    PWND        spwndFocus; 
    PWND        spwndActive; 
//    BYTE        afKeyRecentDown[CBKEYSTATERECENTDOWN]; 
//    BYTE        afKeyState[CBKEYSTATE]; 
    DWORD       QF_flags;            // QF_ flags go here 
    USHORT      cThreads;            // Count of threads using this queue 
    LONG_PTR    ExtraInfo; 
} Q; 
#define		QS_KEY			   0x0001//有用户消息产生 
#define     QS_MOUSEMOVE       0x0002 
#define     QS_MOUSEBUTTON     0x0004 
#define     QS_POSTMESSAGE     0x0008//有POST产生 
#define     QS_TIMER           0x0010 
#define     QS_PAINT           0x0020 
#define     QS_SENDMESSAGE     0x0040//有另外的线程发送消息给自己 
#define     QS_HOTKEY          0x0080 
#define     QS_ALLPOSTMESSAGE  0x0100 
#define     QS_SMSREPLY        0x0200//另外的线程有回应消息给自己 
#define     QS_EVENT           0x2000 
#define		QS_EVENTSET		   0x8000 
#define DLGF_ANSI           0x01    /* lpfnDlg is an ANSI proc */ 
#define TIF_INCLEANUP               (UINT)0x00000001 
#define TIF_DONTATTACHQUEUE         (UINT)0x00000002 
#define TIF_DISABLEINPUT            (UINT)0x00000004 
typedef struct tagTHREADINFO { 
	MLIST 	mlPost;      		// posted message list. 
	PQ 		timerQ;      		// timer message list. 
	PQ 		pq;					// keyboard and mouse input queue 
	PSMS	psmsReceiveList;	// SMSs to be processed《利用hSemaphore来进行保护》 
	PSMS	psmsSent;			// Most recent SMS this thread has sent 
	PSMS	psmsCurrent;		// Received SMS this thread is currently processing 
	int		cQuit; 
	int		exitCode; 
	DWORD	fsWakeMask; 
	DWORD   fsWakeBits;   
  						//QS_SENDMESSAGE:	有另外的线程发送消息给自己 
						//QS_SMSREPLY: 		另外的线程有回应消息给自己 
						//QS_TIMER:				Timer	消息产生 
						//QS_INPUT:				有用户消息产生  
	DWORD   fsChangeBits ; 
	DWORD   fsChangeBitsRemoved;	//Bits removed during PeekMessage 
	INT		cEnterCount; 
	DWORD   TIF_flags; 
	DWORD   timeLast; 
	PWND    pMainWindow; //记录该线程的主窗口 
	HANDLE  hQLock; //信号量保护,消息队列操作保护 
	HANDLE  hSmsLock;   //信号量保护,消息队列操作保护 
	// for debug 
	DWORD   loCount; 
	LONG	hiCount; 
	DWORD	dwStackAddr;//堆栈地址 
	HANDLE  hEvent;		//事件发生时,设置该事件 
	MWLISTHEAD mlWindowClass; 
	DWORD  dwWindows;//该线程创建的窗口个数 
// message define 
#define SMF_REPLY                0x0001      //消息已应答  
#define SMF_RECEIVERDIED         0x0002      //消息已被接收 
#define SMF_SENDERDIED           0x0004      // sender has died 
#define SMF_RECEIVERFREE         0x0008      // receiver should free sms when done 
#define SMF_RECEIVEDMESSAGE      0x0010      // sms has been received 
#define SMF_RECEIVERBUSY         0x4000      // 正在处理消息 
typedef struct tagSMS { 
   		PSMS psmsNext;          // link in global psmsList	 
		PSMS psmsReceiveNext;   // link in queue's ReceiveList 
		PTHREADINFO    ptiSender;    //	消息发送线程 
    	PTHREADINFO    ptiReceiver;  //	消息接收线程 
		DWORD  	 lRet;   			//	消息返回值 
    	DWORD    flags;  			// 	SMF_ flags 
    	WPARAM   wParam;            //  消息域... 
    	LPARAM   lParam;				 
    	INT     message; 
    	HWND    spwnd; 
		DWORD   time;				//  消息发送时间 
 } SMS; 
 * Structure definition for messages as they exist on a Q.  Same as MSG 
 * structure except for the link-pointer and flags at the end. 
typedef struct tagQMSG { 
    PQMSG           pqmsgNext; 
    PQMSG           pqmsgPrev; 
    MSG             msg; 
    ULONG_PTR       ExtraInfo; 
    DWORD           dwQEvent; 
    PTHREADINFO     pti; 
} QMSG; 
 * dwQEvent values for QMSG structure. 
#define QEVENT_SHOWWINDOW           0x0001 
#define QEVENT_CANCELMODE           0x0002 
#define QEVENT_SETWINDOWPOS         0x0003 
#define QEVENT_UPDATEKEYSTATE       0x0004 
#define QEVENT_DEACTIVATE           0x0005 
#define QEVENT_ACTIVATE             0x0006 
#define QEVENT_POSTMESSAGE          0x0007  // Chicago 
#define QEVENT_EXECSHELL            0x0008  // Chicago 
#define QEVENT_CANCELMENU           0x0009  // Chicago 
#define QEVENT_DESTROYWINDOW        0x000A 
#define QEVENT_ASYNCSENDMSG         0x000B 
#define QEVENT_HUNGTHREAD           0x000C 
#define QEVENT_NOTIFYWINEVENT       0x000E 
#define QEVENT_RITSOUND             0x0010 
// QEvent for WM_APPCOMMAND messages - bug 339877 
#define QEVENT_APPCOMMAND           0x0011 
/* window*/ 
struct hwnd { 
	RECT			winrect;	/* window rect in screen coords*/ 
	RECT			clirect;	/* client rect in screen coords*/ 
	RECT			restorerc;	/* restore rect from maximized*/ 
	DWORD			style;		/* window style*/ 
	DWORD			exstyle;	/* window extended style*/ 
	DWORD			screendev;  /* screen type, main-screen or sub-screen*/ 
	WNDCLASS*		pWndClass;	/* window class*/ 
	HBRUSH			hbrBackground; 
	WNDPROC			lpfnWndProc; 
	struct hwnd		*parent;	/* z-order parent window */ 
	struct hwnd		*children;	/* first child window */ 
	struct hwnd		*siblings;	/* next sibling window */ 
	struct hwnd		*owner;		/* owner window*/ 
//	struct hwnd		*next;		/* next window in complete list */ // no listwp. 
	struct hwnd		*focus;		/* prev focus children window */ 
	struct hcursor	*cursor;	/* cursor for this window */ 
	HDC	   owndc;		/* owndc if CS_OWNDC*/ 
	INT				unmapcount;	/* count of reasons not really mapped */ 
	INT				id;			/* window id */ 
	CHAR			szTitle[MAXLEN_WINTITILE+1];/* window title*/ 
	INT				gotPaintMsg;/* window had WM_PAINT PostMessage*/ 
	INT				paintSerial;/* experimental serial # for alphblend*/ 
	INT				paintNC;	/* experimental NC paint handling*/ 
	region			*update;	/* update region in screen coords*/ 
	DWORD			userdata;	/* setwindowlong user data*/ 
	DWORD			userdata2;	/* additional user data (will remove)*/ 
//	DWORD			ThreadID;	/* Thread ID for this window */ 
	MWSCROLLBARINFO	hscroll;	/* NC scrollbars*/ 
	DWORD           existingflag;   /* indicate this window is existing, add by lxq */ 
	INT				nextrabytes;	/* # window extra bytes*/ 
	CHAR			extrabytes[1];	/* window extra bytes - must be last*/ 
void WINAPI RegisterMainWindow(HWND hMainWindow); 
extern PTHREADINFO GetPtiFromThreadId(DWORD);//defined in queue.c 
extern VOID SetWakeBit(PTHREADINFO pti,UINT wWakeBit);	//#defined in queue.c 
extern int CheckMouse(HWND hwnd,int x,int y); 
extern PTHREADINFO PtiCurrent (void); 
extern LRESULT InterSendMsgEx( 
					HWND hWnd, 
					UINT message, 
					WPARAM wParam, 
					LPARAM lParam, 
					PTHREADINFO ptiSender, 
					PTHREADINFO ptiReceiver, 
					UINT uTimeout) ; 
extern  BOOL _PostMessage( 
					PWND pwnd, 
					UINT message, 
					WPARAM wParam, 
					LPARAM lParam); 
BOOL InternalGetMessage( 
					LPMSG lpMsg, 
					HWND hwndFilter, 
					UINT msgMin, 
					UINT msgMax, 
					UINT flags, 
					BOOL fGetMessage); 
extern void GdItemFree( void *address ); 
extern void DestroyMessages(HWND hWnd); 
extern BOOL  MwFocusAble(HWND  hwnd); 
extern void WINAPI ClearThreadInputQueue(DWORD dwThreadId); 
extern BOOL  MwTopMostWindow(HWND  hwnd); 
extern BOOL MwNonTopMostWindow(HWND hwnd); 
extern BOOL	MwMoveWindow(HWND hwnd, HWND hwndAfter); 
/* semaphore for window */ 
void WaitForWindowSema(); 
void ReleaseWindowSema(); 
#ifdef  _DEBUG 
	#define   WaitForWindowSemaphore()   WaitForWindowSema(__FILE__,__LINE__) 
	#define   ReleaseWindowSemaphore()   ReleaseWindowSema(__FILE__,__LINE__) 
	#define   WaitForWindowSemaphore()   WaitForWindowSema() 
	#define   ReleaseWindowSemaphore()   ReleaseWindowSema() 
 *	SendMessage to window of some thread,Post message to window  
 *	if the thread of window isn't current thread, else Sendmessage it. 
#undef   MwSendThdMessage 
#define  MwSendThdMessage(hw,pti,msg,wParam,lParam) \ 
		{									\ 
		if(GETPTI(hw) == pti)				 \ 
			SendMessage(hw,msg,(WPARAM)(wParam),(LPARAM)(lParam)); \ 
		else													\ 
#define UserAssert assert 
#define CheckCritIn() 
#define SET_TIME_LAST_READ(a) 
#define ReceiveMessages(pti) \ 
    while ((pti)->fsWakeBits & QS_SENDMESSAGE) { ReceiveMessage((pti)); } 
BOOL ReadPostMessage(PTHREADINFO pti, LPMSG lpMsg, PWND pwndFilter, 
        UINT msgMin, UINT msgMax, BOOL fRemoveMsg); 
void PostInputMessage(  
    PWND  pwnd, 
    UINT  message, 
    WPARAM wParam, 
    LPARAM lParam, 
    DWORD time, 
    ULONG_PTR dwExtraInfo); 
PQMSG AllocQEntry( PMLIST pml); 
void DelQEntry(PMLIST pml,PQMSG pqmsg); 
void StoreQMessage( 
    PQMSG pqmsg, 
    PWND  pwnd, 
    UINT  message, 
    WPARAM wParam, 
    LPARAM lParam, 
    DWORD time, 
    DWORD dwQEvent, 
    ULONG_PTR dwExtraInfo); 
#define GETPTI(a)		((a)->pti) 
void ClearThreadInputQueueEx(PTHREADINFO pti); 
VOID DestroyWindowMessages(HWND hWnd); 
void DestroyWindowMessage(HWND hWnd,DWORD nMessage,DWORD wParam,DWORD lParam); 
void InitSystemResource();//defined in readres.c 
void InitSystemBitmap();//defined in local.c 
 *	define structure for handle buffer of windows. 
#define		HWITEM_NUM	1000	 
typedef  struct _hwnditem  
	HWND				hWnd; 
	struct _hwnditem*	next; 
//	struct _hwnditem	prev; 
typedef  struct _hwndbuff  
	HWNDITEM	*pHead;	 
	HWNDITEM	*pFree;	 
  #ifdef     _DEBUG 
	DWORD		count; 
void	InitHwndBuff();   /*to initial ghWndBuff.*/ 
UINT	AddHwndItem(HWND hw); 
UINT	RemoveHwndItem(HWND hw); 
UINT	FindHwndItem(HWND hw); 
#endif //