|
Gotcha - thanks for the help.
Christian
#include "std_disclaimer.h"
The careful application of terror is also a form of communication.
Eagles may soar, but weasels don't get sucked into jet engines.
|
|
|
|
|
There's a main project which consists of many VC & VB components as sub projects . Now I need to build a package which gives me an option to install these components by selecting them from the various options of the components - the installation of one of the componenets need to be in the remote machine. How can i do this???
Pl. suggest me some topics to get an idea on this.
Thanx.
regards
Sankar
|
|
|
|
|
Can someone please point out to me what I am missing.
I have a number of classes (Stored Procedures) derived from a base class (CRecordset). The base class has functionality common to all the derived classes (Open, Execute, Close fuctions), so I am trying to create a function where I can pass the object to operate on as a pointer to the base class, find the derived class from the RTTI and call the appropriate functions.
However my problem is that the compiler sees the void * from the dynamic_cast and complains when I try and call members associated with a void *. I can see why this would be a problem, the compiler has no information on the object pointed to by the void *, after all this is only available at runtime, but is there anyway around this problem?
I wondered if I could use pointers to members to create offsets into the class, but again the compiler complains that the left side of the argument points to a void *.
I believe what I am trying to do can be done, I'm just not sure what I am missing.
Thanks,
Richard
|
|
|
|
|
Correct me if I'm wrong, but could you not use the base class instead of void to declare your pointers?
Ben Burnett
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
Here's how to use dynamic_cast. Supposing CMyRecordset is derived from CRecorset.
void somefunc()
{
CMyRecordset objMyRecordset;
CRecordset* pRecordset;
pRecordset = dynamic_cast<CRecordset*>(&objMyRecordset);
if (pRecordset)
{
pRecordset->Open(); //or whatever...
}
}
Good Luck,
Asif
|
|
|
|
|
It's not clear why you're using void * in this context, or, for that matter, why you can't do whatever it is you're trying to do with virtual methods.
dynamic_cast is generally used for up-casting, that is casting something stored in the routine as a pointer to a more generic class to a more specific class (which it must actually be). It should very rarely be needed. You could do something like:
<br />
GeneralClass *p = ......<br />
<br />
SpecificClass *sp = dynamic_class<SpecificClass *>p;<br />
<br />
if(sp) {
...<br />
}<br />
but it's almost always cleaner to do the same thing with virtual methods.
|
|
|
|
|
Hello,
I've created an MDI application based on a CCtrlView.
After that, I copied some code of msdn to create 2 header columns and some list data.
The problem is that I can see the header, but not the data. I know there is data in the grid because if I double click on the small | in the header, the header resizes as if there is data.
Is it due to the fact that the text is also drawn in a white color, or am I doing something wrong here (forgot to initialize something, call a procedure, ... ).
Some info;
In PreCreateWindow I set my style in detail view:
cs.style |= LVS_REPORT
In OnInitialUpdate, I try to create the 'grid':
CListView::OnInitialUpdate();
// this code only works for a report-mode list view
ASSERT(GetStyle() & LVS_REPORT);
CListCtrl& theCtrl = GetListCtrl();
// Insert a column. This override is the most convenient.
theCtrl.InsertColumn(0, _T("Player Name"), LVCFMT_LEFT);
LVCOLUMN col;
col.mask = LVCF_FMT | LVCF_TEXT;
col.pszText = _T("Jersey Number");
col.fmt = LVCFMT_LEFT;
theCtrl.InsertColumn(1, &col);
// Set reasonable widths for our columns
theCtrl.SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER);
theCtrl.SetColumnWidth(1, LVSCW_AUTOSIZE_USEHEADER);
for (int i=0;i < 10;i++)
{
strText.Format(TEXT("item %d"), i);
// Insert the item, select every other item.
theCtrl.InsertItem(
LVIF_TEXT|LVIF_STATE, i, strText,
(i%2)==0 ? LVIS_SELECTED : 0, LVIS_SELECTED,
0, 0);
// Initialize the text of the subitems.
for (int j=1;j < nColumnCount;j++)
{
strText.Format(TEXT("sub-item %d %d"), i, j);
theCtrl.SetItemText(i, j, strText);
}
}
Thanks a lot
Wim Jans
|
|
|
|
|
Works fine for me, exept I just had to add in two lines (in bold bellow)
<br />
ASSERT(GetStyle() & LVS_REPORT);<br />
<br />
CListCtrl& theCtrl = GetListCtrl();<br />
theCtrl.InsertColumn(0, _T("Player Name"), LVCFMT_LEFT);<br />
LVCOLUMN col;<br />
col.mask = LVCF_FMT | LVCF_TEXT;<br />
col.pszText = _T("Jersey Number");<br />
col.fmt = LVCFMT_LEFT;<br />
theCtrl.InsertColumn(1, &col);<br />
theCtrl.SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER);<br />
theCtrl.SetColumnWidth(1, LVSCW_AUTOSIZE_USEHEADER);<br />
<br />
for (int i=0;i < 10;i++)<br />
{<br />
strText.Format(TEXT("item %d"), i);<br />
<br />
theCtrl.InsertItem(<br />
LVIF_TEXT|LVIF_STATE, i, strText, <br />
(i%2)==0 ? LVIS_SELECTED : 0, LVIS_SELECTED,<br />
0, 0);<br />
<br />
CString strText;<br />
int nColumnCount = theCtrl.GetHeaderCtrl()->GetItemCount();<br />
<br />
for (int j=1;j < nColumnCount;j++)<br />
{<br />
strText.Format(TEXT("sub-item %d %d"), i, j);<br />
theCtrl.SetItemText(i, j, strText);<br />
}<br />
}
Ben Burnett
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
The code in Bold was actualy in my view, I only forgot to copy/paste it in
The form I was testing with uses the BCG library but I've just created an normal MDI mfc program based on CListView, copied the code and it worked fine indeed.
After that, I installed the new version of the BCG library and copied the code over to the view, and guess what: the list appeared.
So, I think I will upgrade my library at home too and I can continue to try to get a grip of Visual C++ - which is a lot easier thanks to CodeProject.
Thanks for your time!
Wim
|
|
|
|
|
Has anyone got experiance with extracting features from a bitmap image.
|
|
|
|
|
what do you mean by "features" ?
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
Yes I guess my question was rather broad.
What I have is two finger print bitmaps that I would like to compare the connection points to. This is not generalized graphics but rather a science of forensics.
There are books available on the subject, there seems to be no code guidelines available on who to do this in C++.
Can you help.
|
|
|
|
|
Sorry to ask again but how do I read INTEGER or LONG length values in from a binary file?
At the moment I can only get single bytes.
Do I use GET or READ?
How to I modify the following code to read an integer length value from address 4110 in the DAT file?
==============================================
ofstream path("c:\\windows\\desktop\\debug.dat");
........................
int pos = 4110;
path.seekg(pos);
int bytevalue = path.get();
================================================
Sorry to be dumb, tried to work it out myself but failed (& no online helpfile)
cheers
Richard Edwards
|
|
|
|
|
Hi,
I'm not sure, since I don't often use C++ streams to do I/O, but it seems you should use: path.read((char*)&myInt, 4); if you're using ifstream.
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
Hi all,
When I use the code below to enumerate the shell namespace, a second thread seems to get started by the IEnumIDList::Next(...) function. This function executes normally and gives me the desired results, but for some reason when my program exits, the second thread (not the application thread) always terminates with a return code of -1 and not 0 (like the main thread). This second thread delays the termination of my program quite considerably and is rather annoying. It would seem to suggest that I'm not using IEnumIDList properly, because if I take out the while(...) loop with the ::Next(...) call in it, the second thread never appears. So, my question is, what is wrong with the following call? What am I not doing to stop this second thread that appears out of nowhere??
------ CODE -------
void CFileTreeView::OnInitialUpdate()
{
HTREEITEM rNode;
ITEMIDLIST *pidl;
IShellFolder *pShellRoot;
DWORD iGot;
// Called inherited constructor.
CTreeView::OnInitialUpdate();
// Clear the view.
GetTreeCtrl().DeleteAllItems();
// Get a pointer to the IShellFolder namespace.
pShellRoot = GetDocument()->GetShellRoot();
// Iterate through the shell namespace for devices.
if(SHGetSpecialFolderLocation(m_hWnd, CSIDL_DESKTOP, &pidl) == NO_ERROR)
{
rNode = AddNode( pShellRoot, pidl, pidl );
IEnumIDList *pidlList;
if(pShellRoot->EnumObjects(m_hWnd, SHCONTF_FOLDERS |
SHCONTF_INCLUDEHIDDEN, &pidlList) == NO_ERROR)
{
while( pidlList->Next(1, &pidl, &iGot) == NO_ERROR )
AddNode( pShellRoot, pidl, pidl, rNode );
pidlList->Release();
}
GetTreeCtrl().Expand( rNode, TVE_EXPAND );
}
else AfxMessageBox("SHGetSpecialFolderLocation() failed! No namespace!");
GetDocument()->ReleaseShellRoot();
}
The AddNode(...) function simply fills out a TV_ITEM structure and creates a node, I am aware that the pidl's from the IEnumIDList(...) are not freed, they are dealt with in an OnDelete() handler for the individual tree nodes.
GetShellRoot() and ReleaseShellRoot() simply wrap the AddRef() and Release() functions for IShellFolder and display TRACE messages if I forget to release an instance.
Any help would be appreciated.
Jonathan Thorpe
|
|
|
|
|
Hello All!
I am perplexed and am hoping that someone out there could help me figure this out. I have an application that uses a CListCtrl. When the application window is resized, I would like to dynamically resize each of the columns to fit the view. I have had a little success, however, as the application is resizing, the horizontal scroll bar flickers on and off as the columns are being resized .
This happens only when I have "show window contents while dragging" enabled in Windows, when this is turned off you don't notice the problem. What I am trying to do is similar to Outlook where the columns are resized as the window is resized.
Please help, as I have exhausted all resources trying to find an answer to this, but have had no success.
Warm Regards,
Scott Evans
|
|
|
|
|
Need more detailed info - post your OnSize handler or routine you're using to change the widths.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi,
It could be that you're resizing when the scrollbar has already been shown.
Try to do it in OnSizing (WM_SIZING) or try to SetRedraw(FALSE) before, then SetRedraw(TRUE) after the resizing process.
Hope this helps,
Paolo.
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
I'm writing a DirectDraw program that has a menu at the start from a template. The author of the template uses
TextOut(hDC, MENU_XBEG, MENU_YBEG, szItem, lstrlen(szItem));
to print out a menu item.
I would like to change the size and typeface of the font. How would I accomplish this? SetFont()?
Thanks for the assistance,
Ryan
|
|
|
|
|
First you need to create font. Use CreateFont or CreateFontIndirect for that. Next, you need to make your font 'selected' with SelectObject. You should call DeleteObject when you no longer need the font. I think tyou should read "Font Creation and Selection" in "Platform SDK : Windows GDI" docs before coding. These docs should be installed with your VC++ help.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
does anybody knows how to display an amount with commas?
wibi
|
|
|
|
|
Check GetNumberFormat() or GetCurrencyFormat() in your doc's.
Ben Burnett
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
Also look at COleCurrency. Works like COleDateTime and has a format function that will return a currency in the locale form (such as commas for japan or . if in the US)
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
I have created a onctlcolor function to change to text color of my controls.
but i can not change the text color in the combo box. Is there another funtion to do this?
Thank you
|
|
|
|
|
I have (so far) a default MDI app with a CSizingControlBarG derived bar docked on the left side of my frame. Since it's the default MDI implementation (the one created by AppWizard), I have a menu, one toolbar, and a status bar. When I begin a resize operation on the control bar, the splitter shows up as it should, but is drawn on top of the toolbar, and doesn't go all the way to the status bar. So, the splitter is the correct length, but it's shifted up by the height of the toolbar (seemingly). How do I fix this, so it draws from the bottom of the toolbar (instead of over it) down to the status bar?
Thanks in advance.
Jamie Nordmeyer
Portland, Oregon, USA
Jamie Nordmeyer
Portland, Oregon, USA
|
|
|
|
|