|
How to hide a given column in a CListCtrl ?
thanx
|
|
|
|
|
You may try to set the column width to zero with a call to CListCtrl::SetColumnWidth. Note that users will be able to drag header dividers to make the column visible.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Thanx
|
|
|
|
|
Someone know how we can in MFC/Visual C++, send to the internet explorer a function made in javascript or dhtml to run in the browser ?
I want to make a button in MFC that send do the internet explorer (maby chtmlview) a function made in javascript, dhtml or asp.
Thanks
|
|
|
|
|
Maybe this is not what you're looking for, but I think you can just write an HTML file on the fly with the JavaScript code and then open it with ShellExecute (or whatever method you like to launch IE and load a page).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
If you have a document loaded into a CHtmlView, you can use the Navigate() function to cause a javascript function to be executed:
vwHtml.Navigate("javascript:MyFunc();");
farewell goodnight last one out turn out the lights Smashing Pumpkins, Tales of a Scorched Earth
|
|
|
|
|
Do you need to put your stringarray adds in a try catch block, just in case there is not enough memory to allocate to the array? and if so, what error should you catch? Do you just catch CException or is there a more specific error?
|
|
|
|
|
Assuming that you're using VC6, there will be no exception when memory is exhausted during CStringArray operations. CStringArray::SetSize uses new operator to allocate memory for its slots, and doesn't even check for failure. Operator new in VC6 returns NULL when it fails to allocate, while C++ Standard requires it to throw bad_alloc.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
How about CMemoryException? Wouldn't that catch a CStringArray allocation failure?
|
|
|
|
|
|
Hi, the those are my client and server procedures using CSocket to send a file... When I run the programs onto a single machine, I receive the file without any problems...
But when I run them on two different computers, I get a different file... something is changing my buffer that I send via the socket. Can anyone help me? Does anyone know an article explaining how to use CSocketFile and an example source???
RECEIVING PROCEDURE:
UINT SendProcThread(LPVOID pParam)
{
size = 128;
CSocket sock;
sock.Create(12234);
sock.Listen();
CSocket recv;
sock.Accept(recv);
char num[20];
recv.Receive(num, 20, NULL);
length = atoi(num);
TRACE ("\n%d - length\n", length);
recv.Receive(num, 20, NULL);
int f_name_len = atoi(num);
TRACE("\n%d - name len\n", f_name_len);
char* name;
name = (char*) malloc(f_name_len);
recv.Receive(name, f_name_len, NULL);
strName = name;
strName.ReleaseBuffer(f_name_len);
TRACE("\n%s - name\n", strName);
int l = length/size;
char* buf;
buf = (char*) malloc(size);
try {
CFile file;
file.Open(strName, CFile::modeCreate | CFile::modeReadWrite, NULL);
for (int i=0; i<l; i++)="" {
="" recv.receive(buf,="" size,="" 0);
="" file.seek(size*i,="" cfile::begin);
="" file.write(buf,="" size);
="" }
="" length%size);
="" file.seek(size*l,="" file.close();
="" catch="" (cfileexception*="" e)="" e-="">ReportError();
e->Delete();
}
recv.Close();
sock.Close();
free(name);
free(buf);
CString msg;
msg.Format("%s file with legth %d has arrived!", strName, length);
AfxMessageBox(msg);
return 0;
}
SENDING PROC:
UINT SendFileThreadProc(LPVOID pParam)
{
size = 128;
char* buf;
buf = (char*) malloc(size);
CSocket socket;
socket.Create();
socket.Connect(m_dest_name, 12234);
char num[20];
itoa(length, num, 10);
socket.Send(num, 20, NULL);
TRACE ("\n%d - length\n", atoi(num));
itoa(m_strName.GetLength(), num, 10);
socket.Send(num, 20, NULL);
TRACE("\n%d - name len\n", atoi(num));
socket.Send(m_strName, m_strName.GetLength(), NULL);
TRACE("\n%s - name\n", m_strName);
int l = length/size;
try {
CFile file;
file.Open(m_strFileName, CFile::modeRead, NULL);
for (int i=0; i<l; i++)="" {
="" file.seek(i*size,="" cfile::begin);
="" file.read(buf,="" size);
="" socket.send(buf,="" size,="" 0);
="" }
="" file.seek(size*l,="" length%size);
="" length%size,="" file.close();
="" catch="" (cfileexception*="" e)="" e-="">ReportError();
e->Delete();
}
socket.Close();
free(buf);
return 0;
}
"Needless redundancy is the hobgoblin of software engineering." - Peter Darnell
|
|
|
|
|
(Please tick on the checkbox "Display this messahe as-is (no HTML)" when submitting code. Otherwise, your '<' s won't appear.)
I'd say (though I haven't thoroughly examined your code) that you are implicitly relying on the false assumption that CSocket::Read will read as many bytes as requested. Actually, the only guarantee is that the number of bytes read will be more than zero and not more than requested (unless the connection is closed and no more data is available.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Where can I find the examples of the project?
I am looking for the foollowing project future: open the txt file, read that file and then insert or update the assosiate tables in SQL.
|
|
|
|
|
I can help you, but if you are usin sql server, Is Not better to use dts???
But if you want use the following functions.
CFile::Open
CFile::Read
And then Execute a stored procedure that decide if you need to Insert or Update the Table.
Only you need to select the best way to acces to SQL, ADO, DAO, OLEDB, etc
Best Regards...
Carlos Antollini.
Sonork ID 100.10529 cantollini
A printer consists of three main parts: the case, the jammed paper tray and the blinking red light.
|
|
|
|
|
Hello,
Does anybody know how to build a networked application in a SDI? I've got a good example on how to build the application using simple dialog(I've found it on "MFC programming with Visual C++ Unleashed"), but I want to build using WINSOCK connection(defined in CAsyncSocket class) on SDI or MDI instead on simple dialog. In simple dialog, we create a derived class from CAsyncSocket and define a socket variable in the dialog class.
The problem is that I don't know whether the socket variable is belongs in the document or view class? where do I have to define the variable and how could I use the function on view?
Please help.
|
|
|
|
|
I have never tried to do what you are doing but if you are going to display info or need to place edit boxes etc in a view I would use the Document class to do all the networking work or even the MainFrame class.. and display your results or what not in the view. You would probably want to do some testing.. But I would start by making a SDI or MDI and create the type of view you want, CListView, CFormView etc.. then first try placing your networking code in the Document class for that view..
Hope this gets you pointed in the right direction.
Rob
|
|
|
|
|
thanks for the explanation.
|
|
|
|
|
What I am doing is:
in view.h:
SOCKET m_socket.
Then in view.cpp:
view::OnInitialUpdate()
{
WSAStartup();
m_socket = socket();
bind(); // if server
}
view::~view()
{
closesocket(m_socket);
WSACleanup();
}
Call the corresponding accept, receive, send function when certain event occures, either it's a user triggered event (certain menu item is clicked based on your business logic) or it's a FD_XXX event (for asynchronos socket event).
So, in my opinion, the socket should belong to the view. HTH
|
|
|
|
|
I need some English information about this ,please tell me the particular web sites,thank you!!
huang chun shen
|
|
|
|
|
Check here You can find info abaout several File Formats. I don't remember if it has Info about Word files....
Best Regards
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
My Task:
I am reading data coming in from an instrument over a serial port. The data is received as 2 char bytes (8 bits each) which I need to pack into the lower 16 bits of an int. The instrument sends high-byte low-byte.
What is the most efficient way to do this?
Some of my ideas are:
- assign the first char to the int and bit shift it 8 bits to the left( << 8) and then OR the result with the next 8 bits. This would fill the lower 16 bits but I am concerned about efficiency, which is my greatest problem.
[does an 8-bit shift left require 8 cpu cycles to do this shift?]
- I could also use a union with bitfields to but again I am not sure about efficiency compared to other methods.
- my last thought would be to use a void pointer to step through an array, but I am not completely sure how this would work.
Could anyone shed some light on this topic for me? I would appreciate any suggestions/comments.
Thanks,
- Merle
|
|
|
|
|
I would expect that the quickest way is this:
char l,h;
DWORD dwValue = 0;
dwValue= ((DWORD) h) << 8;
dwValue+=l;
of course, you could do that on one line if you liked. But, the point is that an ADD operation is going to be quicker than an OR. if you init your DWORD to 0, then the add and or are identical in their result anyway.
However, I wouldn't be very worried about speed here. Your data is coming from a serial port, and serial ports ain't that quick. So long as your CPU is faster than an 8088, you'll probably keep up however you do it.
Jon
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
I'd go with shift - work is probably done in CPU registers, which are way faster than memory. OTOH, good compiler could optimize the code and keep union in the one of the registers as well. I believe both solutions will be fast enough - are you expecting this operation to be a bottleneck for your app?
Merle Pittman wrote:
my last thought would be to use a void pointer to step through an array, but I am not completely sure how this would work.
With void pointer you can't step through anything. You could do that with unsigned char pointer, but creating 16-bit int in memory will be probably slower than shifting (see above).
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
hello,
in my current project, I need to store the original file path of files. But they can come from many unit types : FD, local HD, network HD, CD writer, DVD rom etc....
So, for a given computer (the local machine !)I need to know :
- The drive list
- the type of each drive
- the name of each unit (HD name, CD ROM name if one is inserted in the CD Reader..)
I did not find out how to do that in VC++, is there anybody out there who can help me , please ?
You guys, who are so smart I've a new question : how to know if a unit is a CD Writer, a DVD writer ?
Thank you very much for the so numerous and efficient answer ! (hope make me live !)
Best regards
Guy LECOMTE
|
|
|
|
|
For a start, check GetLogicalDriveStrings, GetDriveType and GetVolumeInformation.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|