|
It's hard to know for sure without knowing what bmpsize is, but I would guess that bmpsize is less than 5. When you call memset, you are setting the five bytes starting at the address of bmpsrc to 0xff. If you have allocated less than five bytes, you will be writing to memory you do not own
|
|
|
|
|
harshadha wrote: bmpsrc = (U8 *) malloc(bmpsize);
memset(bmpsrc, 0xff, 5);
Did you check that bmpsrc was not NULL?
bmpsize is checked for being greater than 5?
maybe memset(bmpsrc, 0xff, max( 5, bmpsize)) would be better?
Other than that, the code snippet looks fine.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
What is U8 ? What is value of bmpsize ?
|
|
|
|
|
void example()
{
U32 bmpsize; //this is an integer datatype
U8 *bmpsrc=0x00FC0; //this is the character datatype
//i want to use malloc only .....
bmpsrc =malloc(bmpsize);
memset(bmpsrc, 0x00FC0, 0);
..
..
..
}
this is my actual coding .....
i dont know how to change its memory allocation
|
|
|
|
|
harshadha wrote: bmpsrc =malloc(bmpsize);
What is value of bmpsize ?
harshadha wrote: memset(bmpsrc, 0x00FC0, 0);
Why you are passing last parameter as 0, it should be less than or equal to bmpsize .
|
|
|
|
|
the bmpsize value is taken equal to the data type value(U32 bmpsize that is),it is taken as 2bytes.
My real problem is i want to create a buffer to draw a bmp file...
for that i have to use malloc then i need bmpsrc that is the memory allocated area and the size.....
|
|
|
|
|
harshadha wrote: the bmpsize value is taken equal to the data type value(U32 bmpsize that is),it is taken as 2bytes.
In this case, third parameter to memset in your OP should be
bmpsize . Where as in your OP, you was passing 5, that was causing problem.
harshadha wrote: i have to use malloc then i need bmpsrc that is the memory allocated area and the size.....
May be you can be little clear, what you are trying to say.
|
|
|
|
|
What does your debugger tell you?
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
The instruction at "0x006aoef8" referenced memory at "ox00000000".The memory could not be read.
|
|
|
|
|
That's not a text from your debugger. That's Windows error message.
By using the debugger you have, you can set a break point in your source code. When the program reaches the break point, the debugger will stop the execution of youe program so you can (amongst other things) inspect your variables and find out the cause of the problem.
You should learn how to use the debugger. It's not very hard to do and the debugger will definately save you heaps of time when you are looging for problems with your code.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
unhandled exception in fa.exe:cx0000005 access violation
|
|
|
|
|
Hi,
I need to erase Button edge lines. so that i can not see its rectangle line on dialogbox? But the button should work as like before.
How can i do this ?
Thanks.
|
|
|
|
|
Do you have owner draw for your button?
|
|
|
|
|
you need to owner draw the button..
nave
|
|
|
|
|
How do i that ? Can you show me few examples ?
|
|
|
|
|
you can find many article in the code project describing button owner drawing. search "owner draw button" in code project.
nave
|
|
|
|
|
|
Alright, this may be one of those annoying "how long is a piece of string" questions, but I'm just curious if anyone can give a short but key explanation of
- MFC, Win32. I've seen articles saying MFC is "bad" but not really sure why, I've knocked up many things with the app wizard - dialog apps, and to be honest, probably don't really understand the difference between the two, much less why one is better than the other. I'm sure I've also written stuff in Win32 when I wrote tools for 3DSMax but I've been out of programming for a long while, and probably only ever "knew what I needed to know" when I was doing it. Both MFC and WIn32 use C++ as their core?
- I always assumed this C# and .NET stuff were just an extension of Visual C++ but I can now see I'm very wrong - it's a whole new syntax of code. Is this the best place to start now for writing quick and simple tools/applications?
|
|
|
|
|
I think the main reason people would consider MFC bad and the .Net framework good is that MFC has gradually evolved and expanded over the lifespan of Windows, and so has many weird inconsistencies (e.g. if one function returns a colour, and another takes a colour as an argument, you may find that these colours are different types, so you need to convert between them.)
.Net was developed from scratch from the ground up, so is far more consistent (and thus easier to learn if you've got no prior knowledge of the system - from my experience usually if something looks like it's the right way of doing things, it should work)
Of course, in 25 years, we'll probably be complaining about how bloated and convoluted .NET v12 is, and looking forward to whatever new framework is coming out
|
|
|
|
|
ldsdbomber wrote: MFC, Win32
I won't enter the debate to say if MFC is good or not but I'll try to clarify some points here. The Win32 API, honnestly we don't care if it is written in C++, in assembler, in C or whatever. You just acess a kind of interface (a set of function that lets you interract with the core of windows).
MFC is in fact a bunch of classes that wraps the win32 API and it does a lot of things for you. Honnestly, developping an application in pure win32 takes much much much longer than using MFC. But it doesn't mean that MFC is better than win32. No, it just means that MFC wraps the win32 API
For your second question, I know nothing about .NET so I cannot really help you.
|
|
|
|
|
From my experience, many people don't like MFC mostly because it has some ugly syntax conscerning with so many identifiers and macros, and thus makes the programming not easy. And also some say that there are areas where MFC cannot help, so they turn to other libraries or Win32 itself. But let's not forget the purpose of MFC; it is not an all-purpose but a general-purpose library. If we use MFC in an app, this does not mean that everything should be done in MFC and only in MFC. Rather, we are supposed to use other tools as well, and the main one is Win32 functions [that are not wrapped by MFC].
.NET is an another kind of thing. It is an all-purpose library [though we may call Win32 functions as well]. Actually, .NET is a platform with its own interpreter/compiler and executable code. Everything is managed by CLR (Common Language Runtime)...
For Web based apps ASP.NET is much more comfortable than any other tool [IMO].
For large systems [scientific ot other] I don't think that .NET will do much. On the other hand, C++ based apps [consider MFC also] are the leading ones.
--
======
Arman
|
|
|
|
|
People call MFC bad sometimes because you cannot say it's one of the best Frameworks ever built. It's not perfectly planned. Moreover it's a just wrapper around the Win32 API. If you can do everything so easily(if you so proficient) using Win32 SDK , you can very well write your own classes around and use it. Anyway it's going to take more time than doing by MFC. When you compare MFC with .net you'd rather call MFC as a shortcut to Win32 SDK. .Net is quite robust. A fully planned framework. Even it's going to make API calls underground but the difficulty is completely abstracted to the programmer. The big catch in .net is that it compiles to IL rather than the native machine code. The CLR (the .net runtime) *manages* the IL very well and executes it properly. In short, if you program using .net , your application would be completely controlled & protected by the CLR. that's cool.
Dario: How is "directory" in French? (I mean a file system directory).
John Simmons: "zee file holdaire thingie"
|
|
|
|
|
I recall seeing an example somewhere that showed you how to monitor windows messages so that you could do things in a dialog (maybe the example had loads of controls) and either a popup or some text control displayed the WM_ windows message that had been put into the queue as a result. I would love to see that again as it's a great way to learn how things work in a dialog in terms of events and messages.
|
|
|
|
|
Ate you thinking of the Spy++ tool that comes with Visual Studio (it should be in the tools menu)
|
|
|
|
|
If it's MFC, you could be talking about a PreTranslateMessage ?
Dario: How is "directory" in French? (I mean a file system directory).
John Simmons: "zee file holdaire thingie"
|
|
|
|