|
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 />
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 />
} <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 />
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 />
} <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);
<br />
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);<br />
<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 />
dc.DrawIcon(x, y, m_hIcon);<br />
}<br />
else<br />
{<br />
CDialog::OnPaint();<br />
}<br />
}
|
|
|
|
|
I hope you realise that you have a very strange approach to your problem. The whole move the static control around thing to scroll isn't a good way of doing it and it's not particularly hard to write your own picture control that can encapsulate scrolling. Is this school work?
If you need any more functionality than this like zoom in/out etc, or you find yourself needing to reuse this scrollable picture in a different dialog, you'll see what's wrong with your current approach.
Anyway if this works for normal scrolling using your mouse (make sure you've removed those SetWindowPos() things from your OnMouseMove handler - SetScrollPos should trigger the notifications to get OnVScroll and OnHScroll called). Set breakpoints in OnVScroll and OnHScroll and start dragging and see what's different.
|
|
|
|
|
thank u iam new to vc++.actually my domain is java.
i searched the code for scrollbar and i completed this.
yes,iam reuse this scrollable picture in a different dialog.
do u ahve any example regarding this,or any code
-- modified at 5:46 Tuesday 13th June, 2006
|
|
|
|
|
The proper approach would be to write a custom control, the static picture control is not meant for anything fancy. You can think of writing a custom control as deriving from a JComponent. Wouldn't you agree that moving a JComponent around in a JDialog to achieve scrolling sounds like a bad idea (Yeah it would be nice to have something like JScrollPane in MFC)
I searched codeproject and came up with an article on writing custom controls in MFC. As a bonus the custom control is a simple control that draws a bitmap. (I tried looking for a bitmap control when you first posted but couldn't find one in the Bitmap section - probably because it's considered too simple). It also shows how you can subclass a window on a dialog using DDX.
http://www.codeproject.com/miscctrl/customcontrol.asp[^]
Of course it's a little too simple, but this can be fixed with some cut and pasting from the bitmap scrolling article. The classes he wrote for the article isn't very well designed (Unless his goal was to minimise the number of windows he creates) but it demonstrates how to draw and scroll a bitmap quite clearly. In particular take note of the OnPaint/OnVScroll/OnHScroll handlers and modify the custom control accordingly (Needs some modifications). Note that there's usually no need to create scrollbar windows. A window with the WS_HSCROLL/WS_VSCROLL style will draw a scrollbar on the sides of the window. These are so-called fake scrollbars as they don't have a window but are drawn in response to WM_NCPAINT.
http://www.codeproject.com/bitmap/bmpscroll.asp[^]
You can just tack on the OnLButtonDown/OnMouseMove/OnLButtonUp code that you've already written in the custom control and it should work as expected. As the custom control is entirely encapsulated as a window you can reuse it on dialogs and can even have it as a view on a frame.
|
|
|
|
|
thank u very much.
u directing we very well.
i will try and i will give message after completion of that.
really thank u so much.
sree.
|
|
|
|
|
actually this code is given by my Project leader.he tell do the modification to get the desire result,what we discuss until know.u sended me that customs control,this is useful
when i start the project at 1st step.
so plese tell me how to modify this existing code,
i know iam really troubleing u, but i have no other way,
plese be kind heartly help me
|
|
|
|
|
I have modified the custom control demo with the relevant changes. The source and release binary is included below. It probably has bugs and it has nowhere near the functionality that I usually stuff in my controls (I usually write using WTL, so I also did this as a way to brush up on MFC)
http://www.yousendit.com/transfer.php?action=download&ufid=F1596C4701B5A33B[^]
It sounds like your project leader also doesn't know what is going on. Perhaps you should invest in a good book (I don't have any recommendations as it's ages since I leafed thru an MFC book)
|
|
|
|
|
Oh... Please use
< Pre>
.....code.....
</ Pre> Tags.
Then you can get code with indentation.
Nice talking to you.
If you judge people, you have no time to love them. -- Mother Teresa
|
|
|
|
|
|
You could create a CScrollView derived class's object in the window or dialog, and use its WM_MOUSEMOVE , WM_LBUTTONDOWN , WM_LBUTTONUP etc to move the picture. You can display the picture in your CScrollView-derived class's OnDraw() etc.
There may be easier ways of doing it.
this is this.
|
|
|
|
|
thank u .
any sample code or any link please.
sree.
|
|
|
|
|
|
i ready completed that bitmap scrolling using scrollers.i want bitmap should move bymouse
|
|
|
|
|
As I said in my earlier post, you will need to handle the WM_MOUSEMOVE, WM_LBUTTONDOWN,... etc messages and scroll the window according to that.
It is a sequence of operations requiring you to save the position of the mouse, a flag for the LButton down event, and do the actual scrolling in the WM_MOUSEMOVE handler function.
this is this.
|
|
|
|
|
thank u.
i done like that only.but the problem is only scrollbars are moving but the bitmap is not moving.
sree.
|
|
|
|
|
|
what is the difference between win 32 and win64 ?
|
|
|
|
|
32-bit refers to the number of bits that can be processed or transmitted in parallel, or the number of bits used for single element in a data format.
When used in conjunction with a microprocessor, the term indicates the width of the registers. A 32-bit microprocessor can process data and memory addresses that are represented by 32 bits.
Therefore, 64-bit refers to a processor with registers that store 64-bit numbers. A generalization would be to suggest that 64-bit architecture would double the amount of data a CPU can process per clock cycle.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Thank u.
|
|
|
|
|
wrote: what is the difference between win 32 and win64 ?
Here [^] is the good article on same
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
If you really mean to ask about the "OS" , it's like you have win95, 98, ME.. XP all these are 32 bit OSes. Before these, all were 16 bit OSes i.e Win3.1, now Have you heared about XP64? This is the newer version XP. Which is targetd to run on any 64 bit machines. For the moment, AMD64 bit processors are flying high, when use this OS in it, you'll really get a high performance. Intel's also released it's 64bit(which supports upto 8GB of RAM), but still it's yet to gain popularity cuz it's still expensive. So it's basically the number of Data lines available for the processor to handle data. If it has 32 bit lines, it can handle 32 bits at the same time, so there would be 32 bit registers too. You can stroge a huge 32 bit number without splitting it. If it's 64 bits oh! it's going to be really huge and your processor can do twice the amount of work your PC used to do with a 32 bit processor. but provided , your application makes use of the 64bit feature. If your application is still 32 bit, then it's vision will be limited to the 32 bit range. So A 64 bit OS, a 64 bit processor would make your applications fly!
If you were talking about win32 API, hmm, it's the programming Interface that allows you to make application to run on a 32 bit machine.If you say Win64(I haven't heard about it yet), naturally it's going to allow you make application for a 64bit machine.
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[ ]--
[My Current Status]
|
|
|
|
|
hi ,
it's nitin,please help me out for visual C++ swapnng vcxpawn.exe.
i install microsoft visual C++ 6.0 version but when i going to code something on visual C++ and compile the program then i got the error of
swapnimg vcspawn.exe.so please help me out for that.
nitin
|
|
|
|
|
|
hi,
thaks for send me back.but how could it be can you send me the process of this method.because i click your mail then i got microsoft page and i follow the step which is mention in microsoft page but my code is still not working and i got the spawning error.please help me out for this.
Thanks...........
Nitin dalal
nitin
|
|
|
|
|
Please send me the code or give an idea to display the file name without path in platform SDK.(PURELY WIN32 CODE).
Thanks in advance...:
Ashok Reddy
|
|
|
|