Esempio n. 1
0
	LRESULT Control::ControlProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam,
		UINT_PTR subClassId, DWORD_PTR dataReference)
	{
		Pointer ptr;
		MessageMap msgMap;

		if (!ProcessMessages)
		{
			MSG msg;
			msg.hwnd = hwnd;
			msg.message = message;
			msg.wParam = wParam;
			msg.lParam = lParam;
			QueuedMessages.push_back(msg);
			return DefSubclassProc(hwnd, message, wParam, lParam);
		}

		map<HWND, MessageMap>::iterator iterGlobal = GlobalMessageMap.find(hwnd);

		if (iterGlobal == GlobalMessageMap.end())
			return DefSubclassProc(hwnd, message, wParam, lParam);

		msgMap = iterGlobal->second;

		MessageMap::iterator iter = msgMap.find(message);

		if (iter == msgMap.end())
			return DefSubclassProc(hwnd, message, wParam, lParam);

		ptr = iter->second;
		return (ptr.Window->*ptr.Function)(wParam, lParam);
	}
Esempio n. 2
0
static LRESULT CALLBACK
EditProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) {
    EditCtrl *w = (EditCtrl *)dwRefData;
    CrashIf(w->hwnd != (HWND)lp);

    if (w->preFilter) {
        bool discard = false;
        auto res = w->preFilter(hwnd, msg, wp, lp, discard);
        if (discard) {
            return res;
        }
    }

    if (WM_NCDESTROY == msg) {
        RemoveWindowSubclass(GetParent(w->hwnd), EditParentProc, 0);
        RemoveWindowSubclass(w->hwnd, EditProc, 0);
        return DefSubclassProc(hwnd, msg, wp, lp);
    }

    // Node: this is sent during creation, which is too early for us (we didn't
    // subclass the window yet)
    // currently, we force it with SetWindowPos(... SMP_FRAMECHANGED)
    if (WM_NCCALCSIZE == msg) {
        NCCALCSIZE_PARAMS *p = (NCCALCSIZE_PARAMS *)lp;
        RECT orig = p->rgrc[0];
        LRESULT res = DefSubclassProc(hwnd, msg, wp, lp);
        RECT curr = p->rgrc[0];
        w->ncDx = RectDx(orig) - RectDx(curr);
        w->ncDy = RectDy(orig) - RectDy(curr);
        return res;
    }

    return DefSubclassProc(hwnd, msg, wp, lp);
}
Esempio n. 3
0
static LRESULT CALLBACK TreeProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) {
    UNUSED(uIdSubclass);
    TreeCtrl* w = (TreeCtrl*)dwRefData;
    CrashIf(w->hwnd != (HWND)hwnd);

    if (w->preFilter) {
        bool discard = false;
        auto res = w->preFilter(hwnd, msg, wp, lp, discard);
        if (discard) {
            return res;
        }
    }

    if (WM_ERASEBKGND == msg) {
        return FALSE;
    }

    if (WM_KEYDOWN == msg) {
        if (HandleKey(hwnd, wp)) {
            return 0;
        }
    }

    if (WM_NCDESTROY == msg) {
        Unsubclass(w);
        return DefSubclassProc(hwnd, msg, wp, lp);
    }

    return DefSubclassProc(hwnd, msg, wp, lp);
}
Esempio n. 4
0
LRESULT AeroControlBase::ProgressbarWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg)
    {
    case WM_ENABLE:
    case WM_STYLECHANGED:
        {
            LRESULT res = DefSubclassProc(hWnd, uMsg, wParam, lParam);
            InvalidateRgn(hWnd, NULL, FALSE);
            return res;
        }
        break;
    case WM_PAINT:
        {
            PAINTSTRUCT ps;
            HDC hdc = BeginPaint(hWnd, &ps);
            RECT rc;
            GetWindowRect(hWnd, &rc);
            MapWindowPoints(NULL, hWnd, (LPPOINT)&rc, 2);

            if (hdc)
            {
                PaintControl(hWnd, hdc, &ps.rcPaint, false);

                BP_PAINTPARAMS params = { sizeof(BP_PAINTPARAMS) };
                params.dwFlags = 0L;
                HDC hdcPaint = NULL;
                HPAINTBUFFER hBufferedPaint = BeginBufferedPaint(hdc, &rc, BPBF_TOPDOWNDIB, &params, &hdcPaint);
                if (hdcPaint)
                {
                    COLORREF cr = RGB(0x00, 0x00, 0x00);
                    SetPixel(hdcPaint, 0, 0, cr);
                    SetPixel(hdcPaint, 0, RECTHEIGHT(rc) - 1, cr);
                    SetPixel(hdcPaint, RECTWIDTH(rc) - 1, 0, cr);
                    SetPixel(hdcPaint, RECTWIDTH(rc) - 1, RECTHEIGHT(rc) - 1, cr);

                    EndBufferedPaint(hBufferedPaint, TRUE);
                }
            }

            EndPaint(hWnd, &ps);
            return 0;
        }
        break;
    case WM_NCDESTROY:
    case WM_DESTROY:
        RemoveWindowSubclass(hWnd, SubclassProc, Static);
        subclassedControls.erase(hWnd);
        break;
    }

    return DefSubclassProc(hWnd, uMsg, wParam, lParam);
}
Esempio n. 5
0
static LRESULT CALLBACK FrameSubclass(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR, DWORD_PTR dwRefData)
{
	HWND hwndTransfer = (HWND) dwRefData;
	switch (uMsg)
	{
	case WM_MOVE:
		{
			LPCALC lpCalc = (LPCALC) GetWindowLongPtr(hwndTransfer, GWLP_USERDATA);
			RECT wr;
			GetWindowRect(hwnd, &wr);

			DWORD dwSendWidth = (wr.right - wr.left) * 9 / 10;
			DWORD dwSendHeight = 90; //10 * HIWORD(GetDialogBaseUnits());

			LPSENDINFO lpsi = g_SendInfo[lpCalc];
			RECT rcLcd = { 0 };
			if (lpsi != NULL) {
				GetWindowRect(lpsi->hwndParent, &rcLcd);
			}

			SetWindowPos(hwndTransfer, NULL, 
				wr.left + ((wr.right - wr.left) - dwSendWidth) / 2,
				rcLcd.top + (rcLcd.bottom - rcLcd.top - dwSendHeight) / 2,
				dwSendWidth, dwSendHeight,
				SWP_NOSIZE | SWP_NOZORDER);
			break;
		}
	}
	return DefSubclassProc(hwnd, uMsg, wParam, lParam);
}
Esempio n. 6
0
// the real list view intercepts these keys to control editing
static LRESULT CALLBACK editSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIDSubclass, DWORD_PTR dwRefData)
{
	uiTable *t = (uiTable *) dwRefData;
	HRESULT hr;

	switch (uMsg) {
	case WM_KEYDOWN:
		switch (wParam) {
		// TODO handle VK_TAB and VK_SHIFT+VK_TAB
		case VK_RETURN:
			hr = uiprivTableFinishEditingText(t);
			if (hr != S_OK) {
				// TODO
			}
			return 0;		// yes, the real list view just returns here
		case VK_ESCAPE:
			hr = uiprivTableAbortEditingText(t);
			if (hr != S_OK) {
				// TODO
			}
			return 0;
		}
		break;
	// the real list view also forces these flags
	case WM_GETDLGCODE:
		return DLGC_HASSETSEL | DLGC_WANTALLKEYS;
	case WM_NCDESTROY:
		if (RemoveWindowSubclass(hwnd, editSubProc, uIDSubclass) == FALSE)
			logLastError(L"RemoveWindowSubclass()");
		// fall through
	}
	return DefSubclassProc(hwnd, uMsg, wParam, lParam);
}
Esempio n. 7
0
static LRESULT CALLBACK groupSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
{
	uiGroup *g = uiGroup(dwRefData);
	WINDOWPOS *wp = (WINDOWPOS *) lParam;
	MINMAXINFO *mmi = (MINMAXINFO *) lParam;
	int minwid, minht;
	LRESULT lResult;

	if (handleParentMessages(hwnd, uMsg, wParam, lParam, &lResult) != FALSE)
		return lResult;
	switch (uMsg) {
	case WM_WINDOWPOSCHANGED:
		if ((wp->flags & SWP_NOSIZE) != 0)
			break;
		groupRelayout(g);
		return 0;
	case WM_GETMINMAXINFO:
		lResult = DefWindowProcW(hwnd, uMsg, wParam, lParam);
		uiWindowsControlMinimumSize(uiWindowsControl(g), &minwid, &minht);
		mmi->ptMinTrackSize.x = minwid;
		mmi->ptMinTrackSize.y = minht;
		return lResult;
	case WM_NCDESTROY:
		if (RemoveWindowSubclass(hwnd, groupSubProc, uIdSubclass) == FALSE)
			logLastError(L"error removing groupbox subclass");
		break;
	}
	return DefSubclassProc(hwnd, uMsg, wParam, lParam);
}
LRESULT CALLBACK Explorerplusplus::EditSubclass(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
	switch(msg)
	{
		case WM_KEYDOWN:
			switch(wParam)
			{
				case VK_RETURN:
					OnAddressBarGo();
					return 0;
					break;
			}
			break;

		case WM_SETFOCUS:
			UpdateMainToolbar();
			break;

		case WM_MOUSEWHEEL:
			if(OnMouseWheel(MOUSEWHEEL_SOURCE_OTHER,wParam,lParam))
			{
				return 0;
			}
			break;
	}

	return DefSubclassProc(hwnd,msg,wParam,lParam);
}
LRESULT CALLBACK Explorerplusplus::EditSubclass(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
	switch(msg)
	{
		case WM_KEYDOWN:
			switch(wParam)
			{
				case VK_RETURN:
					SendMessage(m_hContainer,CBN_KEYDOWN,VK_RETURN,0);
					return 0;
					break;
			}
			break;

		case WM_SETFOCUS:
			HandleToolbarItemStates();
			break;

		case WM_MOUSEWHEEL:
			if(OnMouseWheel(MOUSEWHEEL_SOURCE_OTHER,wParam,lParam))
			{
				return 0;
			}
			break;
	}

	return DefSubclassProc(hwnd,msg,wParam,lParam);
}
LRESULT CALLBACK CBookmarksToolbar::BookmarksToolbarParentProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
	switch(uMsg)
	{
	case WM_COMMAND:
		if(LOWORD(wParam) >= m_uIDStart &&
			LOWORD(wParam) <= m_uIDEnd)
		{
			/* TODO: Map the id back to a GUID, and
			then open the bookmark/show a dropdown
			list. */
			return 0;
		}
		break;

	case WM_NOTIFY:
		if(reinterpret_cast<LPNMHDR>(lParam)->hwndFrom == m_hToolbar)
		{
			switch(reinterpret_cast<LPNMHDR>(lParam)->code)
			{
			case TBN_GETINFOTIP:
				{
					//NMTBGETINFOTIP *pnmtbgit = reinterpret_cast<NMTBGETINFOTIP *>(lParam);

					/* TODO: Build an infotip for the bookmark. */
					//return 0;
				}
				break;
			}
		}
		break;
	}

	return DefSubclassProc(hwnd,uMsg,wParam,lParam);
}
Esempio n. 11
0
/***********************************************************************
 * UPDOWN_Buddy_SubclassProc used to handle messages sent to the buddy
 *                           control.
 */
static LRESULT CALLBACK
UPDOWN_Buddy_SubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
                          UINT_PTR uId, DWORD_PTR ref_data)
{
    UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr((HWND)ref_data);

    TRACE("hwnd=%p, uMsg=%04x, wParam=%08lx, lParam=%08lx\n",
          hwnd, uMsg, wParam, lParam);

    switch(uMsg)
    {
    case WM_KEYDOWN:
        UPDOWN_KeyPressed(infoPtr, (int)wParam);
        if ((wParam == VK_UP) || (wParam == VK_DOWN)) return 0;
        break;

    case WM_MOUSEWHEEL:
        UPDOWN_MouseWheel(infoPtr, (int)wParam);
        break;

    default:
        break;
    }

    return DefSubclassProc(hwnd, uMsg, wParam, lParam);
}
Esempio n. 12
0
/***********************************************************************
 * COMCTL32_SubclassProc (internal)
 *
 * Window procedure for all subclassed windows. 
 * Saves the current subclassing stack position to support nested messages
 */
static LRESULT WINAPI COMCTL32_SubclassProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
   LPSUBCLASS_INFO stack;
   LPSUBCLASSPROCS proc;
   LRESULT ret;
    
   TRACE ("(%p, 0x%08x, 0x%08lx, 0x%08lx)\n", hWnd, uMsg, wParam, lParam);

   stack = GetPropW (hWnd, COMCTL32_wSubclass);
   if (!stack) {
      ERR ("Our sub classing stack got erased for %p!! Nothing we can do\n", hWnd);
      return 0;
   }
    
   /* Save our old stackpos to properly handle nested messages */
   proc = stack->stackpos;
   stack->stackpos = stack->SubclassProcs;
   stack->running++;
   ret = DefSubclassProc(hWnd, uMsg, wParam, lParam);
   stack->running--;
   stack->stackpos = proc;
    
   if (!stack->SubclassProcs && !stack->running) {
      TRACE("Last Subclass removed, cleaning up\n");
      /* clean up our heap and reset the original window procedure */
      if (IsWindowUnicode (hWnd))
         SetWindowLongPtrW (hWnd, GWLP_WNDPROC, (DWORD_PTR)stack->origproc);
      else
         SetWindowLongPtrA (hWnd, GWLP_WNDPROC, (DWORD_PTR)stack->origproc);
      Free (stack);
      RemovePropW( hWnd, COMCTL32_wSubclass );
   }
   return ret;
}
Esempio n. 13
0
static LRESULT CALLBACK opacitySliderSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
{
	ID2D1RenderTarget *rt;
	struct colorDialog *c;
	D2D1_POINT_2F *pos;
	D2D1_SIZE_F *size;

	c = (struct colorDialog *) dwRefData;
	switch (uMsg) {
	case msgD2DScratchPaint:
		rt = (ID2D1RenderTarget *) lParam;
		drawOpacitySlider(c, rt);
		return 0;
	case msgD2DScratchLButtonDown:
		pos = (D2D1_POINT_2F *) wParam;
		size = (D2D1_SIZE_F *) lParam;
		c->a = 1 - (pos->x / size->width);
		updateDialog(c, NULL);
		return 0;
	case WM_NCDESTROY:
		if (RemoveWindowSubclass(hwnd, opacitySliderSubProc, uIdSubclass) == FALSE)
			logLastError(L"error removing color dialog opacity slider subclass");
		break;
	}
	return DefSubclassProc(hwnd, uMsg, wParam, lParam);
}
LRESULT CALLBACK Explorerplusplus::MainWndTaskbarThumbnailProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
	if(uMsg == m_uTaskbarButtonCreatedMessage)
	{
		if(m_pTaskbarList != NULL)
		{
			m_pTaskbarList->Release();
		}

		CoCreateInstance(CLSID_TaskbarList,NULL,CLSCTX_INPROC_SERVER,
			IID_PPV_ARGS(&m_pTaskbarList));
		m_pTaskbarList->HrInit();

		m_bTaskbarInitialised = TRUE;

		/* Add each of the jump list tasks. */
		SetupJumplistTasks();

		/* Register each of the tabs. */
		for(auto itr = m_TabProxyList.begin();itr != m_TabProxyList.end();itr++)
		{
			BOOL bActive = (itr->iTabId == m_iObjectIndex);

			RegisterTab(itr->hProxy,EMPTY_STRING,bActive);
			HandleTabText(itr->iTabId);
			SetTabIcon(itr->iTabId);
		}

		RemoveWindowSubclass(hwnd,MainWndProcStub,0);

		return 0;
	}

	return DefSubclassProc(hwnd,uMsg,wParam,lParam);
}
Esempio n. 15
0
LRESULT CALLBACK
FilterListProcedure(
	IN HWND hWnd,
	IN UINT uMsg,
	IN WPARAM wp,
	IN LPARAM lp,
	IN UINT_PTR uIdSubclass,
	IN DWORD_PTR dwRefData
	)
{
	BOOLEAN Handled;

	switch (uMsg) {

		case WM_KEYDOWN:

			if ((ULONG)wp == VK_DELETE) {
				Handled = FilterListOnDelete(hWnd, uMsg, wp, lp);
				if (Handled) {
					return TRUE;
				}
			}
	}

	return DefSubclassProc(hWnd, uMsg, wp, lp);
} 
Esempio n. 16
0
LRESULT CALLBACK TextBoxSubclassProc(
    _In_ HWND hWnd,
    _In_ UINT uMsg,
    _In_ WPARAM wParam,
    _In_ LPARAM lParam,
    _In_ UINT_PTR uIdSubclass,
    _In_ ULONG_PTR dwRefData
    )
{
    switch (uMsg)
    {
    case WM_NCDESTROY:
        RemoveWindowSubclass(hWnd, TextBoxSubclassProc, uIdSubclass);
        break;
    case WM_GETDLGCODE:
        {
            if (wParam == VK_RETURN)
                return DLGC_WANTALLKEYS;
        }
        break;
    case WM_CHAR:
        {
            if (wParam == VK_RETURN)
            {
                SendMessage(GetParent(hWnd), WM_COMMAND, IDC_TEXT_RETURN, 0);
                return 0;
            }
        }
        break;
    }

    return DefSubclassProc(hWnd, uMsg, wParam, lParam);
}
Esempio n. 17
0
	LRESULT RichEdit::ParentWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, 
		UINT_PTR uIdSubclass, DWORD_PTR dwRefData) {
		if(msg==WM_NOTIFY && (((LPNMHDR)lParam)->code)== EN_LINK) {
			ENLINK* enLinkInfo = (ENLINK *)lParam;
			if(enLinkInfo->msg == WM_LBUTTONUP || enLinkInfo->msg == WM_RBUTTONUP) {
				LONG utlBeg = enLinkInfo->chrg.cpMin;
				LONG utlEnd = enLinkInfo->chrg.cpMax;
				if(utlEnd - utlBeg > 0) {
					HWND hRichEdit = enLinkInfo->nmhdr.hwndFrom;
					wchar_t* urlString = new wchar_t[utlEnd-utlBeg+1];
					SendMessageW(hRichEdit, EM_EXSETSEL, 0, reinterpret_cast<LPARAM>(&enLinkInfo->chrg));
					SendMessageW(hRichEdit, EM_GETSELTEXT, 0, reinterpret_cast<LPARAM>(urlString));
					switch(enLinkInfo->msg) {
					case WM_LBUTTONUP:
						ShellExecuteW(NULL, L"open", urlString, NULL, NULL, SW_SHOWNORMAL);
						break;
					case WM_RBUTTONUP:
						copyToClipboard(hRichEdit, urlString);
						break;
					}
					delete [] urlString;
					SendMessage(hRichEdit, EM_SETSEL, utlEnd, utlEnd);
					HideCaret(hRichEdit);
				}
			}
		}
		return DefSubclassProc(hWnd, msg, wParam, lParam);
	}
Esempio n. 18
0
LRESULT AeroControlBase::SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uidSubclass, DWORD_PTR dwRefData)
{
    AeroControlBase * pThis = (AeroControlBase*)dwRefData;
    if (pThis)
    {
        HIGHCONTRAST hc = { sizeof(HIGHCONTRAST) };
        SystemParametersInfo(SPI_GETHIGHCONTRAST, sizeof(HIGHCONTRAST), &hc, FALSE);
        BOOL bEnabled = FALSE;
        if (((hc.dwFlags & HCF_HIGHCONTRASTON) == 0) && SUCCEEDED(DwmIsCompositionEnabled(&bEnabled)) && bEnabled)
        {
            switch (uidSubclass)
            {
            case Static:
                return pThis->StaticWindowProc(hWnd, uMsg, wParam, lParam);
                break;
            case Button:
                return pThis->ButtonWindowProc(hWnd, uMsg, wParam, lParam);
                break;
            case Progressbar:
                return pThis->ProgressbarWindowProc(hWnd, uMsg, wParam, lParam);
                break;
            }
        }
    }

    return DefSubclassProc(hWnd, uMsg, wParam, lParam);
}
Esempio n. 19
0
LRESULT CALLBACK DropWindowSubclass(HWND hwnd,UINT uMsg,
WPARAM wParam,LPARAM lParam,UINT_PTR uIdSubclass,DWORD_PTR dwRefData)
{
	switch(uMsg)
	{
	case WM_APP_COPYOPERATIONFINISHED:
		{
			PastedFilesInfo_t *ppfi = reinterpret_cast<PastedFilesInfo_t *>(wParam);

			ppfi->pao->EndOperation(ppfi->hrCopy,NULL,ppfi->dwEffect);

			ppfi->pDropHandler->Release();

			free((void *)ppfi);

			RemoveWindowSubclass(hwnd,DropWindowSubclass,SUBCLASS_ID);
			return 0;
		}
		break;

	/* TODO: The window we're subclassing may be destroyed
	while the subclass is active. This should be handled in
	some way. */
	/*case WM_NCDESTROY:
		RemoveWindowSubclass(hwnd,DropWindowSubclass,SUBCLASS_ID);
		break;*/
	}

	return DefSubclassProc(hwnd,uMsg,wParam,lParam);
}
Esempio n. 20
0
LRESULT CALLBACK EditBoxChanged(HWND hwnd,UINT message, WPARAM wParam, LPARAM lParam,UINT_PTR uIdSubclass, DWORD_PTR dwRefData) {
char formel[255];
	switch(message) {
		case WM_CHAR:
			switch(wParam)
			{
				case VK_RETURN:
					// Formel überprüfen und hinzufügen, wenn korrekt
					GetWindowText(items[3].handle,formel,255);
					if(strlen(formel) > 0) {
						INFO("Füge Formel zum Verlauf hinzu!");
						list[getListCount(items[4].handle)].text = malloc(sizeof(char*) * 255);
						strcpy(list[getListCount(items[4].handle)].text,formel);
						SendMessage(items[4].handle,LB_ADDSTRING,(WPARAM) NULL,(LONG)formel);
						int Count = getListCount(items[4].handle);
						sprintf(formel,"Einträge: %d",Count);
						SetWindowText(items[1].handle,formel);
						SetWindowText(hwnd,"");
						if(PostThreadMessage(ThreadIds[0],TH_HANDLE,0x0,0x0) == FALSE) {
			ERR("Nachricht konnte nicht gesendet werden!");
		}
					return TRUE; } else {
						WARN("Es wurde versucht eine leere Formel einzugeben!");
						MessageBox(hwnd,"Leere Formeln werden nicht akzeptiert!","Formeleingabe",
						MB_ICONEXCLAMATION | MB_OK); SetFocus(items[3].handle);  return false; }
				break;
			};
		break;
	}
return DefSubclassProc(hwnd,message,wParam,lParam);
}
LRESULT CALLBACK CBookmarksToolbar::BookmarksToolbarProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
	switch(uMsg)
	{
	case WM_MBUTTONUP:
		{
			DWORD dwPos = GetMessagePos();

			POINT ptCursor;
			ptCursor.x = GET_X_LPARAM(dwPos);
			ptCursor.y = GET_Y_LPARAM(dwPos);
			MapWindowPoints(HWND_DESKTOP,m_hToolbar,&ptCursor,1);

			int iIndex = static_cast<int>(SendMessage(m_hToolbar,TB_HITTEST,0,
				reinterpret_cast<LPARAM>(&ptCursor)));

			if(iIndex >= 0)
			{
				TBBUTTON tbButton;
				SendMessage(m_hToolbar,TB_GETBUTTON,iIndex,reinterpret_cast<LPARAM>(&tbButton));

				/* TODO: If this is a bookmark, open it in a new tab. */
			}
		}
		break;
	}

	return DefSubclassProc(hwnd,uMsg,wParam,lParam);
}
LRESULT CALLBACK CManageBookmarksDialog::EditSearchProc(HWND hwnd,UINT Msg,WPARAM wParam,LPARAM lParam)
{
	switch(Msg)
	{
	case WM_SETFOCUS:
		if(m_bSearchFieldBlank)
		{
			RemoveSearchFieldDefaultState();
		}

		m_bEditingSearchField = true;
		break;

	case WM_KILLFOCUS:
		if(GetWindowTextLength(hwnd) == 0)
		{
			m_bSearchFieldBlank = true;
			SetSearchFieldDefaultState();
		}
		else
		{
			m_bSearchFieldBlank = false;
		}

		m_bEditingSearchField = false;
		break;
	}

	return DefSubclassProc(hwnd,Msg,wParam,lParam);
}
Esempio n. 23
0
/**
 * Subclass procedure for any dialog control.  Reports key press events to
 * ooDialog for those key presses connected to an ooDialog method by the user.
 *
 * All messages are passed on unchanged to the control.
 *
 * processKeyPress() is used to actually decipher the key press data and set
 * up the ooDialog method invocation.  That function documents what is sent on
 * to the ooDialog method.
 */
LRESULT CALLBACK KeyPressSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
  LPARAM lParam, UINT_PTR id, DWORD_PTR dwData)
{
    SUBCLASSDATA *pSubclassData = (SUBCLASSDATA *)dwData;
    if ( ! pSubclassData )
    {
        return DefSubclassProc(hwnd, msg, wParam, lParam);
    }

    KEYPRESSDATA *pKeyData = (KEYPRESSDATA *)pSubclassData->pData;

    switch ( msg )
    {
        case WM_GETDLGCODE:
            /* Don't do anything for now. This message has some interesting
             * uses, perhaps a future enhancement.
             */
            break;

        case WM_SYSKEYDOWN:
            /* Sent when the alt key is down.  We need both WM_SYSKEYDOWN and
             * WM_KEYDOWN to catch everything that a keyboard hook catches.
             */
            if (  pKeyData->key[wParam] && !(lParam & KEY_RELEASED) && !(lParam & KEY_WASDOWN) )
            {
                processKeyPress(pSubclassData, wParam, lParam);
            }
            break;

        case WM_KEYDOWN:
            /* WM_KEYDOWN will never have KEY_RELEASED set. */
            if (  pKeyData->key[wParam] && !(lParam & KEY_WASDOWN) )
            {
                processKeyPress(pSubclassData, wParam, lParam);
            }
            break;

        case WM_NCDESTROY:
            /* The window is being destroyed, remove the subclass, clean up
             * memory.
             */
            RemoveWindowSubclass(hwnd, KeyPressSubclassProc, id);
            freeKeyPressData(pSubclassData);
            break;
    }
    return DefSubclassProc(hwnd, msg, wParam, lParam);
}
LRESULT CALLBACK MainWndDevicesSubclassProc(
    _In_ HWND hWnd,
    _In_ UINT uMsg,
    _In_ WPARAM wParam,
    _In_ LPARAM lParam,
    _In_ UINT_PTR uIdSubclass,
    _In_ ULONG_PTR dwRefData
    )
{
    // The IOCTL_MOUNTMGR_CHANGE_NOTIFY callback would have been preferred but doesn't work from non-elevated processes?

    switch (uMsg)
    {
    case WM_DEVICECHANGE:
        {
            switch (wParam)
            {
            case DBT_DEVICEARRIVAL: // Drive letter added
            case DBT_DEVICEREMOVECOMPLETE: // Drive letter removed
                {
                    DEV_BROADCAST_HDR* deviceBroadcast = (DEV_BROADCAST_HDR*)lParam;

                    if (deviceBroadcast->dbch_devicetype == DBT_DEVTYP_VOLUME)
                    {
                        //DEV_BROADCAST_VOLUME* deviceVolume = (DEV_BROADCAST_VOLUME*)deviceBroadcast;

                        PhAcquireQueuedLockShared(&DiskDrivesListLock);

                        for (ULONG i = 0; i < DiskDrivesList->Count; i++)
                        {
                            PDV_DISK_ENTRY entry;

                            entry = PhReferenceObjectSafe(DiskDrivesList->Items[i]);

                            if (!entry)
                                continue;

                            // Reset the DiskIndexName so we can re-query the device letter on the next interval update.
                            PhClearReference(&entry->DiskIndexName);

                            PhDereferenceObjectDeferDelete(entry);
                        }

                        PhReleaseQueuedLockShared(&DiskDrivesListLock);
                    }
                }
            }

            goto DefaultWndProc;
        }
        break;
    }

    return DefSubclassProc(hWnd, uMsg, wParam, lParam);

DefaultWndProc:
    return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
Esempio n. 25
0
	LRESULT Control::OnClose(WPARAM wParam, LPARAM lParam)
	{
		if (IsMainWindow)
		{
			PostQuitMessage(0);
			return 0;
		}
		return DefSubclassProc(ThisWindow, WM_CLOSE, wParam, lParam);
	}
Esempio n. 26
0
	LRESULT Control::OnDestroy(WPARAM wParam, LPARAM lParam)
	{
		if (IsMainWindow)
		{
			PostQuitMessage(0);
			return 0;
		}
		return DefSubclassProc(ThisWindow, WM_DESTROY, wParam, lParam);
	}
LRESULT CALLBACK CContainer::TabBackingProc(HWND hTabCtrl,
UINT msg,WPARAM wParam,LPARAM lParam)
{
	switch(msg)
	{
		case WM_INITMENU:
			SendMessage(m_hContainer,WM_INITMENU,wParam,lParam);
			break;

		case WM_MEASUREITEM:
			{
				MEASUREITEMSTRUCT	*pMeasureItem = NULL;

				pMeasureItem = (MEASUREITEMSTRUCT *)lParam;

				pMeasureItem->itemWidth = 20;
				pMeasureItem->itemHeight = 10;

			}
			break;

		case WM_LBUTTONDBLCLK:
			{
				HRESULT hr;

				hr = BrowseFolder(m_DefaultTabDirectory,SBSP_ABSOLUTE,TRUE,TRUE,FALSE);

				if(FAILED(hr))
					BrowseFolder(m_DefaultTabDirectoryStatic,SBSP_ABSOLUTE,TRUE,TRUE,FALSE);
			}
			break;

		case WM_COMMAND:
			switch(LOWORD(wParam))
			{
				case TABTOOLBAR_CLOSE:
					OnCloseTab();
					break;
			}
			break;

		case WM_NOTIFY:
			switch(((LPNMHDR)lParam)->code)
			{
				case TCN_SELCHANGE:
					OnTabSelectionChange();
					break;

				case TTN_GETDISPINFO:
					OnTabCtrlGetDispInfo(lParam);
					break;
			}
			break;
	}

	return DefSubclassProc(hTabCtrl,msg,wParam,lParam);
}
Esempio n. 28
0
LRESULT CALLBACK fproc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp, UINT_PTR id, DWORD_PTR data)
{
  if(!data) return DefSubclassProc(hwnd, msg, wp, lp);

  STATE* state = (STATE*)data;
  switch(msg)
  {
  case WM_WINDOWPOSCHANGING:
    if(!state->hwnd)
    {
      state->hwnd = hwnd;
      fenum(state);
    }
    if(state->rect_list_n > 0) fposchanging(state, (PWINDOWPOS)lp);
    break;
  }

  return DefSubclassProc(hwnd, msg, wp, lp);
} // fproc
Esempio n. 29
0
LRESULT CALLBACK NoiseGateSettings::PBSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
{
    switch(uMsg)
    {
    case WM_ERASEBKGND:
        return TRUE;

    case WM_PAINT:
        {
            RECT clRect, eclRect;
            PAINTSTRUCT ps;
            PBRANGE pbRange;
            int position;
            bool orientation;
            float perc;

            HBRUSH hGreen  = CreateSolidBrush(0x32CD32);

            orientation = (GetWindowLongPtr(hWnd, GWL_STYLE) & PBS_VERTICAL) == PBS_VERTICAL;  // false = horizontal, true = vertical

            position = (int)SendMessage(hWnd, PBM_GETPOS, 0, 0);

            SendMessage(hWnd, PBM_GETRANGE, TRUE, (LPARAM)&pbRange);

            GetClientRect(hWnd, &clRect);
            memcpy(&eclRect, &clRect, sizeof(RECT));

            HDC hDC = BeginPaint(hWnd, &ps);
            
            perc = float(position - pbRange.iLow) / float(pbRange.iHigh - pbRange.iLow);

            if(orientation)
            {
                clRect.top = clRect.bottom - int(float(clRect.bottom - clRect.top) * perc);
                eclRect.bottom = clRect.top;
            }
            else
            {
                clRect.right = clRect.left + int(float(clRect.right - clRect.left) * perc);
                eclRect.left = clRect.right;
            }

            FillRect(hDC, &eclRect, (HBRUSH)COLOR_WINDOW);
            FillRect(hDC, &clRect, hGreen);

            DeleteObject(hGreen);

            EndPaint(hWnd, &ps);

            return TRUE;
        }
    }
    return DefSubclassProc(hWnd, uMsg, wParam, lParam);
}
Esempio n. 30
0
static LRESULT CALLBACK WndProcFrameRateAssociated(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
{
    if (WM_MOVING == msg ||
        WM_SIZING == msg ||
        WM_WINDOWPOSCHANGED  == msg ||
        WM_MOVE == msg) {
        FrameRateWnd *w = (FrameRateWnd*) dwRefData;
        PositionWindow(w, w->maxSizeSoFar);
    }
    return DefSubclassProc(hwnd, msg, wp, lp);
}