Click here to Skip to main content
15,929,653 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: how we can move the bitmap when the mouse dragged Pin
Justin Tay12-Jun-06 20:22
Justin Tay12-Jun-06 20:22 
GeneralRe: how we can move the bitmap when the mouse dragged Pin
happy_ram12-Jun-06 20:28
happy_ram12-Jun-06 20:28 
GeneralRe: how we can move the bitmap when the mouse dragged [modified] Pin
Justin Tay12-Jun-06 20:55
Justin Tay12-Jun-06 20:55 
Generalhere is my code Pin
happy_ram12-Jun-06 21:24
happy_ram12-Jun-06 21:24 
GeneralRe: here is my code [modified] Pin
Justin Tay12-Jun-06 21:50
Justin Tay12-Jun-06 21:50 
GeneralRe: here is my code Pin
happy_ram12-Jun-06 22:34
happy_ram12-Jun-06 22:34 
GeneralRe: here is my code Pin
Justin Tay12-Jun-06 22:43
Justin Tay12-Jun-06 22:43 
GeneralRe: here is my code Pin
happy_ram12-Jun-06 22:49
happy_ram12-Jun-06 22:49 
m_bitmap is a member varialble for our picture control where we load the picture.
	void CImageDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) <br />
{<br />
	// TODO: Add your message handler code here and/or call default<br />
	int newpos = GetScrollPos(SB_HORZ);<br />
    SCROLLINFO info;<br />
    ::ZeroMemory(&info, sizeof(info));<br />
    info.cbSize = sizeof(info);<br />
    info.fMask = SIF_RANGE | SIF_PAGE | SIF_POS | SIF_TRACKPOS;<br />
    GetScrollInfo(SB_HORZ, &info);<br />
<br />
    int low = info.nMin;<br />
    int high = info.nMax - info.nPage;<br />
<br />
<br />
    CRect view;<br />
       GetClientRect(&view);<br />
   <br />
<br />
<br />
CRect image;<br />
    m_bitmap.GetWindowRect(&image);<br />
    ScreenToClient(&image);<br />
<br />
    <br />
    switch(nSBCode)<br />
       { <br />
	case SB_LINEUP:<br />
	   newpos -= ::GetSystemMetrics(SM_CXVSCROLL);<br />
	   if(newpos < low)<br />
	      newpos = low;<br />
	   break;<br />
	case SB_LINEDOWN:<br />
	   newpos += ::GetSystemMetrics(SM_CXVSCROLL);<br />
	   if(newpos > high)<br />
	      newpos = high;<br />
	   break;<br />
	case SB_PAGEUP:<br />
	   newpos -= view.Height();<br />
	   if(newpos < low)<br />
	      newpos = low;<br />
	   break;<br />
	case SB_PAGEDOWN:<br />
	   newpos += view.Height();<br />
	   if(newpos > high)<br />
	      newpos = high;<br />
	   break;<br />
	case SB_THUMBTRACK:<br />
	   newpos = info.nTrackPos;<br />
	   break;<br />
	case SB_THUMBPOSITION:<br />
	   newpos = info.nTrackPos;<br />
	   break;<br />
       } /* nSBCode */<br />
    SetScrollPos(SB_HORZ, newpos);<br />
    m_bitmap.SetWindowPos(NULL,<br />
			 -newpos,<br />
			 image.top,<br />
			 0, 0,<br />
			 SWP_NOSIZE | SWP_NOZORDER);<br />
	<br />
	CDialog::OnHScroll(nSBCode, nPos, pScrollBar);<br />
}<br />
<br />
void CImageDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) <br />
{<br />
	// TODO: Add your message handler code here and/or call default<br />
	SCROLLINFO info;<br />
    ::ZeroMemory(&info, sizeof(info));<br />
    info.cbSize = sizeof(info);<br />
    info.fMask = SIF_RANGE | SIF_PAGE | SIF_POS | SIF_TRACKPOS;<br />
    GetScrollInfo(SB_VERT, &info);<br />
<br />
    int low = info.nMin;<br />
    int high = info.nMax - info.nPage;<br />
    int newpos = info.nPos;<br />
<br />
    CRect view;<br />
     GetClientRect(&view);<br />
<br />
<br />
CRect image;<br />
     m_bitmap.GetWindowRect(&image);<br />
      ScreenToClient(&image);*/<br />
     switch(nSBCode)<br />
       { <br />
	case SB_LINEUP:<br />
	   newpos -= ::GetSystemMetrics(SM_CYHSCROLL);<br />
	   if(newpos < low)<br />
	       newpos = low;<br />
	   break;<br />
	case SB_LINEDOWN:<br />
	   newpos += ::GetSystemMetrics(SM_CYHSCROLL);<br />
	   if(newpos > high)<br />
	       newpos = high;<br />
	   break;<br />
	case SB_PAGEUP:<br />
	   newpos -= view.Height();<br />
	   if(newpos < low)<br />
	       newpos = low;<br />
	   break;<br />
	case SB_PAGEDOWN:<br />
	   newpos += view.Height();<br />
	   if(newpos > high)<br />
	       newpos = high;<br />
	   break;<br />
	case SB_THUMBTRACK:<br />
	   newpos = info.nTrackPos;<br />
	   break;<br />
	case SB_THUMBPOSITION:<br />
	    newpos = info.nTrackPos;<br />
	    break;<br />
       } /* nSBCode */<br />
    SetScrollPos(SB_VERT, newpos);<br />
    m_bitmap.SetWindowPos(NULL,<br />
			 image.left,<br />
			 -newpos,<br />
			 0, 0,<br />
			 SWP_NOSIZE | SWP_NOZORDER);<br />
<br />
	CDialog::OnVScroll(nSBCode, nPos, pScrollBar);<br />
}<br />
void CImageDlg::OnPaint() <br />
{<br />
	if (IsIconic())<br />
	{<br />
		CPaintDC dc(this); // device context for painting<br />
<br />
		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);<br />
<br />
		// Center icon in client rectangle<br />
		int cxIcon = GetSystemMetrics(SM_CXICON);<br />
		int cyIcon = GetSystemMetrics(SM_CYICON);<br />
		CRect rect;<br />
		GetClientRect(&rect);<br />
		int x = (rect.Width() - cxIcon + 1) / 2;<br />
		int y = (rect.Height() - cyIcon + 1) / 2;<br />
<br />
		// Draw the icon<br />
		dc.DrawIcon(x, y, m_hIcon);<br />
	}<br />
	else<br />
	{<br />
		CDialog::OnPaint();<br />
	}<br />
}

GeneralRe: here is my code Pin
Justin Tay12-Jun-06 23:27
Justin Tay12-Jun-06 23:27 
GeneralRe: here is my code [modified] Pin
happy_ram12-Jun-06 23:45
happy_ram12-Jun-06 23:45 
GeneralRe: here is my code Pin
Justin Tay13-Jun-06 0:37
Justin Tay13-Jun-06 0:37 
GeneralRe: here is my code Pin
happy_ram13-Jun-06 0:45
happy_ram13-Jun-06 0:45 
GeneralRe: here is my code Pin
happy_ram13-Jun-06 1:06
happy_ram13-Jun-06 1:06 
GeneralRe: here is my code Pin
Justin Tay13-Jun-06 3:44
Justin Tay13-Jun-06 3:44 
GeneralRe: here is my code Pin
G Haranadh13-Jun-06 1:19
G Haranadh13-Jun-06 1:19 
GeneralRe: here is my code Pin
happy_ram13-Jun-06 1:23
happy_ram13-Jun-06 1:23 
AnswerRe: how we can move the bitmap when the mouse dragged Pin
khan++12-Jun-06 20:23
khan++12-Jun-06 20:23 
GeneralRe: how we can move the bitmap when the mouse dragged Pin
happy_ram12-Jun-06 20:29
happy_ram12-Jun-06 20:29 
GeneralRe: how we can move the bitmap when the mouse dragged Pin
khan++12-Jun-06 20:37
khan++12-Jun-06 20:37 
GeneralRe: how we can move the bitmap when the mouse dragged Pin
happy_ram12-Jun-06 20:47
happy_ram12-Jun-06 20:47 
GeneralRe: how we can move the bitmap when the mouse dragged Pin
khan++12-Jun-06 20:56
khan++12-Jun-06 20:56 
GeneralRe: how we can move the bitmap when the mouse dragged Pin
happy_ram12-Jun-06 21:02
happy_ram12-Jun-06 21:02 
AnswerRe: how we can move the bitmap when the mouse dragged [modified] Pin
Hamid_RT13-Jun-06 1:19
Hamid_RT13-Jun-06 1:19 
Questiondiff between win 64 and win 32 Pin
Krishnatv12-Jun-06 18:46
Krishnatv12-Jun-06 18:46 
AnswerRe: diff between win 64 and win 32 Pin
_AnsHUMAN_ 12-Jun-06 18:54
_AnsHUMAN_ 12-Jun-06 18:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.