|
I think the problem is the line before the one you've highlighted
try changing
open.read((char*) length, sizeof(short));
to
open.read((char*)(&length), sizeof(short));
System.IO.Path.IsPathRooted() does not behave as I would expect
|
|
|
|
|
|
No worries
What about this...
// Add a terminator
buf[4] = '\n';
usually you would terminate a string with '\0'
System.IO.Path.IsPathRooted() does not behave as I would expect
|
|
|
|
|
Oops... I'm just used to seeing that \n all the time... Thanks!
Windows Calculator told me I will die at 28.
|
|
|
|
|
Please suggest me any correction for this code.
This code is saving image in inverted format.
//This is for getting data from clipboard in CBitmap's object.
OpenClipboard();
Glb=EnumClipboardFormats(0);
HANDLE hBitMap = GetClipboardData(Glb); //getting from clipboard
if(hBitMap == NULL)
{
AfxMessageBox("Error in Capturing Image");
return;
}
//CBitmap * bmp = CBitmap::FromHandle(hBitMap);
CBitmap bmp;
if(!bmp.Attach((HBITMAP)hBitMap))
{
AfxMessageBox( "Error in Loading Image" );
}
BITMAP bitmap ;
bmp.GetBitmap(&bitmap);
int size = ((bitmap.bmWidth)*(bitmap.bmHeight)*(bitmap.bmBitsPixel))/8;
BYTE *lpBits = new BYTE[size];
::GetBitmapBits((HBITMAP)hBitMap,size,lpBits);
WriteBmp("C\\Patient.bmp",&bitmap,(int*)lpBits);
CloseClipboard();
}
For writing ang saving .bmp file.......
void WriteBmp(char* name,BITMAP *bmp,int* data)
{
BITMAPINFO Bmi;
memset(&Bmi,0,sizeof(BITMAPINFO));
Bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
Bmi.bmiHeader.biWidth = (bmp->bmWidth);
Bmi.bmiHeader.biHeight = (bmp->bmHeight);
Bmi.bmiHeader.biPlanes = 1;
Bmi.bmiHeader.biBitCount = bmp->bmBitsPixel;
Bmi.bmiHeader.biCompression = BI_RGB;
Bmi.bmiHeader.biSizeImage = bmp->bmHeight*bmp->bmWidth*bmp->bmBitsPixel/8;
FILE* image = fopen (name,"wb");
if(image==0)
return;
int h = abs(Bmi.bmiHeader.biHeight);
int w = abs(Bmi.bmiHeader.biWidth);
Bmi.bmiHeader.biHeight=h;
Bmi.bmiHeader.biWidth=w;
int sz = Bmi.bmiHeader.biSizeImage;
BITMAPFILEHEADER bfh;
bfh.bfType=('M'<<8)+('B');
bfh.bfOffBits=sizeof(BITMAPFILEHEADER)+ sizeof(BITMAPINFOHEADER);
bfh.bfSize=sz+bfh.bfOffBits;
bfh.bfReserved1=0;
bfh.bfReserved2=0;
fwrite(&bfh,sizeof(bfh),1,image);
fwrite(&Bmi.bmiHeader,sizeof(BITMAPINFOHEADER),1,image);
fwrite(data,sz,1,image);
fclose(image);
}
|
|
|
|
|
|
you have to invert the sign of biHeight see the following excerp of (MSDN):
biHeight
Specifies the height of the bitmap, in pixels. If biHeight is positive, the
bitmap is a bottom-up DIB and its origin is the lower-left corner. If
biHeight is negative, the bitmap is a top-down DIB and its origin is the
upper-left corner.
hope that helps.
|
|
|
|
|
Hi Everyone,
I have created a .Net User control which includes reference to a C++ /CLI component developed with /clr . Since there are some unmanaged resoucrces, i am calling the disposing the C++ /CLI in the dipose method of the user control. If we drag and drop this control in to a Windows form and then try to delete it,it is throwing an exception that the "C++ / CLI " dll could not be located.... however it is working fine while running the application
can anyone help me out.The sample code is
///
/// Clean up any resources being used.
///
/// <param name="disposing" />true if managed resources should be disposed; otherwise, false.
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
if (unmanagedComponent != null)
{
unmanagedComponent = null;
}
}
|
|
|
|
|
|
Hello there.. I have a CTreeCtrl which has the checkboxes style set. I would like all the checkboxes to be set (ticked) by default.
I have function which loops around all the tree items and calls SetCheck() on each tree item.
However when calling this function from inside OninitDialog the checkboxes do not get set.
If i call this function afer the OninitDialog it works fine. Can anyone help me here.
|
|
|
|
|
|
How can we check whether URL is Valid or not through a MFC Application?
|
|
|
|
|
PathIsURL() API
Refer MSDN
|
|
|
|
|
It is just checking URL is valid format or not, but what i want is whether the URL path is exixt or not. for example if we give www.goooggle.com, the i want to tell it is not valid...
|
|
|
|
|
The only way to tell is to try connecting to it.
|
|
|
|
|
Hi,
I have a string variable m_strAddBlob with value in it.I need to convert it to char * .
I do this way
char* buf = (char*)(LPCTSTR)m_strAddBlob;
//nBytes=m_strAddBlob.GetLength();
For checking whether the string is properly typecasted or not I do the following....
CString str(buf);
AfxMessageBox(str);
then I get only first character of the string.
Any Suggestions would be great help.
Thanks
Today is a gift, that's why it is called the present.
|
|
|
|
|
Use CString::GetBuffer()
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
A conversion like
char * buf = (char *)(LPCTSTR)m_strAddBlob;
is not correct in case of Unicode strings -- the result looks like a string consisting of the first character only.
I think you first have to convert your string from Unicode to Ansi. In new MFC this can be done like this:
CStringA ansi(m_strAddBlob);
Then if you actually need a pointer to constant string, then you can use explicit cast:
const char * buff = ansi;
If you realy need a pointer to non-constant string and modify the string, then use GetBuffer and ReleaseBuffer functions:
char * buff = ansi.GetBuffer();
. . .
ansi.ReleaseBuffer();
I hope this helps.
|
|
|
|
|
Why return type is not become part of functions signature.
|
|
|
|
|
Because you cannot differenciate a function by its return type. Your compiler will throw you an error if you have to identical functions that differ only by the return type (it's impossible for him to know wich one needs to be used).
And as function signatures are used to differentiate different overloaded functions, it has no use in the signature.
|
|
|
|
|
hi
I want my application to display menus,messages and captions in marathi.
abbmmm
|
|
|
|
|
What is that you are using to build your application? VC 6 or Above? If VC6, is your application unicode aware? Have you localised your computer with Indic script?
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
I have a large data array and was told to make it static to ensure that I have enough storage allocated
DATA_DETAILS signal_details[NO_FIELDS] = {
"1.000000",
"Integer",
"0",
"0",
etc
Note NO_FIELDS could be 25,000 and some of the elements are char arrays of 4096 bytes. i.e. lots of data.
Now if I make it static; e.g.
static DATA_DETAILS signal_details[NO_FIELDS] = {
"1.000000",
"Integer",
"0",
"0",
etc
the project fails to build as I have extern references; e.g including the keyword static causes a problem.
extern static DATA_DETAILS signal_details[NO_FIELDS];
How can I overcome this problem please.
|
|
|
|
|
I think the static is for the case your array is declared locally in a function. If it is a global variable and is accessed from other modules, then do not add static (otherwise it becomes available from the current file only).
|
|
|
|
|
Why somebody did tell that?
You have not to make it static , since static means only file scope in such context.
You can choose to allocate storage on the stack or on the heap. You don't need to allocate static as you did.
|
|
|
|