|
|
Have you considered a masked edit control?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello everyone,
Am I correct for the understanding of the following three questions about CoInitialize/CoUninitialize?
1.
For each thread which utilizes COM, we need to call CoInitialize/CoUninitialize. Not for each process.
2.
There is no harm to call CoUninitialize even if we do not call CoInitialize? And if we call CoInitialize N times on a thread, we need to call CoUninitialize the same of times (N times, not only 1 time) on a thread to release all resources?
3.
CoInitializeEx will invoke CoInitialize?
thanks in advance,
George
|
|
|
|
|
George_George wrote: For each thread which utilizes COM, we need to call CoInitialize/CoUninitialize. Not for each process.
yes
George_George wrote: And if we call CoInitialize N times on a thread, we need to call CoUninitialize the same of times (N times, not only 1 time) on a thread to release all resources?
yes
George_George wrote: CoInitializeEx will invoke CoInitialize?
No. But CoInitialize calls CoInitializeEx with concurrency model as single-thread apartment.
|
|
|
|
|
Thanks Naveen,
I have tried call CoInitialize multiple times will result in fail? Could you reproduce it?
regards,
George
|
|
|
|
|
Fail means it return E_FAIL ? I hope you have seen the below lines in MSDN
"Typically, the COM library is initialized on a thread only once. Subsequent calls to CoInitialize or CoInitializeEx on the same thread will succeed, as long as they do not attempt to change the concurrency model, but will return S_FALSE"
|
|
|
|
|
Thanks nave,
Question answered. This is what I mean.
regards,
George
|
|
|
|
|
1 and 2 are yes and 3: from th MSDN
New applications should call CoInitializeEx instead of CoInitialize.
|
|
|
|
|
Great reply, thanks Hamid!
regards,
George
|
|
|
|
|
It's said that 32 bit cpu accesses 32 bit data most efficiently.
So does 64 bit.
Is there any type that is always equal to the cpu bit size? (Maybe it should be the data bus size, I'm sure whether they are always equal).
|
|
|
|
|
followait wrote: Is there any type that is always equal to the cpu bit size?
int
modified on Monday, June 30, 2008 12:35 AM
|
|
|
|
|
No, it is 4 bytes in both 32-bit and 64-bit machines.
|
|
|
|
|
Sorry you are right....
|
|
|
|
|
Try DWORD_PTR
« Superman »
|
|
|
|
|
__int3264
LONG_PTR
DWORD_PTR
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
size_t
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
Hi,
This maybe a wtl question however an mfc answer may probably help me. My question is that lets say I created a tree
<br />
son = Father.InsertItem ( _T("Main"), TVI_ROOT, TVI_LAST );<br />
son.AddTail ( _T("Sub1"), 0 );<br />
son.AddTail ( _T("Sub2"), 0 )<br />
Now this will look some thing like this
Main
-Sub1
-Sub2
What I need to do is if a user highlights a Tail how can I know which one is it? for example the user highlights Sub1 how can I know that?
Thanks,
Jayjay
|
|
|
|
|
monsieur_jj wrote: What I need to do is if a user highlights a Tail how can I know which one is it?
When ever user changes the selection in the tree control, a TVN_SELCHANGED message is send to the parent window. The lparam of this message is pointer to NMTREEVIEW strcture and the "itemNew" memeber of this structure is the newly selected item.
|
|
|
|
|
Thank you Naveen, is there a way you can tell me how to do what? And what operation I can use?
|
|
|
|
|
I am not familiar with the WTL. How ever to handle the selection change notification you should add following things in your code.
1. In the message map entry add a handler like..
NOTIFY_HANDLER( IDC_TREE1, TVN_SELCHANGED , OnSelChange )
2. Add a function called OnSelChange in the dialog class as below
LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
3. And in that function cast the pnmh to NMTREEVIEW*
NMTREEVIEW* pNMTreeView = (NMTREEVIEW*)pnmh;
HTREEITEM hSelectedItem = pNMTreeView->itemNew.hItem;
|
|
|
|
|
Hi Nave,
Thanks for the answer I have successfully made the function and made it run. I just wonder how it will give me what is highlighted among the tails? the itemNew has:
UINT mask;
HTREEITEM hItem;
UINT state;
UINT stateMask;
LPSTR pszText;
int cchTextMax;
int iImage;
int iSelectedImage;
int cChildren;
LPARAM lParam;
However even the pszText does not contain the highlighted text? even the iSelectedImage does not have the imageindex number?
Please advise
thanks,
Jayjay
|
|
|
|
|
Only the mask, hItem, state, and lParam members of these structures are valid. So if you want to get the text of the selected item, call CTreeCtrl::GetItemText() function with hItem in the structure.
|
|
|
|
|
Nave,
thank I get it now however when I use getitemtext() it only gives me a part of the string. Should I use string?
for example the item is NewItemNumber 4.23.89.15, it will only get "ber 4.23.89.15", What should I change here?
string A;
DWORD Size, BufferSize;
BufferSize = MAXBYTES;
PPERF_DATA_BLOCK PerfData = (PPERF_DATA_BLOCK) malloc( BufferSize );
Size = BufferSize;
UpdateList.GetItemText(Select, LPTSTR(&A), Size);
Thanks,
Jayjay
|
|
|
|
|
you should not use string.
modify its as
TCHAR tcItemText[MAXBYTES];
UpdateList.GetItemText(Select, tcItemText, MAXBYTES );
|
|
|
|
|
As has been said, the notify struct gives you a HTREEITEM of the newly selected tree item.
The following code may be useful to you. If the 3rd child of the 2 root item is selected, it returns a DWORD array of 2,3 - making it easier to map HTREEITEMS to your own data.
Alternatively, you can attach an lParam to each tree item also.
Iain.
typedef CDWordArray TreeStack;
BOOL CUITreeCtrl::uiGetChildNumberStack (HTREEITEM hItem, TreeStack &stack)
{
stack.SetSize (0);
while (hItem)
{
stack.InsertAt (0, uiGetChildNumber (hItem));
hItem = GetParentItem (hItem);
}
return TRUE;
}
int CUITreeCtrl::uiGetChildNumber (HTREEITEM hItem)
{
if (!hItem)
return -1;
HTREEITEM hSibling = hItem;
while (GetPrevSiblingItem (hSibling))
hSibling = GetPrevSiblingItem (hSibling);
int n = 0;
while (hSibling && hSibling != hItem)
{
n++;
hSibling = GetNextSiblingItem (hSibling);
}
return hSibling ? n : -1;
}
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|