1 /**
2  * This file has no copyright assigned and is placed in the Public Domain.
3  * This file is part of the mingw-w64 runtime package.
4  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5  */
6 #ifndef __DISPDIB_H__
7 #define __DISPDIB_H__
8 
9 #define DISPLAYDIB_NOERROR 0x0000
10 #define DISPLAYDIB_NOTSUPPORTED 0x0001
11 #define DISPLAYDIB_INVALIDDIB 0x0002
12 #define DISPLAYDIB_INVALIDFORMAT 0x0003
13 #define DISPLAYDIB_INVALIDTASK 0x0004
14 #define DISPLAYDIB_STOP 0x0005
15 #define DISPLAYDIB_NOTACTIVE 0x0006
16 #define DISPLAYDIB_BADSIZE 0x0007
17 
18 #define DISPLAYDIB_NOPALETTE 0x0010
19 #define DISPLAYDIB_NOCENTER 0x0020
20 #define DISPLAYDIB_NOWAIT 0x0040
21 #define DISPLAYDIB_NOIMAGE 0x0080
22 #define DISPLAYDIB_ZOOM2 0x0100
23 #define DISPLAYDIB_DONTLOCKTASK 0x0200
24 #define DISPLAYDIB_TEST 0x0400
25 #define DISPLAYDIB_NOFLIP 0x0800
26 #define DISPLAYDIB_BEGIN 0x8000
27 #define DISPLAYDIB_END 0x4000
28 
29 #define DISPLAYDIB_MODE 0x000F
30 #define DISPLAYDIB_MODE_DEFAULT 0x0000
31 #define DISPLAYDIB_MODE_320x200x8 0x0001
32 #define DISPLAYDIB_MODE_320x240x8 0x0005
33 
34 #define DISPLAYDIB_WINDOW_CLASS "DisplayDibWindow"
35 #define DISPLAYDIB_DLL "DISPDIB.DLL"
36 
37 #define DDM_SETFMT WM_USER+0
38 #define DDM_DRAW WM_USER+1
39 #define DDM_CLOSE WM_USER+2
40 #define DDM_BEGIN WM_USER+3
41 #define DDM_END WM_USER+4
42 
DisplayDibWindowMessage(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam,DWORD cbSize)43 static __inline UINT DisplayDibWindowMessage(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam,DWORD cbSize) {
44   COPYDATASTRUCT cds;
45   cds.dwData = MAKELONG(msg,wParam);
46   cds.cbData = lParam ? cbSize : 0;
47   cds.lpData = (LPVOID)lParam;
48   return (UINT)SendMessage(hwnd,WM_COPYDATA,(WPARAM)(HWND)NULL,(LPARAM)(LPVOID)&cds);
49 }
50 
DisplayDibWindowCreateEx(HWND hwndParent,HINSTANCE hInstance,DWORD dwStyle)51 static __inline HWND DisplayDibWindowCreateEx(HWND hwndParent,HINSTANCE hInstance,DWORD dwStyle) {
52   DWORD show = 2;
53   DWORD zero = 0;
54   LPVOID params[4] = {NULL,&zero,&show,0};
55   if((UINT)LoadModule(DISPLAYDIB_DLL,&params) < (UINT)HINSTANCE_ERROR) return NULL;
56   return CreateWindow(DISPLAYDIB_WINDOW_CLASS,"",dwStyle,0,0,GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYSCREEN),hwndParent,NULL,(hInstance ? hInstance : GetWindowInstance(hwndParent)),NULL);
57 }
58 
59 #define DisplayDibWindowCreate(hwndP,hInstance) DisplayDibWindowCreateEx(hwndP,hInstance,WS_POPUP)
60 #define DisplayDibWindowSetFmt(hwnd,lpbi) DisplayDibWindowMessage(hwnd,DDM_SETFMT,0,(LPARAM)(LPVOID)(lpbi),sizeof(BITMAPINFOHEADER) + 256 *sizeof(RGBQUAD))
61 #define DisplayDibWindowDraw(hwnd,flags,bits,size) DisplayDibWindowMessage(hwnd,DDM_DRAW,(WPARAM)(UINT)(flags),(LPARAM)(LPVOID)(bits),(DWORD)(size))
62 
63 #ifdef __cplusplus
64 #define DisplayDibWindowBegin(hwnd) ::ShowWindow(hwnd,SW_SHOWNORMAL)
65 #define DisplayDibWindowEnd(hwnd) ::ShowWindow(hwnd,SW_HIDE)
66 #define DisplayDibWindowBeginEx(hwnd,f) ::SendMessage(hwnd,DDM_BEGIN,(WPARAM)(UINT)(f),0)
67 #define DisplayDibWindowEndEx(hwnd) ::SendMessage(hwnd,DDM_END,0,0)
68 #define DisplayDibWindowClose(hwnd) ::SendMessage(hwnd,DDM_CLOSE,0,0)
69 #else
70 #define DisplayDibWindowBegin(hwnd) ShowWindow(hwnd,SW_SHOWNORMAL)
71 #define DisplayDibWindowEnd(hwnd) ShowWindow(hwnd,SW_HIDE)
72 #define DisplayDibWindowBeginEx(hwnd) SendMessage(hwnd,DDM_BEGIN,0,0)
73 #define DisplayDibWindowEndEx(hwnd) SendMessage(hwnd,DDM_END,0,0)
74 #define DisplayDibWindowClose(hwnd) SendMessage(hwnd,DDM_CLOSE,0,0)
75 #endif
76 #endif
77