- Rename WIN_Handle16 to HWDN_16 and make it a macro.
[wine] / include / win.h
1 /*
2  * Window definitions
3  *
4  * Copyright 1993 Alexandre Julliard
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #ifndef __WINE_WIN_H
22 #define __WINE_WIN_H
23
24 #include "windef.h"
25 #include "winbase.h"
26 #include "wingdi.h"
27 #include "winproc.h"
28 #include "winuser.h"
29 #include "wine/windef16.h"
30
31 #include "user.h"
32
33 #define WND_MAGIC     0x444e4957  /* 'WIND' */
34
35 struct tagCLASS;
36 struct tagDCE;
37 struct tagMESSAGEQUEUE;
38
39 typedef struct tagWND
40 {
41     HWND           hwndSelf;      /* Handle of this window */
42     HWND           parent;        /* Window parent */
43     HWND           owner;         /* Window owner */
44     struct tagCLASS *class;       /* Window class */
45     HWINDOWPROC    winproc;       /* Window procedure */
46     DWORD          dwMagic;       /* Magic number (must be WND_MAGIC) */
47     DWORD          tid;           /* Owner thread id */
48     HINSTANCE    hInstance;     /* Window hInstance (from CreateWindow) */
49     RECT         rectClient;    /* Client area rel. to parent client area */
50     RECT         rectWindow;    /* Whole window rel. to parent client area */
51     LPWSTR        text;           /* Window text */
52     void          *pVScroll;      /* Vertical scroll-bar info */
53     void          *pHScroll;      /* Horizontal scroll-bar info */
54     struct tagDCE *dce;           /* Window DCE (if CS_OWNDC or CS_CLASSDC) */
55     HGLOBAL16      hmemTaskQ;     /* Task queue global memory handle */
56     HRGN           hrgnUpdate;    /* Update region */
57     HRGN           hrgnWnd;       /* window's region */
58     HWND           hwndLastActive;/* Last active popup hwnd */
59     DWORD          dwStyle;       /* Window style (from CreateWindow) */
60     DWORD          dwExStyle;     /* Extended style (from CreateWindowEx) */
61     DWORD          clsStyle;      /* Class style at window creation */
62     UINT           wIDmenu;       /* ID or hmenu (from CreateWindow) */
63     DWORD          helpContext;   /* Help context ID */
64     UINT           flags;         /* Misc. flags (see below) */
65     HMENU16        hSysMenu;      /* window's copy of System Menu */
66     int            cbWndExtra;    /* class cbWndExtra at window creation */
67     int            irefCount;     /* window's reference count*/
68     DWORD          userdata;      /* User private data */
69     void          *pDriverData;   /* Window driver data */
70     DWORD          wExtra[1];     /* Window extra bytes */
71 } WND;
72
73 typedef struct
74 {
75     RECT16         rectNormal;
76     POINT16        ptIconPos;
77     POINT16        ptMaxPos;
78     HWND           hwndIconTitle;
79 } INTERNALPOS, *LPINTERNALPOS;
80
81   /* WND flags values */
82 #define WIN_NEEDS_BEGINPAINT   0x0001 /* WM_PAINT sent to window */
83 #define WIN_NEEDS_ERASEBKGND   0x0002 /* WM_ERASEBKGND must be sent to window*/
84 #define WIN_NEEDS_NCPAINT      0x0004 /* WM_NCPAINT must be sent to window */
85 #define WIN_RESTORE_MAX        0x0008 /* Maximize when restoring */
86 #define WIN_INTERNAL_PAINT     0x0010 /* Internal WM_PAINT message pending */
87 #define WIN_NEED_SIZE          0x0040 /* Internal WM_SIZE is needed */
88 #define WIN_NCACTIVATED        0x0080 /* last WM_NCACTIVATE was positive */
89 #define WIN_ISDIALOG           0x0200 /* Window is a dialog */
90 #define WIN_ISWIN32            0x0400 /* Understands Win32 messages */
91 #define WIN_NEEDS_SHOW_OWNEDPOPUP 0x0800 /* WM_SHOWWINDOW:SC_SHOW must be sent in the next ShowOwnedPopup call */
92 #define WIN_NEEDS_INTERNALSOP  0x1000 /* Window was hidden by WIN_InternalShowOwnedPopups */
93
94   /* Window functions */
95 extern WND *WIN_GetPtr( HWND hwnd );
96 extern int    WIN_SuspendWndsLock( void );
97 extern void   WIN_RestoreWndsLock(int ipreviousLock);
98 extern WND*   WIN_FindWndPtr( HWND hwnd );
99 extern void   WIN_ReleaseWndPtr(WND *wndPtr);
100 extern HWND WIN_Handle32( HWND16 hwnd16 );
101 extern HWND WIN_IsCurrentProcess( HWND hwnd );
102 extern HWND WIN_IsCurrentThread( HWND hwnd );
103 extern void WIN_LinkWindow( HWND hwnd, HWND parent, HWND hwndInsertAfter );
104 extern void WIN_UnlinkWindow( HWND hwnd );
105 extern void WIN_SetOwner( HWND hwnd, HWND owner );
106 extern LONG WIN_SetStyle( HWND hwnd, LONG style );
107 extern LONG WIN_SetExStyle( HWND hwnd, LONG style );
108 extern void WIN_SetRectangles( HWND hwnd, const RECT *rectWindow, const RECT *rectClient );
109 extern BOOL WIN_GetRectangles( HWND hwnd, RECT *rectWindow, RECT *rectClient );
110 extern LRESULT WIN_DestroyWindow( HWND hwnd );
111 extern void WIN_DestroyThreadWindows( HWND hwnd );
112 extern BOOL WIN_CreateDesktopWindow(void);
113 extern BOOL WIN_IsWindowDrawable( HWND hwnd, BOOL );
114 extern HWND *WIN_ListParents( HWND hwnd );
115 extern HWND *WIN_ListChildren( HWND hwnd );
116 extern BOOL WIN_InternalShowOwnedPopups( HWND owner, BOOL fShow, BOOL unmanagedOnly );
117
118 inline static HWND WIN_GetFullHandle( HWND hwnd )
119 {
120     if (!HIWORD(hwnd) && hwnd) hwnd = WIN_Handle32( LOWORD(hwnd) );
121     return hwnd;
122 }
123
124 #define HWND_16(hwnd32)   (LOWORD(hwnd32))
125 #define HWND_32(hwnd16)   ((HWND)(ULONG_PTR)(hwnd16))
126
127 inline static WND *WIN_FindWndPtr16( HWND16 hwnd )
128 {
129     /* don't bother with full conversion */
130     return WIN_FindWndPtr( (HWND)(ULONG_PTR)hwnd );
131 }
132
133 /* to release pointers retrieved by WIN_GetPtr; do not confuse with WIN_ReleaseWndPtr!! */
134 inline static void WIN_ReleasePtr( WND *ptr )
135 {
136     USER_Unlock();
137 }
138
139 #define WND_OTHER_PROCESS ((WND *)1)  /* returned by WIN_GetPtr on unknown window handles */
140
141 extern HWND CARET_GetHwnd(void);
142 extern void CARET_GetRect(LPRECT lprc);  /* windows/caret.c */
143
144 extern BOOL16 DRAG_QueryUpdate( HWND, SEGPTR, BOOL );
145 extern HBRUSH DEFWND_ControlColor( HDC hDC, UINT ctlType );  /* windows/defwnd.c */
146
147 /* Classes functions */
148 struct tagCLASS;  /* opaque structure */
149 struct builtin_class_descr;
150 extern ATOM CLASS_RegisterBuiltinClass( const struct builtin_class_descr *descr );
151 extern struct tagCLASS *CLASS_AddWindow( ATOM atom, HINSTANCE inst, WINDOWPROCTYPE type,
152                                          INT *winExtra, WNDPROC *winproc,
153                                          DWORD *style, struct tagDCE **dce );
154 extern void CLASS_RemoveWindow( struct tagCLASS *cls );
155 extern void CLASS_FreeModuleClasses( HMODULE16 hModule );
156
157 /* windows/focus.c */
158 extern void FOCUS_SwitchFocus( struct tagMESSAGEQUEUE *pMsgQ, HWND , HWND );
159
160 #endif  /* __WINE_WIN_H */