|
Using global variables is often very undesirable in C++. I recommend, instead of creating a global struct, create a singleton class.
class Prices {<br />
private:<br />
Prices();<br />
~Prices();<br />
public:<br />
static Prices* CreateInstance(){<br />
static Prices;<br />
return &Prices;<br />
}<br />
}
Then, anytime you want to get your prices, just call Prices::CreateInstance().
You could even create the class in such a way that it must be initialized with the ticket prices before CreateInstance will return a pointer.
|
|
|
|
|
much better would you create singleton class use it through out the project!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
I have a property sheet in a CFormView. The property pages dont
seem to be created until I visit the specific View, so I do not
want to transfer data from a CPtrArray to display in the property
page until the property page is created.
What function can I use in my View or property pages to transfer data
from a CPtrArray to actually display in the property page? I cant use
OnUpdate. If I do, this is called before I visit the property page and before its Window is created. I have not had any luck with OnActiveView in the CFormView (which would then load data from the property pages).
I tried OnSetFocus and that really throws the whole program off; I cant
type data in edit boxes or doing other really small things. I tried
OnInitialUpdate as well.
Im trying to find a function to call in my CFormView class or in the
property pages that will then let me display data on the property
page.
Please, please, any response any one can give me will be greatly
appreciated.
Sincerely,
Danielle Brina
|
|
|
|
|
In the property pages:
OnInitDialog() is first chance you get to access the page's dialog with a valid HWND.
Just like any dialog, it's a great place to initialize/populate controls.
OnOk() is the last chance.
OnKillActive() gives you a chance to validate user input before allowing the user to switch pages
or leave the sheet.
|
|
|
|
|
I have developed an application that grabs frames from a webcam, but i now need to compare these frames for motion(differences). I have had a look around and the only method i found was to compare each pixel in each frame but the speed of this is far to slow to be pratical.
Can any help me out?
|
|
|
|
|
You don't need to compare each pixel.
Depending on the size of the images ( lets say 640, 480 for example ), build an array of points each indexing a point in the image ( every 50 pixels maybe ). Then in your loop, only call GetPixel() for those points. If 30% of them changed since the last time, you have detected movement.
|
|
|
|
|
True this does speed up my program but i need to pinpoint the motion and highlight it.
|
|
|
|
|
Ok, so im running MS Visual C++ 6.0, programming a C++ MFC program.
Im my dialog i have a edit box (locked to numbers) were the user will type in a float (a price)
So then i have to use GetDlgItemText go get the float into a CString (cant use getdlgitemint as it looses the decimals)
but now i then need to convert the cstring (containing someting like 29.88) into a normal float, like this:
Main->Price=cstringprice;
ive tried loads of things, like atof.. but all of them make errors when trying to use the variable it set
so got any better ideas of getting a float from the dialog into a float? or converting what GetDlgItemText brings into a float?
thanks!
/Johannes
|
|
|
|
|
atof() should work just fine. Perhaps you could show the code for your converting and we may be able to point out the error.
|
|
|
|
|
Ah solved it, problem was elsewhere
thanks anyway!
/Johannes
|
|
|
|
|
You can use of
CString str;
str.Format("%lf",28.29);
But what errors when used of atof?
|
|
|
|
|
try _ttod
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
HI all,
please if any1 could provide me with required codes for locking keyboards and mouses of computers in the same LAN using Java or C++ and under Windows XP Os.
As I am a student working on my senior project, which is 2 implement an instructor control computer, that can control students' computers connected through LAN (I will work on two Pc's only,instructor and student). the teacher can lock their keyboards and mouses, and broadcast his/her desktop screen on their monitors.
Thank you.
|
|
|
|
|
I weep for the company that hires the ex-student who got someone else to write his/her senior
project.
Have you learned anything as freshman/sophomore/junior? I mean everyone knows it's "mice".
not "mouses".
|
|
|
|
|
Mark Salsbery wrote: Have you learned anything as freshman/sophomore/junior? I mean everyone knows it's "mice".
She can't even write her own name. I suppose it save's on the red faces if her classmates saw these threads.
|
|
|
|
|
Hey there,
thanks for being rude, and for your information I have completed a large part of my project which is broadcasting teacher desktop on students' PCs and transfering files between both sides, and I was looking for required commands and configuration for keyboard & mouse lock as an EXTRA FEATURE for my project.
Bottom Line: If you are not capable of providing any help please let others do, AND getting help from experts and websites is a common and right way to accomplish senior projects, hope it is not news for you!!!
Sara
|
|
|
|
|
Do you not consider it rude to refuse those who want to help you the decency of knowing your name?
Do you not consider it rude to refuse allowing people to know a name even after repeated requests that you do so?
Perhaps you should think a little about your own manners before expecting people to help you.
So tell me, why did you finally name yourself? Was it because the site admin forced you to? Or maybe you were fed up of the low voting for your posts? Or maybe you had a reality check?
|
|
|
|
|
Hi WalderMort,
My reply was for Mark Salsbery not for you, I read your comment after posting my second comment, and yah about the name issue,I am new to this site and didnt know that I have to post my name, as this site published my question without my name. And since you are making a big deal about my name, I am Sara A. Khan. Now if you can help me as you mentioned please go for it.
Sara
|
|
|
|
|
Yes I was the one being rude. Sorry. I thought I was being realistic.
"please if any1 could provide me with required codes for locking keyboards and mouses of
computers in the same LAN using Java or C++ and under Windows XP Os" sounds alot like you want
the code written for you. Maybe someone here will do that. In my experience here, I doubt it.
Now, if you provide more details, provide your current solution attempt, describe a portion that's
giving you trouble, THEN there's alot of us here who are glad to help.
And I was joking about mice and mouses...I like the word mouses
Mark
|
|
|
|
|
As a Computer Engineering student not a Computer Science, I am allowed to take codes or some parts of it from various sources, my project supervisor has suggested to ask experts like you people here. The main purpose of my project is how to implement these codes on PCs connected in a network. I heard that there are just few simple commands that should be sent between teacher and student PCs under windowsXP which can provide lock/release feature.
So I want some steps, information or some useful links related to the topic.
Thank you in advance for any assistance.
Sara
|
|
|
|
|
This may be of interest - It looks like Terminal Services has features you are looking for:
Remote Desktop Protocol[^]
For possible code there may be some in these[^] articles.
Mark
|
|
|
|
|
|
I am having a problem with the block on ReadDirectoryChangesW operating in two threads.
Each thread is watching a separate directory. For illustration, Directory1 has a new file written to it periodically, say every 30 seconds. E.g. 1.txt, 2.txt,...,[n-1].txt, [n].txt. In Directory2, there is a single file, sequenceinfo.txt, which has new data written to it on an incremental basis where each line is some reference to each file being written in Directory1. For example,
1: 1.txt ref info
2: 2.txt ref info
...
[n-l]: [n-1].txt ref info
[n]: [n].txt ref info
So basically, ReadDirectoryChangesW watches Directory1 for new files being written sequentially. Each time a new file is written, the file is opened and the data funnelled into a database. The thread watching Directory2 watches for file size changes, seeks to the last line, and funnels the last line into the database being matched to the relevant file info read from Directory1.
The problem I am experiencing is that the longer the watching continues, the longer it takes for the events to fire. There seems to a constant deceleration in the time it takes for ReadDirectoryChangesW to unblock. Is there perhaps a buffer that needs flushing somewhere ot something?
Any ideas or suggestions will be much appreciated.
-- modified at 8:39 Sunday 4th February, 2007
|
|
|
|
|
I would suspect the problem lies in the opening and closing of the file you are writing to. The larger the file becomes, the slower the process of iterating to the end becomes.
In your case, I would use a named memory mapped file and keep it open in both threads.
|
|
|
|
|
This sounds plausible. I am using the Seek method though. While I know disk accesses are not random access..surely by specifying the address of the last line to seek to would make a pretty quick seek, The files aren't massive, 800KB at the most. I don't know a helluva lot about disk I/O though so I could be way off track here. Any suggestions for literature on "named memory mapped" files?
Thanks for the response. Much appreciated.
|
|
|
|