corodinates used by hdc??
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: corodinates used by hdc??

  1. #1
    Join Date
    May 2009
    Posts
    88

    Post corodinates used by hdc??

    what type of co-ordinates is used by standard hDC object when initialised by GetsafeDC()??

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,604

    Re: corodinates used by hdc??

    I guess it depends upon how you initialized this HDC object and what you did with it before this call.
    Read about GDI coordinate space here: http://msdn.microsoft.com/en-us/libr...66(VS.85).aspx
    Victor Nijegorodov

  3. #3
    Join Date
    May 2009
    Posts
    88

    Re: corodinates used by hdc??

    Code:
    void CPflowView::OnLButtonDown(UINT nFlags, CPoint point) 
    {
    	// TODO: Add your message handler code here and/or call default
    	long tempx=point.x ;
    	long tempy=point.y ;
    	CPflowDoc* pDoc = GetDocument();
    	pDC=GetDC();
    	OnPrepareDC(pDC);
    	pDC->DPtoLP(&point);
    	x2=point.x;
    	y2=point.y ;
    	HDC hDC= pDC->GetSafeHdc();
    	
    	if(bCheckBusOpt==FALSE)
    	{
    		if(GetPixel(hDC,point.x,point.y)==RGB(0,0,128))
    		{
    			busindex=pDoc->InBus (x2 ,y2 );
    			/*char temp[10];
    			ltoa(busindex,temp,10);
    			MessageBox(temp);*/
    			if(busindex>=0)
    			{SetCapture();m_dragging=TRUE;}
    		}
    	}
    	
    	if(bCheckBusOpt==TRUE)
    		DrawBus();
    		
    	CScrollView::OnLButtonDown(nFlags, point);
    }
    this is method am using can you please tell what type of initialisation is taking place and what coordinates is being used??

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,604

    Re: corodinates used by hdc??

    Perhaps, GetDeviceCaps and Coordinate Space and Transformation Functions could help you?
    Victor Nijegorodov

  5. #5
    Join Date
    Feb 2005
    Posts
    2,160

    Re: corodinates used by hdc??

    Quote Originally Posted by pinnachio View Post
    Code:
    void CPflowView::OnLButtonDown(UINT nFlags, CPoint point) 
    {
    	// TODO: Add your message handler code here and/or call default
    	long tempx=point.x ;
    	long tempy=point.y ;
    	CPflowDoc* pDoc = GetDocument();
    	pDC=GetDC();
    	OnPrepareDC(pDC);
    	pDC->DPtoLP(&point);
    	x2=point.x;
    	y2=point.y ;
    	HDC hDC= pDC->GetSafeHdc();
    	
    	if(bCheckBusOpt==FALSE)
    	{
    		if(GetPixel(hDC,point.x,point.y)==RGB(0,0,128))
    		{
    			busindex=pDoc->InBus (x2 ,y2 );
    			/*char temp[10];
    			ltoa(busindex,temp,10);
    			MessageBox(temp);*/
    			if(busindex>=0)
    			{SetCapture();m_dragging=TRUE;}
    		}
    	}
    	
    	if(bCheckBusOpt==TRUE)
    		DrawBus();
    		
    	CScrollView::OnLButtonDown(nFlags, point);
    }
    this is method am using can you please tell what type of initialisation is taking place and what coordinates is being used??
    By the looks of it, this would be determined in the OnPrepareDC() call. A default CScrollView::OnPrepareDC() adjusts the viewport offset relative to the scroll position of the scroll view's scroll bars so coordinates are relative to a virtual "document", a section of which is visible through the client window of the view. You maybe should use CClientDC() instead of GetDC() in line 7 of your code.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center