Пример #1
0
void FolderView::OnRightClick(NMHDR* notify_struct, LRESULT* result)
{
	*result = 0;
	CPoint pos(0, 0);
	GetCursorPos(&pos);

	TVHITTESTINFO ht;
	ht.flags = 0;
	ht.hItem = 0;
	ht.pt = pos;
	ScreenToClient(&ht.pt);
	HitTest(&ht);

	rclicked_item_ = ht.hItem;

	ContextMenu(this, pos);
}
Пример #2
0
void
MFCSimpleTypeView::OnRButtonDown(UINT nFlags, CPoint point)
{
	CListView::OnRButtonDown(nFlags, point);
	ContextMenu(nFlags, point);
}
Пример #3
0
void FolderView::OnContextMenu(CWnd* wnd, CPoint pos)
{
	rclicked_item_ = 0;
	ContextMenu(this, pos);
}
Пример #4
0
/*+++++++++++++++++++++++++++++++++++++++++++++++++
 * PluginWindowProc
 * Handle the Windows window-event loop.
 +++++++++++++++++++++++++++++++++++++++++++++++++*/
static LRESULT CALLBACK PluginWindowProc( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
	PluginInstance* This;
	HDC hdc;
	RECT rect;
		
	This = (PluginInstance*) GetProp(hWnd, gInstanceLookupString);

	if(!This) return DefWindowProc( hWnd, Msg, wParam, lParam);

	switch(Msg) {

	case WM_ERASEBKGND:
		{
			HBRUSH br;
			hdc= (HDC)wParam;

			if(This->bkgdbrush)
				br=This->bkgdbrush;
			else
				br=GetStockObject(GRAY_BRUSH);

			GetClientRect(hWnd,&rect);
			FillRect(hdc,&rect,br);
			return 1;
		}

	case WM_HSCROLL:
	case WM_VSCROLL:
		scrollmsg(This,Msg,(int)(LOWORD(wParam)),(short int)(HIWORD(wParam)));
		return 0;

	case WM_SIZE:
		find_window_size(This);
		set_scrollbars(This);
		return 0;


	case WM_CONTEXTMENU: case WM_RBUTTONUP:
		ContextMenu(This, hWnd);
		return 0;


	case WM_SETCURSOR:
		if(LOWORD(lParam)==HTCLIENT) {
			if(This->islink) {
				SetCursor(This->linkcursor);
				return 1;
			}
		}
		break;

	case WM_LBUTTONDOWN:
		SetCapture(This->fhWnd);
		This->mouse_captured=1;

		if(This->dynamicmng && This->mng && !This->errorflag) {
			DynamicMNG_FireEvent(This,4,MAKEPOINTS(lParam));
		}
		return 0;
		
	case WM_LBUTTONUP:
		{
			RECT rc;
			POINT pt;

			if(This->mouse_captured) {
				ReleaseCapture();
				This->mouse_captured=0;
			}
			if(This->dynamicmng && This->mng && !This->errorflag) {
				DynamicMNG_FireEvent(This,5,MAKEPOINTS(lParam));
			}

			// if mouse is not over image, don't follow links, etc.
			GetWindowRect(This->fhWnd,&rc);
			GetCursorPos(&pt);
			if(!PtInRect(&rc,pt)) return 0;

			if(This->islink) {
				NPN_GetURL(This->instance,This->linkurl,This->linktarget);
				return 0;
			}
			else if(This->errorflag) {
				display_last_error(This);
			}
		}
		return 0;

	case WM_MOUSEMOVE:

		if(This->dynamicmng && This->mng && This->lpdib && !This->errorflag) {
			POINTS pos;
			int overimage;

			pos=MAKEPOINTS(lParam);
			overimage=0;
			if(pos.x>=0 && pos.x<This->lpdibinfo->biWidth && pos.y>=0 && pos.y<This->lpdibinfo->biHeight) {
				overimage=1;
			}

			if(overimage) {
				if(This->mouse_over_mng) {
					// mouse is still over image: mouse move event
					DynamicMNG_FireEvent(This,2,pos);  // 2=mouse move
				}
				else {
					// mouse wasn't over the image but now it is: mouse-enter event
					DynamicMNG_FireEvent(This,1,pos); // mouse enter
				}
			}
			else { // mouse not now over image
				if(This->mouse_over_mng) { // ... but it used to be
					pos.x=0; pos.y=0;
					DynamicMNG_FireEvent(This,3,pos); // 3=mouse leave
				}
			}

			This->mouse_over_mng=overimage; // remember for next time

			if(This->mouse_over_mng && (This->dynamicmng==1) ) {
#define MOUSE_POLL_INTERVAL  100    // milliseconds
				SetTimer(This->fhWnd,2,MOUSE_POLL_INTERVAL,NULL);
				This->timer2_set=0;
			}
		}
		return 0;

	case WM_PAINT:
		{
			PAINTSTRUCT paintStruct;
			HDC hdc;
			RECT rect2;

			hdc = BeginPaint( hWnd, &paintStruct );
			SetWindowOrgEx(hdc,This->xscrollpos,This->yscrollpos,NULL);

			GetClientRect(hWnd,&rect);
			if(This) {
				if(This->errorflag || !This->lpdib) {
					SelectObject(hdc,hfontMsg);
					Rectangle(hdc,rect.left,rect.top,rect.right,rect.bottom);
					rect2.left=rect.left+2;
					rect2.top=rect.top+2;
					rect2.right=rect.right-2;
					rect2.bottom=rect.bottom-2;
					if(This->errorflag) {
						DrawText(hdc,"MNG PLUG-IN ERROR!",-1,&rect2,DT_LEFT|DT_WORDBREAK);
					}
					else {
						if(This->loadstate>=STATE_LOADING) {
							DrawText(hdc,"MNG image loading...",-1,&rect2,DT_LEFT|DT_WORDBREAK);
						}
						else {
							DrawText(hdc,"MNG plug-in",-1,&rect2,DT_LEFT|DT_WORDBREAK);
						}
					}
				}
				else if(This->lpdib) {
					StretchDIBits(hdc,
						0,0,This->lpdibinfo->biWidth,This->lpdibinfo->biHeight,
						0,0,This->lpdibinfo->biWidth,This->lpdibinfo->biHeight,
						&((BYTE*)(This->lpdib))[sizeof(BITMAPINFOHEADER)],
						(LPBITMAPINFO)This->lpdib,DIB_RGB_COLORS,SRCCOPY);
				}
			}


			EndPaint( hWnd, &paintStruct );
		}
		return 0;

	case WM_TIMER:
		switch(wParam) {
		case 1: // the main animation timer
			KillTimer(hWnd,1);
			This->timer_set=0;

#ifdef MNGPLG_TRACE
			fprintf(tracefile,"WM_TIMER display_resume bytesloaded=%d\n",This->bytesloaded);
#endif

			if(This->mng) {
				if(!This->needresume) {
					handle_read_error(This, mng_display_resume(This->mng) );
				}
			}
			return 0;

		case 2: // timer for polling mouse position
			{
				RECT rc;
				POINT pt;
				POINTS pos;

				GetWindowRect(hWnd,&rc);
				GetCursorPos(&pt);
				if(!PtInRect(&rc,pt)) {
					KillTimer(hWnd,2);
					pos.x=0; pos.y=0;
					DynamicMNG_FireEvent(This,3,pos); // 3=mouse leave
					This->mouse_over_mng=0;
				}
			}
			return 0;
		}
		break;

	}

	/* Forward unprocessed messages on to their original destination
	 * (the window proc we replaced) */
	return This->fDefaultWindowProc(hWnd, Msg, wParam, lParam);
}