dispdib.h 3.1 KB

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