|
I didn't like the cmd window hanging there with a blinking cursor, Although it did the job.
I added the CoIntialize to the Shell Execute, and it grabs the process, and doesn't let go until the pkgmgr.exe completes now. Before it just came back after the program started running. Now I just need to add the exitCode stuff in case it fails for some reason, and check the errorlevel code at the end.
I'm going to leave it at this for now.
SHELLEXECUTEINFO lpExecInfo = {0};
lpExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
lpExecInfo.lpFile = lp_File;
lpExecInfo.fMask = SEE_MASK_DOENVSUBST|SEE_MASK_NOCLOSEPROCESS ;
lpExecInfo.hwnd = NULL;
lpExecInfo.lpVerb = lp_Operation;
lpExecInfo.lpParameters = lp_Parameters;
lpExecInfo.lpDirectory = lp_Directory;
lpExecInfo.nShow = SW_SHOW ;
lpExecInfo.hInstApp = (HINSTANCE) SE_ERR_DDEFAIL ;
hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
if ( FAILED( hr ) ) {
CoUninitialize();
hr = CoInitializeEx( NULL, COINIT_MULTITHREADED );
if ( FAILED( hr ) ) {
wprintf( L"CoInitialize failed. Error 0x%0x\n", hr );
goto comError;
}
}
exit_Code = ShellExecuteEx(&lpExecInfo);
if(lpExecInfo.hProcess !=NULL) {
::WaitForSingleObject(lpExecInfo.hProcess, INFINITE);
::CloseHandle(lpExecInfo.hProcess);
}
comError:
CoUninitialize();
|
|
|
|
|
you can use cmd /c instead of cmd /k and then the command window will disappear once pkgmgr.exe completes.
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun
|
|
|
|
|
I have a C program and here I invoke the Weka software how can I do? I thank you all for your help!
|
|
|
|
|
|
what I want to do and a C program to invoke the software Weka. I can do this if you like? eg with the previous answer but I would like to understand how to go about my problem! thanks to all
|
|
|
|
|
Did you bother to follow the links provided by Madhu? They clearly demonstrate how to solve your problem.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
I'm still amazed by some of the laziness shown by some site users...
|
|
|
|
|
hi!
how do i get counter of item (index of item in CTreeCtrl) with its HTREEITEM ?
for example: user selects 3th item of CTreeCtrl. in code, with GetSelectedItem() function we have HTREEITEM of item. but index of it?(in this example 3)
please help me...
Zo.Naderi-Iran
|
|
|
|
|
The index based on what? What would be index 0?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
The index concept is not applicable for a TreeItem. The HTREEITEM itself is an index identifier for the item.
Loop through each items and store the index values and HTREEITEM in a map for future use.
zon_cpp wrote: user selects 3th item of CTreeCtrl.
If your issue is to get the exact item when the user clicks on a treeitem - I have a suggestion, to use CTreeCtrl's HitTest[^] to get the item from selected point.
|
|
|
|
|
when user click on item of Tree view. for example 3th item: how do i get (3) numeral index this item?
Zo.Naderi-Iran
|
|
|
|
|
You don't. A Tree does not have or use an index. Even if it had, the moment an item gets removed or added, any stored index values would all be invalidated - so you cannot store an index and hope to later retrieve the correct item through that index, because it might no longer be valid!
The HTREEITEM value you get is what is generally called a 'handle'. It serves as a reference to the actual item, and it will remain valid until this child item is removed from the tree. You should use that handle and retrieve the child item, using HTREEITEM GetChildItem(HTREEITEM hItem) const; (see http://msdn.microsoft.com/en-US/library/yk3ystd6%28v=VS.80%29.aspx[^]).
|
|
|
|
|
Why you need the actual "position" (I assume that's what you want) ?
Assuming you want the position in regards with the parent node
parent
- node1
- node2
- node3
- node4
Anyway, a suggestion :
CTreeCtrl::GetParent of selected node and then use CTreeCtrl::GetChildItem and CTreeCtrl::GetNextSiblingItem (or other similar member) in a loop to get the next item; just count.
Watched code never compiles.
|
|
|
|
|
Good idea, and it actually answers the question - but I wonder whether that's what he (or she) actually needs
|
|
|
|
|
Wouldn't calling GetPrevSiblingItem[^] to walk "upwards" until it returns no more items and counting that work?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
probably.
Watched code never compiles.
|
|
|
|
|
zon_cpp wrote: for example: user selects 3th item of CTreeCtrl.
3rd item relative to what?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
One way: you can pass index in LPARAM lParam argument when inserting items
in treeview; then use GetSelectedItem to get handle to selected tree item
and get it index with CTreeCtrl::GetItem .
HTREEITEM hItem = m_treeFeature.GetSelectedItem();
TVITEM tvItem = {0};
tvItem.mask = TVIF_PARAM;
tvItem.hItem = hItem;
m_treeFeature.GetItem(&tvItem);
int nindex = (int)tvItem.lParam;
HTREEITEM GetSelectedItem( )
http://msdn.microsoft.com/en-us/library/xw6h5d91(v=vs.80).aspx[^]
|
|
|
|
|
In my MFC application i am using CRichEdit control for multiline text.
I have set the below properties for the rich edit control.
ES_MULTILINE | ES_NOHIDESEL | ES_READONLY | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP,WS_EX_CLIENTEDGE | WS_EX_STATICEDGE
Vertical and Horizontal Scrollbar appears automatically when the text entered is more than the display area. This is working as expected.
I am having one clear button in my application which is to clear the text in rich edit control. But when i click the clear button vertical scrollbar disappears but the horizantal scrollbar is not disappearing.
Can anyone help me out in this? .
|
|
|
|
|
I have already responded to this question here[^]. Please do not post in multiple forums.
|
|
|
|
|
Hi!
how do i select 3th item of a CTreeCtrl?
SelectItem() function needs HTREEITEM of specified item, but i have index of item (for example 3th item)
please help me...
Zo.Naderi-Iran
|
|
|
|
|
It's not possible to access nodes by index. You must know the handle of the node. If you don't have records of the node handles, you can parse the tree:
HTREEITEM hRoot = myTree.GetRootItem();
HTREEITEM hChild1 = myTree.GetChildItem(hRoot);
HTREEITEM hChild2 = myTree.GetNextSiblingItem(hChild1)
HTREEITEM hChild3 = myTree.GetNextSiblingItem(hChild2)
|
|
|
|
|
You could do something like this:
HTREEITEM ItemFromIndex(int index)
{
HTREEITEM item = m_tree.GetRootItem();
while (item != NULL && index > 0)
{
item = NextTreeItem(item);
--index;
}
return item;
}
HTREEITEM NextTreeItem(HTREEITEM hStartItem)
{
HTREEITEM hItem = hStartItem;
if (m_tree.ItemHasChildren(hItem))
{
HTREEITEM hChildItem = m_tree.GetChildItem(hItem);
hItem = hChildItem;
}
else
{
bool foundSibling = false;
while (!foundSibling && hItem != NULL)
{
HTREEITEM hSiblingItem = m_tree.GetNextItem(hItem, TVGN_NEXT);
if (hSiblingItem != NULL)
{
hItem = hSiblingItem;
foundSibling = true;
}
else
{
hItem = m_tree.GetParentItem(hItem);
}
}
}
return hItem;
}
Som eof this was written from memory, other sections are code pasts, so take with a pinch of salt.
If you vote me down, my score will only get lower
|
|
|
|
|
Hi all,
I am looking to work on with PIC/Embedded Systems in C/C++. So I just want to find some resources in two aspect.
1. Books, tutorials where i can take a start
2. Development environment (and simulators, real PICs, etc)
Thanks
I appreciate your help all the time...
CodingLover
|
|
|
|
|