|
What is m_FileName ?
It seems to be something like:
char* m_FileName; //This should produce the error.
However,
char m_FileName[MAX_PATH];//This should not result in an error.
It is unclear from your post; it could be something else also.
this is this.
|
|
|
|
|
What is m_FileName declared as?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for - in order to get to the job you need to pay for the clothes and the car, and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
|
|
|
|
|
It depends on what data type m_Filename is.
If it is of type CString, then I think this function will not work without first exposing the memory buffer (GetBuffer(0) ??).
If the variable is an array of characters, then it should work (unless the destination size is less than the source string).
I Dream of Absolute Zero
|
|
|
|
|
vikas amin wrote: strcpy(m_FileName,FileName);
change to
if ((!m_FileName) && (size_allocated_to(m_FileName) > ::strlen(FileName))) {
::strcpy(m_FileName, FileName);
}
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VisualCalc 3.0]
|
|
|
|
|
Ok
I think i got the point
i need to allocate the space for
the destination .
thank you
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
see if u have initialized it first. like khan said
regards,
Rookie
Installing MFC...2% complete
|
|
|
|
|
Hello,
You should beware of the UNICODE problems that your code have when you compile with UNICODE defined. See the following where your problems are:
const char* FileName
= _T("C:\\1.bmp");
To solve this problem, use TCHAR* instead of char* where you want to use the _T macro.
[EDIT]
You should also use the macros from tchar.h[^] so that you use UNICODE functions when you build with UNICODE defined.
[/EDIT]
Hope this helps.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
-- modified at 9:43 Tuesday 20th December, 2005
|
|
|
|
|
Hey. If m_FileName happens to be a CString, then just do this instead:
mFileName = FileName
instead of using anything like strcpy.
You are LUCKY you got the access violation now and not 10 months from now with 10 million copies of your app in the field
No shirt, no shoes, no brains, no service.
|
|
|
|
|
|
Show me EXACTLY here the m_FileName is defined or declared in his original post?
No shirt, no shoes, no brains, no service.
|
|
|
|
|
Since you are using mfc why not use CString and let all this memory allocation for strings automatically be handled for you??
John
|
|
|
|
|
vikas amin wrote: strcpy(m_FileName,FileName);
Why are you not using CString ?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
vikas amin wrote: strcpy(m_FileName,FileName);
Hai Vikas,
what type of variable is m_FileName
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
I have a class in which there is a structe
i want to initialize the structre through the constructer .
class xyz{
struct tagBITMAPFILEHEADER
{
WORD bfType; // must be 'BM'
DWORD bfSize; // size of the whole .bmp file
WORD bfReserved1; // must be 0
WORD bfReserved2; // must be 0
DWORD bfOffBits;
}m_BITMAPFILEHEADER ;
xyz()
{
BITMAPFILEHEADER ={0,0,0,0,0};
}
}
I am getting an error
error C2059: syntax error : '{'
error C2143: syntax error : missing ';' before '{'
am i wrong someware
}
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
If the code that you post is the real code there is a little error:
vikas amin wrote: xyz()
{
BITMAPFILEHEADER ={0,0,0,0,0};
}
xyz()
{
m_BITMAPFILEHEADER ={0,0,0,0,0};
}
Have a nice code day
|
|
|
|
|
|
Sorry that was not the real code it is not copy pasted
i typed it again .
The real problem is how to initialise the structure .
Can anyone tell me
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
|
Why don't use
xyz()
{
m_BITMAPFILEHEADER.bfType=0;
m_BITMAPFILEHEADER.bfSize=0;
m_BITMAPFILEHEADER.bfReserved1=0;
m_BITMAPFILEHEADER.bfReserved2=0;
m_BITMAPFILEHEADER.bfOffBits=0;
}
Because, I don't remember if you could use ={0,0,0,0,0} in that point
Have a nice code day
|
|
|
|
|
My favorite,
ZeroMemory(m_BITMAPFILEHEADER, sizeof(m_BITMAPFILEHEADER));
if you want to set everything to 0.
Does not work if a class with complex objects is embedded wihtin the structure, such as a CString, however.
I can't believe how many times I have seen code setting data structure's fields to all zeroes, when there are several dozen fields, instead of block setting the entire element. If I only had a dollar...
No shirt, no shoes, no brains, no service.
|
|
|
|
|
I understand you!!!
This happens, really, too many times.
Have a nice code day
|
|
|
|
|
Hi everybody,
I need to implement Doc/View/Frame in an ActiveX control. I have tried to copy the code from a standart MFC Wizard generated SDI application in a standart Wizard generated ActiveX control, but it didnt work - all I could get was a bunch of crashes (for the document, I derived my class from COleDocument). Can anybody point me in the right direction. Any information is appreciated.
Thanks in advance,
Dennis.
|
|
|
|
|
hello,
i changed the background color of my dialogs in a dialog based MFC app by adding the following code:
SetDialogBkColor(RGB(150, 150, 150), RGB(0, 0, 0));
in my dialog based applications "Initinstance". However though the dialogs have all changed color, the background color of MessageBox() has not, and also the menu Button (Like File, Edit, Help) bar still follows the windows theme color. The menu options however show in white which is fine. I just want to change the background color of my messagebox and the color of my top menu.
Any pointers on how to do this?
"Some guys hack just to get themselves a girlfriend.What a pathetic reason huh ?"
|
|
|
|
|
Hi,
can anyone tell me how to use a bitmap as a background for my title bar? I have used a bitmap background for the dialogs and the title bar looks very out of place.
thankx
"Some guys hack just to get themselves a girlfriend.What a pathetic reason huh ?"
|
|
|
|
|