|
Thanks very much for your reply.
I think the funtion CFile::GetStatus() can only get the static status of a file, for example, the access mode of a file. But I want to get a dynamic status of a file, for example, the status of being read.
Do you have better methods.
Thanks for helping me.
Maer.
|
|
|
|
|
I'm not sure what you mean by 'being read'. If you mean 'is the file being read from right now' I don't know but if you mean 'when was the file last accessed' I think you can use GetStatus().
/Per
|
|
|
|
|
Thanks for your reply.
I find the "GetStatus" function works well. It really resolves a part of my trouble.
What I mean is "the file being read from right now", I have find a better method to resolve the problem. That is, to set a status bit to show the status.
My project often reads and writes a lot of datas. It often takes a lot of time to do that task. To be more efficient, I want to check out the status of the file to give notifications to other threads waiting for reading/writing in the same file.
Thanks again.
Maer.
|
|
|
|
|
Hi
If you use CreateFile() to open the files it's possible to set some extra options for access e.g.
|
|
|
|
|
In the "OnCreate" funtion of the class "CInPlaceFrame" of a Server Application, there is a statement like this "m_dropTarget.Register(this)". Here are the comments from Microsoft:
// By default, it is a good idea to register a drop-target that does
// nothing with your frame window. This prevents drops from
// "falling through" to a container that supports drag-drop.
The statement really puzzles me. When we are programming in a Container Application, this statement is to register a drag-drop target. But in a Server Application, I can not see the funtion of the statement. If I remove the statement, my server application runs like before.
So my question is:
What is the function of the statement "m_dropTarget.Register(this)"? Can you give me an example?
Thanks.
|
|
|
|
|
In the ActiveX programming, when a property of a control is using the Set/Get mode, there is a statement in the "Set" function like this "SetModifiedFlag".
My Question is:
What operations the statement will result? Should the property that already changed reloads immediately? Or should the property that already changed reloads later? When will the changed property reload? What is the relation between the statement "SetModifiedFlag" and the reloading of the changed property?
Thanks
|
|
|
|
|
Basically, SetModifiedFlag is like setting a "dirty" flag. When the control is destroyed, the control will attempt to save its properties since some of them have been modified. Try changing some properties of your control in the ActiveX Test Container and then closing the container without saving. You'll get a prompt asking if you wish to save changes because the properties have set the modified flag.
Thus, you only really need to call SetModifiedFlag on persistent properties, as any other properties will not be saved.
Hope this helps.
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
Mr. Waters:
Thanks again for answering my question.
Your explanation is very clear and I have understood the function of the "SetModifiedFlag".
Thanks.
Maer.
|
|
|
|
|
In the ActiveX programming, when a property of a control is using the Set/Get mode, there is a statement in the "Set" function like this "SetModifiedFlag".
My Question is:
What operations the statement will result? Should the property that already changed reloads immediately? Or should the property that already changed reloads later? When will the changed property reload? What is the relation between the statement "SetModifiedFlag" and the reloading of the changed property?
Thanks
|
|
|
|
|
How to toggled on the Numlock key on Windows 98?
In MSDN, it seems we cannot toggled on the Numlock key.
Here is the MSDN Description:
Windows 95: The keybd_event function can toggle only the CAPS LOCK and SCROLL LOCK keys. It cannot toggle the NUM LOCK key.
|
|
|
|
|
I have read some articles about the benifits of the Compound File and structured storage. In my opinions, I think one of the benifits of the Compound File is that we can load only a part of the whole document that we need and not have to load all part of the document. It saves a lot of time and simplified the programming.
In the Container Application, the functionality is very clear. For example, suppose a CxxxDocument that contain several bitmaps, we can only load the right one that we want to edit by activating the item from the representation chart. The memory only load the exact part of the document.
I have used the VC++ Debug Tools to trace the MFC source codes of it. I find out the MFC Framework use a linklist data structure to store and load the OLE Items from the document.
But in the with Server Application, the functionality is not very clear. I also trace the MFC source codes. I find out the server document also use a linklist data struture to store and load Server Items. If we use "embed" tactic, there will be only one node in the linklist. If we use "link" tactic, there can be more nodes in the linklist.
It is well known that the Compound File can contain items and use them individually like the document of container application containing OLE items in the linklist.
So my question is: Since the document of the server application is Compound-File enabled, the document also can contain items to manipulate. Are the objects of class COleServerItem the items that we can use structured stroage tactic to manipulate(like the OLE items in the container's document)? Are they built on the basis of COM? Or are they only pure ordinary data streams in the document and these kind of objects can not be manipulaite individually.
|
|
|
|
|
A Simple Question About ActiveX on Internet:
When we embed an ActiveX Control in a Html Web, we often use the term "CLASSID" and "CODEBASE". But what is the relationship between the two terms? Under what circumstance should we use "CLASSID" and do not use "CODEBASE" at the same time? Under what circumstance should we use "CODEBASE" and do not use "CLASSID" at the same time? Under what circumstance should we use both "CODEBASE" and "CLASSID"?
When should we assign a local address to the "CODEBASE"? When should we assign a WWW address to the "CODEBASE"?
Thanks.
|
|
|
|
|
OK, here's my (perhaps limited) knowledge about these two terms.
Basically, CLASSID indicates what type of ActiveX control you want to embed. It is a GUID (idnetifier) that uniquely identifies the type of control to be embedded. The browser should pull out the GUID and try to create an object of that type. If that particular GUID is not registered on the machine, the browser goes to the location specified in CODEBASE to get the ActiveX component. That's where things get tricky. CODEBASE can point to either an OCX directly, provided it's self-registering, or a CAB file that will install it. If you need to build the CAB file, check out "File Packaging With The Packaging And Deployment Wizard" on MSDN. Although it's VB based, the concept is the same. You could also try packaging a simple VB OCX to see what the wizard produces.
Hope this helps.
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
Mr. Waters:
Thanks very much for your reply.
I think I have understood the functions of the two terms.
Maer.
|
|
|
|
|
Here is my code for converting ip address to www address:
/////////////////////////////////
/////////code starts/////////////
/////////////////////////////////
WORD wVersionRequested;
WSADATA wsaData;
UpdateData(true);
wVersionRequested = MAKEWORD( 2, 2 );
WSAStartup( wVersionRequested, &wsaData );
unsigned long i;
hostent* address;
i=inet_addr(m_address);
address=gethostbyaddr((const char *)&i,4,AF_INET); if(address==NULL)
{
int j=WSAGetLastError();
CDialog::OnOK();
}
m_name=address->h_name;
UpdateData(false);
WSACleanup();
////////////////////////////////
//////////code ends/////////////
////////////////////////////////
Description:
m_address is a variable of the type CString; The function "UpdateData" get the input value of ip from a Control on a dialog. The variable "m_name" is to store the value of the www address.
But when I connect the "166.111.4.100"(www.tsinghua.edu.cn), an error occurs(from "WSAGetLastError()"). The error type is "WSANO_DATA", with the explanation "Valid name, no data record of requested type" in MSDN.
My question is:
Why the problem occurs? How can I correct it? Is there better methods to convert ip address to www address?
Thanks
|
|
|
|
|
I think the problem is with the name server of the site you tried to access, not your program, because even standard tools like nslookup can't get the name of 166.111.4.100:
$ nslookup 166.111.4.100
Server: localhost
Address: 127.0.0.1
*** localhost can't find 166.111.4.100: No response from server
$ nslookup www.tsinghua.edu.cn
Server: localhost
Address: 127.0.0.1
Non-authoritative answer:
Name: www.tsinghua.edu.cn
Address: 166.111.4.100
$
|
|
|
|
|
Thanks very much for your reply.
I still have a question. In your reply, you have said that "I think the problem is with the name server of the site you tried to access". Do you mean the work of converting ip address to www address is done by the "name server"? But I think the work is done by other internet servers like the servers converting www address to ip address. Maybe what I think is wrong, because I do not know much about the protocols. Can you give me a simple explanation of how the converting process works? What is the name server you mentioned before in my example(www.tsinghua.edu.cn, 166.111.4.100 or others)?
Thank for helping me.
Maer.
|
|
|
|
|
The name servers take care of both forward (name to IP address) and reverse (IP address to name) mapping. I don't think a simple explanation of DNS is possible , but see the DNS tutorial or the chapter on DNS in the "Rute" The name servers for tshinghua.edu.cn domain are:
ns2.net.edu.cn (202.112.0.33)
dns.tsinghua.edu.cn (166.111.8.28)
ns.pku.edu.cn (202.112.7.13)
ns2.cuhk.hk (137.189.6.21)
I used the DiG (Domain Information Groper) program to look up the name server info.
|
|
|
|
|
Thanks for your reply.
From the article you introduced to me, I have got a simple idea about how the name server works. Thanks again.
I still have a foolish but simple question. That is, is there any tools like the "DiG" or "nslookup" running on Windows Me? Or is there any web sites providing such service like the "DNS tutorial" you introduced to me.
Thanks.
Maer
|
|
|
|
|
The original dig and nslookup commands are parts of the BIND software package. A Google search gives several versions of nslookup for Windows, e.g: WWW interfaces to nslookup, dig, etc. can be found here.
|
|
|
|
|
Thanks very much. I find the tools and web sites you introduced to me is very powerful.
You are a patient and a good teacher. I hope you can help me if I have other question when you are not busy.
Maer
|
|
|
|
|
I need to override the paste command of a CEdit control (When the user chooses Paste from the popup menu or presses Ctrl+V). The problem is that there is no OnPaste or WM_PASTE commands in the class wizard. How do I get this message?
|
|
|
|
|
You'll have to become a wizard yourself. Manually add
ON_MESSAGE(WM_PASTE, OnPaste)
to message map in CYourEdit class. The header of the function should look like this:
afx_msg LRESULT OnPaste(WPARAM, LPARAM);
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I'm having problems updating a database table containing a couple of numeric fields (length=3, precision=4, scale=2) on a MS SQL Server.
When I call the Update method on my CRecordset derived class I get an "Invalid character value for cast specification" error.
I know this is caused by the numeric fields, since without them it works alright.
When I generated my recordset using the class wizard it set the type of these fields as CString, which I assume is because the ODBC driver does not support the numeric datatype. Thus it tries to convert the numeric to a string when reading from the database, and back to a numeric when writing. All this is beyond my control.
What I'm trying to figure out is how to update these fields without getting the above mentioned error message.
Here's a simplified version of my code:
mySet.Open(CRecordset::snapshot, NULL, CRecordset::none); // Selects a unique record in my database (verified)
mySet.Edit();
mySet.m_MyNumeric1 = "2,00";
// In Sweden we used , instead of . as a decimal separator so that's why the
// above value might look suspicious to most of you.
// I've tried changing this field to "2.00" too, but the result is the same.
// The value is also stored with , as separator in the database.
mySet.Update() // Causes the above mentioned exception to be thrown.
I'm starting to fear that this problem is caused by a conflict between . and , in the driver. I've tried changing the field to almost anything by now, but nothing seems to help.
Does anyone recognize this problem? Some tips would be much appreciated.
|
|
|
|
|
I think you are giving the wizard way too much credit when you write
"When I generated my recordset using the class wizard it set the type of these fields as CString, which I assume is because the ODBC driver does not support the numeric datatype. Thus it tries to convert the numeric to a string when reading from the database, and back to a numeric when writing. All this is beyond my control"
You probably need to change the field bindings to numeric fields (if you were unable to do this with the wizard you may have to do it manually) I have found that it is extrememly important to have the data types match or I will experience the same types of exceptions
|
|
|
|