|
What's your problem ? For me, this code looks fine (except that I don't know what send, recv, ... do).
Your send function needs to know how many bytes to send so you have to specify the number of bytes in your string.
Is there a problem with that?
|
|
|
|
|
The code don't have any problem. After I compile, it will show bytesrecv: 21 which is the length of the string. I don't want the length of the string to print out but is the string itself print out. how do I program it?
|
|
|
|
|
Replace:
if (bytesRecv < 0)<br />
return;<br />
printf( "Bytes Recv: %ld\n", bytesRecv );<br />
}<br />
by:
if (bytesRecv < 0)<br />
return;<br />
printf( "String Recv: %s\n", recvbuf);<br />
}<br />
|
|
|
|
|
Its work! How do I change it so that I can type on the dos and send it. The code now is when I type what I want to send in this:
char sendbuf[300] = " ";
and after I compile, it will automatically send to the server. But what I want is when I compile it, I can type on it and then send it to the server.
|
|
|
|
|
It's possible that you have a problem with this line:
bytesSent = send( m_socket, sendbuf, lstrlen(sendbuf), 0 );
Since you use the length of sendbuf, you won't transmit the terminating NULL-byte of sendbuf.
This could present a problem in the receiving end.
If you wan't the original data (a char array) in you have got two options:
1.
Send the terminating NULL-character by doing this:
bytesSent = send( m_socket, sendbuf, lstrlen(sendbuf) + 1, 0 );
2.
At the receiving end, add a '\0' in the receive buffer at offset <noofreceivedbytes>. For instance:
bytesRecv = recv( m_socket, recvbuf, 300, 0 );
recvbuf[bytesRecv] = '\0';
Else, the code looks fine to me.
|
|
|
|
|
Hi
anyone have any idea on how to insert page number into ms word doc. I have an application that creates a report, now I need to include the page number as well.
I tried HeaderFooter class and PageNumbers class but ends up with illegal operation msg. Anyone have any idea?
Thanks in advance.
Thomas
|
|
|
|
|
How to change font of caption of a MFC dialog box ??
Any idea?
Ana
Keywords
Font Caption of Dialog Box, Caption Font of Dialog Box, Dialog Box Caption Font
|
|
|
|
|
u could try the following
CFont font;
font.CreateFont(0,0,0,0,FW_NORMAL,FALSE,FALSE,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH | FF_SWISS,"MS Shell Dlg");
((CEdit*)GetDlgItem(IDC_EDIT1))->SetFont(&font);
this will change the font in that particular edit box
|
|
|
|
|
But, I want to change Font of caption (title) of dialog box ???
Ana
|
|
|
|
|
There's a child windows for which I want to record its visibility after the main program exits. But the value IsWindowVisible() in OnDestroy() returns always zero, where else can I record its visivility before it gets destroyed?
|
|
|
|
|
LiYS wrote:
But the value IsWindowVisible() in OnDestroy() returns always zero...
OnDestroy() is called after the CWnd object is removed from the screen.
LiYS wrote:
...where else can I record its visivility before it gets destroyed?
Try OnClose() .
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Respected All
I am a begginer n VC and having facing problem.I already sent such like problem but no fruitfull help comes to me, now I am going to explain a different manner ,may be helping me.
" I have to load a number of bitmaps for that I used CImageList which loaded all the bitmaps from desk but while using this class you have to fix the size of Imagelist ,but I want that i have temporary buffer like CImageList which reserve memory according to each bitmap size and no more ,,
so
--- is there customize property in CImageList in which we would not bound to fix the size if not
...Then is there any alternate method or class which will fullfill my requirment.
urgently needed plz guide me.
David
david
|
|
|
|
|
|
You can handle the LVN_ENDLABELEDIT message in the CListCtrl, and in the message handler, post a custom Windows message to the parent:
void CMyListCtrl::OnEndLabelEdit(NMHDR* pNMHDR, LRESULT* pResult)
{
...
GetParent()->SendMessage(WM_LISTWASMODIFIED);
...
}
There's a great article on custom windows messages somewhere on CodeProject. I don'w remember who wrote it, but if you google, "custom windows messages codeproject", you should find it.
Hope this helps.
-Ian
|
|
|
|
|
This message will not be sent, when i use SetItemText to change the item
text.
I want the parent to be notified when SetItemText is called, because I don't call SetItemText in CListCtrl's parent.
|
|
|
|
|
When an item is changed, the control will send a LVN_ITEMCHANGED notification to its parent.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Is there any code for seaching a pattern in a given string
example
String given for search -
HELLO THIS IS A TEST
Pattern given for search -
1 - ?ELLO
2 - *IS A
3 - THIS*
4 - *THIS*
5 - T?IS
6 - ?ELLO
7 - ??LLO
These all must return as found the pattern in string
? - For any charecter
* - Any word
|
|
|
|
|
|
Hi,
I have a VB6 application with a listview control in it. I have written an app in VC++ to
get the handle of the ListView control of the VB6 app.Then I used Jeff Ritcher's suggestion
from http://www.microsoft.com/msj/0997/win320997.aspx and according read the items from the
listview.Then I have to select the item. The problem comes here.When I select an item in the
listview, it gets selected ,but the previously selected item is still hilighted.The multiple
selection property of the listview is set to false.I have also tried to deselct the items.But
it didnot work.I am pasting the code below:
void CListtestDlg::OnButton1()
{
CString str1,str2,str3,str4="Item1";
HWND hWnd=::FindWindow ("ThunderRT6FormDC",NULL);
str1.Format ("%x",hWnd);
//::MessageBox(0,str1,"Handle1",MB_OK);
HWND hWnd1=::FindWindowEx (hWnd,NULL,"ListView20WndClass",NULL);
// HWND hWnd1=::GetWindow (hWnd,GW_CHILD);
HWND hWnd2=::FindWindowEx (hWnd,NULL,"ThunderRT6CommandButton",NULL);
str2.Format ("%x",hWnd2);
//::MessageBox(0,str2,"Handle2",MB_OK);
// BOOL hWnd2=::EnableWindow (hWnd,TRUE);
//int m=::GetDlgCtrlID (hWnd1);
/* if(hWnd2)
{
str3.Format ("%d",hWnd2);
::MessageBox (0,str3,"m",MB_OK);
}
//long c=::SendDlgItemMessage(hWnd,
*/
//::SendMessage(hWnd1,LVN_INSERTITEM,1,5);
TCHAR sz[100];
LV_ITEM lvItem;
//LPTSTR lpText=(LPVOID*)::HeapAlloc (::GetProcessHeap (),0,200);
//int x;
//x=ListView_GetCountPerPage(hWnd1);
// lvItem.mask=LVIF_TEXT;
//lvItem.pszText="Item 100";
// lvItem.iItem=0;
// lvItem.iSubItem=0;
// lvItem.pszText=sz;
//lvItem.cchTextMax= sizeof(sz);
//LRESULT lResult = ::SendMessage(hWnd1, LVM_GETITEM, 0, (LPARAM) &lvItem );
//BOOL b = ListView_GetItem(hWnd1,&lvItem);
TCHAR* szText1=NULL;
TCHAR* szText2=NULL;
TCHAR* szText3=NULL;
TCHAR *szText4=" Item 1";
// int n=ListView_GetItemCount(hWnd1);
// str3.Format ("%d",n);
//::MessageBox (hWnd1,str3,"Item count",MB_OK);
getItemTextFromListBox(hWnd1, 0,0, &szText1);
getItemTextFromListBox(hWnd1, 0,1, &szText2);
getItemTextFromListBox(hWnd1, 1,0, &szText3);
// ListView_SetItemState(hWnd1, -1, 0, LVIS_SELECTED)
//int x=ListView_GetItemState(hWnd1,1,1);
// str3.Format ("%d",x);
//::MessageBox (0,str3,"Value",MB_OK);
// ListView_SetItemState(hWnd1,-1,0,LVIS_SELECTED );
//ListView_SetHotItem(hWnd1,2);
//ListView_RedrawItems(hWnd1,0,2);
if( 0==_tcscmp(szText1,szText4))
{
TRACE("Matched");
//
// ListView_RedrawItems(hWnd1,0,2);
// int dd=ListView_GetSelectedCount(hWnd1);
//if(dd>0)
//{
//::SetFocus (hWnd1);
// ::SetActiveWindow (hWnd1);
//ListView_SetItemState(hWnd1, -1, 0, 0);
//::SendMessage(hWnd1,WM_SETFOCUS,0,0);
::SendMessage(hWnd1,WM_SETFOCUS,0,0);
::SendMessage(hWnd1,LVM_SETITEMSTATE,0,0);
//::SendMessage (hWnd1,LVM_REDRAWITEMS,0,0);
//ListView_SetItemState(hWnd1, -1, 0, (LVIS_FOCUSED) ); // deselect // deselect
// ::SetFocus (hWnd1);
// ListView_RedrawItems(hWnd1,0,2);
//if(!x)
//{
// ListView_SetItemState(hWnd1, -1, 0, LVIS_SELECTED);
//ListView_SetItemState(hWnd1, 1, 0, LVIS_SELECTED );
//}
//if(dd>0)
//{
RECT re;
//ListView_GetViewRect(hWnd1,&re);
//long d=re.left ;
//long e
//BOOL k= ::UpdateWindow (hWnd1);
int x=ListView_GetSelectedCount(hWnd1);
// ListView_SetItemCount
//ListView_SetItemState(hWnd1, 2, LVIS_SELECTED , LVIS_SELECTED );
//}
//:: UpdateWindow(hWnd1);// select iListPos
//ListView_SetItemState(hWnd1, 0, LVIS_FOCUSED , LVIS_FOCUSED );
//::UpdateWindow(hWnd2);
// ListView_Update(hWnd1,1);
//Button_Click(hWnd2);
//::SendMessage(hWnd2,WM_LBUTTONDOWN,0,0);
//::SendMessage(hWnd2,WM_LBUTTONUP,0,0);
}
if(szText1)
delete szText1;
if(szText2)
free(szText2);
if(szText3)
free(szText3);
}
bool
getItemTextFromListBox(HWND hWndListView, int item, int subItem, TCHAR** ppwszText)
{
bool retcode=false;
TCHAR szReadBuffer[1024];
memset(szReadBuffer, 0, sizeof(szReadBuffer) );
LV_ITEM* plvi=NULL;
DWORD dwProcessId;
GetWindowThreadProcessId(hWndListView, &dwProcessId);
// Open a handle to the remote process's kernel object
HANDLE hProcess = OpenProcess(
PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE,
FALSE, dwProcessId);
if (hProcess == NULL) {
MessageBox(NULL, __TEXT("Could not communicate with process"),
"ERROR", MB_OK | MB_ICONWARNING);
goto cleanup;
}
// Allocate memory in the remote process's address space
plvi = (LV_ITEM*) VirtualAllocEx(hProcess,
NULL, 4096, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
if(plvi==NULL) {
goto cleanup;
}
// Get the ListView item's text data
// Initialize a local LV_ITEM structure
LV_ITEM lvi;
memset(&lvi, 0, sizeof(LV_ITEM) );
lvi.mask = LVIF_TEXT;
lvi.iItem = item;
lvi.iSubItem = subItem;
// NOTE: The text data immediately follows the LV_ITEM structure
// in the memory block allocated in the remote process.
lvi.pszText = (LPTSTR) (plvi + 1);
lvi.cchTextMax = 100;
// Write the local LV_ITEM structure to the remote memory block
if( !WriteProcessMemory(hProcess, plvi, &lvi, sizeof(lvi), NULL) ) {
goto cleanup;
}
// Tell the ListView control to fill the remote LV_ITEM structure
ListView_GetItem(hWndListView, plvi);
// Read the remote text string into the end of our clipboard buffer
if( !ReadProcessMemory(hProcess, plvi + 1, (LPVOID) &szReadBuffer, sizeof(szReadBuffer), NULL) ) {
goto cleanup;
}
*ppwszText = (TCHAR*) malloc( _tcslen( szReadBuffer ) + sizeof(TCHAR) );
if(!*ppwszText) {
goto cleanup;
}
retcode=true;
_tcscpy(*ppwszText, szReadBuffer);
// ListView_SetItemState(hWndListView, -1, 0, LVIS_SELECTED);
cleanup:
// Free the memory in the remote process's address space
if(hProcess) {
VirtualFreeEx(hProcess, plvi, 0, MEM_RELEASE);
// Cleanup and put our results on the clipboard
CloseHandle(hProcess);
}
return retcode;
}
|
|
|
|
|
A general way is appreciated. Thanks.
|
|
|
|
|
By "flat" do you mean without the 3D style?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
|
The only way I can think of is to not load the 3D library (CTL3D32.DLL). I'm sure there's a way to do it on a control-by-control basis but I've never been inclined to find out.
Another option is to play around with the other styles for that control and see if any of them render it non-3D.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
hi everyone.
i want to watch a special URL in the IE content
when user click it . i want to get the msg
and the url content, then i will to do some thing
but how can i make it?
for example:
there is a URL: http://hi.com/myprogram/
when user click it . i want to pop up the program
but i have no idea to do.
can anyone help me?
best regards
|
|
|
|
|
|