|
Hi, I've never used label editing in TreeView & ListView before, so I guess it's a simple question. I used the EditLabels property (LVS/TVS_EDITLABELS) and create the controls. But a strange thing happens. I click on the label to edit and it's ok, but when I press any key (in both the TV and LV) the dialog is dismissed. Also, when I press ENTER (without any char has been pressed), they behave differently: the LV accepts it but the TV close the dialog.
What is happening ? What is missing here ?
I create a very simple test: a new Win32 App,typical HelloWorld, and include this lines in teste.rc:
CONTROL "List1",100,"SysListView32",LVS_REPORT | LVS_SINGLESEL |
LVS_SHOWSELALWAYS | LVS_EDITLABELS | LVS_NOSORTHEADER |
WS_BORDER | WS_TABSTOP,7,7,132,30
CONTROL "Tree1",200,"SysTreeView32",TVS_HASBUTTONS |
TVS_HASLINES | TVS_EDITLABELS | TVS_SHOWSELALWAYS |
WS_BORDER | WS_TABSTOP,7,43,158,24,WS_EX_CLIENTEDGE
and include InitCommonControls(); at WinMain and
#include "commctrl.h" and put comctl32.lib in the project settings
finally I put this on the About function:
case WM_INITDIALOG:
LVCOLUMN col;
col.mask = LVCF_TEXT | LVCF_WIDTH;
col.pszText = _T("Col1");
col.cx = 100;
ListView_InsertColumn(GetDlgItem(hDlg, 100), 0, &col);
LVITEM lv;
lv.mask = LVIF_TEXT;
lv.pszText = _T("Txt1");
lv.iItem = 0;
lv.iSubItem = 0;
ListView_InsertItem(GetDlgItem(hDlg, 100), &lv);
TVINSERTSTRUCT tv;
tv.hInsertAfter = TVI_LAST;
tv.item.mask = TVIF_TEXT;
tv.hParent = TVI_ROOT;
tv.item.pszText = _T("root");
TreeView_InsertItem(GetDlgItem(hDlg, 200), &tv);
return TRUE;
and that's it. I didn't include the handlers to LVN/TVN_BEGINLABELEDIT and ENDLABELEDIT , but I think this is not the problem. Why the dialog is dismissed when I press any key ? Why the ENTER key is OK with LV but close the dialog in TV ? Did I forget to handle some message or notification here ?
Did they act differently in Windows and Dialogs ?
|
|
|
|
|
I think the Edit control of the TreeView (for label editing) on a dialog doesn't handle the ENTER and ESC keys, so they are processed by the system DefDlgProc and directed to DEFPUSHBUTTON. But I think that it's kind of a bug, because the ListView Control does handle the ENTER and ESC keys.
I will try to subclass the label edit control of the TreeView and handle the WM_GETDLGCODE message and see if it solves the problem.
|
|
|
|
|
hello
iv created my self a frustrating problemb that i just cant seem to resolve,i can think of so many potential problembs that could be rendering my code useless i just dont know where to start!
okay im trying to send a .exe file between my client and server,the file is recived by the client but only 11 bytes or so is actually transfered,i think the problemb could be with how i got my socket's set up to send and recv the file,any ways heres my code,any hints to how i cud solve this wud be much appreciated.
//client code >>//
string downloadCmd = "download "; //command 4 server
std::ofstream oStream;
oStream.open("c:\\file.exe",std::ios::out);
send(Socket,downloadCmd.c_str(),strlen(downloadCmd.c_str()),0);
recv(Socket,inBuffer, MSG_LENGTH, 0);
ZeroMemory(inBuffer,MSG_LENGTH);
if(strcmp(inBuffer,""));
do{
recv(Socket,inBuffer, MSG_LENGTH, 0);
recvbuf += inBuffer;
ZeroMemory(inBuffer,MSG_LENGTH);
}while (!strcmp(inBuffer, ""));
oStream << recvbuf;
ZeroMemory(inBuffer,MSG_LENGTH);
recvbuf = "";
//code for server >>//
std::ifstream iStream;
iStream.open("c:\\windows\\system32\\ftp.exe",std::ios::in);
if(!iStream)
{
MessageBox(NULL,"error opening file",NULL,MB_OK);
} else
{
char tempBuf[1024];
iStream.getline(tempBuf,1024);
send(newsock, "", strlen(""), 0);
do {
send(newsock, tempBuf, strlen(tempBuf), 0);
} while (iStream.getline(tempBuf, 1024));
send(newsock, "", strlen(""), 0);
iStream.close();
}
well theres my rough code,it did seem to wrok with a text file,i think maybe it cant handle the larger chunks of data
thanks for ya time
chris
|
|
|
|
|
Without looking at your code too much, the problem is in your client receive loop. You have not provided the definition of recvbug or inBuffer, but I suspect they are strings. You are using the following to add the last packet of received data onto the main buffer:
recvbuf += inBuffer;
When transferring text this will be ok, as the += will add all the data from inBuffer upto the first null (character 0). However, with binary data a null character can occur anywhere and so you will likely only add a very small amount of data (if any). I would advise using something like memcpy (recvSize must be 0 initially):
int received = recv (Socket, inBuffer, MSG_LENGTH);<br />
<br />
memcpy (recvBuf + recvSize, inBuffer, received);<br />
recvSize += received;
|
|
|
|
|
Since you are working with a binary file, make sure you read in the file in binary mode.
Kuphryn
|
|
|
|
|
Open the file in binary mode and stop using getline() . Use read() instead.
--
I am perpetual, I keep the country clean.
|
|
|
|
|
okay guy's thanks for your advice i applied this to my code,and its almost running just how i want it,before i started using the read() function,when i transfered a .txt file the format of the data in the file was all messed up,now it seems to be fine.
now i have changed the mode to binary,and attempted to send a random exe,im still gettin a error where the size of the file does not match that of the original.
am i using my send() and recv() loops effectively to send my data,i fear that there getting mixed up maybe the loop in the client is running faster than that of the server i dont know,but the loop only has to work once with a small textfile,where ass it looks a little unstable with a larger file.
any more information,or a better way of achiving what i want would be much appreciated.
thanks
chris;)
|
|
|
|
|
hi guys,
i'm looking for a way to write a complete __fastcall function in inline assembler, and i want to skip the epilog and prelog routines.
when using __declspec there is the possibility to use the naked keyword, which doesn't work for __fastcall.
is there any solution?
thx for your answers.
Alexander M.
Don't try it, just do it!
|
|
|
|
|
Probably not a good idea, even it you could do it. Note from MSDN __fastcall article: "Future compiler versions may use different registers to store parameters.". What I would do is write the function using inlining with in line asm wrapped in the function and let the compiler work out the details, it is very good at that. Heck, if the function is small enough, the compiler is very good a inlining (optimizing) it for you, if written in C/C++.
Good luck!
INTP
|
|
|
|
|
there is just a little problem... the compiler wont use SIMD instructions for me!
Don't try it, just do it!
|
|
|
|
|
Alexander M. wrote:
the compiler wont use SIMD instructions for me!
Well, you can still do inline assembly, can't you?
--
I am perpetual, I keep the country clean.
|
|
|
|
|
By the way, if you decide to inline things, make sure you pass any object to the function by reference. That way the compiler can generate the inlined function without any "extra code".
--
I am perpetual, I keep the country clean.
|
|
|
|
|
no, u don't understand...
when i use the __fastcall calling convention in a file, then the 2 parameters are in ECX and EDX.
but the prelog code of the compiler overwrites them...
so my inline asm doesnt work anymore.
Don't try it, just do it!
|
|
|
|
|
Why are they overwritten!? __fastcall specifies that the first two parameters smaller or equal to a DWORD, are passed via ECX and EDX respectively. If that's the contract of __fastcall, then the prolog shall not mess with those registers. In fact, it doesn't as far as I can tell.
--
I am perpetual, I keep the country clean.
|
|
|
|
|
Dear Experts
In my program,I need to have two independent loops that run at different speeds,30Hz and ~1KHz.They don't share a database.The second loop will only run if a condition in the first one is fulfilled.In this case the first one sends an integer to 2nd one and the second one should process the data with the given speed.this is the scenario,but I don't know how to implement it.At the moment I have a 30Hz timer in my application .At each interrupt of the timer,some function are called.I dont know where to put the second timer and how to start the 2nd thread.can anyone of u experts,helps a completly confused novice
Many thanks
p.s.By the way my program is an SDI application
|
|
|
|
|
There are several solutions. One solution is to use a kernel object to control the section worker thread from the first worker thread. Share data between the two threads via pointers.
Kuphryn
|
|
|
|
|
Why not run them in the same thread? One is close enough to be a multiple of the other that it should work.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Dear Experts
In my program,I need to have two independent loops that run at different speeds,30Hz and ~1KHz.They don't share a database.The second loop will only run if a condition in the first one is fulfilled.In this case the first one sends an integer to 2nd one and the second one should process the data with the given speed.this is the scenario,but I don't know how to implement it.At the moment I have a 30Hz timer in my application .At each interrupt of the timer,some function are called.I dont know where to put the second timer and how to start the 2nd thread.can anyone of u experts,helps a completly confused connovice
Many thanks
p.s.By the way my program is an SDI application
|
|
|
|
|
|
I want to write a program that comunicates with another on the same network. There are probably a couple ways to do this but i have no idea where to look up info on doing this. Im completly new to this so if there are any tutorals on thos or examples links would be apperciated
|
|
|
|
|
Search for "Beej's Guide to Network Programming" on google.. easily available online.. It is very good beginning resource for socket programming to communicate on network
hope that helps
Muhammad Shoaib Khan
http://geocities.com/lansolution
|
|
|
|
|
For a quick tutorial on winsock, check out this site.
http://www.tangentsoft.net/wskfaq/
I highly recommend Network Programming for Microsoft Windows, Second Edition by Anthony Jones and Jim Ohmund.
Kuphryn
|
|
|
|
|
|
Hi all, ibe imported a bitmap to my app, and now i get the following warning:
Build : warning : failed to (or don't know how to)build 'D:\Code\FixDesp\vsp.bmp'
i imported the bitmap the "usual" way via the resource pane ->import... context menu option.
im using VC6 in a WTL7 project
any idea of what im doing wrong?
Thanks!
UPDATE:
ibe imported an icon, and i got another warning for it!
WTF??
|
|
|
|
|
Perhaps your file is a mis-named .bmp file ? perhaps it's a JPG or something like that ?
Try to open it with ms-paint and see what happens, same goes for the icon.
|
|
|
|
|