Esempio n. 1
0
static
LRESULT
CALLBACK
WndProc(
    _In_ HWND hWnd,
    _In_ UINT message,
    _In_ WPARAM wParam,
    _In_ LPARAM lParam)
{
    HWND hTest;
    int iwnd = get_iwnd(hWnd, TRUE);

    ok(GetCurrentThreadId() == dwThreadId, "Thread 0x%lx instead of 0x%lx\n", GetCurrentThreadId(), dwThreadId);
    if (message > WM_USER || IsDWmMsg(message) || IseKeyMsg(message))
        return DefWindowProcW(hWnd, message, wParam, lParam);

    RECORD_MESSAGE(iwnd, message, SENT, wParam, lParam);

    switch(message)
    {
    case WM_DESTROY:
        if (GetParent(hWnd))
        {
            /* child window */
            ok(EnumThreadWindows(dwThreadId, EnumProc, (LPARAM)hWnd), "Child window %p (%d) enumerated\n", hWnd, iwnd);
            ok(!EnumChildWindows(GetParent(hWnd), EnumProc, (LPARAM)hWnd), "Child window %p (%d) not enumerated\n", hWnd, iwnd);
            ok(!EnumThreadWindows(dwThreadId, EnumProc, (LPARAM)GetParent(hWnd)), "Parent window of %p (%d) not enumerated\n", hWnd, iwnd);
        }
        else
        {
            /* top-level window */
            ok(!EnumThreadWindows(dwThreadId, EnumProc, (LPARAM)hWnd), "Window %p (%d) not enumerated in WM_DESTROY\n", hWnd, iwnd);
        }
        if (hWnd == hWndList[3])
        {
            hTest = SetParent(hWndList[4], hWndList[2]);
            ok_hwnd(hTest, hWndList[1]);
            hTest = SetParent(hWndList[5], hWndList[1]);
            ok_hwnd(hTest, hWndList[2]);

            ok_hwnd(GetParent(hWndList[1]), NULL);
            ok_hwnd(GetParent(hWndList[2]), NULL);
            ok_hwnd(GetParent(hWndList[3]), hWndList[1]);
            ok_hwnd(GetParent(hWndList[4]), hWndList[2]);
            ok_hwnd(GetParent(hWndList[5]), hWndList[1]);
        }
        break;
    }

    return DefWindowProcW(hWnd, message, wParam, lParam);
}
Esempio n. 2
0
void CMainFrame::OnEndSession (BOOL bEnding)
{

// If we are running as a service, then do not end the program at logoff
// Instead, just remove the icon from the system tray.

	if (NTSERVICENAME[0] ||
	    (WINDOWS95_SERVICE && WM_ENDSESSION_LPARAM && isWindows95 ())) {
		if (TRAY_ICON) {
			((CPrime95App *)AfxGetApp())->TrayMessage (NIM_DELETE, NULL, 0);
			WINDOWS95_TRAY_ADD = 1;
		}

// In addition a Windows NT service must take special actions.  MFC was
// not designed to be used in a NT service as it uses Global Atoms which are
// cleared at logoff.  This fix from knowledge base article Q164166 seems
// to fix the problem.

		if (NTSERVICENAME[0]) {
			DWORD	dwProcessId, dwThreadId;
			dwThreadId = GetWindowThreadProcessId (m_hWnd, &dwProcessId);
			EnumThreadWindows (dwThreadId, EnumProc, (LPARAM) dwThreadId);
		}
	}

// If we aren't running as a service, just do normal processing

	else
		CMDIFrameWnd::OnEndSession (bEnding);
}
Esempio n. 3
0
EXPORT LONG
SetIME(LPCSTR pwszKLID) {
  HMODULE hDllUser32;

  hDllUser32 = LoadLibrary("user32");
  if (hDllUser32)
  {
    HKL (WINAPI *pfnLoadKeyboardLayout)(LPCSTR, UINT);

    pfnLoadKeyboardLayout = (HKL (WINAPI *)(LPCSTR, UINT)) GetProcAddress(hDllUser32, "LoadKeyboardLayoutW");

    if (pfnLoadKeyboardLayout)
    {
      HWND hTop = NULL;
      DWORD dwThreadID;

      dwThreadID = GetCurrentThreadId();
      EnumThreadWindows(dwThreadID, FindWindowProc, (LPARAM)&hTop);

      if (hTop)
      {
        HKL kLayout = NULL;
        SetWindowLong(hTop, GWL_EXSTYLE, GetWindowLong(hTop, GWL_EXSTYLE) | WS_EX_LAYERED);
        kLayout = pfnLoadKeyboardLayout(pwszKLID, 1);
        SendMessage(hTop, WM_INPUTLANGCHANGEREQUEST, SC_RESTORE, (LPARAM)&kLayout);
      }
    }
    FreeLibrary(hDllUser32);
  }
  return GetLastError();
}
Esempio n. 4
0
LRESULT CALLBACK CBaseTrayIcon::WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  CBaseTrayIcon *icon = (CBaseTrayIcon *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
  switch(uMsg) {
  case WM_DESTROY:
    PostQuitMessage(0);
    break;
  case MSG_QUIT:
    DestroyWindow(hwnd);
    break;
  case MSG_TRAYICON:
    {
      UINT trayMsg = LOWORD(lParam);
      if (icon) {
        switch (trayMsg) {
        case WM_LBUTTONUP:
          if (!icon->m_bPropPageOpen) {
            icon->m_bPropPageOpen = TRUE;
            RECT desktopRect;
            GetWindowRect(GetDesktopWindow(), &desktopRect);
            SetWindowPos(icon->m_hWnd, 0, (desktopRect.right / 2) - PROP_WIDTH_OFFSET, (desktopRect.bottom / 2) - PROP_HEIGHT_OFFSET, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
            CBaseDSPropPage::ShowPropPageDialog(icon->m_pFilter, icon->m_hWnd);
            icon->m_bPropPageOpen = FALSE;
          } else {
            EnumThreadWindows(GetCurrentThreadId(), enumWindowCallback, (LPARAM)icon->m_hWnd);
          }
          break;
        }
      }
    }
    break;
  }
  return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
HWND FindHandle(DWORD dwThreadId, string wdwClass, long x, long y) 
{

	int size,cnt=0;
	string str;
	char buffer[256]={0};
	HWND handle;
	EnumThreadWindows(dwThreadId,EnumThreadWndProc,(LPARAM) &handle);
	do {
		if (GetParent(handle)!=NULL && GetParent(handle)!=handle && GetParent(handle)!=GetDesktopWindow() )
			handle = GetParent(handle);
		else 
			break;
	} while (true); 

	POINT Point;
	Point.x = x;
	Point.y = y;

	handle = ChildWindowFromPoint(handle,Point);
	if (handle!=NULL) { 
 		GetClassName(handle,buffer,256); 
		if (StrCmpNI(buffer,wdwClass.c_str(),wdwClass.length())==0) {
			return handle;
		}
	}	
	return 0;
}
BOOL	CWinampScrobbler::StartScrobbling(HINSTANCE hInstance, 
										  HWND hWndWinamp, 
										  HWND hWndWinampML, 
										  CStdString strWorkingDir)
{
	if ( ( hWndWinamp != NULL) &&
		   ( ::IsWindow(hWndWinamp)) )
	{
		m_hWndWinamp		= hWndWinamp;
		m_hWndWinampML		= hWndWinampML;
		
		m_Controller.Init(FALSE, hWndWinamp, hWndWinampML);
		
		BOOL bRet =  CScrobbler::StartScrobbling(strWorkingDir, hInstance);

        EnumThreadWindows( GetCurrentThreadId(), CWinampScrobbler::enumWndProc, (LPARAM)this );

        if( m_bootstrap.bootStrapRequired() )
        {
            PRINTF(DEBUG_FLOW,
                "CWinampScrobbler::StartScrobbling", "Bootstrap is required" );

            m_bootstrap.setParentHwnd( m_mainWinAmpWnd );
            m_bootstrap.sethWndWinampML( m_hWndWinampML );
            m_bootstrap.setScrobSub( m_Submitter );
            m_bootstrap.setModuleHandle( hInstance );
            m_bootstrap.startBootStrap();
        }
        

		return bRet;
	}

	return FALSE;
} 
Esempio n. 7
0
void TEnumWindows::EnumWindows (TEnumMethod em)
{
  LPARAM  lParam = reinterpret_cast<LPARAM> (this);

  mDoingChildWindows = (em == emTopLevelWindows);

  EnumThreadWindows (GetCurrentThreadId(), WndEnumProc, lParam);
}
Esempio n. 8
0
HWND FindThreadWindow(DWORD threadId, wchar_t *windowClass)
{ 
    struct EnumWindowsArg arg;
    arg.windowClass = windowClass;
    arg.foundWindow = NULL;

    EnumThreadWindows(threadId, findChildWindowProc, reinterpret_cast<LPARAM>(&arg));
    return arg.foundWindow;
}
Esempio n. 9
0
static unsigned mbModalFlag(void)
{
  BOOL has = FALSE;
  if (!(HIWORD(GetVersion()) & 0x8000))   // NT can always open task modal
	  return MB_TASKMODAL;
  EnumThreadWindows(GetCurrentThreadId(), (WNDENUMPROC)threadHasWnd,
                    (LPARAM)&has);
  return has ? MB_TASKMODAL : MB_SYSTEMMODAL;
}
Esempio n. 10
0
static Bool
winInstallColormapShadowGDI (ColormapPtr pColormap)
{
  ScreenPtr		pScreen = pColormap->pScreen;
  winScreenPriv(pScreen);
  winScreenInfo		*pScreenInfo = pScreenPriv->pScreenInfo;
  winCmapPriv(pColormap);

  /*
   * Tell Windows to install the new colormap
   */
  if (SelectPalette (pScreenPriv->hdcScreen,
		     pCmapPriv->hPalette,
		     FALSE) == NULL)
    {
      ErrorF ("winInstallColormapShadowGDI - SelectPalette () failed\n");
      return FALSE;
    }
      
  /* Realize the palette */
  if (GDI_ERROR == RealizePalette (pScreenPriv->hdcScreen))
    {
      ErrorF ("winInstallColormapShadowGDI - RealizePalette () failed\n");
      return FALSE;
    }

  /* Set the DIB color table */
  if (SetDIBColorTable (pScreenPriv->hdcShadow,
			0,
			WIN_NUM_PALETTE_ENTRIES,
			pCmapPriv->rgbColors) == 0)
    {
      ErrorF ("winInstallColormapShadowGDI - SetDIBColorTable () failed\n");
      return FALSE;
    }

  /* Redraw the whole window, to take account for the new colors */
  BitBlt (pScreenPriv->hdcScreen,
	  0, 0,
	  pScreenInfo->dwWidth, pScreenInfo->dwHeight,
	  pScreenPriv->hdcShadow,
	  0, 0,
	  SRCCOPY);

  /* Save a pointer to the newly installed colormap */
  pScreenPriv->pcmapInstalled = pColormap;

#ifdef XWIN_MULTIWINDOW
  /* Redraw all windows */
  if (pScreenInfo->fMultiWindow)
    EnumThreadWindows (g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0);
#endif

  return TRUE;
}
extern "C" BOOL
APIENTRY DllMain(
    PVOID hModule,
    ULONG ulReason,
    PCONTEXT pctx
    )
{
	char pszBuffer[ 10 ], pszModuleName[ MAX_PATH ];
	BOOL fResult = TRUE;
	// DLL is instantiated.
  if ( ulReason == DLL_PROCESS_ATTACH )
	{
		GetModuleFileName( NULL, pszModuleName, sizeof( pszModuleName ) );
		if( strstr( _strupr( pszModuleName ), ATTACH_PROCESS_NAME ) ) 
		//if we are attaching to Visual C++ process
		{
			hDebug = _lcreat(	"d:\\debug.txt", 0 ); //temporary
			pszStatus[0] = '\0';

			DWORD nThreadID = GetCurrentThreadId();
			EnumThreadWindows( nThreadID, (WNDENUMPROC) EnumCbck, 0 );
			if( ghDeveloperStudioWnd )
			{
				wsprintf( pszBuffer, "%ld", (DWORD) ghDeveloperStudioWnd );
				ghEvent = OpenEvent( EVENT_MODIFY_STATE, TRUE, pszBuffer );
				if( ghEvent )
				{
					wsprintf( pszBuffer, "M%ld", (DWORD) ghDeveloperStudioWnd );
					ghMutex = OpenMutex( MUTEX_ALL_ACCESS, FALSE, pszBuffer );
					if( !ghMutex )
					{
						fResult = FALSE;
						CloseHandle( ghEvent );
					}
				}
				else
					fResult = FALSE;
			}
			else
				fResult = FALSE;
		}
		
  }
	else if ( ulReason == DLL_PROCESS_DETACH )
	{
		// If we got here and ghMutex is not NULL, it means that dll is unloading
		// from a process space of Visual C, and we can close a mutex handle
		if( ghMutex )
			CloseHandle( ghMutex );
	}

    return fResult;
}
Esempio n. 12
0
LONG _declspec(dllexport) ToggleFullScreen()
{
	HWND hTop = NULL;
	DWORD dwThreadID;

	dwThreadID = GetCurrentThreadId();
	EnumThreadWindows(dwThreadID, FindWindowProc, (LPARAM)&hTop);

	if (hTop)
	{
		/* Determine the current state of the window */

		if ( GetWindowLong(hTop, GWL_STYLE) & WS_CAPTION )
		{
			/* Has a caption, so isn't maximised */

			int cx, cy;
			cx = GetSystemMetrics(SM_CXSCREEN);
			cy = GetSystemMetrics(SM_CYSCREEN);

			/* Remove border, caption, and edges */
			SetWindowLong(hTop, GWL_STYLE, GetWindowLong(hTop, GWL_EXSTYLE) & ~WS_BORDER); 
			SetWindowLong(hTop, GWL_STYLE, GetWindowLong(hTop, GWL_STYLE) & ~WS_CAPTION); 
			SetWindowLong(hTop, GWL_EXSTYLE, GetWindowLong(hTop, GWL_STYLE) & ~WS_EX_CLIENTEDGE); 
			SetWindowLong(hTop, GWL_EXSTYLE, GetWindowLong(hTop, GWL_STYLE) & ~WS_EX_WINDOWEDGE); 

			SetWindowPos(hTop, HWND_TOP, 0, 0, cx, cy, SWP_SHOWWINDOW);

			/* Now need to find the child text area window 
			 * and set it's size accordingly 
			 */
			EnumChildWindows(hTop, EnumChildProc, 0);
		}
		else
		{
			/* Already full screen, so restore all the previous styles */
			SetWindowLong(hTop, GWL_EXSTYLE, GetWindowLong(hTop, GWL_EXSTYLE) | WS_BORDER); 
			SetWindowLong(hTop, GWL_STYLE, GetWindowLong(hTop, GWL_STYLE) | WS_CAPTION); 
			SetWindowLong(hTop, GWL_STYLE, GetWindowLong(hTop, GWL_STYLE) | WS_SYSMENU); 
			SetWindowLong(hTop, GWL_STYLE, GetWindowLong(hTop, GWL_STYLE) | WS_MINIMIZEBOX); 
			SetWindowLong(hTop, GWL_STYLE, GetWindowLong(hTop, GWL_STYLE) | WS_MAXIMIZEBOX); 
			SetWindowLong(hTop, GWL_STYLE, GetWindowLong(hTop, GWL_STYLE) | WS_SYSMENU); 
			SetWindowLong(hTop, GWL_STYLE, GetWindowLong(hTop, GWL_STYLE) | WS_EX_CLIENTEDGE); 
			SetWindowLong(hTop, GWL_STYLE, GetWindowLong(hTop, GWL_STYLE) | WS_EX_WINDOWEDGE); 
			SetWindowLong(hTop, GWL_STYLE, GetWindowLong(hTop, GWL_STYLE) | WS_THICKFRAME); 
			SetWindowLong(hTop, GWL_STYLE, GetWindowLong(hTop, GWL_STYLE) | WS_DLGFRAME); 

			SendMessage(hTop, WM_SYSCOMMAND, SC_RESTORE, 0);
			SendMessage(hTop, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
		}
	}
	return GetLastError();
}
Esempio n. 13
0
DWORD SendShutdownMessages(
    HWND hwndDesktop,
    PCSR_THREAD pcsrt,
    DWORD dwClientFlags)
{
    HWND hwnd;
    DWORD cmd;

    /*
     * Find a top-level window owned by the thread.
     */
    hwnd = NULL;
    EnumThreadWindows((DWORD)pcsrt->ClientId.UniqueThread,
                        &FindWindowFromThread, (LPARAM)&hwnd);
    if (!hwnd)
        return CMDEND_NOWINDOW;
    /*
     * This'll send WM_QUERYENDSESSION / WM_ENDSESSION messages to all
     * the windows of this hwnd's thread.
     */
    cmd = MySendEndSessionMessages(hwnd, pcsrt, FALSE, dwClientFlags);

    switch (cmd) {
    case CMDEND_APPSAYSOK:
        /*
         * This thread says ok... continue on to the next thread.
         */
        break;

    case CMDEND_USERSAYSKILL:
        /*
         * The user hit the "end-task" button on the hung app dialog.
         * If this is a wow app, kill just this app and continue to
         * the next wow app.
         */
        if (!(pcsrt->Flags & CSR_THREAD_DESTROYED)) {
            if (WowExitTask(pcsrt))
                break;
        }

        /* otherwise fall through */

    case CMDEND_USERSAYSCANCEL:
    case CMDEND_APPSAYSNOTOK:
        /*
         * Exit out of here... either the user wants to kill or cancel,
         * or the app says no.
         */
        return cmd;
    }

    return CMDEND_APPSAYSOK;
}
//
// IsFullscreenWindow
// 
HMONITOR FullscreenMonitor::IsFullscreenWindow(HWND hWnd)
{
    if (!IsWindow(hWnd))
    {
        return nullptr;
    }
    
    HMONITOR hMonFS = nullptr;
    EnumThreadWindows(GetWindowThreadProcessId(hWnd, nullptr), _EnumThreadFSWnd, (LPARAM)&hMonFS);
    
    return hMonFS;
}
Esempio n. 15
0
File: misc.c Progetto: nohuhu/TuTTY
HWND launch_putty(int action, char *path)
{
    STARTUPINFO si;
    PROCESS_INFORMATION pi;
    DWORD wait;
    HWND pwin;
    struct process_record *pr;
    char buf[BUFSIZE];

    memset(&si, 0, sizeof(STARTUPINFO));
    si.cb = sizeof(STARTUPINFO);

    memset(&pi, 0, sizeof(PROCESS_INFORMATION));

    sprintf(buf, "%s -%s \"%s\"", config->putty_path,
	    action ? "edit" : "load", path);

    if (!CreateProcess(config->putty_path, buf, NULL, NULL,
		       FALSE, 0, NULL, NULL, &si, &pi))
	return NULL;

    wait = WaitForInputIdle(pi.hProcess, LAUNCH_TIMEOUT);

    if (wait != 0) {
	CloseHandle(pi.hProcess);
	CloseHandle(pi.hThread);
	return NULL;
    };

    CloseHandle(pi.hThread);

    pwin = NULL;
    EnumThreadWindows(pi.dwThreadId, FindPuttyWindowCallback, (LPARAM) &pwin);

    if (!pwin) {
	CloseHandle(pi.hProcess);
	return NULL;
    };

    pr = (struct process_record *) malloc(sizeof(struct process_record));
    pr->pid = pi.dwProcessId;
    pr->tid = pi.dwThreadId;
    pr->hprocess = pi.hProcess;
    pr->window = pwin;
    pr->path = dupstr(path);

    item_insert((void *) &process_handles, &nprocesses, pi.hProcess);
    nprocesses -= 1;
    item_insert((void *) &process_records, &nprocesses, pr);

    return pwin;
};
Esempio n. 16
0
void CSearchDlg::OnClose()
{
	SaveBarState(SEARCH_PARAMS_PROFILE);
	// MORPH leuk_he:run as ntservice v1.. workarround a mfc bug
	if (RunningAsService()) {
		DWORD dwProcessId;
		DWORD dwThreadId= GetWindowThreadProcessId(m_hWnd,&dwProcessId);
		EnumThreadWindows(dwThreadId, EnumProc,(LPARAM) dwThreadId);
	}
	// MORPH leuk_he:run as ntservice v1..

	CFrameWnd::OnClose();
}
Esempio n. 17
0
static BOOL CALLBACK myspace_links_enumwindowsproc(HWND hwnd, LPARAM lParam)
{
    char szBuf[32];

    //LOG(LOG_DEBUG, "Links: enumwindowsproc");
    if (GetClassNameA(hwnd, szBuf, 32))
	{
        if (!strcmp(szBuf, MIRANDACLASS)) {
            //LOG(LOG_DEBUG, "Links: enumwindowsproc - found Miranda window");
            EnumThreadWindows(GetWindowThreadProcessId(hwnd, NULL), myspace_linsk_enumthreadwindowsproc, lParam);
        }
    }
    return TRUE;
}
Esempio n. 18
0
LONG _declspec(dllexport) SetAlpha(LONG nTrans) {
	HWND hTop = NULL;

	EnumThreadWindows(GetCurrentThreadId(), FindWindowProc, (LPARAM)&hTop);

	if(hTop != NULL) {
		if(nTrans == 255) {
			SetWindowLong(hTop, GWL_EXSTYLE, GetWindowLong(hTop, GWL_EXSTYLE) & ~WS_EX_LAYERED); 
		}else{
			SetWindowLong(hTop, GWL_EXSTYLE, GetWindowLong(hTop, GWL_EXSTYLE) | WS_EX_LAYERED);
			SetLayeredWindowAttributes(hTop, 0, (BYTE)nTrans, LWA_ALPHA);
		}
	}
	return GetLastError();
}
Esempio n. 19
0
File: Html.c Progetto: shah-/c-projs
static int ExtractLinks()
{
  static WCHAR szNotepad[16];
  PROCESS_INFORMATION pi = {0};
  STARTUPINFO si = {sizeof(STARTUPINFO)};
  lstrcpy(szNotepad, L"Notepad.exe");
  GetStartupInfo(&si);
  if(!CreateProcess(0, szNotepad, 0, 0, 0, 0, 0, 0, &si, &pi))
    return 0;
  WaitForInputIdle(pi.hProcess, INFINITE);
  EnumThreadWindows(pi.dwThreadId, NotepadMainWndFindProc, 0);
  CloseHandle(pi.hThread);
  CloseHandle(pi.hProcess);
  return 0;
}
Esempio n. 20
0
LONG _declspec(dllexport) EnableTopMost(LONG bEnable) {
	HWND hTop = NULL;
	DWORD dwThreadID;

	dwThreadID = GetCurrentThreadId();
	EnumThreadWindows(dwThreadID, FindWindowProc, (LPARAM)&hTop);

	if(hTop) {
		if (bEnable == 0) {
			SetWindowPos(hTop, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
		}else{
			SetWindowPos(hTop, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
		}
	}
	return GetLastError();
}
Esempio n. 21
0
LRESULT CALLBACK CBaseTrayIcon::WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  CBaseTrayIcon *icon = (CBaseTrayIcon *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
  switch(uMsg) {
  case WM_DESTROY:
    Shell_NotifyIcon(NIM_DELETE, &icon->m_NotifyIconData);
    PostQuitMessage(0);
    break;
  case MSG_QUIT:
    DestroyWindow(hwnd);
    break;
  case MSG_TRAYICON:
    {
      UINT trayMsg = LOWORD(lParam);
      if (icon) {
        switch (trayMsg) {
        case WM_LBUTTONUP:
          if (!icon->m_bPropPageOpen) {
            icon->OpenPropPage();
          } else {
            EnumThreadWindows(GetCurrentThreadId(), enumWindowCallback, (LPARAM)icon->m_hWnd);
          }
          break;
        case WM_RBUTTONUP:
        case WM_CONTEXTMENU:
          if (icon->m_bPropPageOpen) {
            break;
          }
          HMENU hMenu = icon->GetPopupMenu();
          if (hMenu) {
            POINT p;
            GetCursorPos(&p);
            SetForegroundWindow(hwnd);
            int cmd = TrackPopupMenu(hMenu, TPM_RETURNCMD, p.x, p.y, 0, hwnd, NULL);
            PostMessage(hwnd, WM_NULL, 0, 0);
            icon->ProcessMenuCommand(hMenu, cmd);
            DestroyMenu(hMenu);
          }
          break;
        }
      }
    }
    break;
  }
  return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
Esempio n. 22
0
LONG _declspec(dllexport) EnableMaximize(LONG bEnable)
{
	HWND hTop = NULL;
	DWORD dwThreadID;

	dwThreadID = GetCurrentThreadId();
	EnumThreadWindows(dwThreadID, FindWindowProc, (LPARAM)&hTop);

	if (hTop)
	{
		if (bEnable == 0)
			SendMessage(hTop, WM_SYSCOMMAND, SC_RESTORE, 0);
		else
			SendMessage(hTop, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
	}
	return GetLastError();
}
Esempio n. 23
0
LONG _declspec(dllexport) EnableCaption(LONG bCaption)
{
	HWND hTop = NULL;
	DWORD dwThreadID;

	dwThreadID = GetCurrentThreadId();
	EnumThreadWindows(dwThreadID, FindWindowProc, (LPARAM)&hTop);

	if (hTop)
	{
		if (bCaption == 0)
			SetWindowLong(hTop, GWL_STYLE,
				GetWindowLong(hTop, GWL_STYLE) & ~WS_CAPTION); 
		else
			SetWindowLong(hTop, GWL_STYLE,
				GetWindowLong(hTop, GWL_STYLE) | WS_CAPTION); 
	}
	return GetLastError();
}
Esempio n. 24
0
static Bool
winRedrawScreenShadowGDI(ScreenPtr pScreen)
{
    winScreenPriv(pScreen);
    winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;

    /* Redraw the whole window, to take account for the new colors */
    BitBlt(pScreenPriv->hdcScreen,
           0, 0,
           pScreenInfo->dwWidth, pScreenInfo->dwHeight,
           pScreenPriv->hdcShadow, 0, 0, SRCCOPY);

#ifdef XWIN_MULTIWINDOW
    /* Redraw all windows */
    if (pScreenInfo->fMultiWindow)
        EnumThreadWindows(g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0);
#endif

    return TRUE;
}
Esempio n. 25
0
static Bool
winBltExposedRegionsShadowGDI (ScreenPtr pScreen)
{
  winScreenPriv(pScreen);
  winScreenInfo		*pScreenInfo = pScreenPriv->pScreenInfo;
  winPrivCmapPtr	pCmapPriv = NULL;
  HDC			hdcUpdate;
  PAINTSTRUCT		ps;

  /* BeginPaint gives us an hdc that clips to the invalidated region */
  hdcUpdate = BeginPaint (pScreenPriv->hwndScreen, &ps);

  /* Realize the palette, if we have one */
  if (pScreenPriv->pcmapInstalled != NULL)
    {
      pCmapPriv = winGetCmapPriv (pScreenPriv->pcmapInstalled);
      
      SelectPalette (hdcUpdate, pCmapPriv->hPalette, FALSE);
      RealizePalette (hdcUpdate);
    }

  /* Our BitBlt will be clipped to the invalidated region */
  BitBlt (hdcUpdate,
	  0, 0,
	  pScreenInfo->dwWidth, pScreenInfo->dwHeight,
	  pScreenPriv->hdcShadow,
	  0, 0,
	  SRCCOPY);

  /* EndPaint frees the DC */
  EndPaint (pScreenPriv->hwndScreen, &ps);

#ifdef XWIN_MULTIWINDOW
  /* Redraw all windows */
  if (pScreenInfo->fMultiWindow)
    EnumThreadWindows(g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 
            (LPARAM)pScreenPriv->hwndScreen);
#endif

  return TRUE;
}
Esempio n. 26
0
LONG _declspec(dllexport) SetAlpha(LONG nTrans)
{
	HMODULE hDllUser32;

	hDllUser32 = LoadLibrary("user32");
	if (hDllUser32)
	{
		BOOL (WINAPI *pfnSetLayeredWindowAttributes)(HWND,DWORD,BYTE,DWORD);

		pfnSetLayeredWindowAttributes
			= (BOOL (WINAPI *)(HWND,DWORD,BYTE,DWORD))
    			GetProcAddress(hDllUser32, "SetLayeredWindowAttributes");

		if (pfnSetLayeredWindowAttributes)
		{
			HWND hTop = NULL;
			DWORD dwThreadID;

			dwThreadID = GetCurrentThreadId();
			EnumThreadWindows(dwThreadID, FindWindowProc, (LPARAM)&hTop);

			if (hTop)
			{
				if (nTrans == 255)
				{
    				SetWindowLong(hTop, GWL_EXSTYLE,
						GetWindowLong(hTop, GWL_EXSTYLE) & ~WS_EX_LAYERED); 
				}
				else
				{
    				SetWindowLong(hTop, GWL_EXSTYLE,
						GetWindowLong(hTop, GWL_EXSTYLE) | WS_EX_LAYERED); 
					pfnSetLayeredWindowAttributes(
								hTop, 0, (BYTE)nTrans, LWA_ALPHA);
				}
			}
		}
		FreeLibrary(hDllUser32);
	}
	return GetLastError();
}
Esempio n. 27
0
int winapi_EnumThreadWindows(lua_State* L)
{
  DWORD threadId;

  LUASTACK_SET(L);

  threadId = (DWORD)lua_tonumber(L, 1);

  if (lua_isfunction(L, 2))
  {
    EnumThreadWindows(threadId, EnumProc, (LPARAM)L);
  }
  else
  {
    const char *msg = lua_pushfstring(L, "function expected but got %s", luaL_typename(L, 2));
    luaL_argerror(L, 2, msg);
  }

  LUASTACK_CLEAN(L, 0);
  return 0;
}
Esempio n. 28
0
static HWND
GetVimWindow() {
  if (hTopWindow) {
    return hTopWindow;
  }

  HMODULE hDllKernel32 = LoadLibrary("kernel32");
  if (hDllKernel32) {
    HWND (WINAPI *pfnGetConsoleWindow)();
    pfnGetConsoleWindow
      = (HWND (WINAPI *)())
          GetProcAddress(hDllKernel32, "GetConsoleWindow");
    if (pfnGetConsoleWindow && (hTopWindow = (HWND) pfnGetConsoleWindow())) {
      ShowWindow(hTopWindow, SW_SHOW);
      return hTopWindow;
    }
  }
  DWORD dwThreadID = GetCurrentThreadId();
  EnumThreadWindows(dwThreadID, FindWindowProc, (LPARAM)&hTopWindow);
  return hTopWindow;
}
Esempio n. 29
0
HWND GetMainWindow( DWORD dwOwnerPID ) 
{ 
	HWND hWnd = 0; 
	HANDLE hThreadSnap = INVALID_HANDLE_VALUE; 
	THREADENTRY32 te32; 

	// Take a snapshot of all running threads  
	hThreadSnap = CreateToolhelp32Snapshot( TH32CS_SNAPTHREAD, 0 ); 
	if( hThreadSnap == INVALID_HANDLE_VALUE ) 
		return( 0 ); 

	// Fill in the size of the structure before using it. 
	te32.dwSize = sizeof(THREADENTRY32 ); 

	// Retrieve information about the first thread,
	// and exit if unsuccessful
	if( !Thread32First( hThreadSnap, &te32 ) ) 
	{
		CloseHandle( hThreadSnap );     // Must clean up the snapshot object!
		return( 0 );
	}

	// Now walk the thread list of the system,
	// and display information about each thread
	// associated with the specified process
	do 
	{ 
		if( te32.th32OwnerProcessID == dwOwnerPID )
		{

			EnumThreadWindows(te32.th32ThreadID, EnumProc, (LPARAM)&hWnd); 
			if(hWnd) break;

		}
	} while( Thread32Next(hThreadSnap, &te32 ) ); 

	//  Don't forget to clean up the snapshot object.
	CloseHandle( hThreadSnap );
	return( hWnd );
}
Esempio n. 30
0
bool WinReviveNetworkResource(uint16 * _wfileName)
{
   bool result = false;
   HWND windowHandle = null;
   NETRESOURCE nr = { 0 };
   nr.dwType = RESOURCETYPE_DISK;
   nr.lpRemoteName = _wfileName;
   if(_wfileName[0] != '\\' || _wfileName[1] == '\\')
   {
      uint16 volumePathName[MAX_LOCATION];
      if(GetVolumePathName(_wfileName, volumePathName, MAX_LOCATION))
      {
         uint16 remoteName[MAX_LOCATION];
         DWORD size = MAX_LOCATION;
         volumePathName[wcslen(volumePathName)-1] = 0;
         if(WNetGetConnection(volumePathName, remoteName, &size) == ERROR_CONNECTION_UNAVAIL)
         {
            nr.lpRemoteName = remoteName;
            nr.lpLocalName = volumePathName;
         }
         else
            return false;
      }
      else
         return false;
   }
   EnumThreadWindows(GetCurrentThreadId(), EnumThreadWindowsProc, (LPARAM)&windowHandle);
   if(!windowHandle)
   {
      EnumWindows(EnumThreadWindowsProc, (LPARAM)&windowHandle);

   }
   if(WNetAddConnection3(windowHandle, &nr, null, null, CONNECT_INTERACTIVE|CONNECT_PROMPT) == NO_ERROR)
      result = true;
   return result;
}