|
If there's a member variable tied to m_objInfoWindowLineOne (and/or the
IDC_CHECK_TIMEOUT_OVERRIDE button) through DDE then your UpdateData() call is going to write the
contents of that variable to the m_objInfoWindowLineOne control, AFTER you've set the text
directly.
I'm thinking a quick fix for the method you've shown would be to add an UpdateData(TRUE);
before the m_strIPAddress.Empty(); call. It would probably fix it but it's not necessarily
correct or efficient
Maybe for consistency, you could either use DDE or directly set/retrieve info from controls but
not both. If you choose to use both, you need to pay close attention to when controls and
associated member variables are being modified.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the number 3
|
|
|
|
|
When you use SetWindowText, Windows generates a message that actually causes the control to redraw itself, but that message isn't processed until your OnButtonHangUp function has completed.
In order to update the text immediately, you can add
m_objInfoWindowLineOne.UpdateWindow() immediatly after you SetWindowText.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
When I've installed IIS Server in my machine,one program wrote before will report bind error,but that just bind 6543 port,I suppose that port has been occupied by IIS,however,when I use "netstat -an" or other port viewer,this port hasn't used yet.What's the problem?
Later buggers harm more.
|
|
|
|
|
Problem: “error C2678: binary '[' : no operator found which takes a left-hand operand of type 'const ChessBoard::cart_map_type' (or there is no acceptable conversion)”
ChessPiece get_piece(const std::string& coord) const
{
AssertCoord(coord);
cartesian_type cart = coord_cart_conv_[coord]; <- ERROR C2678
return( get_piece(cart.first, cart.second) );
}
Solution:
ChessPiece get_piece(const std::string& coord) const
{
AssertCoord(coord);
cartesian_type cart = coord_cart_conv_.find(coord)->second; <-SOLUTION
return( get_piece(cart.first, cart.second) );
}
Question: Could someone explain to me why the STL does not define the same overloading for operater[] that it does for find ?
Something like const Type& operator[]( const Key& _Key ) const; .
I really would like to know the logic behind this, as it escapes me at the moment.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
I can't see the type of cartesian_type or cart_map_type so it's hard to say much.
Steve
|
|
|
|
|
Well their types do not matter that much with regards to the question, but here they are.
typedef std::pair< int, int > cartesian_type;
typedef std::map< std::string, cartesian_type > cart_map_type;
cart_map_type coord_cart_conv_;
Cartesian is probably not a good name since I am using {row, column} instead of {X, Y}, but I am still playing with the code.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
John R. Shaw wrote: Well their types do not matter that much with regards to the question
Sure they do. A type determines the operations you can perform on an object and your question is asking why you can't perform a certain operation on an object.
That said, I can't see why your code doesn't compile. In fact, when I tried the following code it compiled just fine:
#include "stdafx.h"
#include <utility>
#include <map>
#include <string>
typedef std::pair< int, int > cartesian_type;
typedef std::map< std::string, cartesian_type > cart_map_type;
cart_map_type coord_cart_conv_;
int main(int arvc, char* argv[])
{
using namespace std;
cartesian_type cart = coord_cart_conv_[string("Hello")];
return 0;
}
Steve
|
|
|
|
|
Your code compiles just fine because main is not a constant member function of a class. If I removed the const from the end of the function declaration my original function would compile without error, but if I tried to call it via a constant object, after that, then I would get another set of errors, because you can not call a non-constant member function from a constant object..
The question had to do with calling operator[] in a constant function.
Try this:
class TestClass
{
typedef std::map< int, int > m_test_map;
public:
TestClass()
{
for( int i=0; i<10; ++i)
m_test_map[i] = i;
}
int get_value(int i) const
{
return m_test_map[i];
}
};
I have not tested the above, but it will generate the error in get_value . The reason for this is that no constant operator[] function is defined for maps.
The following should generate the same error for the same reason, because the same thing applies to strings:
class TestClass2
{
std::string m_str;
public:
TestClass() { m_str = "Hello"; }
int get_char(int i) const
{
return m_str[i];
}
};
This is an STL design issue, they have a reason for this behavior and I was just wondering what the logic behind it was.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
As you mentioned, std::map<...>::operator [...] is a non-const function. This by design. operator [] returns a reference to the element based on a key and you can't have a reference to nothing. If you pass a key to operator [] that doesn't exist in the map it is added and a reference to the newly created element is returned; thus it can't be const .
Steve
|
|
|
|
|
|
When I create a CTreeCtrl with the TVS_CHECKBOXES property and then destroy it, it leaks the GDI objects for the TVSIL_STATE image list. I have tried adding the following code to the OnDestroy function of the CTreeCtrl's parent window. It is called but it doesn't have any affect.
// Delete the state image list so it doesn't leak GDI objects
//
CImageList *pStateImageList = m_Tree.GetImageList(TVSIL_STATE);
if (pStateImageList)
{
m_Tree.SetImageList(NULL, TVSIL_STATE);
pStateImageList->DeleteImageList();
}
CWnd::OnDestroy();
}
Any suggestions on how to fix this GDI leak?
|
|
|
|
|
Usually the image list is created as a member variable of some class, so it won't go out of scope. Why are you using pStateImageList?
|
|
|
|
|
The TVSIL_STATE image list is created automatically when the TVS_CHECKBOXES property is set on CTreeCtrl. The image lists contain the images of the checked and unchecked checkboxes.
|
|
|
|
|
This should do the same thing....does it work?
HIMAGELIST hImgList = TreeView_SetImageList(m_Tree.GetSafeHwnd(), NULL, TVSIL_STATE);
if (hImgList)
ImageList_Destroy(hImgList);
If not, is there a TVSIL_NORMAL imagelist that's not getting destroyed?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the number 3
|
|
|
|
|
Thanks for the suggestion. I tried it and it did not fix the problem. There is a TVSIL_NORMAL imagelist and it is being destroyed. Also, I used a GDI leak detection program and I could see that it is the checkbox images that are being leaked.
|
|
|
|
|
Bummer.
I don't have a GDI leak detector but testing with task manager, I get:
// Adds 4 GDI Objects
m_TreeCtl.ModifyStyle(0, TVS_CHECKBOXES);
...
...
// Removes 4 GDI Objects
HIMAGELIST hImgList = TreeView_SetImageList(m_TreeCtl.GetSafeHwnd(), NULL, TVSIL_STATE);
if (hImgList)
ImageList_Destroy(hImgList);
I can't find any info documenting a leak.
Good luck!
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the number 3
|
|
|
|
|
Please Help.
I am using Visual Studio 6 and have just moved my VC6 project into Rational ClearCase.
When I open the project I get a dialog box "Cannot access ClassView information file. ClassView information not available".
What file is Visual Studio looking for?.
|
|
|
|
|
cgb143 wrote: What file is Visual Studio looking for?.
Possibly one with a .clw extension.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
You should not put files with these extensions under source control.
.ncb
.aps
.clw
The .ncb file contains your Class View information, and if it read-only, you'll get the message you see.
The .aps file is your "apstudio" resources and also need to be read/write.
The .clw file is the class wizard file.
In fact, I recommend that you delete those files on a regular basis - they will all be recreated when needed automatically.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
|
You could add the following to that list:
.pch
.mdp
.obj
.exe
.cpl
.awk
.exp
.lib
.idb
.opt
.pdb
.map
.res
.ilk
.bsc
.sbr
.dll
.tlb
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks again,
However, most of these are in the Release / Debug folders which I had already excluded from ClearCase as I knew their contents were re-created during compilation.
|
|
|
|
|
Hi,
I have two CEdit controls in a dialog.
In Change() event handler of first control, I'm using first control's value and setting another random value of second control and finally calling UpdateData(FALSE);
But the text in first control remains same (old - whatever it was set in InitDialog()) and the caret is repositioned at first character.
Why isn't text if first control changing and caret is being positioned at first character again and again?
Can anyone help me out?
Regards,
Abhijeet
|
|
|
|
|
a_b_pathak wrote: Why isn't text if first control changing
You stated "I'm using first control's value and setting another random value of second control".
Why would that change the first control's text?
Can you post the code for your "Change() event handler"?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the number 3
|
|
|
|