|
Hi,
I'm using lots of containers objects such as Vectors and am being constantly frustrated at how awkward it is to look at the contents when debugging. A large Vector (of which I use many) may take half an hour to cycle through within the watch window, doing Vector._first, Vector._first+1, Vector._first+2 etc... seems to be the only way to look at the entire Vector. Please tell me there is some other way??
Thanks in advance,
Julian Churchill
|
|
|
|
|
Add a global function to return entry n, and use the result of that function in the watch window. Something like:
vector<int> vec;
/* I used 'int' arg. type to keep down example size */
int foo(const vector<int>& v, int entry)
{
return v[entry];
}
Then in the watch window, to see entry 47 of vector vec,
foo(vec, 47);
++luck;
|
|
|
|
|
When you are debugging vectors (or any pointer to an array of items), you can follow the expression with a comma and a count. This will display count elements.
So, Vector._first,10 will display 10 elements starting at Vector._first.
Best regards,
John
|
|
|
|
|
thanks for all the help, that's a debugging golden nugget as far as I'm concerned... can't find it anywhere in the help
|
|
|
|
|
hello,
and i'd like to monitor a server, to see when the server is down. of course, i could ping periodically, but is there a better way, maybe to get a notification from windows?
thanks
|
|
|
|
|
to get a UDP notification every time a Microsoft server died...
On second thought... I pay for my own bandwidth. Stop that request!
To answer your question: No, there is no way to get this kind of notification.
If you need to know when a server dies, you add a dedicated network connection (with dedicated NIC's) and send "I'm alive" messages. When they stop, the server has died.
|
|
|
|
|
hello,
how to resolve the ip to a hostname like with ping -a with win32 api?
thanks
enrico
|
|
|
|
|
You can look at the source of ping , its at MSDN.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
gethostbyaddr
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
yes, thanks, this is working. but it takes incredibly long, about 4 seconds to resolve the
name of the pc standing next to me, both win2000. is there a faster way to do this?
thanks
|
|
|
|
|
I don't think so, the delay, I assume is caused by querying, a "DNS server", you could try looking at thw Winsock FAQ
http://tangentsoft.net/wskfaq/[^]
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
Having a struct P { int x, y, z}
and debugging an application with a variable
P* ptrtP;
is it possible to get it pretty printed in the
Values tab of Locals.
Alternatively, if I want to call a pretty print
function in the Command Window - Immediate,
can I return a char*, or a std::string.
Thanks in advance,
andreas
|
|
|
|
|
You could output the stringized representation using OutputDebugString. Just an idea.
|
|
|
|
|
I've create my own CButton derived class with the BS_OWNERDRAW style. Somehow the button's DrawItem method is not called, and the button is not displayed. When I remove the BS_OWNERDRAW style the button is draw. I'm not getting this, am I'm missing something? This should be simple.
|
|
|
|
|
Did you consider the correct declaration of the function, that means did you declare it as
virtual void DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct ) ?
|
|
|
|
|
I did. And I probalby also found the cause of the problem. I copied the code to a simple dialog and it works there. In my current project there are a lot of OnCommand function (I did not write the code) and someting probably goes wrong there.
|
|
|
|
|
I like to autosize the owner draw button depending upon the text that it load dynamically based on localization strings. so some strings are large than others. Keeping this I override DrawItem in the inherited class from CButton.
The sample code is below
void CMyGraphicButton::DrawItem (LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CString cs;
CString cslong;
ASSERT(lpDrawItemStruct->CtlType == ODT_BUTTON);
LPCTSTR lpszText = (LPCTSTR) lpDrawItemStruct->itemData;
if (!lpszText || lpszText == (LPCTSTR)-1)
{
GetWindowText (cs);
}
else
cs = lpszText;
// now i m trying to resize , so let try to increase the size of button unconditioally
// I get
//lpDrawItemStruct>rcItem.left =0
//lpDrawItemStruct>rcItem.right =75
//lpDrawItemStruct>rcItem.top = 0
//lpDrawItemStruct>rcItem.bottom = 25
//As my button is on extreme right side of dialog so i tried to extend/increase the size of
// button of the left side as follows
lpDrawItemStruct>rcItem.left -= 25 ;
// but the above causes the text to be moved on right side insead of resize/increase the
//button size.
other code here...
Any idea or help is appriciated.
Thanks
Anil
[AKS]
|
|
|
|
|
Hello,
I am trying to set password for a existing user in active directory. I have created user in active directory successfully, and when i am trying to set password using the foloowing code it failes. When i tried calling ADsGetLastError i am not getting any error message or error code. It is showing 0 (Error code) always..
IADsUser *pIADsUser = 0;
try{
hr = ADsGetObject(L"LDAP://CN=prasad,OU=Sales,DC=ads,DC=com",IID_IADsUser,(void**)&pIADsUser);
_variant_t ovar;
hr = pIADsUser->SetPassword(L"prasad");
//hr = pIADsUser->SetInfo();
}
catch(const _com_error *e)
{
_bstr_t bst = e->Description();
}
DWORD dwLastError;
WCHAR szErrorBuf[MAX_PATH];
WCHAR szNameBuf[MAX_PATH];
hr = ::ADsGetLastError(&dwLastError,szErrorBuf,MAX_PATH -1 ,szNameBuf,MAX_PATH-1);//it returns dwLastError = 0
It will be apreciated if anybody can help me...
regards
prasad
|
|
|
|
|
prasadkmadam wrote:
try{
hr = ADsGetObject(L"LDAP://CN=prasad,OU=Sales,DC=ads,DC=com",IID_IADsUser,(void**)&pIADsUser);
if(FAILED(hr))
return hr;
if(!pIADsUser)
return E_FAIL;
_variant_t ovar;
hr = pIADsUser->SetPassword(L"prasad");
//hr = pIADsUser->SetInfo();
}
Could you please make the suggested changes and see if any of the added conditions are true.
P.S. Please, please, please use CComPtr instead of raw pointers.
|
|
|
|
|
Thanks for your reply.
I tried with your suggestions but ADsGetObject() funtion is working fine.
It returned SUCCESS (means 0) and the pIADsUser is having a proper value.
There is no assertion while calling SetPassword() and the call is taking some time also (it seems it contacting the server) but it is returned hr contains some junk value and when i tried calling ADsGetLastError it returned me last error as 0..i dont know what went wrong..
It is not even giving a proper error code..
please help
regards
prasad
|
|
|
|
|
hi All,
I have a form-view app. I have changed the color of the form into blue. i have placed one CStatic control (text) on this form. This control background color is gray. To change this background into the form color(blue), I did subclassing and immplemented "message reflection". But still the CStatic is having gray background. i have written the following code in MyCStatic control class.
// this is the handler for WM_CTLCOLOR message
HBRUSH mystatic::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
pDC->SetBkColor(RGB(0,0,255));
m_brush.CreateSolidBrush(RGB(0,0,255));
hbrush = (HBRUSH) m_brush;
return hbrush;
}
|
|
|
|
|
Did you try handling CTLCOLOR_STATIC inside your form view's OnCtlColor function?
|
|
|
|
|
For colored statics, you may find useful info in these articles:
* Using colors in CEdit and CStatic[^]
* Colored/Blinking Controls and Dialogs with any Font[^]
Using message reflection is the way to do so (ON_WM_CTLCOLOR_REFLECT)
You shouldn't create your brush each time OnCtlColor is called. You could initialized it only once and then pass its handle. Moreover, for each CreateSolidBrush should there be a DeleteObject, or your system will run low for GDI objects.
HTH,
K.
HTH,
K.
Angels banished from heaven have no choice but to become demons
Cowboy Bebop
|
|
|
|
|
Hi, thanks alot . Suggestions by both of you helped me really well.
|
|
|
|
|
MAPISendDocuments on Win2K functioned not, with a CreateProcess call by a Printer PortMonitor.
Hello,
I has the following problem:
if I a program normally start and the MAPI function sending document call can I a document by mail dispatch.
if the program startet by a CreateProcess by a PrinterMonitor from a Printer called functions this not and I receive the error message MAPI_E_LOGON_FAILURE
Thanks for answer, K. Bauer
Sorry for my bad english.
|
|
|
|