|
See Cedric's detailed explanations[^].
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
It's been explained to you nearly a half dozen times. What more do you require?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hey I googled for this kinda stuff but only useless stuff came up..
Anyway
char buffer[250];
send(sock, "hello?\n", 8, 0);
recv(sock, buffer, sizeof(buffer), 0);
cout << buffer << endl;
cin.get();
is my code.
Now I obviously do not know how big the buffer will be, the problem is if i set buffer[250], everything after the actual content is trash.
How would I fix that?
Like I wanna see only the actual content and not the jibberish after it.
Thanks.
e// nevermind, I just found out that recv returns the size..
modified on Tuesday, November 16, 2010 7:57 PM
|
|
|
|
|
The documentation for recv[^] shows the prototype looks something like this:
int recv(
__in SOCKET s,
__out char *buf,
__in int len,
__in int flags
);
It describes the return value like this:
If no error occurs, recv returns the number of bytes received and the buffer pointed to by the buf parameter will contain this data received. If the connection has been gracefully closed, the return value is zero.
Otherwise, a value of SOCKET_ERROR is returned, and a specific error code can be retrieved by calling WSAGetLastError.
So what you have to do is add a NULL terminator and where you add it depends on how much data you recieved:
char buffer[250];
char hello[] = "hello?\n";
send(sock, hello, sizeof(hello), 0);
int res = recv(sock, buffer, sizeof(buffer)-1, 0);
if (res != SOCKET_ERROR)
{
buffer[res] = 0;
cout << buffer << endl;
}
cin.get();
Steve
|
|
|
|
|
Well put together answer; an example to us all.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
hello guys... I have a file MyClass.cpp inwhich I declared a vector array. I then added some string data to it and want to access it in MyProjDlg.cpp. It is dialoged based app in vc6. Here it is
MyClass.cpp
-----------
using namespace std;
typedef vector<LPTSTR> StudentData;
void someFunc()
{
StudentData std;
std.push_back(stdentName);
}
MyProjDlg.cpp
-------------
extern StudentData std;
for (int i=0; i<5; i++)
listbox.AddString(std.pop_back());
it is showing 7 defferent errors....any idea whats wrong that im doing?
|
|
|
|
|
in general, you cannot access a function's local variables outside that function.
if you need a variable to be shared across functions, you can:
1. make the variable global (in general, this is poor style)
2. make it a member of the class
3. pass the variable into the function
|
|
|
|
|
You have defined StudentData with a typedef in MyClass.cpp , and then referenced it without definition in MyProjDlg.cpp . Please review the suggestions to your original question on this subject, and also read up on the use of the extern keyword.
[EDIT]Stephen Hewitt even gave you a complete solution to your problem here[^].[/EDIT]
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Richard MacCutchan wrote: Stephen Hewitt even gave you a complete solution to your problem here
thnx.....since <<_superman_>> asked me to use vectors...I did not come to this post again, eventually losing valuable information given by Stephen. thnx
|
|
|
|
|
Hi all,
please tell me how can i use Propetypage as dialog box.
i DoModal() the property page and its open but its not close by any option like OnOK,OnCancel or OnClose.
please tell me how i do this.
thanks in advance.
|
|
|
|
|
Why do you want to use a PropertyPage as a dialog box ?
It is not its purpose. Why don't you simply use a standard dialog ?
|
|
|
|
|
actully i need the same dialog as property page that is i already use,so i try
|
|
|
|
|
CPropertyPage::OnOK() will be called from CPropertySheet::OnOK(), and see here what does the default implementation of CPropertyPage::OnOk does.
CPropertyPage::OnOK
So When you are using the property page as simple dialog, call CDialog::OnOK() to get what you expect.
|
|
|
|
|
tab and esc key not working here.
|
|
|
|
|
Option is, when you are using property page as a dialog,let the messages be handled by CDialog rather than cPropertyPage. Over-ride PreTranslateMessage for this purpose.
BOOL CMyPropPage::PreTranslateMessage(MSG* pMsg)
{
return CDialog::PreTranslateMessage(pMsg);
}
seems crazy
If you are overriding OnCancel(), call CDialog::OnCancel() to dismiss the dialog on escape key.
|
|
|
|
|
You can use a single DIALOG resource in a CDialog derived and a CPropertyPage derived class. Use the same IDD identifier.
class MyPropPage : public CPropertyPage
{
enum { IDD = IDD_MYPAGE };
};
class CMyPropPageDlg : public CDialog
{
enum { IDD = IDD_MYPAGE };
};
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
Le@rner wrote: please tell me how can i use Propetypage as dialog box.
This makes no sense. If you have a property sheet that contains one property page (i.e., tab), you effectively have a dialog box, albeit one that looks "oddly." Unless you have more than one page, just use a dialog box.
See here, here, here, and here for examples.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hi all,
i m using CListCtrl in Report View,
here i m using 5 columns and 10 rows.
in 3rd column i want to use some link or option like more,and when use this option the data of 3rd column display in new window like dialog or message box.
please tell me how can i do this.
thanks in advance.
|
|
|
|
|
|
i dont want to use web links, i m just want to display the item of this item
|
|
|
|
|
okay.. I thought that you want to show the 3rd item as a link. Thats why.
Then Code-o-mat's comment below is worthy.
handle NM_CLICK notification and use CListCtrl::SubItemHitTest() there
void CMyDlg::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
NMITEMACTIVATE* p = (NMITEMACTIVATE*)pNMHDR;
CPoint pt = p->ptAction;
LVHITTESTINFO lvhti;
lvhti.pt = p->ptAction;
m_listctrl.SubItemHitTest(&lvhti);
if (lvhti.flags & LVHT_ONITEMLABEL)
{
CString cs;
cs.Format("Clicked SubItem %d", lvhti.iSubItem);
MessageBox(cs);
}
}
|
|
|
|
|
Well, i'd say, listen to NM_CLICK notifications from send by the list, in the handler use CListCtrl::HitTest to determine if the user clicked in the third column and if yes, do your business.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world.
Fry: But this is HDTV. It's got better resolution than the real world <
|
|
|
|
|
|
Hi All,
VC++ 6, MFC, WinXP
My application's main interface consists of a FormView with a few controls – a tab control and a custom CView based control. In operation, the user *should* (yes, I know …not in the real world) click and then release the left mouse button in this view make a selection. The act of clicking starts a process and the act of releasing ends the process. Specifically, the application sends MIDI notes, similar to a piano keyboard control: MIDI note ON when the left mouse button is pressed, and MIDI note OFF when the button released. I need to send a MIDI note OFF message if the user drags out of the selection window - that would stop the note from playing when the mouse leaves the window. The idea is as long as the left mouse button is pressed, the note will play.
All works fine when the user clicks and releases in the same view but if they click, drag away, then release in a different view, the original view does not get notified and the selection remains - in other words, the note stays playing.
I’ve looked through the forums and articles and have tried a few of the suggestions but have yet not found any method to get notified immediately when the mouse leaves the active view if the left button is still down. Most of the methods have a "delayed action" before they notify the original view and only seem to trigger if the user clicks on another view - AFTER they released the left mouse initially on that non-original view. I need to find a way to get notified immediately should the mouse leave the active view when its left button is down.
Any suggestions and help would be appreciated.
Paul
|
|
|
|
|
See CWnd::SetCapture[^], this redirects all mouse messages to the given window until you either call ReleaseCapture or the mouse capture is lost because of some other event (then you get WM_MOUSECAPTURED[^] to notify you about this, you get this also when calling SetCapture/ReleaseCapture explicitly), alternatively, see TrackMouseEvent[^], maybe that better suits your needs.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world.
Fry: But this is HDTV. It's got better resolution than the real world <
|
|
|
|