|
http://www.codeproject.com/soap/#XML
I vote pro drink
|
|
|
|
|
I have a function which takes the IShellFolder object for a folder as a parameter, and loops through all the items in the folder. If it is a file, it adds it to a ListView control, and if it is a folder it calls itself. But the first time the function encounters a folder and calls itself, the pIShell->EnumObjects returns the error code -2147023673 which, according to the Error Lookup, is "The operation was canceled by the user.".
Can anyone figure out what's wrong? Here's the code:
void AddFilesFromFolder(IShellFolder *pIShell)
{
if (pIShell)
{
IShellFolder *pBrowse = NULL;
LPENUMIDLIST pFolder = NULL;
LPMALLOC pMalloc = NULL;
ITEMIDLIST *pNewId = NULL;
STRRET strDispName;
LVITEM lvItem;
DWORD pActual = 0;
DWORD dwAttrib;
IShellFolder *CurrentFolder;
HRESULT err;
err = SHGetDesktopFolder (&CurrentFolder);
if (err == NOERROR)
{
SHGetMalloc(&pMalloc);
err = pIShell->EnumObjects(NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN, &pFolder);
if (err == NOERROR)
{
lvItem.mask = LVIF_IMAGE | LVIF_TEXT;
while (pFolder->Next(1, &pNewId, &pActual) != S_FALSE)
{
dwAttrib = SFGAO_FOLDER;
pIShell->GetAttributesOf(1, (LPCITEMIDLIST*)&pNewId, &dwAttrib);
if (!(dwAttrib & SFGAO_FOLDER))
{
pIShell->GetDisplayNameOf(pNewId, SHGDN_INFOLDER, &strDispName);
GetID3();
FillInfo();
ListAddItem();
}
if (dwAttrib & SFGAO_FOLDER)
{
CurrentFolder->BindToObject(pNewId, NULL, IID_IShellFolder, (LPVOID*)&pBrowse);
Add2(pBrowse);
}
}
pMalloc->Free(pNewId);
pMalloc->Release();
gbFileOpen = true;
pFolder->Release();
}
CurrentFolder->Release();
}
}
}
Thankyou.
-Rune Svendsen
|
|
|
|
|
Try setting hwndOwner and maybe it will show you a message.
MSDN says "If hwndOwner is set to NULL, the enumerator should not post any messages, and if user input is required, it should silently fail."
Cathy
Life's uncertain, have dessert first!
|
|
|
|
|
Hi I've read the article in Code project about the mschart and how to set data. Now I would like to know how to set the labels.
Can anyone help?
Thanks
|
|
|
|
|
G'Day Anon
I may have the answer for you though I'm not 100% sure because I'm yet to get it working myself - but I have run out of time for the moment.
using the example on code project I have added the following code when the GO button is pressed. I have placed it just before the chart is refreshed.
The first bit sets the legend (only did 1 to see if it worked)
CVcPlot Plot = m_Chart.GetPlot();
CVcSeriesCollection SeriesCollection = Plot.GetSeriesCollection();
CVcSeries Series = SeriesCollection.GetItem(1);
Series.SetLegendText(_T("New Text"));
The next bit was to do the labels for each point on the axis. It is incomplete and not quite working but hopefully it will give you an idea and you can let me know how to fix it I am getting a bad function argument error when calling SetColumnLabel or SetRowLabel - something to do with my indexes I think.
CVcDataGrid DataGrid = m_Chart.GetDataGrid();
short i;
CString strLabel;
short nRows = DataGrid.GetRowLabelCount();
short nColumns = DataGrid.GetColumnLabelCount();
/* for (i=0; i
|
|
|
|
|
Hi Richard,
Sorry that I'm only answering now, it's just that I've been busy and only had the time to do this now.
I tried what you suggested and also get the same "bad function argument" error.
So I tried the following:
short index;
for ( i = 1; i < 11; i++ )
{
//strLabel.Format("row %d", i);
// strLabel = "Row Text";
index = i * 2;
// DataGrid.SetColumnLabel(index, 1, "");
strLabel = DataGrid.GetColumnLabel(index, 1);
}
And I get all the correct column names, i.e. R1, R2, R3, ... R10.
It almost seems to be the actual string variable that seems to give the problem???
Still trying. Have you had any success?
Rui
Rui
|
|
|
|
|
Hi Richard,
I tried the following:
DataGrid.SetColumnLabel(1, 1, "Column 1");
strLabel = DataGrid.GetColumnLabel(1, 1);
AfxMessageBox(strLabel);
This enables the C1 text in the datagrid to be changed. This seems to be the name of the first set of data.
But I'm still not able to change the Column labels.
Does anyone have a clue how to do it?
Regards
Rui
|
|
|
|
|
hi Richard,
The following works:
COleSafeArray saRet;
CString strLabel = "";
DWORD numElements[] = {10, 1}; // 10x10
//DWORD numElements[] = {10};
// Create the safe-array...
saRet.Create(VT_R8, 2, numElements);
// Initialize it with values...
long index[2];
for(index[0] = 0; index[0] < 10; index[0]++)
{
for(index[1] = 0; index[1] < 1; index[1]++)
{
double val = index[0]*10;
saRet.PutElement(index, &val);
}
}
// Return the safe-array encapsulated in a VARIANT...
m_Chart.SetChartData(saRet.Detach());
m_Chart.SetChartType(3);
CVcPlot Plot = m_Chart.GetPlot();
CVcSeriesCollection SeriesCollection = Plot.GetSeriesCollection();
CVcSeries Series = SeriesCollection.GetItem(1);
Series.SetLegendText(_T("New Text"));
CVcDataGrid DataGrid = m_Chart.GetDataGrid();
short i;
short nRows = DataGrid.GetRowLabelCount();
short nColumns = DataGrid.GetColumnLabelCount();
/* for (i=0; i {
strLabel.Format("col %d", i);
DataGrid.SetColumnLabel(i, 1, strLabel);
}
*/
short j;
// DataGrid.SetColumnLabelCount(10);
// count = DataGrid.GetColumnLabelCount();
for ( i = 1; i < 6; i++ )
{
//strLabel.Format("row %d", i);
strLabel = "Row Text";
j = i * 2;
// DataGrid.SetColumnLabel(j, 1, strLabel);
strLabel = DataGrid.GetColumnLabel(j, 1);
//AfxMessageBox(strLabel);
DataGrid.SetRowLabel(i, 1, "Row");
strLabel = DataGrid.GetRowLabel(i, 1);
}
m_Chart.SetShowLegend(TRUE);
m_Chart.Refresh();
Try it.
Thanks for your help
Rui
|
|
|
|
|
G'Day Rui,
I'd forgotten all about this! I'll dig out the code I was playing with at the time and try it out.
Thanks for your help!
Richard.
|
|
|
|
|
In Internet Explorer, when you choose "Organize Favorites" from the Favorites menu, you get a pop-up window with a list of the top level favorites items. You can click-and-drag items up and down in that list and double click on items to edit them. I need to do something similar in a dialog of my application. Is there some kind of scrollable, item-draggable ActiveX list control?
|
|
|
|
|
Plain CListCtrl isn't good? You absolutely need an ActiveX?
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
If CListCtrl will do it, I don't need ActiveX. Does it support the click-and-drag functionality for changing the order of items in the list?
|
|
|
|
|
It notifies you when dragging is about to begin with LVN_BEGINDRAG. From this point you need to process WM_MOUSEMOVE and WM_LBUTTONUP to provide feedback and reordering. There's KB article Q214814 which describes similar steps for CTreeCtrl.
Probably CDragListBox would be easier to use, but it doesn't provide in-place renaming.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
CDragListBox was exactly what I was looking for! My list will be items which should only be editable from a modal child dialog so I won't want in-place renaming since each item in the list is really just a textual representation of more complex data.
Thank you for the help!
|
|
|
|
|
Could somebody tell me where can find the "wmstub.lib"??
|
|
|
|
|
|
Thank you very much!!
But my poor english make that i can't find it to download.
Could you give me the RUL of it?
|
|
|
|
|
|
I could be doing this completely wrong. I am trying to put a web browser inside an already created window. The m_htmlview member is actually a c++ wrapper for the IWebBrowser2 interface.
m_htmlview.Create( NULL,
dwStyle,
CRect( 0, 0, theRect.Width(), theRect.Height() ),
&theBrowser,
KnListID );
m_htmlview.Navigate("http://localhost:10000",NULL,NULL,NULL,NULL);
Problem is that when the Create method is called, it causes a memory exception. Is there anything I need to call before Create to properly initialize it? Or is it just not possible to use the IWebBrowser on anything but a dialog or SDI/MDI.
|
|
|
|
|
CoInitialize has been called?
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
Its an ATL project, so yes. And just in case it wasn't, I put a call to CoInitialize right before Create and it did nothing.
It dies in this code
BOOL CWnd::InitControlContainer()
{
TRY
{
if (m_pCtrlCont == NULL)
here --> m_pCtrlCont = afxOccManager->CreateContainer(this);
}
END_TRY
It would seem that afxOccManager would be NULL, but it is a macro for AfxGetModuleState()->m_pOccManager
hope that helps.
|
|
|
|
|
So you're mixing ATL with MFC... maybe calling AfxEnableControlContainer in InitInstance will help?
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
That worked. Thanks a ton!
|
|
|
|
|
I just recently noticed this remark in the MSDN Library:
[For] Windows 2000/XP: If CREATE_ALWAYS is specified as the value of the dwCreationDisposition parameter and FILE_ATTRIBUTE_NORMAL is specified as the value of the dwFlagsAndAttributes parameter, CreateFile will fail and set the error GetLastError reports to ACCESS_DENIED . In this case, set the value of the dwFlagsAndAttributes parameter to the ORed value of the FILE_ATTRIBUTE_HIDDEN and FILE_ATTRIBUTE_NORMAL attributes to avoid this error.
Now, IIUC, code that once used CREATE_ALWAYS with FLAG_ATTRIBUTE_NORMAL and worked correctly on Win9x and WinNT will now start to FAIL when run on Win2K/XP? That makes no sense to me, because it could break existing applications and code. This also means that I can only create new files if they are initially hidden from now on?
Also, that remark also conflicts with what is mentioned earlier in the page for CreateFile , because it says for FLAG_ATTRIBUTE_NORMAL : "The file has no other attributes set. This attribute is valid only if used alone."
Thoughts? (Note that I am not having any problems relating to this so far, nor have heard any reports.)
Peace!
-=- James.
"Some People Know How To Drive, Others Just Know How To Operate A Car."
(Try Check Favorites Sometime!)
|
|
|
|
|
Tested this on XP, and file is always created - even if file with identical name already exists. Seems like problem with documentation.
HANDLE h = ::CreateFile("c:\\x.txt", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
DWORD dummy;
CString strx;
strx.Format("%d", GetTickCount());
::WriteFile(h, strx, strx.GetLength(), &dummy, NULL);
::CloseHandle(h);
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|