|
Yes, just need to move content and not the window.
|
|
|
|
|
There is an article about that right [here].
|
|
|
|
|
I want to pan the client area using left button of mouse. As one that works with PDF file.
And i want to implement this using MFC/WIN32
-Thanks in advance.
|
|
|
|
|
I guess I know what you mean: You press down the pan mouse button while the cursor is over the view and then you pan by moving the mouse cursor until you release the pan mouse button. This panning basically scrolls the visible portion of the stuff you can see in your view. There is no API to do that, you have to implement it by yourself by handling primitive mouse events like mouse button down, mouse move, and mouse button up events. Custom implementation makes sense because its totally dependent on the program which parameters should be modified by the panning operation.
In a 2D pdf viewer the program stores some position data about which part of the pdf should be drawn to the view. This position is changed when you are panning. In a 3D CAD program there is a 3d world in which you can find an active camera as well with a position and rotation parameter (and also with horizontal and vertical fov). This camera is used by the rednerer to decide which part of the world should be rendered, the camera is like an eye and you see in the view what this eye looks at in the 3d world. This camera has an up and right direction that defines a plane. When you pan with your mouse you basically calculate a 2D offset from the mouse movement and you add this 2D offset to the camera position on the plane that is defined by the up and right vectors of the camera rotation (maybe not right but left if you are using left handed coordinate system...). Even if you are not good at 3D, the answer to your question is: Those pan functions are implemented by those programs, its custom code in them and not some operating system provided api function calls.
How to implement panning: When panning starts (mouse button down) you store the actual pan-start position of the mouse cursor, and also the position value (the 3d cam pos, or the 2d pos in the pdf file) in your program to some variables that wont change during panning. When a mouse move event comes you always calculate the delta between the pan-start mouse pos and the current moved mouse cursor pos, and you use this 2D offset to calculate the pan offset in your world (you can leave it as it is, or any simple transform can do the job, for example multiplying it with something to set panning speed...). When you have your pan offset you add the resulting pan-offset to the stored pan-start position and set the result as the current position.
The panning operation is a kind of dragging operation so you should consider implementing it with correct mouse capturing: Using SetCapture() and ReleaseCapture() correctly (usually during a drag n' drop operation).[^]
Omitting mouse capture is not the end of the world, but try to be always perfect when possible!
|
|
|
|
|
Hello!!
Thank you very much for all your reply.
Mr pasztorpisti - Thank you much for detailed explanation. I will try to implement this and let you know about the same.
-Maha
|
|
|
|
|
|
HI Pasztorpisti,
What the code you have give is to move the window, but what i need to move the client area.
I know if there is a api to capture the client area and move it.
Regards,
Maha
|
|
|
|
|
You have to do exactly the same. You handle the mouse events, and depending on the offset of the mouse move you change an internal variable in your program. In my example program the internal variable to change was the position of the window, but it could be anything else, for example the offset in your picture or pdf file for drawing on the client area of your window. All you have to do is using/changing something else, not the window position, for example the position where you draw your picture on the client area.
|
|
|
|
|
In your program you have used SetWindowPos() to change the position of window.
But to move the client area, which API should i use.
Say,
Mouse button down
1) capture initial position of mouse using GetCursorPos()
Mouse move.
2) Calculate the difference of x and y coordinates using previous cursor position and current cursor position
Mouse button UP
3)After calculating the latest value as said about, which api should be used to move the client coordinates. (in your program you have used SetWindowPos())
-Maha
|
|
|
|
|
What do you mean on moving the client area? You can't move it. All you can do is drawing something on it and changing some of the parameters of the drawing when you are panning. Alternatively you could change the positions of some child controls on the window but that has not much usefulness.
|
|
|
|
|
I cant achieve this still, can any one of you give me a sample code. To pan the client area of a window.
Thanks in advance.
|
|
|
|
|
Hi,
I am working on an application where I have to change the text in a text box while user enters from the keyboard. I have an edit box on a dialog in MFC. I want when user enters any character in the edit box, a text box should be created on the dialog and the typed character should also be displayed in the text box. As user types the characters, at the same time it should be displayed in the text box. And how to make that text box movable after user has entered the text.
Can anybody have an idea about this.?
Thanx & Regards,
|
|
|
|
|
You need to capture the EN_CHANGE [^] notification, and copy the text from the edit box to the text box. I'm not sure about moving the text box, something along the lines of capturing the mouse (using WM_LBUTTONDOWN [^]) and then using MoveWindow() as the mouse moves.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
hi,
I need to generate some reports using Crystal Report in my VC++ application by this week
I am using VC++, Visual Studio 2008 for my development. And I could not find any Crystal Report template for me to add into my VC++ project.
I am new to Crystal Report development, and I have checked through the articles and forum here. Most of the Crystal Report were developed using C#.
Would greatly appreciate if any of you could offer some advice or sample VC++ codes for me to kickstart the development. Your help is much appreciated!
Thanks!
|
|
|
|
|
Most C++ Crystal Reports [code] here is MFC based. Almost no C++ Visual Studio 2008 code .
Like you discovered, Most of it is in C#. Even [MSDN's] own code samples.
|
|
|
|
|
Hi,
I have a richedit display which I populate whitin the CDialig::OnInitDialog
via a streamin fuction
The Dialog is createded on the Heap while the richedit is a member of the of the CDialog Class
In the Initdialog I :: Create The Richedit then subclass the richedit via
DDX_CONTROL
Calculate the size I want for the richedit
DO a MoveWindow for the size I want
the Richedit is displayed with the text I want but then instantously an exception
occurs
I commneted out all my messages from the BEGIN_MESSAGE_MAP figuring I wasn't processing one of the messages correctly
but the exception still occurs
When I run the code via Visual studio and have Break point on the BEGIN_MESSAGE_MAP
for the CDialog the exception usally occurs after 9th time the BEGIN_MESSAGE_MAP is
executed
Any help would appreciated
|
|
|
|
|
ForNow wrote: an exception occurs
ForNow wrote: but the exception still occurs
ForNow wrote: the exception usally occurs after
And the exception details are what?
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
The Following is the text from Dialog Box
Unhandled exception at 0x5e7fa640 in HERC_CMD.exe: 0xC0000005: Access violation reading location 0x00000118.
Thanks
|
|
|
|
|
That merely shows that you have an access violation somewhere in your program. I'm afraid the above information is not nearly enough for anyone else to guess what might be happening. You need to use your debugger to isolate the section of code where it occurs.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Hi,
I tracked my exception problem to OUT OF MEMORY as I hadn't checked the return code from my CDialog::Create
Since I am doing Interprocess communication with a console program I allocate most of my objects on the Heap
So my question(s) now are
1) How can I tell how much heap storage is allocated to my app
2) Is there anyway from the Visual Studio debugger to tell how much heap I have used
The only information I have is from task manager in the memory coulmn (private working set) says I am using 2,540 for my process
My laptop has 3.00 gb I think I could go up to 4 gb though I don't think adding more memory is the root of the problem
thanks
|
|
|
|
|
Hi,
ForNow wrote: 1) How can I tell how much heap storage is allocated to my app
1) Derrive All classes from a common abstract class. 'MyCommonClass'
2) Declare a Static property: 'QWORD MyCommonClass::m_qw_AllocMem=0;'
3) Declare a Pure Virtual Function 'DWORD MyCommonClass::_GetSize()=0'
4) Write a Contructor:'MyCommonClass::MyCommonClass(){m_qw_AllocMem+=_GetSize();}'
5) Write a Destructor:'MyCommonClass::~MyCommonClass(){m_qw_AllocMem-=_GetSize();}'
ForNow wrote: 2) Is there anyway from the Visual Studio debugger to tell how much heap I have
used
Well I'm using C++ 5.00, and, No, there is none there.
ForNow wrote: The only information I have is from task manager in the memory coulmn (private
working set) says I am using 2,540 for my process My laptop has
3.00 gb I think I could go up to 4 gb though I don't think adding more memory is
the root of the problem
Well I dont'know what you are trying to achieve. I take it that you've only one thread. Also, you will get the same message if you exhaust the stack. This can happen if you have an Not Terminating recursion. (A recursion is a routine calling itself)
A 'RichEdit' is not an easy control to set up. It relies on COM Objects to do its bidding. I have always avoided this control for that reason. COM objects, by their nature are linked at Runtime, the details of the actual DLL and Function to be called extracted from the Registry. That latter process is notoriouisly slow, and consumes large amounts of memory.
Also, some libaries simply report 'Out Of Memory' when any other error occurs, which the author did not document further.
Hope this was usefull,
Bram van Kampen
|
|
|
|
|
What do you put in the body of _GetSize() ?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hi,
Richard Andrew x64 wrote: What do you put in the body of _GetSize() ?
In the Base Class we have _GetSize()=0; (Pure Virtual Function)
In each of the Derrived classes:
int MyClass::_GetSize(){return sizeof(*this);}
Because the function is declared Pure Virtual in the base class, the compiler will insist that an implementation of a derrived class includes the function declaration and definition for _GetSize() (i.e.: One cannot 'forget' to include it.)
Regards
Bram.
Bram van Kampen
|
|
|
|
|
Brilliant!
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
1. See the comments in MSDN on operator new[^].
2. Not that I am aware of, as I have never run into this problem.
It may well be that you are going in the wrong direction with this issue. You need to go back to your application and try to determine why you are running out of memory, rather than trying to find out how much may be available.
One of these days I'm going to think of a really clever signature.
|
|
|
|