ReactOS  0.4.14-dev-317-g96040ec
ghost.c File Reference
#include <user32.h>
#include <strsafe.h>
#include "ghostwnd.h"
Include dependency graph for ghost.c:

Go to the source code of this file.

Macros

#define GHOST_TIMER_ID   0xFACEDEAD
 
#define GHOST_INTERVAL   1000
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (ghost)
 
static HBITMAP IntCreate32BppBitmap (INT cx, INT cy)
 
static HBITMAP IntGetWindowBitmap (HWND hwnd, INT cx, INT cy)
 
static VOID IntMakeGhostImage (HBITMAP hbm)
 
static GHOST_DATAGhost_GetData (HWND hwnd)
 
static HWND Ghost_GetTarget (HWND hwnd)
 
static LPWSTR Ghost_GetText (HWND hwndTarget, INT *pcchTextW, INT cchExtra)
 
static BOOL Ghost_OnCreate (HWND hwnd, CREATESTRUCTW *lpcs)
 
static void Ghost_Unenchant (HWND hwnd, BOOL bDestroyTarget)
 
static void Ghost_OnDraw (HWND hwnd, HDC hdc)
 
static void Ghost_OnNCPaint (HWND hwnd, HRGN hrgn, BOOL bUnicode)
 
static void Ghost_OnPaint (HWND hwnd)
 
static void Ghost_OnMove (HWND hwnd, int x, int y)
 
static void Ghost_OnDestroy (HWND hwnd)
 
static void Ghost_DestroyTarget (GHOST_DATA *pData)
 
static void Ghost_OnNCDestroy (HWND hwnd)
 
static void Ghost_OnClose (HWND hwnd)
 
static void Ghost_OnTimer (HWND hwnd, UINT id)
 
static HICON Ghost_GetIcon (HWND hwnd, INT fType)
 
LRESULT WINAPI GhostWndProc_common (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL unicode)
 
LRESULT CALLBACK GhostWndProcA (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
LRESULT CALLBACK GhostWndProcW (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Variables

const struct builtin_class_descr GHOST_builtin_class
 

Macro Definition Documentation

◆ GHOST_INTERVAL

#define GHOST_INTERVAL   1000

Definition at line 15 of file ghost.c.

◆ GHOST_TIMER_ID

#define GHOST_TIMER_ID   0xFACEDEAD

Definition at line 14 of file ghost.c.

Function Documentation

◆ Ghost_DestroyTarget()

static void Ghost_DestroyTarget ( GHOST_DATA pData)
static

Definition at line 382 of file ghost.c.

383 {
384  HWND hwndTarget = pData->hwndTarget;
385  DWORD pid;
387 
388  pData->hwndTarget = NULL;
389  GetWindowThreadProcessId(hwndTarget, &pid);
390 
392  if (hProcess)
393  {
396  }
397 
398  DestroyWindow(hwndTarget);
399 }
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Definition: winddi.h:3835
#define CloseHandle
Definition: compat.h:398
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
BOOL WINAPI DestroyWindow(_In_ HWND)
DWORD WINAPI GetWindowThreadProcessId(HWND, PDWORD)
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1227
#define PROCESS_TERMINATE
Definition: pstypes.h:149
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
Definition: proc.c:1532
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827

Referenced by Ghost_OnNCDestroy().

◆ Ghost_GetData()

static GHOST_DATA* Ghost_GetData ( HWND  hwnd)
static

Definition at line 109 of file ghost.c.

110 {
112 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define GetWindowLongPtrW
Definition: winuser.h:4730
#define GWLP_USERDATA
Definition: treelist.c:63

Referenced by Ghost_GetIcon(), Ghost_GetTarget(), Ghost_OnDraw(), Ghost_OnNCDestroy(), Ghost_OnTimer(), and Ghost_Unenchant().

◆ Ghost_GetIcon()

static HICON Ghost_GetIcon ( HWND  hwnd,
INT  fType 
)
static

Definition at line 487 of file ghost.c.

488 {
490  HICON hIcon = NULL;
491 
492  if (!pData)
493  return NULL;
494 
495  // same as the original icon
496  switch (fType)
497  {
498  case ICON_BIG:
499  {
500  hIcon = (HICON)GetClassLongPtrW(pData->hwndTarget, GCLP_HICON);
501  break;
502  }
503 
504  case ICON_SMALL:
505  {
506  hIcon = (HICON)GetClassLongPtrW(pData->hwndTarget, GCLP_HICONSM);
507  break;
508  }
509  }
510 
511  return hIcon;
512 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
static HICON
Definition: imagelist.c:84
#define ICON_SMALL
Definition: tnclass.cpp:48
smooth NULL
Definition: ftsmooth.c:416
#define GCLP_HICONSM
Definition: winuser.h:670
#define GCLP_HICON
Definition: winuser.h:669
HICON hIcon
Definition: msconfig.c:44
static GHOST_DATA * Ghost_GetData(HWND hwnd)
Definition: ghost.c:109
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
#define GetClassLongPtrW
Definition: winuser.h:4465
#define ICON_BIG
Definition: tnclass.cpp:51

Referenced by GhostWndProc_common().

◆ Ghost_GetTarget()

static HWND Ghost_GetTarget ( HWND  hwnd)
static

Definition at line 115 of file ghost.c.

116 {
118  if (!pData)
119  return NULL;
120  return pData->hwndTarget;
121 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
smooth NULL
Definition: ftsmooth.c:416
static GHOST_DATA * Ghost_GetData(HWND hwnd)
Definition: ghost.c:109
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827

Referenced by Ghost_OnMove().

◆ Ghost_GetText()

static LPWSTR Ghost_GetText ( HWND  hwndTarget,
INT pcchTextW,
INT  cchExtra 
)
static

Definition at line 124 of file ghost.c.

125 {
126  LPWSTR pszTextW = NULL, pszTextNewW;
127  INT cchNonExtra, cchTextW = *pcchTextW;
128 
129  pszTextNewW = HeapAlloc(GetProcessHeap(), 0, cchTextW * sizeof(WCHAR));
130  for (;;)
131  {
132  if (!pszTextNewW)
133  {
134  ERR("HeapAlloc failed\n");
135  if (pszTextW)
136  HeapFree(GetProcessHeap(), 0, pszTextW);
137  return NULL;
138  }
139  pszTextW = pszTextNewW;
140 
141  cchNonExtra = cchTextW - cchExtra;
142  if (InternalGetWindowText(hwndTarget, pszTextW,
143  cchNonExtra) < cchNonExtra - 1)
144  {
145  break;
146  }
147 
148  cchTextW *= 2;
149  pszTextNewW = HeapReAlloc(GetProcessHeap(), 0, pszTextW,
150  cchTextW * sizeof(WCHAR));
151  }
152 
153  *pcchTextW = cchTextW;
154  return pszTextW;
155 }
int32_t INT
Definition: typedefs.h:56
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define ERR(fmt,...)
Definition: debug.h:109
INT WINAPI InternalGetWindowText(_In_ HWND hWnd, _Out_writes_to_(cchMaxCount, return+1) LPWSTR pString, _In_ int cchMaxCount)
#define HeapReAlloc
Definition: compat.h:393
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by Ghost_OnCreate().

◆ Ghost_OnClose()

static void Ghost_OnClose ( HWND  hwnd)
static

Definition at line 435 of file ghost.c.

436 {
437  INT id;
438  WCHAR szAskTerminate[128];
439  WCHAR szHungUpTitle[128];
440 
441  // stop timer
443 
445  szAskTerminate, ARRAYSIZE(szAskTerminate));
447  szHungUpTitle, ARRAYSIZE(szHungUpTitle));
448 
449  id = MessageBoxW(hwnd, szAskTerminate, szHungUpTitle,
451  if (id == IDYES)
452  {
453  // destroy the target
455  return;
456  }
457 
458  // restart timer
460 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
#define IDYES
Definition: winuser.h:829
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
HINSTANCE User32Instance
Definition: dllmain.c:27
int32_t INT
Definition: typedefs.h:56
#define MB_YESNO
Definition: winuser.h:811
#define GHOST_INTERVAL
Definition: ghost.c:15
smooth NULL
Definition: ftsmooth.c:416
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
__wchar_t WCHAR
Definition: xmlstorage.h:180
static void Ghost_Unenchant(HWND hwnd, BOOL bDestroyTarget)
Definition: ghost.c:298
#define MB_ICONINFORMATION
Definition: winuser.h:796
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define IDS_ASK_TERMINATE
Definition: resource.h:12
#define GHOST_TIMER_ID
Definition: ghost.c:14
#define IDS_HUNG_UP_TITLE
Definition: resource.h:13
GLenum GLuint id
Definition: glext.h:5579

Referenced by GhostWndProc_common().

◆ Ghost_OnCreate()

static BOOL Ghost_OnCreate ( HWND  hwnd,
CREATESTRUCTW lpcs 
)
static

Definition at line 158 of file ghost.c.

159 {
160  HBITMAP hbm32bpp;
161  HWND hwndTarget, hwndPrev;
162  GHOST_DATA *pData;
163  RECT rc;
164  DWORD style, exstyle;
165  WCHAR szTextW[320], szNotRespondingW[32];
166  LPWSTR pszTextW;
167  INT cchTextW, cchExtraW, cchNonExtraW;
168  PWND pWnd = ValidateHwnd(hwnd);
169  if (pWnd)
170  {
171  if (!pWnd->fnid)
172  {
174  }
175  else if (pWnd->fnid != FNID_GHOST)
176  {
177  ERR("Wrong window class for Ghost! fnId 0x%x\n", pWnd->fnid);
178  return FALSE;
179  }
180  }
181 
182  // get the target
183  hwndTarget = (HWND)lpcs->lpCreateParams;
184  if (!IsWindowVisible(hwndTarget) || // invisible?
185  (GetWindowLongPtrW(hwndTarget, GWL_STYLE) & WS_CHILD) || // child?
186  !IsHungAppWindow(hwndTarget)) // not hung?
187  {
188  return FALSE;
189  }
190 
191  // check prop
192  if (GetPropW(hwndTarget, GHOST_PROP))
193  return FALSE;
194 
195  // set prop
196  SetPropW(hwndTarget, GHOST_PROP, hwnd);
197 
198  // create user data
199  pData = HeapAlloc(GetProcessHeap(), 0, sizeof(GHOST_DATA));
200  if (!pData)
201  {
202  ERR("HeapAlloc failed\n");
203  return FALSE;
204  }
205 
206  // get window image
207  GetWindowRect(hwndTarget, &rc);
208  hbm32bpp = IntGetWindowBitmap(hwndTarget,
209  rc.right - rc.left,
210  rc.bottom - rc.top);
211  if (!hbm32bpp)
212  {
213  ERR("hbm32bpp was NULL\n");
215  return FALSE;
216  }
217  // make a ghost image
218  IntMakeGhostImage(hbm32bpp);
219 
220  // set user data
221  pData->hwndTarget = hwndTarget;
222  pData->hbm32bpp = hbm32bpp;
223  pData->bDestroyTarget = FALSE;
225 
226  // get style
227  style = GetWindowLongPtrW(hwndTarget, GWL_STYLE);
228  exstyle = GetWindowLongPtrW(hwndTarget, GWL_EXSTYLE);
229 
230  // get text
231  cchTextW = ARRAYSIZE(szTextW);
232  cchExtraW = ARRAYSIZE(szNotRespondingW);
233  cchNonExtraW = cchTextW - cchExtraW;
234  if (InternalGetWindowText(hwndTarget, szTextW,
235  cchNonExtraW) < cchNonExtraW - 1)
236  {
237  pszTextW = szTextW;
238  }
239  else
240  {
241  cchTextW *= 2;
242  pszTextW = Ghost_GetText(hwndTarget, &cchTextW, cchExtraW);
243  if (!pszTextW)
244  {
245  ERR("Ghost_GetText failed\n");
246  DeleteObject(hbm32bpp);
248  return FALSE;
249  }
250  }
251 
252  // don't use scrollbars.
254 
255  // set style
258 
259  // set text with " (Not Responding)"
261  szNotRespondingW, ARRAYSIZE(szNotRespondingW));
262  StringCchCatW(pszTextW, cchTextW, szNotRespondingW);
263  SetWindowTextW(hwnd, pszTextW);
264 
265  // free the text buffer
266  if (szTextW != pszTextW)
267  HeapFree(GetProcessHeap(), 0, pszTextW);
268 
269  // get previous window of target
270  hwndPrev = GetWindow(hwndTarget, GW_HWNDPREV);
271 
272  // hide target
273  ShowWindowAsync(hwndTarget, SW_HIDE);
274 
275  // shrink the ghost to zero size and insert.
276  // this will avoid effects.
277  SetWindowPos(hwnd, hwndPrev, 0, 0, 0, 0,
279  SWP_DRAWFRAME);
280 
281  // resume the position and size of ghost
282  MoveWindow(hwnd, rc.left, rc.top,
283  rc.right - rc.left, rc.bottom - rc.top, TRUE);
284 
285  // make ghost visible
287 
288  // redraw
290 
291  // start timer
293 
294  return TRUE;
295 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define SWP_DRAWFRAME
Definition: winuser.h:1224
#define TRUE
Definition: types.h:120
#define SW_HIDE
Definition: winuser.h:762
LONG top
Definition: windef.h:292
HANDLE HWND
Definition: compat.h:13
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define GWL_EXSTYLE
Definition: winuser.h:845
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
#define WS_CHILD
Definition: pedump.c:617
#define GetWindowLongPtrW
Definition: winuser.h:4730
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
static HBITMAP IntGetWindowBitmap(HWND hwnd, INT cx, INT cy)
Definition: ghost.c:53
static VOID IntMakeGhostImage(HBITMAP hbm)
Definition: ghost.c:84
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
HINSTANCE User32Instance
Definition: dllmain.c:27
int32_t INT
Definition: typedefs.h:56
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
BOOL WINAPI ShowWindowAsync(_In_ HWND, _In_ int)
DWORD fnid
Definition: ntuser.h:673
#define GHOST_INTERVAL
Definition: ghost.c:15
BOOL WINAPI IsHungAppWindow(HWND hwnd)
Definition: window.c:1872
#define GWLP_USERDATA
Definition: treelist.c:63
smooth NULL
Definition: ftsmooth.c:416
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
BOOL WINAPI SetPropW(_In_ HWND, _In_ LPCWSTR, _In_opt_ HANDLE)
if(!(yy_init))
Definition: macro.lex.yy.c:714
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SWP_NOACTIVATE
Definition: winuser.h:1227
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WS_HSCROLL
Definition: pedump.c:628
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
PWND FASTCALL ValidateHwnd(HWND hwnd)
Definition: misc.c:369
LPVOID lpCreateParams
Definition: winuser.h:2929
#define IDS_NOT_RESPONDING
Definition: resource.h:257
#define GHOST_PROP
Definition: ghostwnd.h:11
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
static LPWSTR Ghost_GetText(HWND hwndTarget, INT *pcchTextW, INT cchExtra)
Definition: ghost.c:124
#define ERR(fmt,...)
Definition: debug.h:109
#define GWL_STYLE
Definition: winuser.h:846
Definition: ntuser.h:657
#define FNID_GHOST
Definition: ntuser.h:837
INT WINAPI InternalGetWindowText(_In_ HWND hWnd, _Out_writes_to_(cchMaxCount, return+1) LPWSTR pString, _In_ int cchMaxCount)
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define WS_VSCROLL
Definition: pedump.c:627
HANDLE WINAPI GetPropW(_In_ HWND, _In_ LPCWSTR)
#define GHOST_TIMER_ID
Definition: ghost.c:14
BOOL WINAPI IsWindowVisible(_In_ HWND)
LONG bottom
Definition: windef.h:294
BOOL NTAPI NtUserSetWindowFNID(HWND hWnd, WORD fnID)
Definition: window.c:4122
#define SWP_NOMOVE
Definition: winuser.h:1229
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SetWindowLongPtrW
Definition: winuser.h:5247
static HBITMAP
Definition: button.c:44
WCHAR * LPWSTR
Definition: xmlstorage.h:184
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
Arabic default style
Definition: afstyles.h:93
#define WS_VISIBLE
Definition: pedump.c:620
#define GW_HWNDPREV
Definition: winuser.h:757
#define HeapFree(x, y, z)
Definition: compat.h:394
#define SWP_NOOWNERZORDER
Definition: winuser.h:1234

Referenced by GhostWndProc_common().

◆ Ghost_OnDestroy()

static void Ghost_OnDestroy ( HWND  hwnd)
static

Definition at line 376 of file ghost.c.

377 {
379 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define GHOST_TIMER_ID
Definition: ghost.c:14

Referenced by GhostWndProc_common().

◆ Ghost_OnDraw()

static void Ghost_OnDraw ( HWND  hwnd,
HDC  hdc 
)
static

Definition at line 309 of file ghost.c.

310 {
311  BITMAP bm;
312  HDC hdcMem;
314 
315  if (!pData || !GetObject(pData->hbm32bpp, sizeof(bm), &bm))
316  return;
317 
319  if (hdcMem)
320  {
321  HGDIOBJ hbmOld = SelectObject(hdcMem, pData->hbm32bpp);
322  BitBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight,
323  hdcMem, 0, 0, SRCCOPY | CAPTUREBLT);
324  SelectObject(hdcMem, hbmOld);
325  DeleteDC(hdcMem);
326  }
327 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
static VOID NTAPI BitBlt(IN ULONG Left, IN ULONG Top, IN ULONG Width, IN ULONG Height, IN PUCHAR Buffer, IN ULONG BitsPerPixel, IN ULONG Delta)
Definition: vga.c:410
#define GetObject
Definition: wingdi.h:4463
HDC hdc
Definition: main.c:9
BOOL WINAPI DeleteDC(_In_ HDC)
Definition: bl.h:1331
static GHOST_DATA * Ghost_GetData(HWND hwnd)
Definition: ghost.c:109
#define CAPTUREBLT
Definition: wingdi.h:1375
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
#define SRCCOPY
Definition: wingdi.h:332
HDC hdcMem
Definition: welcome.c:104

Referenced by Ghost_OnNCPaint(), and GhostWndProc_common().

◆ Ghost_OnMove()

static void Ghost_OnMove ( HWND  hwnd,
int  x,
int  y 
)
static

Definition at line 362 of file ghost.c.

363 {
364  RECT rc;
365  HWND hwndTarget = Ghost_GetTarget(hwnd);
366 
367  GetWindowRect(hwnd, &rc);
368 
369  // move the target
370  SetWindowPos(hwndTarget, NULL, rc.left, rc.top, 0, 0,
373 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
LONG top
Definition: windef.h:292
LONG left
Definition: windef.h:291
#define SWP_NOSENDCHANGING
Definition: winuser.h:1236
static HWND Ghost_GetTarget(HWND hwnd)
Definition: ghost.c:115
smooth NULL
Definition: ftsmooth.c:416
#define SWP_NOACTIVATE
Definition: winuser.h:1227
#define SWP_NOSIZE
Definition: winuser.h:1230
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SWP_NOOWNERZORDER
Definition: winuser.h:1234

Referenced by GhostWndProc_common().

◆ Ghost_OnNCDestroy()

static void Ghost_OnNCDestroy ( HWND  hwnd)
static

Definition at line 402 of file ghost.c.

403 {
404  // delete the user data
406  if (pData)
407  {
409 
410  // delete image
411  DeleteObject(pData->hbm32bpp);
412  pData->hbm32bpp = NULL;
413 
414  // remove prop
415  RemovePropW(pData->hwndTarget, GHOST_PROP);
416 
417  // show target
419 
420  // destroy target if necessary
421  if (pData->bDestroyTarget)
422  {
424  }
425 
427  }
428 
430 
431  PostQuitMessage(0);
432 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
static void Ghost_DestroyTarget(GHOST_DATA *pData)
Definition: ghost.c:382
#define SW_SHOWNOACTIVATE
Definition: winuser.h:768
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define FNID_DESTROY
Definition: ntuser.h:859
HANDLE WINAPI RemovePropW(_In_ HWND, _In_ LPCWSTR)
BOOL WINAPI ShowWindowAsync(_In_ HWND, _In_ int)
#define GWLP_USERDATA
Definition: treelist.c:63
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
#define GHOST_PROP
Definition: ghostwnd.h:11
static GHOST_DATA * Ghost_GetData(HWND hwnd)
Definition: ghost.c:109
BOOL NTAPI NtUserSetWindowFNID(HWND hWnd, WORD fnID)
Definition: window.c:4122
#define SetWindowLongPtrW
Definition: winuser.h:5247
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
#define HeapFree(x, y, z)
Definition: compat.h:394
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)

Referenced by GhostWndProc_common().

◆ Ghost_OnNCPaint()

static void Ghost_OnNCPaint ( HWND  hwnd,
HRGN  hrgn,
BOOL  bUnicode 
)
static

Definition at line 330 of file ghost.c.

331 {
332  HDC hdc;
333 
334  // do the default behaivour
335  if (bUnicode)
337  else
339 
340  // draw the ghost image
341  hdc = GetWindowDC(hwnd);
342  if (hdc)
343  {
345  ReleaseDC(hwnd, hdc);
346  }
347 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
static HDC
Definition: imagelist.c:92
UINT_PTR WPARAM
Definition: windef.h:207
static void Ghost_OnDraw(HWND hwnd, HDC hdc)
Definition: ghost.c:309
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_NCPAINT
Definition: winuser.h:1669
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC hdc
Definition: main.c:9
static HRGN hrgn
Definition: win.c:55
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HDC WINAPI GetWindowDC(_In_opt_ HWND)

Referenced by GhostWndProc_common().

◆ Ghost_OnPaint()

static void Ghost_OnPaint ( HWND  hwnd)
static

Definition at line 350 of file ghost.c.

351 {
352  PAINTSTRUCT ps;
353  HDC hdc = BeginPaint(hwnd, &ps);
354  if (hdc)
355  {
356  // don't draw at here
357  EndPaint(hwnd, &ps);
358  }
359 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
static HDC
Definition: imagelist.c:92
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
HDC hdc
Definition: main.c:9

Referenced by GhostWndProc_common().

◆ Ghost_OnTimer()

static void Ghost_OnTimer ( HWND  hwnd,
UINT  id 
)
static

Definition at line 463 of file ghost.c.

464 {
465  HWND hwndTarget;
467 
468  if (id != GHOST_TIMER_ID || !pData)
469  return;
470 
471  // stop the timer
472  KillTimer(hwnd, id);
473 
474  hwndTarget = pData->hwndTarget;
475  if (!IsWindow(hwndTarget) || !IsHungAppWindow(hwndTarget))
476  {
477  // resume if window is destroyed or responding
479  return;
480  }
481 
482  // restart the timer
484 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define GHOST_INTERVAL
Definition: ghost.c:15
BOOL WINAPI IsHungAppWindow(HWND hwnd)
Definition: window.c:1872
smooth NULL
Definition: ftsmooth.c:416
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
static void Ghost_Unenchant(HWND hwnd, BOOL bDestroyTarget)
Definition: ghost.c:298
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
static GHOST_DATA * Ghost_GetData(HWND hwnd)
Definition: ghost.c:109
#define GHOST_TIMER_ID
Definition: ghost.c:14
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827

Referenced by GhostWndProc_common().

◆ Ghost_Unenchant()

static void Ghost_Unenchant ( HWND  hwnd,
BOOL  bDestroyTarget 
)
static

Definition at line 298 of file ghost.c.

299 {
301  if (!pData)
302  return;
303 
304  pData->bDestroyTarget |= bDestroyTarget;
306 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
BOOL WINAPI DestroyWindow(_In_ HWND)
static GHOST_DATA * Ghost_GetData(HWND hwnd)
Definition: ghost.c:109
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827

Referenced by Ghost_OnClose(), Ghost_OnTimer(), and GhostWndProc_common().

◆ GhostWndProc_common()

LRESULT WINAPI GhostWndProc_common ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL  unicode 
)

Definition at line 515 of file ghost.c.

517 {
518  switch (uMsg)
519  {
520  case WM_CREATE:
522  return -1;
523  break;
524 
525  case WM_NCPAINT:
526  Ghost_OnNCPaint(hwnd, (HRGN)wParam, unicode);
527  return 0;
528 
529  case WM_ERASEBKGND:
531  return TRUE;
532 
533  case WM_PAINT:
535  break;
536 
537  case WM_MOVE:
539  break;
540 
541  case WM_SIZE:
542  break;
543 
544  case WM_SIZING:
545  return TRUE;
546 
547  case WM_SYSCOMMAND:
548  switch ((UINT)wParam)
549  {
550  case SC_MAXIMIZE:
551  case SC_SIZE:
552  // sizing-related
553  return 0;
554  }
555  if (unicode)
556  return DefWindowProcW(hwnd, uMsg, wParam, lParam);
557  else
558  return DefWindowProcA(hwnd, uMsg, wParam, lParam);
559 
560  case WM_CLOSE:
562  break;
563 
564  case WM_TIMER:
566  break;
567 
568  case WM_NCMOUSEMOVE:
569  if (unicode)
570  DefWindowProcW(hwnd, uMsg, wParam, lParam);
571  else
572  DefWindowProcA(hwnd, uMsg, wParam, lParam);
574  return 0;
575 
576  case WM_GETICON:
577  return (LRESULT)Ghost_GetIcon(hwnd, (INT)wParam);
578 
579  case WM_COMMAND:
580  if (LOWORD(wParam) == 3333)
582  break;
583 
584  case WM_DESTROY:
586  break;
587 
588  case WM_NCDESTROY:
590  break;
591 
592  default:
593  {
594  if (unicode)
595  return DefWindowProcW(hwnd, uMsg, wParam, lParam);
596  else
597  return DefWindowProcA(hwnd, uMsg, wParam, lParam);
598  }
599  }
600  return 0;
601 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
static void Ghost_OnNCPaint(HWND hwnd, HRGN hrgn, BOOL bUnicode)
Definition: ghost.c:330
static void Ghost_OnPaint(HWND hwnd)
Definition: ghost.c:350
static void Ghost_OnClose(HWND hwnd)
Definition: ghost.c:435
static HDC
Definition: imagelist.c:92
static BOOL Ghost_OnCreate(HWND hwnd, CREATESTRUCTW *lpcs)
Definition: ghost.c:158
#define WM_MOVE
Definition: winuser.h:1592
static void Ghost_OnDraw(HWND hwnd, HDC hdc)
Definition: ghost.c:309
int32_t INT
Definition: typedefs.h:56
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static void Ghost_OnNCDestroy(HWND hwnd)
Definition: ghost.c:402
#define WM_NCPAINT
Definition: winuser.h:1669
short SHORT
Definition: pedump.c:59
static void Ghost_OnMove(HWND hwnd, int x, int y)
Definition: ghost.c:362
#define SC_MAXIMIZE
Definition: winuser.h:2563
#define WM_SIZING
Definition: winuser.h:1789
smooth NULL
Definition: ftsmooth.c:416
#define IDC_WAIT
Definition: winuser.h:684
#define WM_DESTROY
Definition: winuser.h:1591
static HICON Ghost_GetIcon(HWND hwnd, INT fType)
Definition: ghost.c:487
#define WM_SIZE
Definition: winuser.h:1593
#define WM_TIMER
Definition: winuser.h:1724
#define WM_CLOSE
Definition: winuser.h:1603
#define WM_NCDESTROY
Definition: winuser.h:1666
static void Ghost_Unenchant(HWND hwnd, BOOL bDestroyTarget)
Definition: ghost.c:298
static void Ghost_OnTimer(HWND hwnd, UINT id)
Definition: ghost.c:463
#define WM_PAINT
Definition: winuser.h:1602
#define WM_COMMAND
Definition: winuser.h:1722
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define LoadCursor
Definition: winuser.h:5713
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define SC_SIZE
Definition: winuser.h:2559
unsigned int UINT
Definition: ndis.h:50
#define WM_CREATE
Definition: winuser.h:1590
#define HIWORD(l)
Definition: typedefs.h:246
#define WM_ERASEBKGND
Definition: winuser.h:1607
LONG_PTR LRESULT
Definition: windef.h:209
static void Ghost_OnDestroy(HWND hwnd)
Definition: ghost.c:376
#define WM_SYSCOMMAND
Definition: winuser.h:1723
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define WM_NCMOUSEMOVE
Definition: winuser.h:1673

Referenced by GhostWndProcA(), GhostWndProcW(), and RegisterClientPFN().

◆ GhostWndProcA()

LRESULT CALLBACK GhostWndProcA ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 604 of file ghost.c.

605 {
606  return GhostWndProc_common(hwnd, uMsg, wParam, lParam, FALSE);
607 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
LRESULT WINAPI GhostWndProc_common(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL unicode)
Definition: ghost.c:515
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139

Referenced by RegisterClientPFN().

◆ GhostWndProcW()

LRESULT CALLBACK GhostWndProcW ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 610 of file ghost.c.

611 {
612  return GhostWndProc_common(hwnd, uMsg, wParam, lParam, TRUE);
613 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
LRESULT WINAPI GhostWndProc_common(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL unicode)
Definition: ghost.c:515
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139

Referenced by RegisterClientPFN().

◆ IntCreate32BppBitmap()

static HBITMAP IntCreate32BppBitmap ( INT  cx,
INT  cy 
)
static

Definition at line 29 of file ghost.c.

30 {
31  HBITMAP hbm = NULL;
32  BITMAPINFO bi;
33  HDC hdc;
34  LPVOID pvBits;
35 
36  ZeroMemory(&bi, sizeof(bi));
37  bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
38  bi.bmiHeader.biWidth = cx;
39  bi.bmiHeader.biHeight = cy;
40  bi.bmiHeader.biPlanes = 1;
41  bi.bmiHeader.biBitCount = 32;
42 
44  if (hdc)
45  {
46  hbm = CreateDIBSection(hdc, &bi, DIB_RGB_COLORS, &pvBits, NULL, 0);
47  DeleteDC(hdc);
48  }
49  return hbm;
50 }
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1471
struct tagBITMAPINFOHEADER BITMAPINFOHEADER
static HDC
Definition: imagelist.c:92
#define ZeroMemory
Definition: winbase.h:1642
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:581
smooth NULL
Definition: ftsmooth.c:416
HDC hdc
Definition: main.c:9
BOOL WINAPI DeleteDC(_In_ HDC)
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:197
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
_Out_opt_ int * cx
Definition: commctrl.h:581
static HBITMAP
Definition: button.c:44
#define DIB_RGB_COLORS
Definition: wingdi.h:366

Referenced by IntGetWindowBitmap().

◆ IntGetWindowBitmap()

static HBITMAP IntGetWindowBitmap ( HWND  hwnd,
INT  cx,
INT  cy 
)
static

Definition at line 53 of file ghost.c.

54 {
55  HBITMAP hbm = NULL;
56  HDC hdc, hdcMem;
57  HGDIOBJ hbmOld;
58 
59  hdc = GetWindowDC(hwnd);
60  if (!hdc)
61  return NULL;
62 
64  if (!hdcMem)
65  goto earth;
66 
68  if (hbm)
69  {
70  hbmOld = SelectObject(hdcMem, hbm);
71  BitBlt(hdcMem, 0, 0, cx, cy, hdc, 0, 0, SRCCOPY | CAPTUREBLT);
72  SelectObject(hdcMem, hbmOld);
73  }
74 
76 
77 earth:
78  ReleaseDC(hwnd, hdc);
79 
80  return hbm;
81 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
static VOID NTAPI BitBlt(IN ULONG Left, IN ULONG Top, IN ULONG Width, IN ULONG Height, IN PUCHAR Buffer, IN ULONG BitsPerPixel, IN ULONG Delta)
Definition: vga.c:410
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:581
smooth NULL
Definition: ftsmooth.c:416
HDC hdc
Definition: main.c:9
BOOL WINAPI DeleteDC(_In_ HDC)
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
HDC WINAPI GetWindowDC(_In_opt_ HWND)
_Out_opt_ int * cx
Definition: commctrl.h:581
#define CAPTUREBLT
Definition: wingdi.h:1375
static HBITMAP
Definition: button.c:44
static HBITMAP IntCreate32BppBitmap(INT cx, INT cy)
Definition: ghost.c:29
#define SRCCOPY
Definition: wingdi.h:332
HDC hdcMem
Definition: welcome.c:104

Referenced by Ghost_OnCreate().

◆ IntMakeGhostImage()

static VOID IntMakeGhostImage ( HBITMAP  hbm)
static

Definition at line 84 of file ghost.c.

85 {
86  BITMAP bm;
87  DWORD i, *pdw;
88 
89  GetObject(hbm, sizeof(bm), &bm);
90 
91  if (bm.bmBitsPixel != 32 || !bm.bmBits)
92  {
93  ERR("bm.bmBitsPixel == %d, bm.bmBits == %p\n",
94  bm.bmBitsPixel, bm.bmBits);
95  return;
96  }
97 
98  pdw = bm.bmBits;
99  for (i = 0; i < bm.bmWidth * bm.bmHeight; ++i)
100  {
101  *pdw = *pdw | 0x00C0C0C0; // bitwise-OR with ARGB #C0C0C0
102  ++pdw;
103  }
104 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned long DWORD
Definition: ntddk_ex.h:95
#define GetObject
Definition: wingdi.h:4463
#define ERR(fmt,...)
Definition: debug.h:109
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
Definition: bl.h:1331

Referenced by Ghost_OnCreate().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( ghost  )

Variable Documentation

◆ GHOST_builtin_class

const struct builtin_class_descr GHOST_builtin_class
Initial value:
=
{
L"Ghost",
0,
0,
}
LRESULT CALLBACK GhostWndProcW(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: ghost.c:610
smooth NULL
Definition: ftsmooth.c:416
#define IDC_WAIT
Definition: winuser.h:684
LRESULT CALLBACK GhostWndProcA(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: ghost.c:604
static const WCHAR L[]
Definition: oid.c:1250

Definition at line 17 of file ghost.c.