|
I'd like to make an ActiveX control, but deriving it from MFC's CListCtrl class. Is this possible? I try the regular MFC ActiveX control wizard and choose 'none' for which class to subclass, but when I try to replace all instances of the COleControl, I get a bunch of errors. Can anyone help? I want to do a little extending to the MFC control and allow VB users to use it. Thanks in advance!!!;);)
If it's broken, I probably did it
bdiamond
|
|
|
|
|
It might be that your terminology is a bit wrong, but let's see now...
An ActiveX control is a control of it's very own type. Just like a CListCtrl represents a list control, an ActiveX control represents an ActiveX control
Normally, the ActiveX control contains a normal window. This window can then contain other controls, like the list control you specified.
The most effective way here would be to use the wizards to create a standard, windowed ActiveX control. Then, in the construction routine of the window, initialize a member variable of type CListCtrl. On the creation routine (of the window), create a standard Windows child list control, for which the ActiveX control's window works as a parent.
This way, the actual control class will expose the interfaces that are required to make it an ActiveX control. The window and the child list control can be used just like a normal CWnd-class window that has a list control.
Just remember to add properties and necessary methods to the ActiveX controls for VB users to control all the necessary features of the control. And of course remember to implement all these properties so that they'll also do something
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
thank you!!! that was just what I needed;P;P
If it's broken, I probably did it
bdiamond
|
|
|
|
|
|
excerpted from MSN" The user scrolls the content of a window by clicking one of the arrow buttons, by clicking the area in the shaded shaft, or by dragging the scroll box. When the user clicks an arrow button, the application scrolls the content by one unit (typically a single line or column). "
Question: how to retrieve the size (by pixel) of a unit?
|
|
|
|
|
Do GetScrollRange() , GetScrollPos() , or GetScrollInfo() help?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Is that your Scroll Bar? How did you set its sizes?
Get trial copy of comment generating tool CommentMakerPro, std::string and std::string containers viewer FeinEvaluatorPro and windows manager for Microsoft Visual Studio .NET FeinWindows at www.FeinSoftware.com
|
|
|
|
|
Hi all this may be a simple question but how can I put a delete character (Hex vale 0x7F) at the end of a CString tried every thing I can think.
The code is
chBcc = GetBcc(strPack);<br />
strPack.Insert(32, chBcc);
chBcc can be the delete character.
thank you
Ketil b
|
|
|
|
|
Anonymous wrote:
strPack.Insert(32, chBcc);
Does strPack.Insert(32, chBcc) not work? If not, have you stepped into the code to find out why?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
|
I've a tree with many items and subitems; any item has an unique itemdata value.
Sometimes I need to find the item that has a certain itemdata value.
Actually I start by the ROOT item and I check every item and subitem looking for their itemdata values.
The items I look for are usually few and I look for them very often, so I thought to use a CMAp for caching the last searches I did.
The only problem is to know if the HTREEITEM I found in the map is still valid.
Any idea?
|
|
|
|
|
You could call GetItem() with your HTREEITEM value in the TVITEM structure.
If it returns TRUE - your item is valid.
Get trial copy of comment generating tool CommentMakerPro, std::string and std::string containers viewer FeinEvaluatorPro and windows manager for Microsoft Visual Studio .NET FeinWindows at www.FeinSoftware.com
|
|
|
|
|
Does the tree change frequently? The HTREEITEM is valid until the item is deleted or the tree destroyed.
if the tree changes ferquently, you might be better off with separating the data (in some STL-built container maybe) from a "tree renderer".
we are here to help each other get through this thing, whatever it is Vonnegut jr.
sighist || Agile Programming | doxygen
|
|
|
|
|
It represents some data stored in a DB; there are folders and subfolders.
When the DB changes I need to update the corresponding tree item, so I must find it
The three change frequently, also because the item may be deleted and cretated in another folder, so the cached data maybe obsolete.
I think that GetItem is OK, thanks vladfein.
Paolo
|
|
|
|
|
Is there any easy way to connect mysql database with mfc? I don't know how to use odbc The mysql++ api i downloaded could not run under microsoft visual c++.net ....
|
|
|
|
|
|
how is it if the other user uses my program to remotely connect to the mysql database in my computer?Do they need to install the mysql odbc too?
|
|
|
|
|
ODBC is a database connectivity interface on the Win32 platform that can connect to various DBMSs including MySQL.
Kuphryn
|
|
|
|
|
I made a dll to connect to a mysql database, run a query and insert the results into a .dbf file or .xls. I think the only thing you have to do is include the MySQL.h file in your project and link to the library. From there just use the functions declared in the MySQL header file. If this sounds like a reasonable solution and you need a sample, just let me know and I'll dig up the code and paste a snippet here.
If it's broken, I probably did it
bdiamond
|
|
|
|
|
Ofcourse i need a sample since i can't find out the functions' name inside the dll;P
|
|
|
|
|
The functions are declared in the "Mysql.h" header file, and the definitions are in the mysql.cpp file
wherever your mysql folder is there's a folder in there called 'Include'. all the files in there
should be included in your project.
#include the mysql.h file in your [yourapp.cpp] file. then here's a snippet: well a whole function
Sorry it's a little sloppy; It's time to leave work now, and I'm doing this at the last minute
int Export(BSTR szServer, BSTR szDB, BSTR szUser, BSTR szPassword, BSTR szSQL, int nExportType)
{
SQLRETURN sr;
int numOfRows=0;
int numOfFields=0;
int connected=0;
MYSQL *dbHandle;
MYSQL_RES *res;
MYSQL_FIELD *field;
MYSQL_ROW row;
char errmsg[512];
hDbConn =0;
hOdbcEnv = 0;
dbHandle=mysql_init((MYSQL*)0);
CString szDBFName;
CString strPath,strTblName;
try
{
CString sFileFilter;
if(nExportType)
sFileFilter = "Excel Spreadsheet (*.xls)|*.xls||";
else
sFileFilter = ".dbf files (*.dbf)|*.dbf||";
CFileDialog dlg(FALSE,".DBF",NULL,OFN_ENABLESIZING | OFN_HIDEREADONLY,sFileFilter);
if(dlg.DoModal() == IDOK)
{
szDBFName = dlg.GetPathName();
strTblName = dlg.GetFileName();
if((szDBFName.GetLength() || strTblName.GetLength() ) == 0)
{
AfxMessageBox("Export Canceled",MB_OK | MB_ICONINFORMATION);
return 0;
}
}
else
{
AfxMessageBox("Export Canceled",MB_OK | MB_ICONINFORMATION);
return 0;
}
int nPos = szDBFName.Find(strTblName,0);
strPath = szDBFName.Left(nPos);
if(mysql_real_connect(dbHandle,
(char*)szServer,
(char*)szUser,
(char*)szPassword,
(char*)szDB,
MYSQL_PORT,
NULL,
0))
{
connected=1;
}
else
{
sprintf(errmsg, "\nConnection Error: %s\n", mysql_error(dbHandle));
AfxMessageBox(errmsg);
connected = 0;
}
if(mysql_select_db(dbHandle,(char*)szDB))
{
sprintf(errmsg, "\nSelect DB Error: %s\n", mysql_error(dbHandle));
AfxMessageBox(errmsg);
return 0;
}
if(mysql_query(dbHandle,(char*)szSQL))
{
sprintf(errmsg, "\nError: %s\n", mysql_error(dbHandle));
AfxMessageBox(errmsg);
return 0;
}
res=mysql_store_result(dbHandle);
CString strConnect;
if(nExportType)
strConnect.Format("Driver={Microsoft Excel Driver (*.xls)};DriverId=790;DefaultDir=%s;",strPath);
else
strConnect.Format("Driver={Microsoft dBase Driver (*.dbf)};DriverID=533;Dbq=%s;",strPath);
if(hDbConn != SQL_NULL_HANDLE)
SQLFreeHandle(SQL_HANDLE_DBC, hDbConn);
if(hOdbcEnv != SQL_NULL_HANDLE)
SQLFreeHandle(SQL_HANDLE_ENV,hOdbcEnv);
sr = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &hOdbcEnv);
SR_CHECK
sr = SQLSetEnvAttr(hOdbcEnv, SQL_ATTR_ODBC_VERSION ,(SQLPOINTER)SQL_OV_ODBC3, SQL_IS_INTEGER);
SR_CHECK
sr = SQLAllocHandle(SQL_HANDLE_DBC, hOdbcEnv, & hDbConn);
SR_CHECK
sr = SQLSetConnectAttr(hDbConn,SQL_ATTR_LOGIN_TIMEOUT,(void*)5,0);
SR_CHECK
char szConnectString[512];
sprintf(szConnectString,"%s",strConnect);
char szDescription[1024];
SQLSMALLINT length;
sr = SQLDriverConnect(hDbConn,NULL , (UCHAR*)szConnectString, 512,
(UCHAR*)szDescription,1023,&length,SQL_DRIVER_COMPLETE_REQUIRED);
SR_CHECK
CString sColumns;
numOfRows = (int) mysql_num_rows(res);
numOfFields= (int) mysql_num_fields(res);
if(numOfRows > 255)
{
AfxMessageBox("Too many fields for export.");
return 0;
}
char * bNeedTics = new char[numOfFields] ;
int * nFieldLen = new int[numOfFields];
CString sColumnsToInsert;
sColumnNames = new CString[numOfFields];
for(int i = 0; i < numOfFields; i++)
{
bNeedTics[i] = 'N';
}
CString* sStatements = new CString[numOfRows];
for (i =0;i < numOfFields;i++)
{
field=mysql_fetch_field(res);
CString sTemp = field->name;
sColumnsToInsert += sTemp + ",";
int nType = field->type;
int nLen = (int)field->length;
CString sCol;
nFieldLen[i] = nLen;
sTemp = CheckFieldname(sTemp,i);
sColumnNames[i] = sTemp;
switch(nType)
{
case FIELD_TYPE_ENUM:
case FIELD_TYPE_TINY:
case FIELD_TYPE_SHORT:
sCol.Format("%s %s,",sTemp,"INTEGER ");
break;
case FIELD_TYPE_LONG:
sCol.Format("%s %s,",sTemp,"LONG ");
break;
case FIELD_TYPE_FLOAT:
case FIELD_TYPE_DECIMAL:
sCol.Format("%s %s,",sTemp,"FLOAT ");
break;
case FIELD_TYPE_DOUBLE:
sCol.Format("%s %s,",sTemp,"DOUBLE ");
break;
case FIELD_TYPE_NULL:
break;
case FIELD_TYPE_LONGLONG:
case FIELD_TYPE_INT24:
sCol.Format("%s %s,",sTemp,"LONG ");
break;
case FIELD_TYPE_YEAR:
case FIELD_TYPE_DATE:
case FIELD_TYPE_NEWDATE:
bNeedTics[i] = 'D';
sCol.Format("%s %s,",sTemp,"DATE ");
break;
case FIELD_TYPE_TIME:
case FIELD_TYPE_DATETIME:
case FIELD_TYPE_TIMESTAMP:
bNeedTics[i] = 'D';
sCol.Format("%s %s,",sTemp,"DATETIME ");
break;
case FIELD_TYPE_SET:
sCol.Format("%s %s,",sTemp,"int ");
break;
case FIELD_TYPE_TINY_BLOB:
case FIELD_TYPE_MEDIUM_BLOB:
case FIELD_TYPE_LONG_BLOB:
case FIELD_TYPE_BLOB:
bNeedTics[i] = 'T';
sCol.Format("%s %s,",sTemp,"MEMO ");
break;
case FIELD_TYPE_VAR_STRING:
case FIELD_TYPE_STRING:
bNeedTics[i] = 'T';
sCol.Format("%s TEXT(%d),",sTemp,nLen);
break;
}
sColumns += sCol;
}
sColumnsToInsert = sColumnsToInsert.Left(sColumnsToInsert.GetLength() - 1);
sColumns = sColumns.Left(sColumns.GetLength() - 1);
sColumns = "CREATE TABLE " + strTblName + " (" + sColumns + ")";
char tmp1[10000];
sprintf(tmp1,"%s",sColumns);
SQLCHAR* SQL1 = (SQLCHAR*)tmp1;
if(!nExportType)
executeSQL(SQL1);
SQLSMALLINT cols = 0;
CString sTic;
CString sTemp;
CString sValues,sInsertString;
SQLDisconnect(hDbConn);
CDBFRecordset* m_Set = 0;
CString str;
if(!nExportType)
{
m_Set = new CDBFRecordset;
m_Set->Open(szDBFName);
for(i=0;i<numOfRows;i++)
{
row=mysql_fetch_row( res );
m_Set->AddNew();
sValues = "";
for (int col=0;col<numOfFields;col++)
{
field=mysql_fetch_field(res);
str = row[col];
CString sYear,sMonth,sDay,sHour,sMinute,sSecond;
COleDateTime * t;
BOOL bDate = FALSE;
if(bNeedTics[col] == 'D')
{
str.Remove('-');
int len = str.GetLength();
sYear = str.Mid(0,4);
sMonth = str.Mid(4,2);
sDay = str.Mid(6,2);
if(len > 8)
{
sHour = str.Mid(8,2);
sMinute = str.Mid(10,2);
sSecond = str.Mid(12,2);
}
else
{
sHour = sMinute = sSecond = "0";
}
bDate = TRUE;
t = new COleDateTime(atoi(sYear),
atoi(sMonth),atoi(sDay),atoi(sHour),atoi(sMinute),atoi(sSecond));
}
COleVariant fVar;
if(bDate)
fVar = *t;
else
fVar = str;
m_Set->SetFieldValue(col,fVar);
}
m_Set->Update();
}
m_Set->Close();
delete m_Set;
}
mysql_free_result( res ) ;
dbHandle->free_me;
If it's broken, I probably did it
bdiamond
|
|
|
|
|
Thx for your helpful reply and i'm able to connect to my mysql database now!
|
|
|
|
|
Hello gurus
I need to serialize an STL type called valarray but the the Serialize function is giving me errors regarding the << and the >> operator is there anyway or alternative to get over this thing please help
Regards
Ahmed
|
|
|
|
|
Anybody use frames in dhtml ed control. Plz give suggestion.
lokesh
|
|
|
|
|
"Hi I'm developing dll which will do some changing stuff with ListView. I have a funny problem I want to change value of iImage in a LV_ITEM according to pszText value. Problem occurs when I want to test value of pszText, exception ouccrs Access Violation 0xC0000005 But I'm testing if pitem and pitem->pszText are not null even if I tryed to use strdup(pitem->pszText) the same exception occurs. There is no problem when I tryed to change value of iItem. Is is somehow connected witch injection dll into some application ?? and its address space ??
"
<br />
(WNDPROC) gfnListProc;<br />
gfnListProc = (WNDPROC)SetWindowLong(listview, GWL_WNDPROC,(LONG)ListProc);<br />
<br />
__declspec(dllexport) LRESULT CALLBACK ListProc(HWND hwnd, UINT uiMsg,WPARAM wParam, LPARAM lParam)<br />
{<br />
<br />
switch (uiMsg)<br />
{<br />
case LVM_INSERTITEM:<br />
{<br />
LV_ITEM FAR* pitem = (LV_ITEM FAR*) lParam;<br />
if(pitem && pitem->pszText)<br />
MessageBox(0, pitem->pszText,":-)",MB_OK); <br />
<br />
break;<br />
}<br />
}<br />
return CallWindowProc(gfnListProc, hwnd, uiMsg, wParam, lParam);<br />
}<br />
<br />
<br />
typedef struct tagLVITEMW<br />
{<br />
UINT mask;<br />
int iItem;<br />
int iSubItem;<br />
UINT state;<br />
UINT stateMask;<br />
LPWSTR pszText;<br />
int cchTextMax;<br />
int iImage;<br />
LPARAM lParam;<br />
#if (_WIN32_IE >= 0x0300)<br />
int iIndent;<br />
#endif<br />
} LVITEMW, FAR* LPLVITEMW;<br />
<br />
<br />
#define ListView_InsertItem(hwnd, pitem) \<br />
(int)SNDMSG((hwnd), LVM_INSERTITEM, 0, (LPARAM)(const LV_ITEM FAR*)(pitem))<br />
<br />
Thaks for reading that stuff
Pain is a weakness living the body
|
|
|
|
|