|
I am starting to look into writing some TSR programs and haven't found any good articles or examples. Does anybody know of any urls or places where I can learn more about programming them? Thanks in advance,
- Travis
|
|
|
|
|
hey travis
tsr programming ... now that takes me back ... terminate and stay resident apps were a dos thing that let you make the system look like it was multitasking when in fact it wasnt ... in windows you don't really need such things
are you doing dos work? or are you just not understanding the difference with the windows way of doing things?
mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them
|
|
|
|
|
Hi,
I am new to visual C++ programming and I need some help please. How can I access a simple int variable defined in a Document from within a Modal Dialog?
I thank you in advance,
Christos P.
|
|
|
|
|
You need to declare a pointer to the document from your dialog class ( or I suppose you could pass it in the contructor, but what I am about to show you will be more generally useful, so here goes )
To get a pointer to your main window do something like this
CMainFrame* pMain = (CMainFrame*) AfxGetMainWnd();
then in an SDI app you can get the view like this:
CMpAppView* pView = (CMyAppView*) pMain->GetActiveView();
and the doc like this
CMyAppDoc* pDoc = (CMyAppDoc*) pView->GetDocument();
Of course, you may find you need to impliment get/set methods to your data, or declare your dialog to be a friend of your document class. Please don't take the cheap way and make all of your document data public, it is a poor design, even if it is quick 'n' dirty.
If your program is MDI, just insert MDIGetActive()-> before GetActiveView, the rest is the same. And for the sake of completeness, AfxGetApp() returns your CWinApp derived class ( don't forget to cast it ).
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
We have some troubles to make a program creating Child Window in CRichEditView
(for example, CButton using Create function)
We create Thread which can check the ScrollBar's position (position checker) every 0.1second.
It makes Child Window move as much as Scroll moves.
But When we are Scrolling the CRichEditView,
Child Window is not scrolled properly as Whole size is changed for using Backspace, Delete key
although the Text is scrolled.
Becuase the value, CRichEditView's movement, is not informed to ScrollBar accurately.
We need Function to transfer Scroll Pixel value whenever CRichEdiView moves,
Function to return Region which Text occupied or
Function to get ScrollBar's address and handle on the View basis.
Please Let us know how to make a function like that or there is any API having this function
Thank you!!!
mailto:freeflow@netsgo.com
|
|
|
|
|
are you trying to have say a button in the view that moves with a block of text as it scrolls? kinda like a html page?
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
Yes. We try to have Button (created using CButton::Create) scrolled as parent View moves in the end like a Html with Submit Button.
|
|
|
|
|
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
|
|
|
|