|
Two suggestions:
- create a socket only once and call Close();Connect() in your OnConnectButton() method. I am using my own network class, but I think to remember that am instance of CAsyncSocket needs to be closed before it can be reopened again.
- consider making your reconnect logic timer driven, e.g. allow only delayed reconnects and set a top limit for number of reconnects per hour. Best is to work out a reconnect policy, something like reconnect only if the server was at least identified once in current session, etc. This will prevent harming the network with reconnects going berzerk.
Hope it helps.
|
|
|
|
|
I have added a picture control in my dialog. While moving mouse over the picture I want to change the control style to "ModalFrame". In Classwizard I could see only WM_CLICK message for this control. So I want ot know, How to enable mouse move message handling function for the picture control?
Vel
|
|
|
|
|
To receive notifications static controls must have the style...
SS_NOTIFY
Change the ID of the static control from IDC_STATIC to something else.
Nibu thomas
Software Developer
|
|
|
|
|
Hi
Is Gdiplus image will take any image as color image. Please help me.
thanks in advance
|
|
|
|
|
Hello all,
I have a LogIn Form which should close and destroy itself upon verification of password and username.
How can I link the text inputed to be verified from an Access file?.
Also,I want the logIn form to be closed and load a diferent Form (Not CDialog form). Any help is highly appreciated. Tks
---------------------------------------------------------
new to Visual C++, bt we gonna make it catch-a-fi-er
|
|
|
|
|
My friend was going through an interview the other day, and he came up with a interview question: find at lease 8 problems out of the following code snippet.
#define max (1*1024*1024)
int main()
{
char *f;
char tmp[max];
int i,j;
f = "In the second season, the show's writers introduce numerous new storylines for";
for(i=0;i<=max;i++)
{
if(f[i]='\n')
{
tmp[j++]=f[i];
tmp[j]=0;
printf(tmp);
j=0;
}
else
{
tmp[j++]=f[i];
}
}
return 0;
}
when I trying to debug, I was confronted with "stack overflow" initially, I wonder what's wrong with 'f'
all the comments are my answers, but it doesn't anywhere near to 8 problems, so what do you think where the other problems lie and why.
-- modified at 9:16 Tuesday 14th March, 2006
|
|
|
|
|
1. Should be char *f = "In the second season, the show\'s writers introduce numerous new storylines for"; . Initialize f immediately.
2. Note the escaped single quote in the string constant.
3. The for statement is commented out. The statements inside the braces are executed once.
4. for(i=0;i<=max;i++) will overflow the bounds of the tmp string.
5. for(i=0;i<=max;i++) may overflow the bounds of the f string. Would be better to use
i = 0;
while (f[i]) {
6. if(f='\n') : assignment within an if condition.
7. tmp[j++] : j is never initialized.
Software Zen: delete this;
|
|
|
|
|
Gary R. Wheeler wrote: The for statement is commented out. The statements inside the braces are executed once.
really ?
~RaGE();
|
|
|
|
|
He's updated the post. The original one had the for statement commented out.
Software Zen: delete this;
|
|
|
|
|
LiYS wrote: f = "In the second season, the show's writers introduce numerous new storylines for";
better use a strcpy in this case, such an assignment cannot work.
~RaGE();
|
|
|
|
|
Actually, it does. f is defined as char *f , so assigning a constant string is perfectly valid. strcpy(f,...) would work only if you had allocated memory to f previously in the code.
Software Zen: delete this;
|
|
|
|
|
8. The line tmp[j++]=f[i]; is in both branches of the if , so you might as well move it above the if .
Software Zen: delete this;
|
|
|
|
|
Gary R. Wheeler wrote: The line tmp[j++]=f[i];
sorry, I don't see any problem with that. or if you could be more specific.
|
|
|
|
|
It's not so much an error, as it's redundant. Since the same line appears in both branches of the if statement, it doesn't depend upon the condition. You should move the statement above the if in this case.
Software Zen: delete this;
|
|
|
|
|
In addition to what has already been mentioned:
max is not declared.
Missing <stdio.h> .
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: max is not declared.
Sorry!I forgot to add the original
#define max (1*1024*1024)
DavidCrow wrote: Missing <stdio.h>
It counts, Thanks!
-- modified at 9:15 Tuesday 14th March, 2006
|
|
|
|
|
LiYS wrote: char tmp[max];
worst thing to do , i.e. allocating 1mb of memory on the stack. That is why it overflowed.
-Prakash
|
|
|
|
|
BOOL CPerformanceGraph::ReadFromFile()
{
CFile fp;
CPtrList tempList;
CString szFileName= "c:\\PerfGraph.txt";
if(!fp.Open(szFileName,CFile::modeRead))
{
MessageBox( "Unable to open file for Performance Graph Configuration");
return FALSE;
}
pGraphList.RemoveAll();
CPerfGraph *oPerfGraph = new CPerfGraph();
while(fp.Read( oPerfGraph, sizeof( class CPerfGraph )))
{
//for checking
int n;
n=oPerfGraph->No_of_Points;
char temp[10];
strcpy(temp,oPerfGraph->Id);
strcpy(temp,oPerfGraph->TagX);
//end of checking
tempList.AddTail(oPerfGraph);
}
POSITION Pos = tempList.GetHeadPosition();
while(Pos)
{
CPerfGraph *oTemp=(CPerfGraph *)tempList.GetAt(Pos); //for checking
CString mTagX = oTemp->TagX;
CString mTagY = oTemp->TagY;
//end of checking
tempList.GetNext(Pos);
}
fp.Close();
return TRUE;
}
This is my coding...Im reading datas from File and put it into CPtrList.But It doesn't get adding properly.
I have two set of values as graph1 and graph 2.
But it adds only the last Graph2 value.
How can i get the Graph 1 value.
I think im using the correct way to add the file data in to List.
Kindly give me solution...
|
|
|
|
|
BOOL CPerformanceGraph::ReadFromFile()
{
CFile fp;
CPtrList tempList;
CString szFileName= "c:\\PerfGraph.txt";
if(!fp.Open(szFileName,CFile::modeRead))
{
MessageBox( "Unable to open file for Performance Graph Configuration");
return FALSE;
}
pGraphList.RemoveAll();
CPerfGraph *oPerfGraph = new CPerfGraph();
while(fp.Read( oPerfGraph, sizeof( class CPerfGraph )))
{
int n;
n=oPerfGraph->No_of_Points;
char temp[10];
strcpy(temp,oPerfGraph->Id);
strcpy(temp,oPerfGraph->TagX);
tempList.AddTail(oPerfGraph);
oPerfGraph = new CPerfGraph();
}
if (oPerfGraph != NULL) delete OPerfGraph;
POSITION Pos = tempList.GetHeadPosition();
while(Pos)
{
CPerfGraph *oTemp=(CPerfGraph *)tempList.GetNext(Pos);
CString mTagX = oTemp->TagX;
CString mTagY = oTemp->TagY;
}
fp.Close();
return TRUE;
} Check out the two bold lines of code. After you add an entry to the list, you need to allocate a new one for the next entry. The second line, outside the read loop, deletes the last entry. The loop terminates on a failed read, which means the last allocated entry isn't needed. Minor style note when using the CPtrList class: the GetNext function retrieve the entry in the list at the position value, and advances the position value, in one step.
Software Zen: delete this;
|
|
|
|
|
Anu_Bala wrote: CPerfGraph *oPerfGraph = new CPerfGraph();
This will need to be inside of the while loop.
Anu_Bala wrote: strcpy(temp,oPerfGraph->Id);
strcpy(temp,oPerfGraph->TagX);
The second call to strcpy() will overwrite the first. Perhaps you meant to use strcat() instead.
Anu_Bala wrote: fp.Close();
It's a good idea to close the file as soon as you are done with it.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Hi All,
I need to implement Drag and drop of files between my namespace extension and windows desktop folders. When the user drags a file from a desktop folder and drops it on a folder in my namespace, I need to show the user a dialog box for user I/P. On the drop event when I do DoModal(), the dialog box just appears momentarily and disappears.
Can anyone please indicate where the problem could be?
Thanks and Regards,
Anil
-- modified at 7:10 Tuesday 14th March, 2006
|
|
|
|
|
A drag-drop operation is run by a modal message loop (possibly cross-process) inside OLE32. I imagine that trying to start another modal UI loop is causing the problem.
In your OnDrop() handler, collect whatever data is necessary and store it somewhere. Post yourself a window message and do your UI in the message handler.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Hi Michael,
I tried this approach.... but its crashing there too.
Any other suggestions?
Thanks and Regards,
Anil
|
|
|
|
|
i am using SQL Server.
may i know how to acess data base In LAN?
can i acess data base from a public IP of remote system?
if so how to do?
thanks in advance.
JAYARAJ
|
|
|
|
|
In MFC wizard I have created a dialog form with two EditBoxs(IDC_EDIT1 and IDC_EDIT2). m_var1 and m_var2 are type unsigned integer. The type of the two edit boxes are of unsigned integer data type . The names of the member variables are m_var1 and m_var2. Their is a Button on the Dialog form
Kindly observe the code given
void CMFC_7Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
UINT abc = m_var1;
m_var2 = abc;
UpdateData(FALSE);
}
the problem is that when click the button1, the value entered in IDC_EDIT1 is not assigned to the temporary variable abc. When I debug the code, the value assigned to abc is zero. For example if enter a unsigned value 23 , the value is not assinged to the variable abc.
Kindly observe the code which is given below
void CMFC_7Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_var2 = m_var1;
UpdateData(TRUE);
}
In the above code, the value enter in IDC_EDIT1 is not transferred to IDC_EDIT2 even though m_var1 and m_var2 are both unsigned integer data type.
Kindly observe the code which is given below
void CMFC_7Dlg::OnButton1()
{
m_var2 = m_var1;
}
In the above given code, the direct assinged of m_var1 to m_var2 is not possible. When I debug the program , only zero is assinged to m_var2.
My question is why the value enter the IDC_EDIT1 is not shown in IDC_EDIT2?
Can any one please help me in this matter.
-- modified at 6:01 Tuesday 14th March, 2006
|
|
|
|