|
instantiate? what do you mean with that?
would that work for all 3 file types : DLLs, EXEs, OCXs?
a couple of lines of codse would be great
Thanks
Fady Elias
|
|
|
|
|
The following declaration is from two header files for two classes.
Class Abstract
{
...
...
}
Class Specific : public Abstract
{
private
static const int m_nNumberOfColumns;
static const char* m_pszColumnsTitles[];
}
In the implementation file of each 'specific' class, the variables are initialised as
const int Specific::m_nNumberOfColumns = 2;
const char* Specific::m_pszColumnsTitles[Specific::m_nNumberOfColumns] = {"Account Number", "Account Name"};
As I have started to develop several 'specific' classes, I have come across a couple of
methods that should be implemented in the Abstract class like the following
for ( int i = 0; i < m_nNumberOfColumns; i++ )
{
InsertColumn(i, m_pszColumnsTitles[i]);
}
What protected data types should I declare in the Abstract class and how should I initialise them in the
specific class ctor, so that the above for loop could be put into a method of the Abstract class.
Suggestions gratefully appreciated. Thanks.
Chris
|
|
|
|
|
I'd add the following abstract members to Abstract class:
virtual int GetColumnCount() const = 0
virtual const char* GetColumnName(int columnIndex) const = 0;
The code in the 'Abstract' class would look like this:
for (int i = 0; i < GetColumnCount(); i++ )
{
InsertColumn(i, GetColumnName(i));
}
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Tomasz, thanks a lot. That's exactly what I was searching for, but the fog is clearing a little slower today than normal.
Chris
|
|
|
|
|
I am trying to create a multi column list box, using a list control with a report view. The problem is i can't seem to add text to the second and third columns. The code fragment i perform on init of my dialog is show below.
m_list.InsertColumn(1,"DISEASE",LVCFMT_LEFT,350,0);
m_list.InsertColumn(2,"CODE",LVCFMT_LEFT,80,1);
m_list.InsertColumn(3,"DESCRIPTION",LVCFMT_LEFT,350,2);
LV_ITEM lvitem;
lvitem.mask = LVIF_TEXT;
lvitem.iItem = 0;
lvitem.iSubItem = 0;
lvitem.pszText = "tester";
m_list.InsertItem(&lvitem);
LV_ITEM lvitem2;
lvitem2.mask = LVIF_TEXT;
lvitem2.iItem = 0;
lvitem2.iSubItem = 1;
lvitem2.pszText = "tester2";
m_list.InsertItem(&lvitem2);
Anyone Any Clues?
Cheers
Rich
|
|
|
|
|
The function CListCtrl::InsertItem() is used to insert new items. You need to use thr function CListCtrl::SetItem().
|
|
|
|
|
You only call InsertItem() once per row, to create the row. Use SetItemText() to put text in all the columns after the first.
--Mike--
http://home.inreach.com/mdunn/
Sometimes, arming yourself with a big pointy stake just won't do you any good.
|
|
|
|
|
Hi all,
Sorry to keep asking stupid questions, but I am very new to MFC and don't have any good reference books yet. I want to attach to the system image list in 9x / NT to display OS icons in a CListView. I've got the system imagelist handle from a call to SHGetFileInfo(...), the only way I know how, and now I want to attach it to a CImageList, but the HIMAGELIST parameter appears to be a structure of some type and I can't find any useful declarations of it in the header files.
So, the question simply is; How to I attach to the system image list??
Thanks.
Jonathan Thorpe.
|
|
|
|
|
|
That's the problem, SHGetFileInfo(...) doesn't return a HIMAGELIST, it returns a DWORD that is the handle of the system imagelist. The only way to make Attach(...) accept it is to cast it to HIMAGELIST, which works fine, but the imagelist contains 0 images (so I don't reckon it worked), although I now have no icons on the start menu anymore!! Anymore ideas? Is there a way to get a handle to the system imagelist via MFC that will return the necessary HIMAGELIST or a pointer to a CImageList object?
Jon.
|
|
|
|
|
Just cast the value returned by SHGetFileInfo:
HIMAGELIST hImgList = (HIMAGELIST)SHGetFileInfo(...);
HIMAGELIST hImgList = reinterpret_cast<HIMAGELIST>(SHGetFileInfo(...));
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
although I now have no icons on the start menu anymore!!
That's because you didn't detach your CImageList from the image list, so the CImageList destructor destroyed the underlying image list. Or you were using a list control and it didn't have the LVS_SHAREIMAGELISTS style, so when the control was destroyed, it destroyed the image list. Oops! Bye-bye icons. You'll need to reboot to fix that.
--Mike--
http://home.inreach.com/mdunn/
Sometimes, arming yourself with a big pointy stake just won't do you any good.
|
|
|
|
|
Send a message to the ListView control (for example):
TreeView_SetImageList(*this, hSysImageList, TVSIL_NORMAL);
Paolo.
|
|
|
|
|
Hi
I will want to know: is latest version of VC correspond ISO C++ Standard?
Ernst
|
|
|
|
|
No, VC 6.0 is not ISO compliant.
Nor will the new version be when Visual Studio NET is released, although it should be alot better than the current version.
Bear in mind that there aren't many ISO C++ compilers available -
In fact I don't believe that there are ANY ISO C++ compilers, but I'm sure someone will correct me if I'm wrong.
James
|
|
|
|
|
The "latest" version of VC++ is 3 years old, and was never intended to be ISO compliant (since the standard wasn't finished when it was written). VC7 will be much closer, but will still lack a few important features like Partial Template Specialization. They claim that VC8 will have a heavy standards focus, and that it won't take 3 years for it to reach the light of day
|
|
|
|
|
We have an app which is associated with graphic files (jpg, bmp, etc). When we drag files of these types over the app and drop them on the mainframe, the app opens an appropriate view.
We also have a document template that allows us to view/edit simple ascii text files. When I drag a .TXT file over the app and drop it, it tries to open a view of the wrong type (a graphics view).
I've tried handling the WM_DROPFILES message in CMainFrame, but the code is never executed.
Does a file extension *HAVE TO BE* associated with the app before I can successfuylly drag a file into the app?
|
|
|
|
|
Make sure the window has the extended style WS_EX_ACCEPTFILES set.
Alternatively you can use DragAcceptFiles.
|
|
|
|
|
Does a file extension *HAVE TO BE* associated with the app before I can successfuylly drag a file into the app?
I don't think so. I've just successfully dropped .txt file into my MFC app that doesn't even have a template for such files (of course, I've got parsing error, because program doesn't read plain text).
Can you post relevant parts of CYourApp::InitInstance (especially, the AddDocTemplate calls) ?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
In InitInstance(), I have this:
DragAcceptFiles(TRUE);
EnableShellOpen();
RegisterShellFileTypes(TRUE);
I added a handler for the WM_DROPFILES message, but it never gets into that message handler function.
I think it might be Stingray's code that's interfering.
|
|
|
|
|
In InitInstance(), I have this:
In fact, I was expecting AddDocTemplate calls Anyway, if the doc is opening but the type is wrong, put the breakpoint in CDocTemplate::MatchDocType (mfc\src\doctempl.cpp, line 186 on VC6 SP5) - this method is called by MFC when file is dropped onto mainframe. Matching is done by comparing file extensions - you'll be able to see exactly what's going on.
Have no idea on Stingray's impact. Hate the toolkit, have to live with grid
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
i have a program that connect to odbc((user DSN))
and i want to install it with installshield
i don't know that set odbc connection in install shield.
thanks .
|
|
|
|
|
What I am trying to do is do is to add a new entry to a database table with an
SQL insert-statement, and then find the, by the DBMS, auto-assigned id for the new entry.
So far I've managed to accomplish this by first using the SQLExecute command,
followed by a select-statement to identify the id of the new entry.
Unfortunately I've stumbled across a table containing lots of dublicates,
where I've found no way to uniquely identify the new entry using a select-
statement.
Is there any other way than using a select-statement to find the id for my new
entry? The only one I can think of is looking for the highest id in the table,
and assume that this is the id I'm looking for. This, I feel, is kind of risky
though, since I'm not sure about how id's are assigned in the DBMS (Microsoft
SQL Server). If the DBMS decides to start reusing lower order id's my program
would stop functioning correctly.
Any advice would be much appreciated.
Thanks,
Jimmy Ehrnström
|
|
|
|
|
SQLServer has system variable @@IDENTITY that returns the last-inserted identity value.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Thanks, but I still can't get it to work. @@IDENTITY returns NULL and not an id. I've read all information about this I could find but found no explanation of what's wrong.
Here's a sample of my code:
pDB->ExecuteSQL(sql);
CRecordset rs(pDB);
if (rs.Open(CRecordset::snapshot, _T("SELECT @@IDENTITY"), CRecordset::readOnly)) {
if (!rs.IsBOF()) {
rs.MoveFirst();
CDBVariant dbId;
rs.GetFieldValue((short)0, dbId);
rs.Close();
if (databasId.m_dwType == DBVT_LONG)
int entryId = databasId.m_lVal;
}
}
Thanks,
Jimmy Ehrnström
|
|
|
|