|
I am trying to Saving and Restoring Toolbars status by sending TB_SAVERESTORE message. MSDN says if you don't have user data to store with the toolbar buttons, you don't need to handle TBN_SAVE or TBN_RESTORE notification. So, now, the saving and restoring are fine, the program restores toolbar buttons correctly. However, if I try to kill that toolbar control restored, Visual Studio gives a warning message "Unhandled exception at 0x7c901230 in win32tst.exe: User breakpoint." This warning only shows if the program is launched inside the Visual Studio. It just runs fine if launched outside of Visual Studio. So I tried to debug with WinDbg.exe, and it gives a more detailed description of that user breakpoint warning "Invalid Address specified to RtlFreeHeap". Anybody knows what's wrong with the restoring? Thanks.
case WM_NOTIFY:
{
switch (((LPNMHDR)lParam)->code)
{
case TBN_GETBUTTONINFO:
{
LPTBNOTIFY lpTbNotify = (LPTBNOTIFY)lParam;
// Pass the next button from our array. There is no need to
// filter out buttons that are already used; they will be
// ignored.
int buttonCount = sizeof(tbButtons) / sizeof(TBBUTTON);
if (lpTbNotify->iItem < buttonCount)
{
lpTbNotify->tbButton = tbButtons[lpTbNotify->iItem];
return TRUE;
}
else
{
// No more buttons.
return FALSE;
}
}
break;
case TBN_QUERYINSERT:
case TBN_QUERYDELETE:
return TRUE;
case TBN_ENDADJUST:
{
TBSAVEPARAMS tbSave;
tbSave.hkr = HKEY_CURRENT_USER;
tbSave.pszSubKey = "Software\\key";
tbSave.pszValueName = "tbsave";
SendMessage(GetDlgItem(hWnd,ID_TOOLBAR),TB_SAVERESTORE, TRUE, (LPARAM)&tbSave);
}
return TRUE;
}
}
break;
|
|
|
|
|
We have a huge C++ code, developed on Microsoft Visual Studio 6.0. This contains but server and client code. Now the requirement is to add a support for memory leak detection.
So can any one help me to code, which should check the existing whole code base for memory leaks.
Thanks,
Nandu
|
|
|
|
|
|
Thanks, But the above mentioned will not support VS6.0, I need a similar solution for VS 6.0
-Nandu
|
|
|
|
|
See Visual Leak Detector [^].
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Help me with these program
/* program to illustrte read function with pointer */
//this program may not work properly because of memory problems in read
#include<stdlib.h>
#include<stdio.h>
#include<unistd.h>
#include<string.h>
int main()
{
char *buf,c;
int nread;
memset(buf,0,0);
buf=malloc(1024);
nread=read(0,&buf,100);
printf("characters read: %d\n",nread);
if(nread == -1)
{
write(2,"An error occured in read function\n",27);
}
else
{
if(nread==0)
write(2,"Data is not written to the filedescriptor\n",27);
else
write(1,&buf,nread);
}
free(buf);
}
output:
sandeep@sandeep $ ./a.out <x
characters read: 75
this is Kead program
which is throwing lots of errore
lets correct them
Segmentation fault
|
|
|
|
|
sandeep_dhruwa wrote: char *buf,c;
int nread;
memset(buf,0,0);
buf=malloc(1024);
You have to call malloc before calling memset. Otherwise, you will try to write into an invalid pointer.
|
|
|
|
|
still I am getting the error
|
|
|
|
|
And for the read and write functions, don't pass the address of your buffer variable: it is already a pointer. Pass the pointer directly:
read(...,buffer,...);
(apply that for every read and write).
|
|
|
|
|
thanks it solved
thankyou
|
|
|
|
|
sandeep_dhruwa wrote: nread=read(0,&buf,100);
sandeep_dhruwa wrote: write(1,&buf,nread);
You should use buf , not &buf .
For instance
nread = read(0, buf, 100);
BTW your code is a mess, you really need a good C tutorial.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
class CA{
private:
int m_Var;
public:
CA(int x=0): m_Var(x){cout<<"1";}
bool operator < (const CA &obj2) { cout<<"2"; return (m_Var < obj2.m_Var) ? true : false;}
};
int main(void) {
CA obj1=2;
if(obj1 < 3){cout << "In If block" << endl;}
}
the output of this code is 112In If block .. i can understand the reason behind the first 1 and "2In If block" .. i dont understand when the second 1 is being called?
as per my understanding when (obj1<3) executes it may call obj1.operator<(3)
But constructor is being called but whats makes it to call?
kindly explain why the second 1 is being displayed?
|
|
|
|
|
Member 3974347 wrote: as per my understanding when (obj1<3) executes it may call obj1.operator<(3)
Not actually. It is actually called like
obj1.operator<( CA(3));// A local temporary object is created here.
Here the integer 3 is automatically converted to a CA object by involking the constructor. Such conversions are called implicit conversions. You can prevent such conversions using the explicit keyword[^]
|
|
|
|
|
You are so fast!
|
|
|
|
|
Well, I borrowed some monkeys[^] from Rajesh.
|
|
|
|
|
Thanks.
|
|
|
|
|
Member 3974347 wrote: But constructor is being called but whats makes it to call?
Because constructor accepts a int .
Member 3974347 wrote: as per my understanding when (obj1<3) executes it may call obj1.operator<(3)
Your operator overload accepts const CA & but you specified the expression obj1<3 , since type CA has a constructor which takes int, a temporary will be created by passing 3 to the constructor of CA and this is the reason for the second time constructor call.
Use explicit keyword to avoid the confusion.
|
|
|
|
|
Thanks
|
|
|
|
|
in turbo c on executing the program i get linked error and undefined symbol even for predefined functions like rectangle line etc... even the example programs given encounter the same problem..
please help
vicky
|
|
|
|
|
vigneshvdm wrote: in turbo c on executing the program i get linked error and
undefined symbol even for predefined functions like rectangle line
These cannot happen when you execute your program. Can happen, however when you try to compile your sources.
vigneshvdm wrote: undefined symbol
You probably forget to include graphics.h that is required to compile when using graphic functions and data structures.
vigneshvdm wrote: i get linked error
You got linker error because you probably forget to link with graphics.lib .
See, for instance [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Dear all,
I have two lan cards.
So I have two ip address, too.
When I connect to server, how to get ip address of connected socket (clinet side NOT server side).
I could get ip address list of desktop using 'gethostbyname()'
But I didn't figure what ip address is current ip(lan card)
Do you have any solution?
Thanks.
cozyu
|
|
|
|
|
|
Hi there how are u am fine and then to the point am a fresh student in some university and i have an assignment in modular c programing that work arijister of university the fuction must contain the student's nam, id number,nationality,father's name,occopation bed number.And am not any acces to do these am search many sits but am not get much for my problem pleas help me download the answer as you can and am went to say you do not worry about my grammer it is not my mother tounghthank you.
|
|
|
|
|
seiyfu yesuf wrote: pleas help me download the answer
The answer to what? You haven't asked a question...
I'm assuming you haven't been given this project in the first week of your course, so you must have learned some programming before this. What have you done to make a start on it? What have you done in the way of system design? In programming?
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
Do your assignment yourself.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|