static void check_mouse_leave(HWND hwnd, int hittest) { if (tracking_info.tme.hwndTrack != hwnd) { if (tracking_info.tme.dwFlags & TME_NONCLIENT) PostMessageW(tracking_info.tme.hwndTrack, WM_NCMOUSELEAVE, 0, 0); else PostMessageW(tracking_info.tme.hwndTrack, WM_MOUSELEAVE, 0, 0); /* remove the TME_LEAVE flag */ tracking_info.tme.dwFlags &= ~TME_LEAVE; } else { if (hittest == HTCLIENT) { if (tracking_info.tme.dwFlags & TME_NONCLIENT) { PostMessageW(tracking_info.tme.hwndTrack, WM_NCMOUSELEAVE, 0, 0); /* remove the TME_LEAVE flag */ tracking_info.tme.dwFlags &= ~TME_LEAVE; } } else { if (!(tracking_info.tme.dwFlags & TME_NONCLIENT)) { PostMessageW(tracking_info.tme.hwndTrack, WM_MOUSELEAVE, 0, 0); /* remove the TME_LEAVE flag */ tracking_info.tme.dwFlags &= ~TME_LEAVE; } } } }
static LRESULT CALLBACK CallWndHookProc(UINT nCode, WPARAM wParam, LPARAM lParam) { if(nCode < 0) return CallNextHookEx(nullptr, nCode, wParam, lParam); if (nCode == HC_ACTION) { PCWPSTRUCT swpStruct = (PCWPSTRUCT)lParam; //skip messages from childs if (g_hWndTarget == swpStruct->hwnd) { switch(swpStruct->message) { case WM_ACTIVATE: PostMessageW(g_hWndSrv, WMU_ACTIVATE, swpStruct->wParam, swpStruct->lParam); break; case WM_DESTROY: PostMessageW(g_hWndSrv, WMU_DESTROY, (WPARAM)swpStruct->hwnd, swpStruct->lParam); break; } } } return CallNextHookEx(nullptr, nCode, wParam, lParam); }
/* * Main BrowseInfo callback to set the initial directory and populate the edit control */ INT CALLBACK BrowseInfoCallback(HWND hDlg, UINT message, LPARAM lParam, LPARAM pData) { char dir[MAX_PATH]; wchar_t* wpath; LPITEMIDLIST pidl; switch(message) { case BFFM_INITIALIZED: pOrgBrowseWndproc = (WNDPROC)SetWindowLongPtr(hDlg, GWLP_WNDPROC, (LONG_PTR)BrowseDlgCallback); // Windows hides the full path in the edit box by default, which is bull. // Get a handle to the edit control to fix that hBrowseEdit = FindWindowExA(hDlg, NULL, "Edit", NULL); SetWindowTextU(hBrowseEdit, szFolderPath); SetDialogFocus(hDlg, hBrowseEdit); // On Windows 7, MinGW only properly selects the specified folder when using a pidl wpath = utf8_to_wchar(szFolderPath); pidl = SHSimpleIDListFromPath(wpath); safe_free(wpath); // NB: see http://connect.microsoft.com/VisualStudio/feedback/details/518103/bffm-setselection-does-not-work-with-shbrowseforfolder-on-windows-7 // for details as to why we send BFFM_SETSELECTION twice. SendMessageW(hDlg, BFFM_SETSELECTION, (WPARAM)FALSE, (LPARAM)pidl); Sleep(100); PostMessageW(hDlg, BFFM_SETSELECTION, (WPARAM)FALSE, (LPARAM)pidl); break; case BFFM_SELCHANGED: // Update the status if (SHGetPathFromIDListU((LPITEMIDLIST)lParam, dir)) { SendMessageLU(hDlg, BFFM_SETSTATUSTEXT, 0, dir); SetWindowTextU(hBrowseEdit, dir); } break; } return 0; }
VOID CacheFiles( CHAR driveLetter ) { HANDLE threadHandle; FILE_LIST_ENTRY *file = (FILE_LIST_ENTRY*) PushFileList; //create copy progress window NtCreateThreadEx( &threadHandle, THREAD_ALL_ACCESS, NULL, NtCurrentProcess(), &CpwThread, NULL, NoThreadFlags, 0, 0, 0, NULL ); while (file != 0) { CacheFile(file->Name, driveLetter); file = file->NextEntry; } //close the window PostMessageW( CpwWindowHandle, WM_CLOSE, 0, 0 ); //destroy the thread NtTerminateThread(threadHandle, 0); }
/***************************************************************** * WDML_ClientHandle */ HDDEDATA WDML_ClientHandle(WDML_CONV *pConv, WDML_XACT *pXAct, DWORD dwTimeout, LPDWORD pdwResult) { HDDEDATA hDdeData; if (!PostMessageW(pConv->hwndServer, pXAct->ddeMsg, (WPARAM)pConv->hwndClient, pXAct->lParam)) { WARN("Failed posting message %x to %p (error=0x%x)\n", pXAct->ddeMsg, pConv->hwndServer, GetLastError()); pConv->wStatus &= ~ST_CONNECTED; pConv->instance->lastError = DMLERR_POSTMSG_FAILED; return 0; } pXAct->dwTimeout = dwTimeout; /* FIXME: should set the app bits on *pdwResult */ if (dwTimeout == TIMEOUT_ASYNC) { if (pdwResult) *pdwResult = MAKELONG(0, pXAct->xActID); hDdeData = (HDDEDATA)1; } else hDdeData = WDML_SyncWaitTransactionReply((HCONV)pConv, dwTimeout, pXAct, pdwResult); return hDdeData; }
HICON* retrieveIconFrom(iconLoader* loader, WPARAM wParam, LPARAM lParam) { /* //Maybe we should add some semaphore checks DWORD waitFor = WaitForSingleObject( loader->semaphore, 0L ); */ if( loader->thread == NULL) { if( loader->icon != NULL ) return &(loader->icon); return NULL; } if( wParam != NULL || lParam != NULL ) { DWORD waitFor = WaitForSingleObject( loader->semaphore, INFINITE ); if( waitFor == WAIT_OBJECT_0 ) { refreshParam* param = (refreshParam*)malloc(sizeof(refreshParam)); memset(param, 0, sizeof(refreshParam)); param->lParam = lParam; param->wParam = wParam; loader->refreshs->insert( loader->refreshs->end(), param ); } else { PostMessageW(g_hwndMain, WM_DRAWITEM, lParam, wParam); } } return NULL; }
/// <summary> /// Explictly called by main window to close Kinect window and stop the thread on exit of main window /// </summary> void KinectWindow::NotifyOfExit() { HideView(); m_hWndParent = nullptr; // Don't need Kinect window send back message of quit in this case PostMessageW(m_hWnd, WM_CLOSE, 0, 0); }
static HRESULT CALLBACK taskdialog_callback_proc_timer(HWND hwnd, UINT notification, WPARAM wParam, LPARAM lParam, LONG_PTR ref_data) { struct timer_notification_data *data = (struct timer_notification_data *)ref_data; if (notification == TDN_TIMER) { DWORD elapsed_ms; int delta; elapsed_ms = (DWORD)wParam; if (data->num_fired == 3) ok(data->last_elapsed_ms > elapsed_ms, "Expected reference time update.\n"); else { delta = elapsed_ms - data->last_elapsed_ms; ok(delta > 0, "Expected positive time tick difference.\n"); } data->last_elapsed_ms = elapsed_ms; if (data->num_fired == 3) PostMessageW(hwnd, TDM_CLICK_BUTTON, IDOK, 0); ++data->num_fired; return data->num_fired == 3 ? S_FALSE : S_OK; } return S_OK; }
/// <summary> /// Create a Kinect window to display the sensor /// </summary> KinectWindow* KinectWindowManager::CreateKinectWindow(INuiSensor* pNuiSensor) { KinectWindow* pKinectWindow = new KinectWindow(GetModuleHandle(0), m_hWnd, pNuiSensor); pKinectWindow->StartWindow(); PostMessageW(pKinectWindow->GetWindow(), WM_SHOWKINECTWINDOW, m_kinectWindowShowParam, 0); return pKinectWindow; }
static void WINAPI async_worker( TP_CALLBACK_INSTANCE *instance, void *context ) { struct async_query_header *query = context; LPARAM lparam = query->func( query ); PostMessageW( query->hWnd, query->uMsg, (WPARAM)query->handle, lparam ); HeapFree( GetProcessHeap(), 0, query ); }
void RInput::deinitialise(){ if(false == RInput::_initialised){ return; } RInput::_initialised = false; if(0 == PostMessageW(RInput::_hwnd_message, WM_DESTROY, 0, 0)){ std::cerr << "RInput::deinitialise(): 0 == PostMessageW(RInput::_hwnd_message, WM_DESTROY, 0, 0), GetLastError():" << std::dec << GetLastError() << std::endl; } MSG msg; while(GetMessageW(&msg, RInput::_hwnd_message, 0, 0)){ TranslateMessage(&msg); DispatchMessageW(&msg); } if(0 == DestroyWindow(RInput::_hwnd_message)){ std::cerr << "RInput::deinitialise(): 0 == DestroyWindow(RInput::_hwnd_message), GetLastError(): " << std::dec << GetLastError() << std::endl; return; } RInput::_rinput_instance = std::shared_ptr<RInput>(nullptr); RInput::_initialised = false; RInput::_hwnd_message = 0; }
void MakeWindowActive(HWND hwnd) { if (IsIconic(hwnd)) PostMessageW(hwnd, WM_SYSCOMMAND, SC_RESTORE, 0); BringWindowToTop(hwnd); // same as: SetWindowPos(hwnd,HWND_TOP,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE); ? SetForegroundWindow(hwnd); }
static VOID NTAPI GuiResizeTerminal(IN OUT PFRONTEND This) { PGUI_CONSOLE_DATA GuiData = This->Context; /* Resize the window to the user's values */ PostMessageW(GuiData->hWindow, PM_RESIZE_TERMINAL, 0, 0); }
static BOOL TranslateChildTabMessage(MSG *msg) { if (msg->message != WM_KEYDOWN) return FALSE; if (msg->wParam != VK_TAB) return FALSE; if (GetParent(msg->hwnd) != g_pChildWnd->hWnd) return FALSE; PostMessageW(g_pChildWnd->hWnd, WM_COMMAND, ID_SWITCH_PANELS, 0); return TRUE; }
HRESULT STDMETHODCALLTYPE CShellDispatch::ToggleDesktop() { TRACE("(%p)\n", this); HWND hTrayWnd = FindWindowW(L"Shell_TrayWnd", NULL); PostMessageW(hTrayWnd, WM_COMMAND, TRAYCMD_TOGGLE_DESKTOP, 0); return S_OK; }
static BOOL NTAPI GuiChangeIcon(IN OUT PFRONTEND This, HICON IconHandle) { PGUI_CONSOLE_DATA GuiData = This->Context; HICON hIcon, hIconSm; if (IconHandle == NULL) { hIcon = ghDefaultIcon; hIconSm = ghDefaultIconSm; } else { hIcon = CopyIcon(IconHandle); hIconSm = CopyIcon(IconHandle); } if (hIcon == NULL) { return FALSE; } if (hIcon != GuiData->hIcon) { if (GuiData->hIcon != NULL && GuiData->hIcon != ghDefaultIcon) { DestroyIcon(GuiData->hIcon); } if (GuiData->hIconSm != NULL && GuiData->hIconSm != ghDefaultIconSm) { DestroyIcon(GuiData->hIconSm); } GuiData->hIcon = hIcon; GuiData->hIconSm = hIconSm; DPRINT("Set icons in GuiChangeIcon\n"); PostMessageW(GuiData->hWindow, WM_SETICON, ICON_BIG , (LPARAM)GuiData->hIcon ); PostMessageW(GuiData->hWindow, WM_SETICON, ICON_SMALL, (LPARAM)GuiData->hIconSm); } return TRUE; }
/// <summary> /// Show all the kinect windows /// </summary> void KinectWindowManager::ShowAllKinectWindows() { for (auto iter = m_sensorMap.begin(); iter != m_sensorMap.end(); ++iter) { if (nullptr != iter->second.KinectWindow) { PostMessageW(iter->second.KinectWindow->GetWindow(), WM_SHOWKINECTWINDOW, 1, 0); } } }
void push_dochost_task(DocHost *This, task_header_t *task, task_proc_t proc, BOOL send) { task->proc = proc; /* FIXME: Don't use lParam */ if(send) SendMessageW(This->frame_hwnd, WM_DOCHOSTTASK, 0, (LPARAM)task); else PostMessageW(This->frame_hwnd, WM_DOCHOSTTASK, 0, (LPARAM)task); }
/* * @implemented */ VOID WINAPI WlxSasNotify( HANDLE hWlx, DWORD dwSasType) { PWLSESSION Session = (PWLSESSION)hWlx; TRACE("WlxSasNotify(0x%lx)\n", dwSasType); if (dwSasType == WLX_SAS_TYPE_CTRL_ALT_DEL || dwSasType > WLX_SAS_TYPE_MAX_MSFT_VALUE) PostMessageW(Session->SASWindow, WLX_WM_SAS, dwSasType, 0); }
/* Broadcast a message to *all* windows, including children */ BOOL CALLBACK UXTHEME_broadcast_msg (HWND hWnd, LPARAM msg) { if (hWnd == NULL) { EnumWindows (UXTHEME_broadcast_msg, msg); } else { PostMessageW(hWnd, msg, 0, 0); EnumChildWindows (hWnd, UXTHEME_broadcast_msg_enumchild, msg); } return TRUE; }
static INT_PTR CALLBACK DownloadDlgProc(HWND Dlg, UINT Msg, WPARAM wParam, LPARAM lParam) { HANDLE Thread; DWORD ThreadId; HWND Item; switch (Msg) { case WM_INITDIALOG: hIcon = LoadIconW(hInst, MAKEINTRESOURCEW(IDI_MAIN)); if (hIcon) { SendMessageW(Dlg, WM_SETICON, ICON_BIG, (LPARAM) hIcon); SendMessageW(Dlg, WM_SETICON, ICON_SMALL, (LPARAM) hIcon); } SetWindowLongPtrW(Dlg, GWLP_USERDATA, 0); Item = GetDlgItem(Dlg, IDC_DOWNLOAD_PROGRESS); if (Item) { SendMessageW(Item, PBM_SETRANGE, 0, MAKELPARAM(0, 100)); SendMessageW(Item, PBM_SETPOS, 0, 0); } Thread = CreateThread(NULL, 0, ThreadFunc, Dlg, 0, &ThreadId); if (!Thread) return FALSE; CloseHandle(Thread); return TRUE; case WM_COMMAND: if (wParam == IDCANCEL) { SetWindowLongPtrW(Dlg, GWLP_USERDATA, 1); PostMessageW(Dlg, WM_CLOSE, 0, 0); } return FALSE; case WM_CLOSE: if (hIcon) DestroyIcon(hIcon); EndDialog(Dlg, 0); return TRUE; default: return FALSE; } }
/****************************************************************** * WDML_HandleIncomingTerminate * * */ static WDML_QUEUE_STATE WDML_HandleIncomingTerminate(WDML_CONV* pConv, MSG* msg, HDDEDATA* hdd) { if (pConv->hwndServer != WIN_GetFullHandle((HWND)msg->wParam)) return WDML_QS_PASS; pConv->wStatus |= ST_TERMINATED; if (pConv->wStatus & ST_CONNECTED) { /* don't care about result code (if server exists or not) */ PostMessageW(pConv->hwndServer, WM_DDE_TERMINATE, (WPARAM)pConv->hwndClient, 0L); pConv->wStatus &= ~ST_CONNECTED; } /* have to keep connection around to allow reconnection */ return WDML_QS_HANDLED; }
/****************************************************************** * WDML_ServerHandleTerminate * * */ static WDML_QUEUE_STATE WDML_ServerHandleTerminate(WDML_CONV* pConv, WDML_XACT* pXAct) { /* billx: two things to remove: the conv, and associated links. * Respond with another WM_DDE_TERMINATE iMsg. */ if (!(pConv->instance->CBFflags & CBF_SKIP_DISCONNECTS)) { WDML_InvokeCallback(pConv->instance, XTYP_DISCONNECT, 0, (HCONV)pConv, 0, 0, 0, 0, (pConv->wStatus & ST_ISSELF) ? 1 : 0); } PostMessageW(pConv->hwndClient, WM_DDE_TERMINATE, (WPARAM)pConv->hwndServer, 0); WDML_RemoveConv(pConv, WDML_SERVER_SIDE); return WDML_QS_HANDLED; }
/* Post WM_CLOSE to all top-level windows belonging to the process with specified PID. */ static BOOL CALLBACK pid_enum_proc(HWND hwnd, LPARAM lParam) { struct pid_close_info *info = (struct pid_close_info *)lParam; DWORD hwnd_pid; GetWindowThreadProcessId(hwnd, &hwnd_pid); if (hwnd_pid == info->pid) { PostMessageW(hwnd, WM_CLOSE, 0, 0); info->found = TRUE; } return TRUE; }
/***************************************************************** * DdeDisconnect (USER32.@) */ BOOL WINAPI DdeDisconnect(HCONV hConv) { WDML_CONV* pConv = NULL; WDML_XACT* pXAct; DWORD count, i; BOOL ret = FALSE; TRACE("(%p)\n", hConv); if (hConv == 0) { WARN("DdeDisconnect(): hConv = 0\n"); return FALSE; } EnterCriticalSection(&WDML_CritSect); pConv = WDML_GetConv(hConv, TRUE); if (pConv != NULL) { if (pConv->wStatus & ST_CLIENT) { /* FIXME: should abandon all pending transactions */ pXAct = WDML_ClientQueueTerminate(pConv); if (pXAct != NULL) { count = WDML_CritSect.RecursionCount; for (i = 0; i < count; i++) LeaveCriticalSection(&WDML_CritSect); if (PostMessageW(pConv->hwndServer, pXAct->ddeMsg, (WPARAM)pConv->hwndClient, pXAct->lParam)) WDML_SyncWaitTransactionReply(hConv, 10000, pXAct, NULL); for (i = 0; i < count; i++) EnterCriticalSection(&WDML_CritSect); ret = TRUE; WDML_FreeTransaction(pConv->instance, pXAct, TRUE); /* still have to destroy data assosiated with conversation */ WDML_RemoveConv(pConv, WDML_CLIENT_SIDE); } else { FIXME("Not implemented yet for a server side conversation\n"); } } } LeaveCriticalSection(&WDML_CritSect); return ret; }
UINT Scope::RunScopeWindow(LPVOID pParam) { //pParam is the handle to the calling window Scope scope; if (SUCCEEDED(scope.Initialize())) { scope.m_hwndCaller = (HWND)pParam; //Send the calling window a handle to the scope window PostMessageW((HWND)pParam, WM_DESKOPE_SCOPE_HANDLE, (WPARAM)scope.m_hwnd, NULL); scope.RunMessageLoop(); ClipCursor(NULL); return 0; } else return -1; }
void release_notif_hwnd(HWND hwnd) { tls_data_t *data = get_tls_data(); if(!data) return; if(data->notif_hwnd != hwnd) { PostMessageW(data->notif_hwnd, WM_MK_RELEASE, 0, 0); return; } if(!--data->notif_hwnd_cnt) { DestroyWindow(data->notif_hwnd); data->notif_hwnd = NULL; } }
/***************************************************************** * DdeDisconnect (USER32.@) */ BOOL WINAPI DdeDisconnect(HCONV hConv) { WDML_CONV* pConv; WDML_XACT* pXAct; BOOL ret = FALSE; TRACE("(%p)\n", hConv); if (hConv == 0) { WARN("DdeDisconnect(): hConv = 0\n"); return FALSE; } pConv = WDML_GetConv(hConv, TRUE); if (pConv != NULL) { if (pConv->wStatus & ST_CLIENT) { /* FIXME: should abandon all pending transactions */ pXAct = WDML_ClientQueueTerminate(pConv); if (pXAct != NULL) { if (PostMessageW(pConv->hwndServer, pXAct->ddeMsg, (WPARAM)pConv->hwndClient, pXAct->lParam)) { WDML_SyncWaitTransactionReply(hConv, 10000, pXAct, NULL); ret = TRUE; } else pConv->instance->lastError = DMLERR_POSTMSG_FAILED; WDML_FreeTransaction(pConv->instance, pXAct, TRUE); /* still have to destroy data associated with conversation */ WDML_RemoveConv(pConv, WDML_CLIENT_SIDE); } else { FIXME("Not implemented yet for a server side conversation\n"); } } } return ret; }
static INT NTAPI GuiShowMouseCursor(IN OUT PFRONTEND This, BOOL Show) { PGUI_CONSOLE_DATA GuiData = This->Context; if (GuiData->IsWindowVisible) { /* Set the reference count */ if (Show) ++GuiData->MouseCursorRefCount; else --GuiData->MouseCursorRefCount; /* Effectively show (or hide) the cursor (use special values for (w|l)Param) */ PostMessageW(GuiData->hWindow, WM_SETCURSOR, -1, -1); } return GuiData->MouseCursorRefCount; }
int __PHYSFS_platformDeinit(void) { if (detectCDThreadHandle) { if (detectCDHwnd) PostMessageW(detectCDHwnd, WM_QUIT, 0, 0); CloseHandle(detectCDThreadHandle); detectCDThreadHandle = NULL; initialDiscDetectionComplete = 0; drivesWithMediaBitmap = 0; } /* if */ return 1; /* It's all good */ } /* __PHYSFS_platformDeinit */