|
|
Hi geeks... I mean guys guys...
I need to use a very large integer that does not fit in a long. So I attempted using _int64 and the values are at least stored in the declared variable. However if I try to send it to the screen, it gives me this compiler error...
error C2593: 'operator <<' is ambiguous
Can anyone give me a simple explanation and solution? Is there any other place I need to be aware of where I'll run into trouble if using this data type?
Thanks a bunch!!!
|
|
|
|
|
knapak wrote:
error C2593: 'operator <<' is ambiguous
operator << is not defined for __int64. Therefore it has to try and cast it to something else ( which is plainly not going to work BTW ), and it can't decide what it should cast it to, hence the operator is ambiguous. You probably have to define your own operator <<, and I guess then any other STL operation you try to do, that is type specific.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hello,
The __int64 is not supported by the standard, but it is rather compiler specific. The C standard has support for a 64 bit integer: long long . See here[^] for more information.
You always can write the number in hexadecimal in two steps: first write the upper 32 bits and then the lower 32 bits.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Hello all.
As an assignment, I'm trying to design front end for a database prepared in Ms Access using Visual C++. I'm using ODBC.
I'm designing an SDI Application with Multiple Views. The parent view is "Employee" and the child view is details about "core Staff members", if an employee is a Core staff member, clicking the button for "Core Staff" takes you to another view, with details regarding the employee. This child view has a button which takes you back to the parent view, say "Employee View".
Now, the problem is that when I click the "Core Staff" button, I get the new view if the current employee is a core staff member, but the problem is that the new view is "un-clickable" I cant click anything, If I try clicking something the window freezes on me. I can however navigate through the fields using the tab key, or the short cut keys. However, when I select the "EMployee View" button and press enter, I get the message for Invalid View ID, which is supposed to be displayed if the "View doesnt exist".
Here's the code for the "SelectView" function in the CMainFrame class.
[code]
void CMainFrame::SelectView(UINT ViewID)
{
CView* pOldActiveView = GetActiveView();
CView* pNewActiveView = (CView*)GetDlgItem(ViewID);
if(pNewActiveView == NULL)
{
switch(ViewID)
{
case CORE_VIEW:
pNewActiveView = (CView*)new CCoreView;
break;
default:
AfxMessageBox("Invalid View ID");
return;
}
CCreateContext context;
context.m_pCurrentDoc = pOldActiveView->GetDocument();
pNewActiveView->Create(NULL, NULL, 0L, CFrameWnd::rectDefault,this,ViewID,&context);
pNewActiveView->OnInitialUpdate();
}
if(ViewID == CORE_VIEW && ! ((CCoreView*)pNewActiveView)->IsCore())
{
AfxMessageBox("Current Employee is not a Core Staff Member");
return;
}
SetActiveView(pNewActiveView);
pOldActiveView->ShowWindow(SW_HIDE);
pNewActiveView->ShowWindow(SW_SHOW);
pOldActiveView->SetDlgCtrlID(m_CurrentViewID);
pNewActiveView->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
m_CurrentViewID = ViewID;
RecalcLayout();
}
[/code]
The code for the Button on the "Employee View" is:
[code]
((CMainFrame*)GetParentFrame())->SelectView(CORE_VIEW);
[/code]
Similarly, the code for the button on the "Core VIew" is:
[code]
((CMainFrame*)GetParentFrame())->SelectView(EMPLOYEE_VIEW);
[/code]
I'm following "Ivor Horton's" "Beginning Visual C++6". Since, the "Parent View" alread exists, GetDlgItem() should return the address of the view, otherwise return Null.
I dont know whats wrong here.
Can anyone please help?
Thanks
and here are the screenies.
EMPLOYEE VIEW
[img]http://img196.imageshack.us/img196/282/employee9ps.jpg[/img]
CORE VIEW
[img]http://img211.imageshack.us/img211/7392/core5nq.jpg[/img]
Thanks again.
|
|
|
|
|
Say i have a client and server. Server listening at 10.10.10.10 on port 4000. Client connects from 11.11.11.11. Server sends back a message saying:
"You are connected from <ip> on port <port>"
Where having the server use GetPeerName would give the proper ip of 11.11.11.11, but the port will be some other number other than 4000 in my case. So the message to the client would say something like:
"You are connected from 11.11.11.11 on port 3000"
Should GetPeerName be returning 4000 as the port? Or is the port of the client just a random one?
|
|
|
|
|
Type: netstat -n
GetPeerName will return the "remote address" column (only a single item of course).
Don't try it, just do it!
|
|
|
|
|
Ok thanks. The client port is just a random one. I get it now.
|
|
|
|
|
I am starting a project soon and the contact wants to control the record volume settings from within the application. Is there a way to do this with sndvol32 or some other way without using DirectX? He is concerned about file size, that's why he doesn't wish to use DirectX. Thanks.
Bill Dennis
Orlando, FL
|
|
|
|
|
billiam904 wrote:
He is concerned about file size
Using DirectX does not create big binaries at all!
By the way: DirectX does adjust the volume of a single buffer, but not the volume of the system. You can use waveOutSetVolume to set the output volume.
Don't try it, just do it!
|
|
|
|
|
what would i use to set the Line In record level?
Bill Dennis
Orlando, FL
|
|
|
|
|
mixerSetControlDetails
Don't try it, just do it!
|
|
|
|
|
Hi,
I am quite new to vc++. I am doing a project in win32. I want to set timeout value for a while loop. I am checking a condition in a while loop. If that condition is not satisfied at all, instead of looping forever I want to set timeout value like 300 msec then exit the while loop. I want to do this with CreateEvent() and waitforsingleobject(), but I dont know how to do it exactly.
Can someone help me with sample code???
Thanks a lot.
|
|
|
|
|
You can't create an easy timeout loop that way. What kind of code is running in the loop? There are normally better ways.
Don't try it, just do it!
|
|
|
|
|
Actually inside the while loop I am reading or writing to a usb device using our library apis...what are the other ways doing it better.
|
|
|
|
|
Use completion routines and kinda timeout thread, that makes it easier.
Don't try it, just do it!
|
|
|
|
|
HANDLE hEvent = CreateEvent( NULL, TRUE, FALSE, NULL );<br />
<br />
while ( looping )<br />
{<br />
if( WaitForSingleObject( hEvent, 300 ) == WAIT_TIMEOUT )<br />
{<br />
}<br />
else<br />
{<br />
}<br />
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
That does not work because when there are more than 1 loop the timeout will be 300ms FOR EVERY LOOP, and not for the whole loop.
Don't try it, just do it!
|
|
|
|
|
Where was it mentioned that multiple loops were involved?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I don't know if this is a good way to do it but you could try something like:
DWORD t = GetTickCount();
while (1)
{
if ((GetTickCount() - t) > 300)
break;
}
|
|
|
|
|
Hi
I am using the library I found here:
http://www.codeproject.com/system/serial.asp
in my program. However, I run into the following problem when I am reading from a comport. (example listener).
I took the code, and created a little function
int readme(CSerial &serial)<br />
{<br />
LONG lLastError = ERROR_SUCCESS;<br />
lLastError = serial.SetMask(CSerial::EEventBreak |<br />
CSerial::EEventCTS |<br />
CSerial::EEventDSR |<br />
CSerial::EEventError |<br />
CSerial::EEventRing |<br />
CSerial::EEventRLSD |<br />
CSerial::EEventRecv);<br />
if (lLastError != ERROR_SUCCESS)<br />
return ::ShowError(serial.GetLastError(), _T("Unable to set COM-port event mask"));<br />
<br />
lLastError = serial.SetupReadTimeouts(CSerial::EReadTimeoutNonblocking);<br />
if (lLastError != ERROR_SUCCESS)<br />
return ::ShowError(serial.GetLastError(), _T("Unable to set COM-port read timeout."));<br />
<br />
bool fContinue = true;<br />
do<br />
{<br />
lLastError = serial.WaitEvent();<br />
if (lLastError != ERROR_SUCCESS)<br />
return ::ShowError(serial.GetLastError(), _T("Unable to wait for a COM-port event."));<br />
<br />
const CSerial::EEvent eEvent = serial.GetEventType();<br />
<br />
if (eEvent & CSerial::EEventBreak)<br />
{<br />
printf("\n### BREAK received ###\n");<br />
}<br />
<br />
if (eEvent & CSerial::EEventCTS)<br />
{<br />
printf("\n### Clear to send %s ###\n", serial.GetCTS()?"on":"off");<br />
}<br />
<br />
if (eEvent & CSerial::EEventDSR)<br />
{<br />
printf("\n### Data set ready %s ###\n", serial.GetDSR()?"on":"off");<br />
}<br />
<br />
if (eEvent & CSerial::EEventError)<br />
{<br />
printf("\n### ERROR: ");<br />
switch (serial.GetError())<br />
{<br />
case CSerial::EErrorBreak: printf("Break condition"); break;<br />
case CSerial::EErrorFrame: printf("Framing error"); break;<br />
case CSerial::EErrorIOE: printf("IO device error"); break;<br />
case CSerial::EErrorMode: printf("Unsupported mode"); break;<br />
case CSerial::EErrorOverrun: printf("Buffer overrun"); break;<br />
case CSerial::EErrorRxOver: printf("Input buffer overflow"); break;<br />
case CSerial::EErrorParity: printf("Input parity error"); break;<br />
case CSerial::EErrorTxFull: printf("Output buffer full"); break;<br />
default: printf("Unknown"); break;<br />
}<br />
printf(" ###\n");<br />
}<br />
<br />
if (eEvent & CSerial::EEventRing)<br />
{<br />
printf("\n### RING ###\n");<br />
}<br />
<br />
if (eEvent & CSerial::EEventRLSD)<br />
{<br />
printf("\n### RLSD/CD %s ###\n", serial.GetRLSD()?"on":"off");<br />
}<br />
<br />
if (eEvent & CSerial::EEventRecv)<br />
{<br />
DWORD dwBytesRead = 0;<br />
char szBuffer[101];<br />
do<br />
{<br />
lLastError = serial.Read(szBuffer,sizeof(szBuffer)-1,&dwBytesRead);<br />
if (lLastError != ERROR_SUCCESS)<br />
return ::ShowError(serial.GetLastError(), _T("Unable to read from COM-port."));<br />
<br />
if (dwBytesRead > 0)<br />
{<br />
szBuffer[dwBytesRead] = '\0';<br />
<br />
printf("%s|", szBuffer);<br />
<br />
if (strchr(szBuffer,EOF_Char))<br />
fContinue = false;<br />
}<br />
}<br />
while (dwBytesRead == sizeof(szBuffer)-1);<br />
}<br />
}<br />
while (fContinue);<br />
serial.Close();<br />
lLastError = serial.Open(_T("COM1"),0,0,false);<br />
if (lLastError != ERROR_SUCCESS)<br />
return ::ShowError(serial.GetLastError(), _T("Unable to open COM-port"));<br />
<br />
lLastError = serial.Setup(CSerial::EBaud38400,CSerial::EData8,CSerial::EParNone,CSerial::EStop1);<br />
if (lLastError != ERROR_SUCCESS)<br />
return ::ShowError(serial.GetLastError(), _T("Unable to set COM-port setting"));<br />
return 0;<br />
}
then, what I do is following:
int __cdecl _tmain (int , char** )<br />
{<br />
CSerial serial;<br />
LONG lLastError = ERROR_SUCCESS;<br />
<br />
lLastError = serial.Open(_T("COM1"),0,0,false);<br />
if (lLastError != ERROR_SUCCESS)<br />
return ::ShowError(serial.GetLastError(), _T("Unable to open COM-port"));<br />
<br />
lLastError = serial.Setup(CSerial::EBaud38400,CSerial::EData8,CSerial::EParNone,CSerial::EStop1);<br />
if (lLastError != ERROR_SUCCESS)<br />
return ::ShowError(serial.GetLastError(), _T("Unable to set COM-port setting"));<br />
<br />
<br />
<br />
<br />
lLastError = serial.Write("\nwhoami\n");<br />
int r;<br />
<br />
if (lLastError != ERROR_SUCCESS)<br />
return ::ShowError(serial.GetLastError(), _T("Error sending a return"));<br />
lLastError = serial.Write("\nwhoami\n");<br />
<br />
r = readme(serial);<br />
if (lLastError != ERROR_SUCCESS)<br />
return ::ShowError(serial.GetLastError(), _T("Error sending a return"));<br />
<br />
<br />
if (lLastError != ERROR_SUCCESS)<br />
return ::ShowError(serial.GetLastError(), _T("Error sending a return"));<br />
<br />
serial.Close();<br />
return 0;<br />
}
ok when the first is commented out, I see the results of both functions. but when the first readme is there, it only reads up to that point, and goes no further.
why is that so? I would like to read information step by step, as it needs to processed.
thanks alot for any help
quarry
|
|
|
|
|
Hello,
Put the caret next to that line and than hit "run to cursor" in your Debug menu. Second step in your code and see where your code hangs and post more specific information on your problem. Until then, most people here will not bother to look at your post with so much code.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
hey thanks for the answer
if (strchr(szBuffer,EOF_Char))<br />
fContinue = false;
I think the problem is, that this never happens.
so it gets stuck in this while loop, where there is a function
lLastError = serial.WaitEvent();
but nothing happens here neither. how can interupt this loop?
thanks
|
|
|
|
|
Hello,
I think your problem is that you wait forever for an event. So I guess that no event arrives on your COM port and that you are stuck in the WaitEvent() function.
See if this helps:
lLastError = serial.WaitEvent(NULL , 100 );
if( lLastError == ERROR_TIMEOUT )
{
}
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Hi All,
Ive got a project which was developed in Visual C++ version 6.0.
Now Ive got to make it access a web service to get data from a database...
First of all im COMPLETELY ignorant on these matters, but i suppose we've all got to take the plunge sometime...
I know that in the Visual Studio .NET version there are some tools to "automatically" generate the volumes of code required to do the web service method accessing stuff, but I dont want to change to .NET just to do this little thing!
Is there a simple generalized web service accessing API which wraps all the crap required to access a web service into a few simple routines?
Ive been looking around the net but im not convinced that Ive found the perfect solution.
Thanks in advance for any pointers,
Dave
|
|
|
|
|