|
Hi,
I'm sending queries to many game servers via UDP in a for -loop. But in the receive function there seems to be a problem:
void CMainFrame::OnReceiveUDP()
{
SOCKADDR_IN fromAddr;
int fromSize = sizeof(fromAddr);
TCHAR pkt[PACKETLEN];
int respStringLen = m_sSocket.ReceiveFrom(pkt, PACKETLEN-1, (SOCKADDR*)&fromAddr, &fromSize, 0);
if(respStringLen == SOCKET_ERROR)
{
CString string;
string.Format("CUDPSocket::ReceiveFrom() failed\nReason: %i", GetLastError());
MessageBox(string, "Error", MB_OK|MB_ICONSTOP);
return;
}
else
{
CListView* pView = (CListView*)GetActiveView();
CListCtrl &list = pView->GetListCtrl();
list.InsertItem(idx, pkt);
idx++;
}
}
But after about 30 servers I only have garbage characters in the variable pkt , although the servers send normal packets. How can this happen?
thanks in advance
Greg
modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
for(int i=0; i<servercount; i++)
{
CServer server = arServers.GetAt(i);
if (m_sSocket.SendTo("\\status\\", 8, server.QueryPort, server.IP, 0) != 8)
{
}
}
arServers is an CArray of servers
I know this code is crappy, but I don't know how to make it better.
reagrds
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi !!
I started with VC6 a simple console application. The project is emtpy, I just have an empty main() and and include of stdafx.h.
Now, I'd like to use some functions of the Win32 API (ShellExecuteEx for instance), but I have no idea which headers I have to include. I checked in the msdn but didn't find anything.
When I try to compile, even basic windows types like DWORD are not declared.
Does anyone could tell me where, for each Win32 functions, I can find exactly which lib and which header file I have to add to my project ?
Thanks !
Jerome
|
|
|
|
|
If you have VC++6 or a recent-ish Platform SDK, there is a WIN32API.CSV file which tells you exactly this in the LIB directory.
Normally, you would start with <windows.h>, optionally defining stuff like WIN32_LEAN_AND_MEAN to remove stuff. There are lots of other defines you can do to suppress the inclusion/definition of various Win32 subsystems.
Steve S
[This signature space available for rent]
|
|
|
|
|
Launch VC6, and use the Win32 application classwizard to create a project with all the things that you need. It includes windows.h in stdafx.h
She's so dirty, she threw a boomerang and it wouldn't even come back.
|
|
|
|
|
If you look at the MSDN and find the ShellExecuteEx function you will have this on the botom of the page (this is a very usefull piece of information)
Function Information
Stock Implementation shell32.dll version 4.00 or later
Custom Implementation No
Header shellapi.h
Import library shell32.lib
Minimum operating systems Windows NT 4.0, Windows 95
Casa.Sapo.pt
|
|
|
|
|
Thank you for your informations !
This is something I never understood with my MSDN. For plenty of function, I get the useful informations you mentionned in your post, but for the ShellExecuteEx, and for some others, I don't get the usual layout of functions description. What I get is a page called 'Internet Tools & Technologies', without these useful informations I was looking for !
Anyway, thanks again for your help !
Jerome
|
|
|
|
|
I have a CString which I pass into:
m_editExerciseName.GetWindowText(m_ExerciseName);
However MSDN says
void GetWindowText( CString& rString ) const;
Its & rString the & that is bothering me> How should I change my GetWindowText statement so that a & goes in?
I declared m_ExerciseName as a plain old CString.
Appreciate your help,
ns
|
|
|
|
|
Your code as it shows should compile and run OK. Do a search for "references" on any C++ tutorial to know more about the & character.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Good to know. I guess I am off to look into & now.
Appreciate your help,
ns
|
|
|
|
|
void GetWindowText( CString& rString ) const; implies that the function it self will not change any data that belongs to the CWindow class. Your code will work fine.
|
|
|
|
|
I would like to catch user changes on a combo, but only once he is finished typing. How could I do that?
NOTE: CBN_EDITCHANGE don't work. In fact, it is called every time the user types something in the edit, and CBN_SELCHANGED is only called when the user selects an item in the list.
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
Try catching the killfocus event of the combobox -- when the cursor leaves the control, you can assume they're done with it.
"If at any time I announce that a nation or kingdom is to be uprooted, torn down and destroyed, and if that nation I warned repents of its evil, then I will relent and not inflict on it the disaster I had planned. And if at another time I announce that a nation or kingdom is to be built up and planted, and if it does evil in my sight and does not obey me, then I will reconsider the good I had intended to do for it." -- Jeremiah 18:7-10 (God, commenting on the value of the United Nations)
|
|
|
|
|
Consider CBN_DROPDOWN event handler.
Kuphryn
|
|
|
|
|
My CDialog has two editboxes. I want the Enter key to tab from one box to the other. How would I do this?
Appreciate your help,
ns
|
|
|
|
|
Override the BOOL CMyXxx::PreTranslateMessage(MSG* pMsg) handler and then try something like:
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN)
{
if(pMsg->hWnd == m_edit1.GetSafeHwnd())
m_edit2.SetFocus();
else if(pMsg->hWnd == m_edit2.GetSafeHwnd())
m_edit1.SetFocus();
return CXxxx::PreTranslateMessage(pMsg);
}
"If at any time I announce that a nation or kingdom is to be uprooted, torn down and destroyed, and if that nation I warned repents of its evil, then I will relent and not inflict on it the disaster I had planned. And if at another time I announce that a nation or kingdom is to be built up and planted, and if it does evil in my sight and does not obey me, then I will reconsider the good I had intended to do for it." -- Jeremiah 18:7-10 (God, commenting on the value of the United Nations)
|
|
|
|
|
So thats how its done! MAny thanks.
Appreciate your help,
ns
|
|
|
|
|
I get this warning:
C:\DbInput.cpp(72) : warning C4715: 'CDbInput::PreTranslateMessage' : not all control paths return a value for the code you gave me above> how can I fix this warning?
Appreciate your help,
ns
|
|
|
|
|
This is even easier:
BOOL CYourClass::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN)
{
CWnd *pWnd = GetFocus() ;
CButton *pButton = static_cast<CButton*>(pWnd) ;
if (pButton == NULL)
pMsg->wParam = VK_TAB ;
}
return CDialog::PreTranslateMessage(pMsg);
}
Roger Allen
Sonork 100.10016
I think I need a new quote, I am on the prowl, so look out for a soft cute furry looking animal, which is really a Hippo in disguise. Its probably me.
|
|
|
|
|
Hi !
I am using MSFlexGrid on one of my dialogs. When I run the program on my PC it runs OK, but when I run it on a PC that does not have the developer studio on it it will crash with :
Debug assertion fail on "winocc.cpp line 301"
When I went to this file, this is the function it runs
BOOL CWnd::ShowWindow(int nCmdShow)<br />
{<br />
ASSERT(::IsWindow(m_hWnd));<----This is line 301<br />
<br />
if (m_pCtrlSite == NULL)<br />
return ::ShowWindow(m_hWnd, nCmdShow);<br />
else<br />
return m_pCtrlSite->ShowWindow(nCmdShow);<br />
}
I tried to copy the msflxgrd.ocx file to this PC and still no help.
To active the window with the flex grid, I use from the main dialog this sequance:
ctst *y=new ctst;<br />
y->Create(IDD_DIALOG1,this);<br />
y->ShowWindow(SW_SHOWNORMAL);
So aperantly it fails on the ShowWindow,
But why ???????????????????//
|
|
|
|
|
Did you register the ocx ?
Signature space for rent. Apply by email to....
|
|
|
|
|
Some controls bundled with Visual Studio, though redistributable, still require a runtime license (and MSFlexGrid.ocx is one of them). I encountered a similar problem before I used the IClassFactory2 interface to request a runtime license for the FlexGrid. Look into this. If you need some help with the coding of this let me know.
The following link might help you get started:
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q151771
Adam
Adam Gardner
|
|
|
|
|
Thank you for the answer.
I decided not to take the risk, since my code is going to be distributed over few different Windows platforms. I will try to use the ListCtrl as much as I can.
Shay
|
|
|
|
|
I'm having the same problem as I'm using the flexgrid control. I've looked up your link and requested the license but now I'm not sure how to implment it. I've read something about having to embed it into the executable but how/where? Do, I have to override GetLicenseKey() or some other function in the flex grid control?
If you have some code on how to do this, I would really appreciate it. Thanks.
|
|
|
|