|
Just some pointers (ooh I made a C++ joke... :rolleyes) or a tip or two would be helpful. I can figure it out once I get shown the start of the path
I am trying to return more than one result at a time from the CP Webservice and storing them into what I would call an array. Not sure what you call it in C++. Calling the webservice is fine, I have managed to pass it the input parameteres it needs. It is getting out all the results in one go that is troubling me. Right now my code returns it variable by variable, with a call to the webservice for each result and variable! Not very good at all.
I managed to do this:
__gc struct ArticleBriefs
{
public:
String* URL;
String* Title;
String* Author;
String* Posted;
String* Updated;
String* Status;
String* Description;
};
And I managed to load it one at a time like so:
LatestBrief* proxy = new LatestBrief();
ArticleBriefs* cArticles = new ArticleBriefs();
cArticles->Author = proxy->GetLatestArticleBrief(iNumArticles)[0]->Author;
...
However that is not an array (though obviously the right hand bit is an array, but I cannot transfer it over to the left hand, ya see?)
So my simple question is how do I turn that struct into an array and then how do I return the multiple values from the GetLatestArticleBrief web service method into the array?
*grumble* this is so easy in C# or VB *grumble*
And yes, you may laugh yourself silly at my question/code/vb-simplified-mind, I have my thick fire proof suit on
Thanks guys.
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
The greatest thing you'll ever learn is just to love, and to be loved in return - Moulin Rouge
Tim Smith wrote:
Over here in the third world of humor (a.k.a. BBC America),
peterchen wrote:
We should petition microsoft to a "target=_Paul" attribute.
|
|
|
|
|
Not sure whether I understood what you want.
But this is enough
ArticleBrief* pArticles[] = proxy->GetLatestArticleBrief(iNumArticles);
You don't need new.
Paul Watson wrote:
grumble* this is so easy in C# or VB *grumble*
It would be same in C++ You can translate easily b/w C# and C++
|
|
|
|
|
Rama Krishna wrote:
ArticleBrief* pArticles[] = proxy->GetLatestArticleBrief(iNumArticles);
That is how I originally thought it was done. I even tried it but kept getting an error. However after re-reading your code I noticed that you had put down ArticleBrief and not ArticleBriefs...
Man do I feel like a mullet. I had it back to front!
Thank you very much
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
The greatest thing you'll ever learn is just to love, and to be loved in return - Moulin Rouge
Tim Smith wrote:
Over here in the third world of humor (a.k.a. BBC America),
peterchen wrote:
We should petition microsoft to a "target=_Paul" attribute.
|
|
|
|
|
ArticleBriefs cArticles[10];
code...
or...
ArticleBriefs *cArticles = (ArticleBriefs*)malloc(sizeof(ArticleBriefs) * 10);
code...
free(cArticles);
in both cases you use cArticles[0] to cArticles[9] to access the 10 items in the array
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
This will not work as ArticleBrief is a managed class.
|
|
|
|
|
Anders Molin wrote:
ArticleBriefs *cArticles = (ArticleBriefs*)malloc(sizeof(ArticleBriefs) * 10);
Thanks Anders.
Your code and Rama's code set me straight.
I think I should have stuck to unmanaged VC++ for my first foray. At least then I would have some good samples and tutorials to help me out. MC++ samples and tuts are thin on the ground.
It is working now:
ArticleBrief* cArticles[] = proxy->GetLatestArticleBrief(iNumArticles);
I had it back to front (ArticleBriefs instead of just ArticleBrief.)
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
The greatest thing you'll ever learn is just to love, and to be loved in return - Moulin Rouge
Tim Smith wrote:
Over here in the third world of humor (a.k.a. BBC America),
peterchen wrote:
We should petition microsoft to a "target=_Paul" attribute.
|
|
|
|
|
I have a CTreeCtrl with Parent nodes which have each 4 Child nodes. I´d like to associate an image on the child nodes, but not on the parent nodes. How do I manage to do that :
TVINSERTSTRUCT tvInsert;
HTREEITEM ChildItem;
CString Text;
CTreeCtrl *pOutprob;
pOutprob=(CTreeCtrl *) GetDlgItem(IDC_TREEPROB);
pOutprob->SetImageList(m_ImageList,TVSIL_NORMAL);
tvInsert.hParent = NULL;
tvInsert.hInsertAfter = TVI_SORT;
tvInsert.item.stateMask=0;
for(i=0;i<Tree.Nb_Vars();i++)
{
tvInsert.item.mask = TVIF_TEXT;
tvInsert.item.pszText =(unsigned short *)Text.operator LPCTSTR();
tvInsert.hParent = NULL;
tvInsert.hInsertAfter = NULL;
ChildItem=pOutprob->InsertItem(&tvInsert);
tvInsert.hParent = ChildItem;
tvInsert.hInsertAfter = NULL;
for(j=0;j<Tree.Variable_Parents[i].weight();j++)
{
tvInsert.item.mask = TVIF_TEXT|TVIF_IMAGE;
tvInsert.item.pszText =(unsigned short *)Text.operator LPCTSTR();
S_ID=pOutprob->InsertItem(&tvInsert);
pOutprob->SetItemImage(S_ID,imgnb,imgnb);
}
}
(Sorry if there is not the whole code here ) This displays an image for both parent and children .. and i do not see why ...
~RaGE();
|
|
|
|
|
Rage wrote:
pOutprob->SetImageList(m_ImageList,TVSIL_NORMAL);
To my concern the problem really is in this line of code. TreeView can either HAVE Images or HAVE NOT images ... so as soon as you declare an ImageList for the Tree it HAS images. To my opinion there's no way NOT to show images for the parent items in that case.
Crey
|
|
|
|
|
CreyBax wrote:
there's no way NOT to show images for the parent items in that case.
That´s what I was afraid of ... well, thanks anyway...
~RaGE();
|
|
|
|
|
there are two types of image lists
one depends on items state and so item can be without it
(you can see OnPaint/if(itemState & TVIS_STATEIMAGEMASK) into cp/treectrl/rgree sources)
t!
|
|
|
|
|
In a MFC dialog-based application i've created a worker thread.
In the worker thread i call Sleep(5000) and the interface blocks for the specified period.
I have to mention that the thread is involved in many operations including mutexes and objects located in some other threads, but not the main one of the interface.
Could you tell me how should i handle the problem?
rechi
|
|
|
|
|
Bogdan Rechi wrote:
In the worker thread i call Sleep(5000) and the interface blocks for the specified period.
By 'interface' you mean 'user interface'?
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
|
Calling Sleep() in worker should have no effect on main thread. Unless you're waiting for worker to finish...
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
It's strange, because i use a mutex - working excellent even in such conditions - to synchronize the access to some data located in an object belonging to another thread, but not the main-one.
Indeed, it seems that the delay comes from this mutex and hard times are to come.
Anyway, thanx!
rechi
|
|
|
|
|
I have an application with many different views, but I want to have only a single document open for a process. How can I best block OnFileOpen() and OnFileNew()?
1. I have tried OnUpdate in my CMainFrame by using CCmdUI. Can't make it work.
2. I override the OnFileOpen() and OnFileNew() to check if a document is already active. But if I use
CDocument* pDoc=((CFrameWnd*)m_pMainWnd)->GetActiveDocument();
I always get a NULL pointer ??
Regards, Haakon S.
|
|
|
|
|
Haakon S. wrote:
How can I best block OnFileOpen() and OnFileNew()?
I'm not sure why do you want to block. Just close open document and create/open another.
Haakon S. wrote:
I always get a NULL pointer ??
CWinApp::CloseAllDocuments does what name suggests.
I'd override CWinApp::OpenDocumentFile (which is also called for new docs) to close everything before new doc is open/created.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
I don't want anybody to have several documents open at the same time (in the same process), which you can normally do in a MDI apllication. I want to disable this functionality.
Haakon S.
|
|
|
|
|
I know what you want to do. I just think that instead of blocking File/New and File/Open you should close current document and load/create new one. This will result in at most one document open in any given moment.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
What you are saying is the right thing to do. You know it and I know it. But what about the next man? It should be possible to totally rule out the option.
There are several reasons, by the way. First, if you have many different views it gets totally messed up if you have several documents. Secondly, my app. will probably break with several documents (probably poor programming, but anyway... ).
So, once again, help in this matter will be greatly appreciated.
Haakon S.
|
|
|
|
|
My solution (close open document before opening/creating new one) gives you exactly what you need: you have MDI app --and-- at most one document is open. Your app will not break; user will be working with exactly one document.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
CMDIFrameWnd *pFrame =
(CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
CMDIChildWnd *pChild = pFrame->MDIGetActive();
|
|
|
|
|
Description:
============
There are a lot of times in a dialog box that one would want to read-in/display a number that has a unit. For instance, this can be achieved by a pair of edit box and static box.
Edit box control containing the value Static Control displaying the unit:
2.378e-3 Meter
User can also choose his favorite unit system in a centralized dialog box. For example, he could specify whether he would rather to have the lengths to be displayed in Meter, Inch, Centimeter, ...
Question:
=========
I thought the best way to accomplish this task is deriving a customized edit box and static controls from MFC's CEdit and CStatic classes and adding the following paramteres to it:
double m_Conversion; // Conversion factor from SI to the user's selected unit.
CString m_UnitName; // The Unit's name, "m", "cm", "mm", ...
This seems to be such a common problem that I thought there might have already been some specialized codes written by other people for this purpose.
I appreciate any input/suggestion/pointers in regards to my question. Please e-mail a copy of your response to "asi@enginia.com".
Thank you.
Ali Asi
asi@enginia.com
Ali Asi
|
|
|
|
|
I am using a system doing exactly what you are asking for.
1. First, you establish a vector of UINT's where the user enters all preferences. For example, length is put in m_UnitVector[2].
2. Secondly, you establish the options in a pairs of const char* and conversion factors:
const char* CUnit::m_Length[]={" [m]"," [ft]"," [mm]"," [in]",NULL};
const float CUnit::m_fLength[]={1.0F,3.280839F,1000.0F,39.37008F};
Here, length is stored in meters as the base unit.
3. In your edit box showing the unit you enter m_unit.m_Length[m_UnitVector[2]], in the box showing the number you show m_fMyLength*m_unit.m_fLength[m_UnitVector[2]]. Of course, when you go the other way with UpdateData(TRUE), you divide instead of multiply.
Hope you can make use of this.
Regards, Haakon S.
|
|
|
|
|
Hi All,
I've got a CFormView derived class, where I am creating controls at runtime and placing them on the form. This seems to work OK, but I am wondering how to get some resource ID's to use with theswe controls at runtime. SHould I just reserve a bunch of them, or is there a way to get them dynamically?
Thanks,
Aaron
|
|
|
|