|
Hello everyone!
OK, I have:
vector<Vehicle> vehicles;
Class Vehicle doesn't have a constructor. However, when I add a constructor, I get this error on the line in which vehicles is declared (see above):
1>c:\incoming\war game\Game.h(11) : error C2065: 'Vehicle' : undeclared identifier
The declaration of the constructor is as follows:
Vehicle(int x, int y, int id);
What is wrong with this code? Thanks!
Windows Calculator told me I will die at 28.
|
|
|
|
|
If you don't add a constructor, the compiler automatically adds an emtpty one for you. Add an empty constructor to your class, and it should work.
|
|
|
|
|
That's the problem - if I add an (empty) constructor, it gives me the error...
It's error-free when I don't add one.
Windows Calculator told me I will die at 28.
|
|
|
|
|
You must add a default constructor that doesn't need any parameters: Vehicle::Vehicle()
|
|
|
|
|
Hi..
Someone please help me to insert/add a GIF image in VC++ 6.0. And also I want to change the image's position (In XY Coordinates) and to rotate the Image in specified angles.(rotate only the image not the whole panel in the frame)
It is better if you can provide me some sample codes to do that.
I need someones help in the above matter...
Thanks
Dhananjaya
ENTC
UoM
|
|
|
|
|
Look into GDI+.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Use CImage . CImage can do some of you want .
|
|
|
|
|
|
See GDI+
Image::RotateFlip
|
|
|
|
|
Hi,
As u Suggested I started to use Image object in GDI+.My intention was to make a Image object and manupulate its position and orientation.(As given in msdn page titled Drawing, Positioning, and Cloning Images - refer the link below)
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdicpp/GDIPlus/AboutGDIPlus/IntroductiontoGDIPlus/OverviewofGDIPlus.asp[^]
I tried to insert a image to my main frame using "Image" in GDI+. But a runtime error (unhandled exception) is occuring when im going to run the program.The details are as follows.
I have included "gdiplus.h" in StdAfx.h. There were no issues on that.But the problem started when i tried to insert a image using the guidelines given in above msdn link(.Drawing, Positioning, and Cloning Images - GDI+)
As per that method I used the following code:
CPaintDC dc(this);<br />
Graphics myGraphics(dc.m_hDC);<br />
<br />
Image myImage(L"robot.gif");
myGraphics.DrawImage(&myImage, 20, 10);
The program Built & compiled successfully in VC++ 6.0.But didn't run.It gaves a error.
When I insert that code to a .NET project the error message says that ;"Unhandled exception at 0x7c9105f8 in tttdk.exe: 0xC0000005: Access violation reading location 0x00000010."
When I break it , it shows the location of the error in the following cpp file.
D:\VS\VC\atlmfc\src\atl\atls\allocate.cpp
..<br />
<br />
...<br />
<br />
CAtlTraceCategory *CAtlAllocator::GetCategory(int iCategory) const<br />
<br />
{<br />
<br />
if(iCategory == m_pProcess->CategoryCount())<br />
<br />
return NULL;<br />
<br />
<br />
<br />
ATLASSERT((iCategory < m_pProcess->CategoryCount()) || (iCategory == -1));<br />
<br />
CAtlTraceCategory *pCategory = NULL;<br />
<br />
if(iCategory >= 0)<br />
<br />
{<br />
<br />
BYTE *pb = reinterpret_cast(m_pProcess) + m_pProcess->MaxSize();
<br />
pCategory = reinterpret_cast(pb) - iCategory - 1;<br />
<br />
}<br />
<br />
return pCategory;<br />
<br />
}<br />
<br />
.............. Please help me regarding the above matter ASAP.or else tell me way to Insert a GIF image to a MFC frame and to change its position and rotate by given angles time to time.
Dhananjaya
ENTC
UoM
ENTC
UoM
|
|
|
|
|
if you want to show gif or jpeg or png or bmp you can use from CImage class but im not sure its working in VC6.0 or no but this problem
I think this code solve your problem
<br />
ULONG_PTR m_gdiToken;<br />
GdiplusStartupInput gdiplusStartup;<br />
<br />
GdiplusStartup(&m_gdiToken, &gdiplusStartup, NULL);<br />
<br />
img = Image::FromFile(L"c:\\0.jpg");<br />
<br />
CPaintDC dc(this);<br />
Graphics myGraphics(dc.m_hDC);<br />
...<br />
...<br />
|
|
|
|
|
How can be allocated virtual memory? (PAGEFILE)?
|
|
|
|
|
VirtualAlloc()
Tanvon
happy programming
the brain behind ...
|
|
|
|
|
Thanks
|
|
|
|
|
You probably don't want to do what you think you want to.
The operating system will use the page file to back any virtual memory allocation that doesn't come from a memory-mapped file. This is completely automatic - as demand for memory increases, and on a periodic basis to ensure that a reserve of physical memory is available, the operating system removes pages from your process's 'working set' - a process called 'trimming' - to return them to the available physical memory pool. If the page has been modified since last written to disk, the new contents will be written to the appropriate place in the page file.
The 'working set' is the set of pages that the OS thinks are most appropriate to be in memory for the process at the current time. When trimming, it removes the pages that have been used least recently. A phenomenon known as 'locality of reference' normally means that the pages used most recently are the most likely to be referenced next; a program that has poor locality of reference can lead to thrashing as the OS removes the least recently used page, the program then references it and the OS has to read it back in - page it in - from the page file.
To ensure that it can always write any given page without running out of space in the page file, the operating system reserves space in the page file for each virtual memory page allocated, at the time of the allocation. You don't need to do anything for this to happen.
The VirtualAlloc function only allows you to make page-sized allocations (4KB on x86), and then only from 64KB-sized address space reservations. Using VirtualAlloc badly will waste your virtual address space. Only use it if you really know what you're doing. For most normal programming, you should use a heap, allocating with new , malloc , LocalAlloc or HeapAlloc . A heap is simply a data structure that manages a block of virtual memory, and the Heap Manager has the ability to deal with virtually any size block quite well. This flexibility does mean that it can be slower than a specialised implementation handling allocation for specific data structures, but in general it's a good choice.
|
|
|
|
|
i'm very impressed
Thanx a lot.
|
|
|
|
|
I was trying to follow through a tutorial I found at the following site to implement a linked list:
http://etude.uwaterloo.ca/~ctrudeau/lessons/C++/tutorial2.html. The source code is on the website, and I was trying to test this class so I could inherit it from an implementation I was trying to code.
The code breaks when the method 'first' is called
p = (DataObject *)list.first();
which calls inline function *first
List.cpp
void *first()
{
if( pHead == NULL )
return( NULL );
return( pHead->Data() );
}
Which calls method *Data
..
List.h
void *Data() { return( pData ); }
Then the code breaks and the following error is displayed:
Unhandled exception at 0x... in ListClass.exe: 0x... (another memory address) Access violation reading location 0x... (another memory address).
Any idea what might have caused this leak?
Jon
|
|
|
|
|
i'm going to guess that pHead contains random junk data (was never initialized to NULL, nor set to hold valid data).
|
|
|
|
|
Hi all,
I had created one mainframe window and several document templates inside it. I had called all those from the "App" class.
Now I want to disable some buttons in the toolbar in one of its view class.
I tried....
CTCToolBar m_wndtoolbar; // Derived from CToolBar
m_wndtoolbar.SendMessage(TB_ENABLEBUTTON,ID_USECASE_NEW,FALSE);
and---->
m_wndtoolbar.GetToolBarCtrl().EnableButton(ID_USECASE_NEW,false);
But the application crashed...
can any one help me....
Thanks in advance..
vinsankar
|
|
|
|
|
Vinod A Sankaranarayanan wrote: CTCToolBar m_wndtoolbar; // Derived from CToolBar
m_wndtoolbar.SendMessage(TB_ENABLEBUTTON,ID_USECASE_NEW,FALSE);
Did you even create the toolbar between those two calls ???
if the toolbar already exists then you need to grab a pointer to that already created toolbar and not create a new instance by CTCToolBar m_wndtoolbar; .
Don't believe everything you think.
|
|
|
|
|
Thanks...
I grab that pointer and try to disable some buttons by using the functions described in my first message.
But it doesn't work...
Is there any other solution?
vinsankar
|
|
|
|
|
Map command-update handler (using ON_UPDATE_COMMAND_UI).
As for example we have a toolbar button with command identifier ID_MYCOMMAND:
class CMyView : public CView
{
afx_msg void OnUpdateMycommand(CCmdUI* pCmdUI);
DECLARE_MESSAGE_MAP()
};
ON_UPDATE_COMMAND_UI(ID_MYCOMMAND, OnUpdateMycommand)
END_MESSAGE_MAP()
void CMyView::OnUpdateMycommand(CCmdUI* pCmdUI)
{
pCmdUI->Enable(FALSE);
}
Ovidiu Cucu
Microsoft MVP - Visual C++
|
|
|
|
|
Hi CuCu....,
Thanks......a lot..........
it works.........
Once again.....thanks......!!!
Regards
vinsankar
|
|
|
|
|
Hi Vinsankar,
You are welcome!
Ovidiu
|
|
|
|
|
How do you use from CTCToolBar in your code that you get a crash?
|
|
|
|