|
I want to find %cpu usage per process on win9x machines. Some people said that I have to write vxd for that. Do you people think that. Or I have to hack Win Kernel to do this. Please suggest some ideas. Reply me back if you want more info about question.
|
|
|
|
|
How could i find out if a IE window has any toolbars
or if the window is resizable?
Some code example would be good.
And if someone then knows how to find out the same
things with Netscape i would be in heaven.
|
|
|
|
|
I thank it for three weeks
but I don't know...
I racked my brains for an answer but came up with none.
Please comment about this subject...
I want to know simply about this subject maked out MFC
|
|
|
|
|
// ip addres and hostname from this computer
WSADATA wsaData;
struct sockaddr_in sock;
CString strHostname;
int lLen = 255;
WSAStartup(0x0101, &wsaData);
gethostname(strHostname.GetBuffer(lLen), lLen);
HOSTENT * lpHost = gethostbyname(strHostname.GetBuffer(lLen));
memcpy(&(sock.sin_addr), lpHost->h_addr_list[0], lpHost->h_length);
TRACE2 ("Host Name: %s IP address : %s\n",strHostname, inet_ntoa(sock.sin_addr));
WSACleanup();
Hope this will help you
|
|
|
|
|
Aren't you a easier method than it?
Please reply a easier method.
No settlement is remotely possible.(above construction)
In truth, I don't know yet
|
|
|
|
|
hi
your code perfectly correct.
But it is not working in Windows 95. it says WSAHOST_NOT_FOUND.
if i given value of hostname in gethostbyname function as Win95 m/c's name and i run it in Win98, its fetching the IP address perfectly(Win95 m/c ip address).
i don't know why its not fetching in Win95?
these system are all DHCP configured.
please get me if u have any idea
Thanks in advance.
regards
Halid
|
|
|
|
|
Recently I've been designing my document structure. I have to save a list of patients, each with a list of consultations, each with a list of images, each with a list of annotations, etc. My UML looks roughly like this:
CMyDoc
------
[list]CPatient
CString rootDir
CPatient
--------
[list]CVisit
CString firstName
CString lastName
...
CVisit
------
[list]CImageDoc
COleDateTime date
CImageDoc
---------
CWinBmop * bmp
[list]CAnnotaiton
etc. etc.
But this high level of nesting is making things very messy. For instance just to find at which index the currently selected index is, one of my functions is:
int CPatientView::GetVisitIndex(CString name, int parent)
{
CSOFIDoc * pDoc = (CSOFIDoc*) GetDocument();
CObArray * pPatientList = (CObArray*) pDoc->GetPatientList();
CPatient * pPatient = (CPatient*) pPatientList->GetAt(parent);
CObArray * pVisitList = (CObArray*) pPatient->GetVisitList();
for (int i=0; i < pVisitList->GetSize(); i++) {
CVisit * pVisit = (CVisit*) pVisitList->GetAt(i);
if (pVisit->GetPath() == name)
return i;
}
}
Now I'm no system architect, but i reckon that's just too messy and prone to errors and I'm not even at the ImageDoc level!. Anyone give me some broad ideas at how I can make things simpler and neater?
Thanks for any help
|
|
|
|
|
Looks like it's time for you to toss your MFC arrays and lists and use STL ones. This will allow you to to replace the pVistList with an stl::map<cstring,cvist*> and just do a .find(name) to quickly locate the data.
|
|
|
|
|
i am slightly puzzled here
design the database tables and relationships first and then get the data out using the right sql statements ... databases are good at fishing around in twisted relationships so we don't have to be
... and the world was a happy place after all ...
mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them
|
|
|
|
|
Well, this is where the STL comes in handy. There are some nice little algorithms for finding data within collections, without the need for complex iteration statements.
Additionally, unless the objects can be NULL, you should use references instead of pointers, this will reduce the possibility of pointer errors.
There are lots of solutions to your problem. For instance, you might have a member of your Document called GetPatient, which will do much of the looking up of the data for you, instead of requiring you to do it everytime you need it.
You can also create helper functions (not everything has to be a member of a class to be Object Oriented) that takes an object and does something with it. For instance, you might have a function called GetLastPatientVisitData(CPatient& patient) that returns the data you need.
|
|
|
|
|
Hi Brendan,
This answer assumes you are designing an application that allows the entry and display/reporting of patient records. If this isnt correct, let us know what the application is and I'll have another stab.
Anyway, here goes.
I agree with Lauren, I think you would be better off using a database to store the records in this case. A database allows you to not worry about the details of how the records are stored. Any relational database will do here. Access if the system is small, SQL Server or Oracle if the system is a biggie. You can use Active Data Objects to then access the database. Its much easier this way. You can use SQL (or some other means) to join the tables into a recordset that has only the fields that you need.
I also suggest that the Doc/View architecture may not be appropriate here also. Doc/View is great for things like word processor documents, pictures, html, whatever. It falls down a bit though when it comes to handling databases. If you end up using a database, then it may be easier to develop a dialog based app than a SDI (or MDI) application.
I tend to think that whether you use STL or MFC (MFC has a map class too), using the approach that you outlined will produce the messiness that you are trying to avoid. If you are constrained to a object approach rather than a database approach I suggest the following (its just of the top of my head so I havent thought it through that well.)
Instead of embedding each list in a previous class have them separate to each other. This is good OOD too since it reduces the coupling of objects.
CMainObject
{
private:
CMap<patientindex, patientindex,="" patientrec,="" patientrec=""> m_PatientList;
CMap<visitindex, visitindex,="" visitrec,="" visitrec=""> m_VisitList;
...
};
Define your PatientRec class with all of it the appropriate details.
Define your PatientIndex class with the patient identifier.
Do the same for the Visit classes. The VisitIndex class should have the same key as the PatientIndex, this way you can look up all patients in the VisitRec class.
You can do this for all of the list classes. Some of your index classes could have two keys as part of the index. For example the ImageIndex should have a patient and a visit component. These I think both need to be filled in to find the record, but I'm not completely sure of that.
If the CMap class doesnt allow partial matching of keys, you could create your own map class that does.
So then you could have a method that finds a visit.
VisitRec CMainObject::FindVisit(patientID)
{
VisitIndex index;
VisitRec record;
index.patientID = patientID;
m_VisitList.Lookup(index, record);
return record;
}
Anyway, this was a bit rushed. I hope it helps.
regards
John
|
|
|
|
|
Hi Brendan,
This answer assumes you are designing an application that allows the entry and display/reporting of patient records. If this isnt correct, let us know what the application is and I'll have another stab.
Anyway, here goes.
I agree with Lauren, I think you would be better off using a database to store the records in this case. A database allows you to not worry about the details of how the records are stored. Any relational database will do here. Access if the system is small, SQL Server or Oracle if the system is a biggie. You can use Active Data Objects to then access the database. Its much easier this way. You can use SQL (or some other means) to join the tables into a recordset that has only the fields that you need.
I also suggest that the Doc/View architecture may not be appropriate here also. Doc/View is great for things like word processor documents, pictures, html, whatever. It falls down a bit though when it comes to handling databases. If you end up using a database, then it may be easier to develop a dialog based app than a SDI (or MDI) application.
I tend to think that whether you use STL or MFC (MFC has a map class too), using the approach that you outlined will produce the messiness that you are trying to avoid. If you are constrained to a object approach rather than a database approach I suggest the following (its just of the top of my head so I havent thought it through that well.)
Instead of embedding each list in a previous class have them separate to each other. This is good OOD too since it reduces the coupling of objects.
CMainObject
{
private:
CMap<patientindex, patientindex,="" patientrec,="" patientrec=""> m_PatientList;
CMap<visitindex, visitindex,="" visitrec,="" visitrec=""> m_VisitList;
...
};
Define your PatientRec class with all of it the appropriate details.
Define your PatientIndex class with the patient identifier.
Do the same for the Visit classes. The VisitIndex class should have the same key as the PatientIndex, this way you can look up all patients in the VisitRec class.
You can do this for all of the list classes. Some of your index classes could have two keys as part of the index. For example the ImageIndex should have a patient and a visit component. These I think both need to be filled in to find the record, but I'm not completely sure of that.
If the CMap class doesnt allow partial matching of keys, you could create your own map class that does.
So then you could have a method that finds a visit.
VisitRec CMainObject::FindVisit(patientID)
{
VisitIndex index;
VisitRec record;
index.patientID = patientID;
m_VisitList.Lookup(index, record);
return record;
}
Anyway, this was a bit rushed. I hope it helps.
regards
John
|
|
|
|
|
Dear all,
I have created a CListBox, with several lines of string, in a dialogbox.
How can I call another function automatically whenever the selection of string in the list box is changed (by the up and down arrow key)?
For example, in the function I want to get the text of the new position of the
cursor selection whenever the selection is changed etc..
Looking forward to your sincere reply! Thanks!
|
|
|
|
|
1- Add the OnSelchangeList() for selection handler
2- Get the index of the current selection like this:
int index = m_List.GetCurSel();
3- Do whatever you want with the index. One idea is to put a switch statement and call functions within.
Good Luck!
|
|
|
|
|
Hi,
let's say I have a 'CString ii("5 1 2 3 4 6")'. The first number '5' represents the quantity of numbers in the subsequent string; question is, after extracting the number '5' how do i then extract & put the rest of the numbers in say.. an array of int?? Tried using sscanf etc. with no luck. Help!!
Thanks in advance.
|
|
|
|
|
strtok or _tcstok depending on whether or not u are using unicode
mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them
|
|
|
|
|
Hi,
I'm implementing a class that implements a Timer Pool,
my problem is that i don't want to use user timers, we do a lot of system
programming, but the Waitable Timers functions like CreateWaitableTimer
doesn't implement timeout values, have you already sometime implemented a
clean solution using this kind of timers with timeouts? Any
help will be appreciated,
thanks,
Joao Vaz
|
|
|
|
|
is WaitForSingleObjectEx() no use to you? It can wait for WaitableTimers
mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them
|
|
|
|
|
The timer itself doesn't implement timeouts because the function you use to wait for the timer does. WaitForSingleObject[Ex] and WaitForMultipleObject[Ex] do.
|
|
|
|
|
I am writing a property-sheet application (actually a dialog app with tabs - nothing to do with properties !). The property pages contain various controls including edit boxes. For some reason the property page receives a PSN_KILLACTIVE notification whenever the user makes a change in an edit control. This calls CPropertyPage::OnKillActive() which calls UpdateData().
This not only makes the tab look as if it has lost focus, it also completely messes up the range checking in DoDataExchange() - for example if the user deletes a character, or all the characters, in order to enter a new value, the value goes out of range and is trapped by DoDataExchange() before the user can enter the new value.
This doesn't appear to happen with other controls such as radio buttons.
Has anyone elese experienced this? Is it a bug? Is there a work-around?
Dave
Dave
|
|
|
|
|
I've noticed that sometimes when saving data to a (JET) database while using ADO, a query performed right after the changes may not contain the changes....in particular if you have more than a single connection object to the same database.
I've played with events to make sure that the data is actually commited to the database (the CommitTransComplete method is getting called), but haven't found any solution except to hard-code a wait which I suspect is a very very bad idea.
Anyone have any ideas or know have an idea what I'm fighting against??
Thanks!
Paul
|
|
|
|
|
my understanding is that changes are not broadcast across multiple connections as the potential traffic on the network (in a multiuser scenario) would be grim
the solution we came up with was either to build in an auto-refresh every minute or two, or to give the users a refresh button on the data entry screens
sql server works this way to in fact
mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them
|
|
|
|
|
The information seems to be available within a few seconds (somewhere between 2 and 4 seconds) so refreshing every minute wouldn't really help any....and I need the data within a second of having saved it to the database.
I don't want to hardcode a wait into the application, and the whole point of the current set of work that I'm doing is to optimize for speed....having just saved the user 10 seconds, I'd hate to have to give half of it away waiting for data.
I've come across a Q article which indicates that Jet has "lazy" writes and caches information within the connection. I've set a connection property that is suposed to make sure that transaction data is to be saved right to the file, but haven't found any way of making sure that the other connection's cache is refreshed. ;(
Paul
|
|
|
|
|
I had the same problem a couple of months ago with an Access 2000 database and ADO. The solution looks like the following:
pConnection->BeginTrans();
//modify data base in some method
pConnection->CommitTrans();
After CommitTrans() other connections will see the change that occurred between BeginTrans and CommitTrans. This will flush the result back to the database.
There is an article in the MSDN library that explains transactions in ADO. Search MSDN for "Using Transactions in Your Solutions" as an exact phrase. There should be one article, its in Visual Basic but the solution is similar in VC++.
John
|
|
|
|
|
Now I have a dual-monitor system. Is there any API function with which I can enable or disable the second monitor, but not by using control panel?
Thanks in advance!
Wang Huaizhi
|
|
|
|