|
Hi All,
First of all many thanks to all who have given their valuable suggestion. I am not getting the Exception now but I get an Access Violation error like this in my output window and my notepad doesnt launch.
ChristopherAtCodeProject wrote: First-chance exception in Threading Sample.exe (NTDLL.DLL): 0xC0000005: Access Violation.
First-chance exception in Threading Sample.exe (NTDLL.DLL): 0xC0000005: Access Violation.
Any help on this please. Do I need to give some security descriptors or something. To the best of my knowledge its not required I suppose as even if we pass NULL to them it will consider the default Security.
Many Thanks
|
|
|
|
|
Hi All,
Its working fine now. I had to fill in the STARTUPINFO struture.
Thanks
|
|
|
|
|
hi all
i want to image processing.i want to load image to the picturebox and then extract the values from it. i m loading image on the picturebox through the code loadimage and variable of picbox.setbitmap.
After loading this image i want to perfrom data extraction i mean read RGB values.what is fastest method of it
either use the device context and and perform the data extraction or use the cimage atl class for this purpose.
ddd+
|
|
|
|
|
Hmm the fastest way to load files into memory that I know if is by using memory mapped files. Map the entire file into your process address space. I assume that you are using a bitmap file format?? You could do something like this:
HANDLE hFile;
HANDLE hFileMappingObject;
BYTE * lpBaseAddress;
BITMAPFILEHEADER * lpBitmapFileHeader;
BITMAPINFOHEADER * lpBitmapInfoHeader;
RGBQUAD * lpRGBQuad;
BYTE * lpColorIndexArray;
if(OpenDialog1->Execute())
{
hFile=CreateFile(OpenDialog1->FileName.c_str(),GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
if(hFile==INVALID_HANDLE_VALUE)
{
MessageBox(Handle,"Could not open file","Error",MB_OK|MB_ICONERROR);
return;
}
hFileMappingObject=CreateFileMapping(hFile,NULL,PAGE_READWRITE|SEC_COMMIT,0,0,NULL);
if(hFileMappingObject==NULL)
{
MessageBox(Handle,"Could not create file mapping object","Error",MB_OK|MB_ICONERROR);
CloseHandle(hFile);
return;
}
lpBaseAddress=(BYTE*)MapViewOfFile(hFileMappingObject,FILE_MAP_WRITE,0,0,0);
if(lpBaseAddress==NULL)
{
MessageBox(Handle,"Could not map view of file","Error",MB_OK|MB_ICONERROR);
CloseHandle(hFileMappingObject);
CloseHandle(hFile);
return;
}
lpBitmapFileHeader=(BITMAPFILEHEADER*)&lpBaseAddress[0];
lpBitmapInfoHeader=(BITMAPINFOHEADER*)&lpBaseAddress[sizeof(BITMAPFILEHEADER)];
lpRGBQuad=(RGBQUAD*)&lpBaseAddress[sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)];
lpColorIndexArray=&lpBaseAddress[lpBitmapFileHeader->bfOffBits];
//Use lpColorIndexArray to acces your RGB values
UnmapViewOfFile(lpBaseAddress);
CloseHandle(hFileMappingObject);
CloseHandle(hFile);
}
|
|
|
|
|
I am writing a dialog based MFC prog.
I dont want the "close" button in title bar of that dialog. But I want the icon in the title bar. Thats why I cannot disable the entire title bar or sys menu. Is there any procedure so that i can disable the close button, but icon is still there in the title bar?
|
|
|
|
|
Look here[^]
Nibu thomas
Software Developer
|
|
|
|
|
If your dialog have only the close button add this to OnInitDialog just before return..
<br />
((CMenu*)GetSystemMenu(FALSE))->DeleteMenu(1, 1024);<br />
|
|
|
|
|
Hi
I am working with excel automation. I need to write an excel file from VC++. The format of the excel file should be
Events Table
Date&Time,Source,Cause,Description,Fault - 3rd row
Mar 13 2006 12:25:05.000078,HMI,H-0001,Startup,N
Mar 13 2006 12:25:05.000187,HMI,H-0005,Caution,Y
ect...
Footer
I used excel automation as shown below.
CoInitialize(NULL);
try
{
Excel::_ApplicationPtr excel;
// Initialize Excel and make sure it's initialized
HRESULT hr = excel.CreateInstance(L"Excel.Application");
Excel::_WorkbookPtr workbook = excel->Workbooks->Add(static_cast<long> (Excel::xlWorksheet));
Excel::_WorksheetPtr worksheet = excel->ActiveSheet;
worksheet->Range["A1"]->Value = "Header1";
worksheet->Range["A2"]->Value = "Header2";
worksheet->SaveAs("c:\\test1.xls"); // Save it
workbook->Close(); // Close the workbook
excel->Quit(); // Quit excel
}
catch(_com_error &ce)
{
AfxMessageBox("Error");
}
CoUninitialize();
Now the problem is, since I don't have the number of cells varry , I want to run a ForLoop where I can input the values in the Range function as shown here.....worksheet->Range["A1"]->Value = "Header1";
I am facing some problems when I try to give the values here as
char* str = new char(3);
str = "B3";
worksheet->Range[str]->Value = "Header1";
Can anyone please help me with some sample code for doing this?
Thanks
Madhavi..
|
|
|
|
|
What exacty are the problems you are getting?
I have excel up and running in my current project, but I used a slightly different method. I created a DLL coded in Visual Basic and included it into my project.
As for your problem, instead of inserting the value using the range method, why not try the cell method instead?
worksheet->Cell[inty,intX]->Value = "Header";
|
|
|
|
|
What does the below line mean?
CCheckPoint():m_cRef(0), m_pConnection(NULL){}
where
CCheckPoint is a class,
m_cRef is ULONG,
m_pConnection is IConnectionPoint*
Can anyone help me in understanding what the bove code means?
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
it is the default constructor of the class CCheckPoint , which invokes in its initializer list the copy constructors for the members m_cRef and m_pConnection .
it is quite equivalent to this (but not equal though) :
CCheckPoint() {
this->m_cRef = ULONG(0);
this->m_pConnection = (IConnection*)NULL;
}
the constructors initializer list is particularly mandatory when initializing constant data members which cannot be assigned in the constructor body.
it is also useful when a class inherits from a base class. the base class members must be initialized before the members of the child. the initialization list can so be used to call the base class constructor :
class A {
int m_i;
public:
A(void) : m_i(0) { }
A(const A& a) : m_i(a.m_i) { }
A(int i) : m_i(i) { }
};
class B : public A {
public:
B() : A() { }
B(const B& b) : A(b) { }
};
|
|
|
|
|
Thanks...
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
|
Save My Soul - (SMS) wrote: CCheckPoint():m_cRef(0), m_pConnection(NULL){}
This is inline intialization of member variables. m_cRef(0) is initialized to 0 and m_pConnection a pointer is initialized to NULL .
This gets initialized before any other variable could get initialized. This is also used to pass values to base class constructors like this...
CCheckPoint(int n):BaseClass(n), m_cRef(n)
{
} Here we are calling BaseClass constructor and initializing m_cRef with the value n .
Nibu thomas
Software Developer
|
|
|
|
|
Thanks...
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
What u see is the initialisation list.
Here in the constructor, the member variables have been initalised( m_cRef with 0 and m_pConnection with NULL).
The above code is same as
CCheckPoint()
{
m_cRef = 0;
m_pConnection = NULL;
}
nave
|
|
|
|
|
Thanks...
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
Hi
i am working with mfc.
in the onpaint in a cdialog, i need to draw some shapes and for each i need to add a button to it. the user can add more of this shapes and also for each new shape there is a button
i was able to create the button in onpaint but clicking it causes the app to freeze
is there any solution for this, or any other approach for adding the button
thanks alot
|
|
|
|
|
Waw, this is... bad ! You know that OnPaint will be called each time the app needs to be refreshed ? So for example, a windows comes before your app and then disapear, then OnPaint will be called again. Thus you will create new buttons over and over again... This is crazy.
You should create the buttons once only, at the creation of the window.
|
|
|
|
|
excuse me
you draw some shapes and you create buttons in the WM_PAINT and when you click in the button they are freeze.
buttons are controls for shapes?
you can once buttons and use them
I think Its not good create button in wm_paint
|
|
|
|
|
I know that creating controls in wm_paint is bad and crazy and waw.
Each shape on the dialog has a button (drawn inside the shape) to do some action on the shape.
but lets suppose that i have one shape now, and i created its button outside the wm_paint.
now in run_time the user will add new shape,
but how i ll create a new button to associate with the new shape?
|
|
|
|
|
|
I suggestion
Use HWND hwnd[20];
if user will add new shape then user use WM_LBUTTONDOWN
and you can then create button if you need use handle button in the onpaint
|
|
|
|
|
I think you need to re-think your design; you simply cannot create controls in the OnPaint.
in your main view, you will draw an OBJECT.
that OBJECT will be a class ( CWnd derived ) that will take care of creating/owning its Button and drawing the shape.
for example, a rough implementation :
class CButtonShape : public CWnd
{
DECLARE_DYNAMIC(CButtonShape)
CBrush m_Brush;
CButton m_Button;
public:
CButtonShape();
virtual ~CButtonShape();
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnPaint();
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
};
and use the view to create and display that class ( or many as you wish ).
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Hi all,
Do anybody know why the font size is normally said as 8, 10, 12, 14, 16, 18, 20, 24, 36, 48, etc?
Is there any speciality for these numbers?
- NS -
|
|
|
|