|
|
Hi,
i have some problems with getting info whether the given parent item is expanded or collapsed. My code is:
if (TVIS_EXPANDED == m_cMyTree.GetItemState(hMyTreeItem,TVIF_STATE))
else
but it seems not to work, and I cannot find info on this. Could you please help?
Thanks
R.
|
|
|
|
|
I might be wrong but have you tried.....
if (TVIS_EXPANDED == m_cMyTree.GetItemState(hMyTreeItem,TVIS_EXPANDED))
//Expanded
else
//not expanded
Or something like that, there is an axample in the MSDN Library that seems to indicate you need to change TVIF_STATE to TVIS_EXPANDED
JohnJ
http://www.rainbow-innov.co.uk
|
|
|
|
|
it is quite surprising for me but both function calls return the same results:
m_cTree.GetItemState(m_hType,TVIF_STATE);
m_cTree.GetItemState(m_hType,TVIS_EXPANDED);
the problem was that the return value contains bitwise information so the call must have been used in this way:
if (TVIS_EXPANDED & m_cTree.GetItemState(m_hType,TVIS_EXPANDED))
else
Thank you for pointing the above issue out.
R.
|
|
|
|
|
This is the map definitions:
typedef std::map<int, std::string> strmap;
strmap mPaths;
strmap::iterator miIterator;
First you do this:
miIterator = mPaths.find(index);
right? but what do you do next if you want to copy ther string into a char *?
thanks
|
|
|
|
|
You need to post more info on the map declaration:
Is is a map<string, int> or what?
You might find your answer in .second and .first
miIterator.first->c_str()
....
James
|
|
|
|
|
oh, it got lost due to html formatting, here it is:
typedef std::map<int, std::string> strmap;
strmap mPaths;
strmap::iterator miIterator;
if i then insert an item like this:
mPaths.insert(strmap::value_type(index, path));
how do i retrieve it again and copy it into a char array? first i do this right:?
miIterator = mPaths.find(index);
but what do i do next?
thanks in advance
|
|
|
|
|
miIterator->second is the string you're after.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Ohhhh, careful... I often see STL code that does stuff like this:
<br />
typedef std::vector< DWORD > VectDWORD;<br />
typedef std::vector< DWORD > VectDWORDIter;<br />
VectDWORD vecDWORD;<br />
VectDWORDIter iterDWORD;<br />
iterDWORD = vecDWORD.begin();<br />
<br />
FunctionThatTakesADWORDPointer( iterDWORD );<br />
Which works under some STL implementations, but may not really be correct: pointers can be treated like iterators under some situations, but the reverse? Stricter implementations will not let you do that (the stock one that comes with VC++ 6.0 will, however).
Peace!
-=- James.
"Some People Know How To Drive, Others Just Know How To Operate A Car."
[Get Check Favorites 1.4 Now!]
|
|
|
|
|
First of all, these typedefs are plain dumb. They make your code illegible.
Second of all, you can do the inserts much nicer like this:
mPaths[index] = path;
Thirdly, if you know for sure an index is in there, you can pull it out like this:
string s = mPaths[index];
beware - if you don't know for sure it is in there, you should use the method you've been using, the find and then ->second. Otherwise empty records will be entered into your map.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
Where to get simple REAL HTTP/1.1-compatible proxy?
|
|
|
|
|
This is a point I've seen many people hold confusing ideas about. Essentially, if the other party falls down or there's a cut-off somewhere along the connection path, your connection end won't notice immediately. It is after some time-out has elapsed that the Winsock stack will decide the other end is not responsive and the connection will be aborted. To understand this, just consider that a TCP/IP connection is nothing but a couple of software entities that has settled upon some IP addresses and TCP ports to send and receive data to each other. The connection ends do not have the slightest idea of how the data actually travel from one side to the other, so they have to rely on timeout mechanisms to react to cutoffs.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Got it. Tnx
|
|
|
|
|
I'm writing a UNICODE class that uses both the unsigned short as an integer value and wchar_t as a character. But since they are both the same data type, how can I tell the difference between them? For example:
int MyClass::operator>>(unsigned short value)
int MyClass::operator>>(wchar_t character)
The compiler complains that they are duplicate definitions of the same function. I thought of adding another parameter to one of them, but can't do that either because operators take only one parameter.
Any ideas?
|
|
|
|
|
wchar_t and unsigned short are the same thing in VC6
In VC7 you can define wchar_t as a native type but I am not able to find the documenetation link which specifies how to do it.
|
|
|
|
|
This is an unfortunate non-conformance to the standard by VC++. You'll have to workaround it somehow. For instance, by defining a disambiguating wrapper around wchar_t :
struct wchar_wrapper{
wchar_wrapper(wchar_t wc):wc(wc){}
operator wchar_t& (){return wc;}
operator wchar_t ()const{return wc;}
private:
wchar_t wc;
} Now you can declare your two operators like:
int MyClass::operator>>(unsigned short value);
int MyClass::operator>>(wchar_wrapper character); and use the second as folows:
wchar_t wc;
MyClass mc;
mc>>wchar_wrapper(wc);
PS: By the way operator >> is usually defined as returning a reference to the stream, like:
MyClass& MyClass::operator>>(unsigned short value);
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Do you know how to return an IStream pointer from a COM interface's method. I mean in the [out, retval] position.
rechi
|
|
|
|
|
STDMETHODIMP MyCOMClass::FuncReturningIStream(IStream* *ppStm)
{
if (ppStm == NULL)
return E_POINTER;
(*ppStm = m_pMyStream)->AddRef();
return S_OK;
}
|
|
|
|
|
STDMETHODIMP MyCOMClass::FuncReturningIStream(IStream* *ppStm)
{
if (ppStm == NULL)
return E_POINTER;
return this->QueryInterface(IID_IStream, (void **)ppStm)
}
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
I have some code where i use the DialogBox function. When i have called that function, the dialog box appears and i can move it and press buttons, but it's like the execution stops there. If i place a breakpoint at the DialogBox line and press F10 to go to the next line, it just stays there, it doesen't advance to the next line.
Here's the code to show the dialogbox:
DialogBox(ghInstance, MAKEINTRESOURCE(IDD_ADDFILES), ghWnd, DialogAddProc);
And here's the dialog box' dialog procedure.
BOOL __stdcall DialogAddProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_COMMAND:
switch (wParam)
{
case IDC_CANCEL:
gbAbort = true;
break;
}
break;
case WM_INITDIALOG:
ghAddDialog = hWnd;
break;
case WM_CLOSE:
DestroyWindow(hWnd);
break;
default:
return FALSE;
break;
}
return (0L);
}
Anyone know what i am doing wrong?
Thankyou in advance.
|
|
|
|
|
Control will resume at the line after DialogBox when the user exits the dialog.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Then how do i create a dialog box that does the same as CreateDialog except it's modal?
|
|
|
|
|
What you're getting is precisely a modal dialog:CreateDialog creates modeless dialogs (returns control immediately, it's up to you to destroy the dialog on due time.)
DialogBox creates modal dialogs, which capture the flow of execution till the user closes them.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
OK. Maby i have misunderstood some of the terms. How do i create a modeless dialog box, where the parent window can't be used till the dialog box is closed? A dialog box that performs all the actions after the showing of the dialogbox, but where the parent window can't be used untill the dialog box is closed.
|
|
|
|
|
Disable the parent window before showing the dialog. When the dialog is destroyed renable the parent. Use EnableWindow function.
|
|
|
|