|
This sould work (I think):
#define RUN_TRACE(instr) instr;TRACE("%s\n", #instr);
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
That works. Thanks a lot.
Tiny Flying Elephant
I love flying...
|
|
|
|
|
Hi
I created an ATL project in VC7, and chose to have it as a Service exe. I register it as a service (myservice.exe /service), and try to start it using the Service Control Manager. The SCM tells me it cannot start the service, and no error was returned.
I didn't touch a single piece of code. Why in hell can't a wizard produce code that works out of the box???
Btw, I have written some services in ATL 3.0 and didn't have any problem starting them
Tx
Michel
If I am wrong or said something stupid, I apologize in advance
|
|
|
|
|
I found the problem, and I will tell it here for the sake of sharing the knowledge.
When you create an ATL 7.0 Service, the CAtlExeModuleT::RegisterClassObjects method returns S_FALSE if there is no object to register. And in CAtlServiceModuleT::Run method, there is a line that says:
if (hr == S_OK) {
...
}
I overrode the Run function, and replaced the line by:
if (SUCCEEDED(hr)) {
...
}
and everything works fine.
Tx.
Michel
If I am wrong or said something stupid, I apologize in advance
|
|
|
|
|
Michou wrote:
if (hr == S_OK) {
instead of
Michou wrote:
if (SUCCEEDED(hr)) {
What
This is a f***ing beginner mistake , i don't f***ing believe that this was done on ATL 7 framework ! The guys have been doing serious drinking ...
Another stupid bug in a good framework !!!
Joao Vaz
|
|
|
|
|
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
|
|
|
|
|