|
A .NET assembly can be exported as a COM dll, by using the regasm.exe tool provided in the .NET SDK (or tlbexp.exe + regsvr32.exe). Once created and registered, the type library can be used like any other COM object.
[edit]Of course, the COM object itself is only an entry-point to the .NET EE. As a consequence you need to distribute the .NET run-time (dotnetfx.exe) along with your MFC app.[/edit]
|
|
|
|
|
I have the following code which will populate the list control from a recordset.
But it gives error and crashes .
Can anyone rectify the problem.
void CReport::OnGetdispinfoList1(NMHDR* pNMHDR, LRESULT* pResult)
{
LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
// TODO: Add your control notification handler code here
CString szValue = "\0";
CDBVariant varValue;
long index = pDispInfo->item.iItem;
long subItem = pDispInfo->item.iSubItem;
if(pDispInfo->item.mask & LVIF_TEXT)
{
try
{
crs->SetAbsolutePosition(index+1);//Set the file to desired index
}
//<sql>
catch(CDBException* e)
{
AfxMessageBox(message += e->m_strError,MB_ICONEXCLAMATION );
e->Delete();
return;
}
try
{
if(subItem)
crs->GetFieldValue((short)subItem,varValue);
else
crs->GetFieldValue((short)0,varValue);
}
//<sql>
catch(CDBException* e)
{
AfxMessageBox(message += e->m_strError,MB_ICONEXCLAMATION );
e->Delete();
return;
}
const CDBVariant variant =varValue;
try
{
switch(variant.m_dwType)
{
case DBVT_SHORT:{ szValue.Format("%d", variant.m_iVal);
break;
}
case DBVT_LONG:{ szValue.Format("%d", variant.m_lVal);
break;
}
case DBVT_SINGLE:{ if ( variant.m_fltVal == 0.0 )
szValue = "Verify";
else
szValue.Format("%.1f", variant.m_fltVal);
break;
}
case DBVT_DOUBLE:{ if ( variant.m_dblVal == 0.0 )
szValue = "Verify";
else
szValue.Format("%.1f", variant.m_dblVal);
break;
}
case DBVT_DATE:{
szValue.Format("%B %d, %Y",variant.m_pdate );
break;
}
case DBVT_STRING:{ szValue = *variant.m_pstring;//szValue = V_BSTRT( &varValue );//convert BSTR to CString
break;
}
case DBVT_BOOL:{ if(variant.m_boolVal)
szValue = "TRUE";
else
szValue = "FALSE";
break;
}
case DBVT_UCHAR:{ szValue = (char*)variant.m_chVal;
break;
}
case DBVT_NULL:{
szValue = "Error";
break;
}
default:{
szValue = "\0";
break;
}
}//switch
lstrcpyn(pDispInfo->item.pszText, szValue.GetBuffer(szValue.GetLength()), pDispInfo->item.cchTextMax);//set item text
}
catch(CException *e)
{
TCHAR szCause[255];
AfxMessageBox(e->GetErrorMessage(szCause,255),MB_ICONEXCLAMATION );
return;
}
}// End of sorting
*pResult = 0;
}//OnGetdispinfoList1
|
|
|
|
|
How to Play the Images round the Ellipse or Circle?
|
|
|
|
|
hi i wanted to make a linked list in Visual C++ 6.0 , i had done it in c++ but cant do the same in VC. please help me.
i get a run time eror (memory acces error) when i use this code in Visual cpp
typedef struct str
{
int x;
str * next;
}a;
a * node=NULL;
node->x=0; // error occurs in this
|
|
|
|
|
Alright, I was going to respond with a smartass answer, but I won't. First of all, the code you've shown will indeed work if it's running on some special embedded device created by you. However, acessing the address of 0 (NULL) is usually a really bad idea (in usual circumstances, i.e. almost every operating system), and it's why most programmers set pointer addresses to zero when they initialize them: So it will cause a fault when you access an invalid address. So, what you need to do, is allocate your node pointer on the heap. Do this:
a * node = new a;
Don't forget to delete it when you are done with it:
delete a;
Also, since you are using C++, why not use the std::list? It would provide you with all the cool stuff like storage, traversal, etc.
Chris Richardson
C/C++ Include Finder[^]
|
|
|
|
|
I am developing a application,which requiresMS Paint as external editor. But How to check MS Paint is present in system or not?. 
|
|
|
|
|
Holy crap, I feel sorry for you.
|
|
|
|
|
LOL! 
|
|
|
|
|
MS Paint is installed along with the operating system.
|
|
|
|
|
Just check if file "mspaint.exe" exists in system32....
BOOL FileExists(const char *pszPath)
{
if (GetFileAttributes(pszPath) != HFILE_ERROR)
return true;
return false;
}
|
|
|
|
|
Hi, everyone!
When using the following statement,
--------
#include <ntddk.h>
--------
in Win 2k and VC7.0, an error occurs,
"ntddk.h": No such file or directory.
How to resolve the trouble?
Thanks in advance,
George
|
|
|
|
|
I'm sorry, but if you cannot solve this problem on your own, maybe a mini-gateway is a little hard task for you.
Zoltan
Ps:
Check the include path (add NTDDK\inc and NTDDK\inc\ddk to the path)!
Zolee
|
|
|
|
|
Thanks, Zoltan buddie!
I can not find a folder named NTDDK on my machine.
Maybe I have something lost? Please help.
Cheers,
George
|
|
|
|
|
Download Device Drive Kit (DDK) from Microsoft[^] site.
A. Riazi
|
|
|
|
|
Hi, A. Riazi buddie!
I can not find the download page for DDK.
Can you point me the page?
Thanks in advance,
George
|
|
|
|
|
|
Thanks, Riazi buddie!
George
|
|
|
|
|
Hi, everyone!
I want to implement a mini-gateway on Windows platform.
Where can I get some sample codes for it? I need a gateway
that can implement basic functions, for example, check whether
a package from a certain IP address can pass through.
Thanks in advance,
George
|
|
|
|
|
I am using SetDialogBkColor to change the background color of our dialogs. Unfortunately CPropertySheet does not apply this setting. I have been able to change the property sheets background color via WM_CTRLCOLOR, but I can't seem to do this for the tab control embedded on the property sheet. I have tried subclassing the tab control, but I don't get WM_CTRLCOLOR messages for some reason. I have also tried overriding WM_DRAWITEM and WM_ERASEBGND with no success. Any ideas short of writing my own property sheet class? Thanks
Chris Hafey
|
|
|
|
|
hello,
i make a console application ,who give me the handel of one windows,and i want to use one API who use this handel given by the console application.Is that it is feasible?and how can to make it?
|
|
|
|
|
It's possible to use any Win32 API from console applications.
A. Riazi
|
|
|
|
|
Howdy'
I want to "replace" the 3d border around a CEdit with a simple rectangle ( that I can change color when the CEdit gets and looses the focus ).
How, Where (and maybe when), should I do this ?
I try overriding the WM_PAINT, but that doesn't go well,
void CCustomEdit::OnPaint()
{
CPaintDC dc(this);
CRect rect;
GetWindowRect( rect );
CBrush brush;
brush.CreateSolidBrush( RGB( 200, 0, 0 ) );
dc.FillRect( rect, &brush );
}
I was expecting to have at least a redish rectangle drawn somewhere, or at least a red flicker... but I only get a badly redrawn CEdit.
Thanks for you input!
Max.
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
You can draw your own border by handling the WM_NCPAINT message. WM_PAINT is used for the client area.
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
It doens't work ...
This is what I do :
void CCustomEdit::OnNcPaint()
{
CRect rect;
GetWindowRect( rect );
CDC* pDC = this->GetDC();
rect.InflateRect( 10, 10 );
CBrush* pOldBrush =pDC->SelectObject( &m_Brush );
pDC->FillRect( rect, &m_Brush );
pDC->SelectObject( pOldBrush );
CEdit::OnNcPaint();
}
I think, this should fill a rectangle around the edit box.
Thanks again for your input.
Max.
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
Try using GetWindowDC() instead of GetDC(). also, do not call CEdit::OnNCPaint() because that will simply cause the OS to draw over any drawing you have just done. also, (part two) be sure to call ReleaseDC().
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|