|
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.
|
|
|
|
|
Hi,
I have 4 CWinThread objects which are wrappers for 4 CAsyncObjects I commented out the creation of these objects and still I get an out of memory when trying to do the create for the modeless dialog box
I am going to start post to see if there are any plug-in to the Visual Studio debugger which track Heap storage
Thanks
|
|
|
|
|
You have changed your explanation of the problem from your original post; where did this modeless dialog come into the equation? As I said above, you really need to spend some time going through your code to find out where (and why) you are using all this storage.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Sorry I was getting exceptions and wasn't sure truth is I didn't check the return codes
I just did some reading in a Book MFC internals and there is a section there about memory leaks using the CMemoryState functions
I am going track the heap memory I use
Thanks
|
|
|
|
|
OnSize(UINT nType, int cx, int cy)
{
IsWindow(xxx.GetSafeHwnd())
{
}
}
|
|
|
|
|
What does this mean and why have you posted it to me?
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I have a working static splitter frame and need to retrieve pane based on CFormView.
I am getting assertion in GetPane MFC (4.0 / VC 6.0) function , and only on this type of splitter pane.
Plain CView works fine.
I did search on similar problems and it looks like the CFormView is the problem.
Any suggestion how to fix this?
Please no “ upgrade to xxxx”, not an option.
CWnd* CSplitterWnd::GetPane(int row, int col) const
{
ASSERT_VALID(this);
CWnd* pView = GetDlgItem(IdFromRowCol(row, col));
ASSERT(pView != NULL); // panes can be a CWnd, but are usually CViews
return pView;
}
Your help is as allways appreciated.
Cheers Vaclav
|
|
|
|