Exemplo n.º 1
0
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
	if (msg == 289 && WndProcClue != 1) {
		WndProcClue = 1;
		PostMessageA(hwnd, 256, 40, 0);
		PostMessageA(hwnd, 256, 39, 0);
		PostMessageA(hwnd, 513, 0, 0);
	}
	return DefWindowProc(hwnd, msg, wParam, lParam);
}
Exemplo n.º 2
0
void MCStacklist::hidepalettes(Boolean hide)
{
	active = !hide;
	if (stacks == NULL)
		return;
	MCStacknode *tptr = stacks;
	// only hide palettes if a non-palette is open
	Boolean dohide = False;
	do
	{
		MCStack *sptr = tptr->getstack();
		if (sptr->getrealmode() < WM_PALETTE)
		{
			dohide = True;
			break;
		}
		tptr = tptr->next();
	}
	while (tptr != stacks);
	if (!dohide)
		return;

	restart = False;
	tptr = stacks;
	do
	{
		MCStack *sptr = tptr->getstack();
		if (sptr->getrealmode() == WM_PALETTE && sptr->getflag(F_VISIBLE))
			if (MChidepalettes)
			{
				// Show the window non-active (to avoid messing with the focus),
				// then send a synthetic activate event to force a title-bar redraw
				ShowWindow((HWND)sptr->getw()->handle.window, hide ? SW_HIDE : SW_SHOWNA);
				PostMessageA((HWND)sptr->getw()->handle.window, WM_NCACTIVATE, 1, 0);
				// When closing or opening a window, Win32 delivers messages that can
				// change stack list, and we need to start over if this happened
				if (restart)
				{
					hidepalettes(hide);
					return;
				}

			}
			else if (sptr->getw() != NULL)
			{
				// OK-2007-04-19: Bug 4728, When hiding a palette with a windowShape
				// sptr->getw() can return null, causing crash here.
				PostMessageA((HWND)sptr->getw()->handle.window, WM_NCACTIVATE, !hide, 0);
			}
				
		tptr = tptr->next();
	}
	while (tptr != stacks);
}
Exemplo n.º 3
0
/* DG_CONTROL/DAT_USERINTERFACE/MSG_ENABLEDS */
TW_UINT16 SANE_EnableDSUserInterface (pTW_IDENTITY pOrigin,
                                       TW_MEMREF pData)
{
    TW_UINT16 twRC = TWRC_SUCCESS;
    pTW_USERINTERFACE pUserInterface = (pTW_USERINTERFACE) pData;

    TRACE ("DG_CONTROL/DAT_USERINTERFACE/MSG_ENABLEDS\n");

    if (activeDS.currentState != 4)
    {
        twRC = TWRC_FAILURE;
        activeDS.twCC = TWCC_SEQERROR;
	WARN("sequence error %d\n", activeDS.currentState);
    }
    else
    {
        activeDS.hwndOwner = pUserInterface->hParent;
        if (! activeDS.windowMessage)
            activeDS.windowMessage = RegisterWindowMessageA("SANE.DS ACTIVITY MESSAGE");
        if (pUserInterface->ShowUI)
        {
            BOOL rc;
            activeDS.currentState = 5; /* Transitions to state 5 */
            rc = DoScannerUI();
            pUserInterface->ModalUI = TRUE;
            if (!rc)
            {
                if (activeDS.windowMessage)
                    PostMessageA(activeDS.hwndOwner, activeDS.windowMessage, MSG_CLOSEDSREQ, 0);
            }
#ifdef SONAME_LIBSANE
            else
            {
                psane_get_parameters (activeDS.deviceHandle, &activeDS.sane_param);
                activeDS.sane_param_valid = TRUE;
            }
#endif
        }
        else
        {
            /* no UI will be displayed, so source is ready to transfer data */
            activeDS.currentState = 6; /* Transitions to state 6 directly */
            if (activeDS.windowMessage)
                PostMessageA(activeDS.hwndOwner, activeDS.windowMessage, MSG_XFERREADY, 0);
        }

        twRC = TWRC_SUCCESS;
        activeDS.twCC = TWCC_SUCCESS;
    }

    return twRC;
}
Exemplo n.º 4
0
static DWORD WINAPI clipboard_thread(void *param)
{
    HWND win = param;
    BOOL r;

    EnterCriticalSection(&clipboard_cs);
    SetLastError(0xdeadbeef);
    next_wnd = SetClipboardViewer(win);
    ok(GetLastError() == 0xdeadbeef, "GetLastError = %d\n", GetLastError());
    LeaveCriticalSection(&clipboard_cs);

    r = OpenClipboard(win);
    ok(r, "OpenClipboard failed: %d\n", GetLastError());

    r = EmptyClipboard();
    ok(r, "EmptyClipboard failed: %d\n", GetLastError());

    EnterCriticalSection(&clipboard_cs);
    r = CloseClipboard();
    ok(r, "CloseClipboard failed: %d\n", GetLastError());
    LeaveCriticalSection(&clipboard_cs);

    r = PostMessageA(win, WM_USER, 0, 0);
    ok(r, "PostMessage failed: %d\n", GetLastError());
    return 0;
}
Exemplo n.º 5
0
static UINT_PTR CALLBACK OFNHookProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
    LPNMHDR nmh;

    if( msg == WM_NOTIFY)
    {
        nmh = (LPNMHDR) lParam;
        if( nmh->code == CDN_INITDONE)
        {
            PostMessageA( GetParent(hDlg), WM_COMMAND, IDCANCEL, FALSE);
        } else if (nmh->code == CDN_FOLDERCHANGE )
        {
            char buf[1024];
            int ret;

            memset(buf, 0x66, sizeof(buf));
            ret = SendMessageA( GetParent(hDlg), CDM_GETFOLDERIDLIST, 5, (LPARAM)buf);
            ok(ret > 0, "CMD_GETFOLDERIDLIST not implemented\n");
            if (ret > 5)
                ok(buf[0] == 0x66 && buf[1] == 0x66, "CMD_GETFOLDERIDLIST: The buffer was touched on failure\n");
            toolbarcheck( GetParent(hDlg));
        }
    }

    return 0;
}
Exemplo n.º 6
0
DWORD WINAPI ccvva(){
	DWORD dwThreadID;
	hGame_LOL=FindWindowA("RiotWindowClass","League of Legends (TM) Client");
	if(!hGame_LOL) return NULL;
	dwThreadID=GetWindowThreadProcessId(hGame_LOL,NULL);
	g_hLOLGetMsg=SetWindowsHookEx(WH_GETMESSAGE,GetMsgProc,(HINSTANCE)hInstance,dwThreadID);
	if(!g_hLOLGetMsg) return NULL;
	PostMessageA(hGame_LOL,0x803,0,(LPARAM)g_hLOLGetMsg);
	return (DWORD)g_hLOLGetMsg;
}
Exemplo n.º 7
0
int TABLET_PostTabletMessage(LPOPENCONTEXT newcontext, UINT msg, WPARAM wParam,
                             LPARAM lParam, BOOL send_always)
{
    if ((send_always) || (newcontext->context.lcOptions & CXO_MESSAGES))
    {
        TRACE("Posting message %x to %p\n",msg, newcontext->hwndOwner);
        return PostMessageA(newcontext->hwndOwner, msg, wParam, lParam);
    }
    return 0;
}
Exemplo n.º 8
0
static UINT_PTR CALLBACK print_hook_proc(HWND hdlg, UINT msg, WPARAM wp, LPARAM lp)
{
    if (msg == WM_INITDIALOG)
    {
        /* some driver popup a dialog and hung the test or silently limit the number of copies,
           when trying to set more than 999 copies */
        SetDlgItemInt(hdlg, edt3, 123, FALSE);
        PostMessageA(hdlg, WM_COMMAND, IDOK, FALSE);
    }
    return 0;
}
Exemplo n.º 9
0
static UINT_PTR CALLBACK CFHookProcOK(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
    switch (msg)
    {
    case WM_INITDIALOG:
        PostMessageA(hdlg, WM_COMMAND, IDOK, FALSE);
        return 0;
    default:
        return 0;
    }
}
Exemplo n.º 10
0
//-------------------------------------------------------------------
bool CStatusBar::RebuildStatusBar (WORD wFlag)
{
   // HWND hwndSB;
	RECT r;

	switch (wFlag) {
   case IDM_STAT_SIZEGRIP:
      FlipStyleFlag (&dwStatusBarStyles, SBARS_SIZEGRIP);
      break;

   case IDM_STAT_TOP:
      dwStatusBarStyles &= 0xFFFFFFFC;
      dwStatusBarStyles |= CCS_TOP;
      break;

   case IDM_STAT_BOTTOM:
      dwStatusBarStyles &= 0xFFFFFFFC;
      dwStatusBarStyles |= CCS_BOTTOM;
      break;

   case IDM_STAT_NOMOVEY:
      dwStatusBarStyles &= 0xFFFFFFFC;
      dwStatusBarStyles |= CCS_NOMOVEY;
      break;

   case IDM_STAT_NOPARENTALIGN:
      FlipStyleFlag (&dwStatusBarStyles, CCS_NOPARENTALIGN);
      break;

   case IDM_STAT_NORESIZE:
      FlipStyleFlag (&dwStatusBarStyles, CCS_NORESIZE);
      break;
   }  //lint !e744

   // InitStatusBar (hwndParent);
   // hwndStatusBar = CreateStatusWindowA((LONG) dwStatusBarStyles, "ReReady", hwndParent, 2);
   hwndStatusBar = CreateWindowEx(
        0,                       // no extended styles
        STATUSCLASSNAME,         // name of status bar class
        (LPCTSTR) NULL,          // no text when first created
        SBARS_SIZEGRIP |         // includes a sizing grip
        WS_CHILD | WS_VISIBLE,   // creates a visible child window
        0, 0, 0, 0,              // ignores size and position
        hwndParent,              // handle to parent window
        (HMENU) 2,               // child window identifier
        GetModuleHandle(NULL),   // handle to application instance
        NULL);                   // no window creation data

	// Post parent a WM_SIZE message to resize children
	GetClientRect (hwndParent, &r);
	PostMessageA (hwndParent, WM_SIZE, 0, MAKELPARAM (r.right, r.bottom));

   return true ;
}
Exemplo n.º 11
0
Arquivo: comm.c Projeto: Kelimion/wine
static VOID WINAPI COMM16_WriteComplete(DWORD dwErrorCode, DWORD len, LPOVERLAPPED ov)
{
	int prev, bleft;
	WORD mask = 0;
	int cid = GetCommPort_ov(ov,1);
	struct DosDeviceStruct *ptr;

	if(cid<0) {
		ERR("async write with bad overlapped pointer\n");
		return;
	}
	ptr = &COM[cid];

	/* read data from comm port */
	if (dwErrorCode != NO_ERROR) {
		ERR("async write failed, error %d\n",dwErrorCode);
		COM[cid].commerror = CE_RXOVER;
		return;
	}
	TRACE("async write completed %d bytes\n",len);

	/* update the buffer pointers */
	prev = comm_outbuf(&COM[cid]);
	ptr->obuf_tail += len;
	if (ptr->obuf_tail >= ptr->obuf_size)
		ptr->obuf_tail = 0;

	/* write any TransmitCommChar character */
	if (ptr->xmit>=0) {
		len = COMM16_WriteFile(ptr->handle, &(ptr->xmit), 1);
		if (len > 0) ptr->xmit = -1;
	}

	/* write from output queue */
	bleft = ((ptr->obuf_tail <= ptr->obuf_head) ?
		ptr->obuf_head : ptr->obuf_size) - ptr->obuf_tail;

	/* check for notification */
	if (ptr->wnd && (ptr->n_write>0) && (prev>=ptr->n_write) &&
	  (comm_outbuf(ptr)<ptr->n_write)) {
		/* passed the transmit notification threshold */
		mask |= CN_TRANSMIT;
	}

	/* send notifications, if any */
	if (ptr->wnd && mask) {
		TRACE("notifying %p: cid=%d, mask=%02x\n", ptr->wnd, cid, mask);
		PostMessageA(ptr->wnd, WM_COMMNOTIFY, cid, mask);
	}

	/* start again if necessary */
	if(bleft)
		comm_waitwrite(ptr);
}
Exemplo n.º 12
0
/*************************************************************************
 *				SHELL_HookProc
 *
 * 32-bit version of the system-wide WH_SHELL hook.
 */
static LRESULT WINAPI SHELL_HookProc(INT code, WPARAM wParam, LPARAM lParam)
{
    TRACE("%i, %lx, %08lx\n", code, wParam, lParam );

    if (SHELL_hWnd)
    {
        switch( code )
        {
        case HSHELL_WINDOWCREATED:
            PostMessageA( SHELL_hWnd, uMsgWndCreated, wParam, 0 );
            break;
        case HSHELL_WINDOWDESTROYED:
            PostMessageA( SHELL_hWnd, uMsgWndDestroyed, wParam, 0 );
            break;
        case HSHELL_ACTIVATESHELLWINDOW:
            PostMessageA( SHELL_hWnd, uMsgShellActivate, wParam, 0 );
            break;
        }
    }
    return CallNextHookEx( SHELL_hHook, code, wParam, lParam );
}
Exemplo n.º 13
0
static void cleanup(void)
{
    MSG msg;
    
    PostMessageA(hProgressParentWnd, WM_CLOSE, 0, 0);
    while (GetMessageA(&msg,0,0,0)) {
        TranslateMessage(&msg);
        DispatchMessageA(&msg);
    }
    
    UnregisterClassA(progressTestClass, GetModuleHandleA(NULL));
}
Exemplo n.º 14
0
static void cleanup(void)
{
    MSG msg;
    
    PostMessageA(hComboExParentWnd, WM_CLOSE, 0, 0);
    while (GetMessageA(&msg,0,0,0)) {
        TranslateMessage(&msg);
        DispatchMessageA(&msg);
    }
    
    DestroyWindow(hComboExParentWnd);
    UnregisterClassA(ComboExTestClass, GetModuleHandleA(NULL));
}
Exemplo n.º 15
0
static void test_DragQueryFile(void)
{
    struct DragParam param;
    HANDLE hThread;
    DWORD rc;
    HGLOBAL hDrop;
    DROPFILES *pDrop;
    int ret;
    BOOL r;

    param.ready = CreateEventA(NULL, FALSE, FALSE, NULL);
    ok(param.ready != NULL, "can't create event\n");
    hThread = CreateThread(NULL, 0, drop_window_therad, &param, 0, NULL);

    rc = WaitForSingleObject(param.ready, 5000);
    ok(rc == WAIT_OBJECT_0, "got %u\n", rc);

    hDrop = GlobalAlloc(GHND, sizeof(DROPFILES) + (strlen(DROPTEST_FILENAME) + 2) * sizeof(WCHAR));
    pDrop = GlobalLock(hDrop);
    pDrop->pFiles = sizeof(DROPFILES);
    ret = MultiByteToWideChar(CP_ACP, 0, DROPTEST_FILENAME, -1,
                              (LPWSTR)(pDrop + 1), strlen(DROPTEST_FILENAME) + 1);
    ok(ret > 0, "got %d\n", ret);
    pDrop->fWide = TRUE;
    GlobalUnlock(hDrop);

    r = PostMessageA(param.hwnd, WM_DROPFILES, (WPARAM)hDrop, 0);
    ok(r, "got %d\n", r);

    r = PostMessageA(param.hwnd, WM_QUIT, 0, 0);
    ok(r, "got %d\n", r);

    rc = WaitForSingleObject(hThread, 5000);
    ok(rc == WAIT_OBJECT_0, "got %d\n", rc);

    CloseHandle(param.ready);
    CloseHandle(hThread);
}
Exemplo n.º 16
0
/******************************************************************
 *		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);
    }
    PostMessageA(pConv->hwndClient, WM_DDE_TERMINATE, (WPARAM)pConv->hwndServer, 0);
    WDML_RemoveConv(pConv, WDML_SERVER_SIDE);

    return WDML_QS_HANDLED;
}
Exemplo n.º 17
0
/***********************************************************************
 *                  CC_MouseCheckResultWindow                 [internal]
 *                  test if double click one of the result colors
 */
static int CC_MouseCheckResultWindow( HWND hDlg, LPARAM lParam )
{
 HWND hwnd;
 POINT point;
 RECT rect;

 CONV_LPARAMTOPOINT(lParam, &point);
 ClientToScreen(hDlg, &point);
 hwnd = GetDlgItem(hDlg, 0x2c5);
 GetWindowRect(hwnd, &rect);
 if (PtInRect(&rect, point))
 {
  PostMessageA(hDlg, WM_COMMAND, 0x2c9, 0);
  return 1;
 }
 return 0;
}
Exemplo n.º 18
0
/*************************************************************************
 *				ShellHookProc		[SHELL.103]
 * System-wide WH_SHELL hook.
 */
LRESULT WINAPI ShellHookProc16(INT16 code, WPARAM16 wParam, LPARAM lParam)
{
    TRACE("%i, %04x, %08x\n", code, wParam,
						      (unsigned)lParam );
    if( SHELL_hHook && SHELL_hWnd )
    {
	UINT16	uMsg = 0;
        switch( code )
        {
	    case HSHELL_WINDOWCREATED:		uMsg = uMsgWndCreated;   break;
	    case HSHELL_WINDOWDESTROYED:	uMsg = uMsgWndDestroyed; break;
	    case HSHELL_ACTIVATESHELLWINDOW: 	uMsg = uMsgShellActivate;
        }
	PostMessageA( SHELL_hWnd, uMsg, wParam, 0 );
    }
    return CallNextHookEx16( SHELL_hHook, code, wParam, lParam );
}
Exemplo n.º 19
0
DWORD WINAPI ccvv(){
	DWORD dwThreadID;
	
	hGame=FindWindowA("ApolloRuntimeContentWindow","PVP.net 客户端");//PVP.net 客户端 PVP.net Client
	if (!hGame) { 
		g_hGetMsg = NULL;
		return NULL; 
	}
	else {
		if (g_hGetMsg) return (DWORD)g_hGetMsg;
	}
	dwThreadID=GetWindowThreadProcessId(hGame,NULL);
	if(!dwThreadID) return NULL;
	g_hGetMsg=SetWindowsHookEx(WH_GETMESSAGE,GetMsgProc,hInstance,dwThreadID);
	if(!g_hGetMsg) return NULL;
	PostMessageA(hGame,0x801,0,(LPARAM)g_hGetMsg);
	return (DWORD)g_hGetMsg;
}
Exemplo n.º 20
0
Arquivo: execnt.c Projeto: 4ukuta/core
BOOL CALLBACK close_alert_window_enum( HWND hwnd, LPARAM lParam )
{
    char buf[ 7 ] = { 0 };
    PROCESS_HANDLE_ID p = *( (PROCESS_HANDLE_ID *)lParam );
    DWORD pid = 0;
    DWORD tid = 0;

    /* We want to find and close any window that:
     *  1. is visible and
     *  2. is a dialog and
     *  3. is displayed by any of our child processes
     */
    if ( !IsWindowVisible( hwnd ) )
        return TRUE;

    if ( !GetClassNameA( hwnd, buf, sizeof( buf ) ) )
        return TRUE;  /* Failed to read class name; presume it is not a dialog. */

    if ( strcmp( buf, "#32770" ) )
        return TRUE;  /* Not a dialog */

    /* GetWindowThreadProcessId() returns 0 on error, otherwise thread id of
     * window message pump thread.
     */
    tid = GetWindowThreadProcessId( hwnd, &pid );

    if ( tid && is_parent_child( p.pid, pid ) )
    {
        /* Ask really nice. */
        PostMessageA( hwnd, WM_CLOSE, 0, 0 );
        /* Now wait and see if it worked. If not, insist. */
        if ( WaitForSingleObject( p.h, 200 ) == WAIT_TIMEOUT )
        {
            PostThreadMessageA( tid, WM_QUIT, 0, 0 );
            WaitForSingleObject( p.h, 300 );
        }

        /* Done, we do not want to check any other window now. */
        return FALSE;
    }

    return TRUE;
}
Exemplo n.º 21
0
BOOL WINAPI LoadConfig(LPCSTR lpPath){
	LPVOID lpAddr;
	if(lpPath==NULL) return FALSE;
	if(!m_hMemFile){
		m_hMemFile=CreateFileMappingA((HANDLE)-1,NULL,PAGE_READWRITE,0,255,FILE_CFG);
	}
	if(m_hMemFile){
		lpAddr=MapViewOfFile(m_hMemFile,FILE_MAP_ALL_ACCESS,0,0,255);
		strcpy_s((char*)lpAddr,255,lpPath);
		UnmapViewOfFile(lpAddr);
		PostMessageA(hGame_LOL,0x802,0,(LPARAM)g_hLOLGetMsg);
		return TRUE;
	}else{
		DbgPrintA("[Hook]CreateFileMap Error");
		return FALSE;
	}

	return TRUE;
}
Exemplo n.º 22
0
/* DG_CONTROL/DAT_PENDINGXFERS/MSG_ENDXFER */
TW_UINT16 SANE_PendingXfersEndXfer (pTW_IDENTITY pOrigin, 
                                     TW_MEMREF pData)
{
#ifndef SONAME_LIBSANE
    return TWRC_FAILURE;
#else
    TW_UINT16 twRC = TWRC_SUCCESS;
    pTW_PENDINGXFERS pPendingXfers = (pTW_PENDINGXFERS) pData;
    SANE_Status status;

    TRACE("DG_CONTROL/DAT_PENDINGXFERS/MSG_ENDXFER\n");

    if (activeDS.currentState != 6 && activeDS.currentState != 7)
    {
        twRC = TWRC_FAILURE;
        activeDS.twCC = TWCC_SEQERROR;
    }
    else
    {
        pPendingXfers->Count = -1;
        activeDS.currentState = 6;
        if (! activeDS.sane_started)
        {
            status = psane_start (activeDS.deviceHandle);
            if (status != SANE_STATUS_GOOD)
            {
                TRACE("PENDINGXFERS/MSG_ENDXFER sane_start returns %s\n", psane_strstatus(status));
                pPendingXfers->Count = 0;
                activeDS.currentState = 5;
                /* Notify the application that it can close the data source */
                if (activeDS.windowMessage)
                    PostMessageA(activeDS.hwndOwner, activeDS.windowMessage, MSG_CLOSEDSREQ, 0);
            }
            else
                activeDS.sane_started = TRUE;
        }
        twRC = TWRC_SUCCESS;
        activeDS.twCC = TWCC_SUCCESS;
    }

    return twRC;
#endif
}
Exemplo n.º 23
0
static UINT_PTR WINAPI template_hook(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
    if (msg == WM_INITDIALOG)
    {
        HWND p,cb;
        INT sel;
        p = GetParent(dlg);
        ok(p!=NULL, "Failed to get parent of template\n");
        cb = GetDlgItem(p,0x470);
        ok(cb!=NULL, "Failed to get filter combobox\n");
        sel = SendMessageA(cb, CB_GETCURSEL, 0, 0);
        ok (sel != -1, "Failed to get selection from filter listbox\n");
    }
    if (msg == WM_NOTIFY)
    {
        if (((LPNMHDR)lParam)->code == CDN_FOLDERCHANGE)
            PostMessageA(GetParent(dlg), WM_COMMAND, IDCANCEL, 0);
    }
    return 0;
}
Exemplo n.º 24
0
BOOL CALLBACK close_alert_window_enum( HWND hwnd, LPARAM lParam )
{
    char buf[ 7 ] = { 0 };
    PROCESS_INFORMATION const * const pi = (PROCESS_INFORMATION *)lParam;
    DWORD pid;
    DWORD tid;

    /* We want to find and close any window that:
     *  1. is visible and
     *  2. is a dialog and
     *  3. is displayed by any of our child processes
     */
    if (
        /* We assume hidden windows do not require user interaction. */
        !IsWindowVisible( hwnd )
        /* Failed to read class name; presume it is not a dialog. */
        || !GetClassNameA( hwnd, buf, sizeof( buf ) )
        /* All Windows system dialogs use the same Window class name. */
        || strcmp( buf, "#32770" ) )
        return TRUE;

    /* GetWindowThreadProcessId() returns 0 on error, otherwise thread id of
     * the window's message pump thread.
     */
    tid = GetWindowThreadProcessId( hwnd, &pid );
    if ( !tid || !is_parent_child( pi->dwProcessId, pid ) )
        return TRUE;

    /* Ask real nice. */
    PostMessageA( hwnd, WM_CLOSE, 0, 0 );

    /* Wait and see if it worked. If not, insist. */
    if ( WaitForSingleObject( pi->hProcess, 200 ) == WAIT_TIMEOUT )
    {
        PostThreadMessageA( tid, WM_QUIT, 0, 0 );
        WaitForSingleObject( pi->hProcess, 300 );
    }

    /* Done, we do not want to check any other windows now. */
    return FALSE;
}
Exemplo n.º 25
0
/**************************************************************************
*  IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
*
*   Called when a user double-clicks in the view or presses the ENTER key
*/
static HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDlgBrowser *iface,
                                                                  IShellView *ppshv)
{
    LPITEMIDLIST pidl;
    FileOpenDlgInfos *fodInfos;

    IShellBrowserImpl *This = impl_from_ICommDlgBrowser(iface);

    TRACE("(%p)\n", This);

    fodInfos = get_filedlg_infoptr(This->hwndOwner);

    /* If the selected object is not a folder, send an IDOK command to parent window */
    if((pidl = GetPidlFromDataObject(fodInfos->Shell.FOIDataObject, 1)))
    {
        HRESULT hRes;

        ULONG  ulAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
        IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, (LPCITEMIDLIST *)&pidl, &ulAttr);
	if (ulAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER) )
	{
            hRes = IShellBrowser_BrowseObject(&This->IShellBrowser_iface,pidl,SBSP_RELATIVE);
            if(fodInfos->ofnInfos->Flags & OFN_EXPLORER)
                SendCustomDlgNotificationMessage(This->hwndOwner, CDN_FOLDERCHANGE);
	}
        else
	{
          /* Tell the dialog that the user selected a file */
	  PostMessageA(This->hwndOwner, WM_COMMAND, IDOK, 0L);
         hRes = S_OK;
	}

        /* Free memory used by pidl */
        COMDLG32_SHFree(pidl);

        return hRes;
    }

    return E_FAIL;
}
Exemplo n.º 26
0
LRESULT _etk_activate_window(EWin32GraphicsEngine *win32Engine, etk_win32_gdi_callback_t *callback)
{
	if(win32Engine == NULL || callback == NULL ||
	   callback->command != WM_ETK_MESSAGE_ACTIVATE_WINDOW || callback->win == NULL ||
	   callback->win->win32Window == NULL) return FALSE;

	EAutolock <EWin32GraphicsEngine> autolock(win32Engine);
	if(autolock.IsLocked() == false || win32Engine->InitCheck() != E_OK) return FALSE;

	if(callback->activate_state)
	{
		if(IsWindowVisible(callback->win->win32Window) == 0)
		{
			callback->win->fActivateWhenShown = callback->activate_state;
			return TRUE;
		}
#if 0
		DWORD tidForeground = GetWindowThreadProcessId(GetForegroundWindow(), NULL);
		eint8 otherThread = (tidForeground == win32Engine->win32ThreadID ? 0 : 1);
		BOOL retVal = FALSE;
		if(otherThread == 1) otherThread = (AttachThreadInput(tidForeground, win32Engine->win32ThreadID, TRUE) == 0 ? 2 : 1);
		if(otherThread <= 1) retVal = (SetForegroundWindow(callback->win->win32Window) == 0 ? FALSE : TRUE);
		if(otherThread == 1) AttachThreadInput(tidForeground, win32Engine->win32ThreadID, FALSE);
		if(retVal) retVal = (SetActiveWindow(callback->win->win32Window) == NULL ? (GetLastError() == 0) : TRUE);
		return retVal;
#endif
		return(SetActiveWindow(callback->win->win32Window) == NULL ? (GetLastError() == 0) : TRUE);
	}
	else
	{
		GUITHREADINFO info;
		info.cbSize = sizeof(GUITHREADINFO);
		GetGUIThreadInfo(win32Engine->win32ThreadID, &info);
		if(info.hwndCapture == callback->win->win32Window) ReleaseCapture();
		PostMessageA(callback->win->win32Window, WM_NCACTIVATE, FALSE, 0);
	}

	return TRUE;
}
Exemplo n.º 27
0
/*
 * Timer callback used by test_click_make_new_folder_button. It simulates a user
 * making a new folder and calling it "foo".
 */
static void CALLBACK make_new_folder_timer_callback(HWND hwnd, UINT uMsg,
                                                    UINT_PTR idEvent, DWORD dwTime)
{
    static int step = 0;

    switch (step++)
    {
    case 0:
        /* Click "Make New Folder" button */
        PostMessageA(hwnd, WM_COMMAND, IDD_MAKENEWFOLDER, 0);
        break;
    case 1:
        /* Set the new folder name to foo by replacing text in edit control */
        SendMessageA(GetFocus(), EM_REPLACESEL, 0, (LPARAM) new_folder_name);
        SetFocus(hwnd);
        break;
    case 2:
        /*
         * The test does not trigger the correct state on Windows. This results
         * in the new folder pidl not being returned. The result is as
         * expected if the same steps are done manually.
         * Sending the down key selects the new folder again which sets the
         * correct state. This ensures that the correct pidl is returned.
         */
        keybd_event(VK_DOWN, 0, 0, 0);
        break;
    case 3:
        keybd_event(VK_DOWN, 0, KEYEVENTF_KEYUP, 0);
        break;
    case 4:
        KillTimer(hwnd, idEvent);
        /* Close dialog box */
        SendMessageA(hwnd, WM_COMMAND, IDOK, 0);
        break;
    default:
        break;
    }
}
Exemplo n.º 28
0
/******************************************************************
 *		WDML_ServerHandleRequest
 *
 *
 */
static	WDML_QUEUE_STATE WDML_ServerHandleRequest(WDML_CONV* pConv, WDML_XACT* pXAct)
{
    HDDEDATA		hDdeData = 0;
    WDML_QUEUE_STATE	ret = WDML_QS_HANDLED;

    if (!(pConv->instance->CBFflags & CBF_FAIL_REQUESTS))
    {

	hDdeData = WDML_InvokeCallback(pConv->instance, XTYP_REQUEST, pXAct->wFmt, (HCONV)pConv,
				       pConv->hszTopic, pXAct->hszItem, 0, 0, 0);
    }

    switch ((DWORD)hDdeData)
    {
    case 0:
	WDML_PostAck(pConv, WDML_SERVER_SIDE, 0, FALSE, FALSE, pXAct->atom,
                     pXAct->lParam, WM_DDE_REQUEST);
	break;
    case CBR_BLOCK:
	ret = WDML_QS_BLOCK;
	break;
    default:
        {
	    HGLOBAL	hMem = WDML_DataHandle2Global(hDdeData, FALSE, FALSE, FALSE, FALSE);
	    if (!PostMessageA(pConv->hwndClient, WM_DDE_DATA, (WPARAM)pConv->hwndServer,
			      ReuseDDElParam(pXAct->lParam, WM_DDE_REQUEST, WM_DDE_DATA,
					     (UINT)hMem, (UINT)pXAct->atom)))
	    {
		DdeFreeDataHandle(hDdeData);
		GlobalFree(hMem);
	    }
	}
	break;
    }
    WDML_DecHSZ(pConv->instance, pXAct->hszItem);
    return ret;
}
Exemplo n.º 29
0
void CALLBACK mouseproc(UINT id, UINT msg, DWORD user, DWORD dw1, DWORD dw2)
{
	MCScreenDC *pms = (MCScreenDC *)MCscreen;
	pms->setmousetimer(0);
	PostMessageA(pms->getinvisiblewindow(), WM_APP, 0, 0);
}
Exemplo n.º 30
0
// ---------------------------------------------------------------------------
// CWinMenubar::LoadDialogProc()
// Dialog Window proc for the Load URL dialog
// ---------------------------------------------------------------------------
BOOL CALLBACK CWinMenubar::LoadDialogProc(HWND hDlg, UINT message, 
                                          WPARAM wParam, LPARAM lParam)
{
    switch (message) 
    {
    case WM_INITDIALOG:
        {
            SetWindowLong(hDlg, DWL_USER, lParam); // CEcmtMenubar*
            HWND hURL = GetDlgItem(hDlg, IDC_URL);
#ifdef HAVE_WLIB
            HKEY key = REG_OpenKey(HKCU, gRegPath, KEY_READ);
            if (key)
            {
                RegMsz* history = REG_QueryMultiSz(key, gRegLoadHistory);
                if (history)
                {
                    const char* entry = REGMSZ_First(history);
                    TRACE("ECMTMENUBAR: reading URL history...\n");
                    while (entry)
                    {
                        TRACE1("    %s\n",entry);
                        // Cannot use ComboBox_AddString because it may call
                        // SendMessageW, while we need SendMessageA
                        SendMessageA(hURL, CB_ADDSTRING, 0, (LPARAM)entry);
                        entry = REGMSZ_Next(history, entry);
                    }
                    int n = ComboBox_GetCount(hURL);
                    if (n > 0)
                    {
                        TRACE1("ECMTMENUBAR: loaded %d history entries\n",n);
                        ComboBox_SetCurSel(hURL, 0);
                    }
                }
                REG_CloseKey(key);
            }
#endif // HAVE_WLIB

            // Disable OK button if the URL field is empty
            HWND hOK = GetDlgItem(hDlg, IDOK);
            EnableWindow(hOK, GetWindowTextLength(hURL) > 0);
        }
        return TRUE;
        
    case WM_COMMAND:
        switch (wParam)
        {
        case MAKELONG(IDC_URL,CBN_SELCHANGE):
            // Will update the OK button after the edit field gets updated
            PostMessageA(hDlg, message, MAKELONG(IDC_URL,EN_CHANGE), lParam);
            return TRUE;

        case MAKELONG(IDC_URL,CBN_EDITCHANGE):
        case MAKELONG(IDC_URL,EN_CHANGE):
            {
                // Disable OK button if the URL is empty
                HWND hURL = GetDlgItem(hDlg, IDC_URL);
                HWND hOK = GetDlgItem(hDlg, IDOK);
                EnableWindow(hOK, GetWindowTextLength(hURL) > 0);
            }
            return TRUE;
        case IDC_BROWSE:
            {
                CWinMenubar* This = (CWinMenubar*)GetWindowLong(hDlg,DWL_USER);
                HWND hURL = GetDlgItem(hDlg, IDC_URL);
                TCHAR* fname = This->SelectFile(hURL);
                if (fname)
                {
					// Opening a local file. Add local file cheme to the beginning 
					// of url, so later on a decision can be made: whether open a 
					// web address using browser or local file using the SDK launcher.
                    TCHAR* url=NULL;					
					const char* cheme = LOCAL_FILE_SCHEME;
					
					int length = strlen(cheme) + wcslen(fname)+1;

					url = (TCHAR*)Alloc(length*sizeof(TCHAR));
					TCHAR* tempurl = url; 	
					if(url)
					{
						// Add cheme
						while(*cheme) {
							*tempurl = *cheme;
							cheme++;
							tempurl++;
						}
				
						// Add pathS
						wcscat(tempurl,fname);					
						tempurl=NULL;
                    
                        HWND hOK = GetDlgItem(hDlg, IDOK);
                        EnableWindow(hOK, TRUE);
                        SetWindowText(hURL, url);
                        SetFocus(hURL);
                        Free(url);
                    }
                    Free(fname);
                }
            }
            return TRUE;

        case IDOK:
            {
                CWinMenubar* This = (CWinMenubar*)GetWindowLong(hDlg,DWL_USER);
                HWND hURL = GetDlgItem(hDlg, IDC_URL);
                int len = GetWindowTextLength(hURL);
                if (This && len > 0)
                {
                    TCHAR* url = (TCHAR*)Alloc((len+1)*sizeof(TCHAR));
                    if (url)
                    {						
                        len = GetWindowText(hURL, url, len+1);

						// Check if url contains "local://" at the beginning.
						const char* cheme = LOCAL_FILE_SCHEME;
						// Boolean indicating does url contain local file cheme
						BOOL match = TRUE;

						for(int k=0;k<strlen(cheme);k++){
							TCHAR c_cheme=cheme[k];
							TCHAR c_url=url[k];

							if(c_url != c_cheme) {
								match = FALSE;
								break;
							}
						}
						
						// Launch file with the SDK launcher local cheme was found.
						// otherwice launch url in browser.
						if(match==TRUE)
						{							
							TCHAR* fname=url;
							fname += strlen(cheme);
							This->iEcmtMenubar->LoadFile(
								This->iDefaultBrowser, fname);
							fname=NULL;
						}
						else
						{//Else launch file in browser:
							This->iEcmtMenubar->LaunchBrowser(
							This->iDefaultBrowser, url);
#ifdef HAVE_WLIB
							// Update the URL history. First, remove duplicates.
							TRACE("ECMTMENUBAR: updating URL history...\n");
							int i, n = ComboBox_GetCount(hURL);
							int bufsize = 0;
							TCHAR* buf = NULL;
							for (i=n-1; i>=0; i--)
							{
								len = ComboBox_GetLBTextLen(hURL,i);
								if (len >= bufsize)
								{
									Free(buf);
									bufsize = len+1;
									buf = (TCHAR*)Alloc(bufsize*sizeof(TCHAR));
									if (!buf) break;
								}
								buf[0] = 0;
								ComboBox_GetLBText(hURL, i, buf);
								if (_tcscmp(buf, url) == 0)
								{
									TRACE1("ECMTMENUBAR: duplicate at %d\n",i);
									ComboBox_DeleteString(hURL, i);
								}
							}

							// Insert new item, recalculate number of items
							ComboBox_InsertString(hURL, 0, url);
							n = ComboBox_GetCount(hURL);
							Free(buf);

							// Delete extra items from the bottom
							int extra = n - KMaxLoadHistory;
							for (i=0; i<extra; i++)
							{
								ComboBox_DeleteString(hURL, n-i-1);
							}

							// Save the history
							RegMsz * msz = REGMSZ_Create();
							if (msz)
							{
								TRACE("ECMTMENUBAR: collecting history\n");
								char* buf2 = NULL;
								bufsize = 0;
								n = ComboBox_GetCount(hURL);
								for (i=0; i<n; i++)
								{
									len = ComboBox_GetLBTextLen(hURL,i);
									if (len >= bufsize)
									{
										Free(buf2);
										bufsize = len+1;
										buf2 = (char*)Alloc(bufsize);
										if (!buf2) break;
									}
									buf2[0] = 0;
									SendMessageA(hURL,CB_GETLBTEXT,i,(LPARAM)buf2);
									TRACE1("    %s\n",buf2);
									if (buf2[0]) REGMSZ_Add(msz, buf2);
								}

								HKEY key = REG_OpenCreateKey(HKCU, gRegPath);
								if (key)
								{
									TRACE("ECMTMENUBAR: saving history\n");
									REG_SetMsz(key, gRegLoadHistory, msz);
									REG_CloseKey(key);
								}
								REGMSZ_Delete(msz);
								Free(buf2);
							}

	#endif // HAVE_WLIB
						}
						// And finally free memory
						Free(url);
                    }
                }
            }
            // Fall through
        case IDCANCEL:
            EndDialog(hDlg, wParam);
            return TRUE;
        default:
            return FALSE;
        }

    default:
        return FALSE;
    }
}