|
Yes, but the problem is that I do not want to block updates completely. Say that someone is moving through the records on-screen and updating them. In that case they will lose the update if they change a field and move to the next. It is just the key/id field that I want to protect on existing records. Am I making sense?
|
|
|
|
|
Is it imperitive that this "key field" be manually assigned/updated? If not, just change the field in the database to be auto-increment. Remove that one field from the recordset class. When a new record is added, it will get the next available number. When the navigational buttons are clicked, no update to the auto-increment will take place.
Another option would be to add a "Go To" button next to the edit box containing the key field. That way, this button would not be tied to the other navigational buttons.
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
"Is it imperitive that this "key field" be manually assigned/updated? "
Yes, unfortunately. The user must be able to specify new items. An analogy would be a POS system where the unique ID is the EAN-code.
"Another option would be to add a "Go To" button next to the edit box containing the key field. That way, this button would not be tied to the other navigational buttons."
Not sure that I follow you there?
|
|
|
|
|
Anders Gustafsson wrote: Not sure that I follow you there?
I meant to say there should be two additional buttons. One labeled "Go To" and the other labeled "Add." Now if you type in an item number and click the "Add" button, it will clear the form and add a new record with that item number. If you type in an item number and click the "Go To" button, it will populate the form with that item's information. If you click one of the navigational buttons, appropriate item will be displayed.
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
OK. Problem is that I cannot rely on buttons alone. The app must be navigable by keyboard alone. Skilled operators get very nervous when they have to take their hands off the keyboard. At the same time the system should be friendly to novices
One very drastic solution would be to disable the nav-buttons entirely, but that would make me rather unpopular with existing users.
Any thoughts about my idea to "mark" fields and prevent the DDX unless we are in add mode?
|
|
|
|
|
Anders Gustafsson wrote: Any thoughts about my idea to "mark" fields and prevent the DDX unless we are in add mode?
Sounds good.
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
OK. Thanks. I will try that approach and have some users betatest it.
|
|
|
|
|
Remember the previous value in the key field and restore it in the PreviousRecord handler before doing the OnMove.
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|
|
"PreviousRecord handler"
Now you lost me? Where is that? Ie member of what class?
|
|
|
|
|
I mean whichever function gets called when the user presses "PreviousRecord"
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|
|
OK. That means OnMove. But that would mean a rather complicated copy of OnMove in every data input view and there are at least ten of them for various tables.
If I prevent the DDX in the class (derived from RecordView where they all inherit, then I need just one line per data input view, to set one or more fields as "protected" unless we are adding a new record.
|
|
|
|
|
Hi All,
I want to draw text inside a bounding rect.Therefore I want to change the font size to fit the rect. I am trying to find a way to calculate the text width and height, knowing it's font.
Why do different fonts with the same size have different height?
Thanks, Udi Raz
|
|
|
|
|
See DrawText() with the DT_CALCRECT flag, GetTextMetrics(), GetCharABCWidths(), GetCharWidthFloat() and GetCharWidth32
onwards and upwards...
|
|
|
|
|
Thanks but already tried it all and everything else I found in the msdn regarding fonts.
The answer for the height in all methods is the font height. The problem is that fonts don't use the whole width to draw their characters. As a result, if I create a rectangle with the size x, a certain font with the size of x will be drawn perfectly well inside my rectangle but a second font (for Hindi fonts) will be drawn very small. What I need (and start to think there is no such a method) is a method that gives me the true height of the character.
Any Ideas?
|
|
|
|
|
Use GetTextMetrics(). Read the info on MSDN on font layout. You can then calculate the actual line height via the members in the TEXTMETRIC struct that is filled out from the call to GetTextMetrics(). Specifically, the tmHeight and tmOverhang members.
onwards and upwards...
|
|
|
|
|
Thanks again for your patience.
I checked each of the TEXTMETRIC members and didn't see the answer.
tmHeight is the font size and tmOverhang is the extra width if I use Italic or Bold which I use none of them.
Still, If I choose "Ariel" with the size X and "Comic Sans MS" with the same size, the display font height are different. In addition, Using the same font, the letter 'a' and the letter 'b' have a different height. Therefore to know the real height of a specific font, the query method needs to the recieve the specific text in addition to the HDC. I am not sure there is such a method and I will be satisfied with known the difference between fonts
please advise
Thanks in advance, Udi Raz
|
|
|
|
|
I hope you don't mind me sneaking in here. I have the same problem with showing numbers in CEdit controls. How to find the TRUE pixel width of the text? I need to know how many digits can be shown in the control so that I can put in as many as possible, and round the number correctly.
It is easy enough to use DrawText() with the DT_CALCRECT flag, making sure that SetFont is done correctly, and for small font sizes the code works well. But as the fonts get bigger, DrawText's calculations just do not agree with those of CEdit.
I'm stumped too, and have temporarily had to restrict the font face and size, and apply magic numbers to get the stuff to work.
Shraddhan
|
|
|
|
|
Hi Shraddhan,
I get the filling that there is no way to get the real height, but as regarding the width, although I can't help you right now, I think in one of my attempts I got the real width using one of the following methods GetTextMetrics(), GetTextExtentPoint32(). It depands whether you are using a raster font or a open type/true type font.
I think that is works for me, but don't remember how. I still trying to find the real height...
Udi Raz
|
|
|
|
|
I couldn't find information on GetTextExtentPoint32.
GetTextMetrics returns a TEXTMETRIC structure that gives average and maximum character width, which are no good for my purposes.
Under GetTextExtent and GetOutputTextExtent, Microsoft notes:
Since some devices do not place characters in regular cell arrays (that is, they carry out kerning), the sum of the extents of the characters in a string may not be equal to the extent of the string.
So clearly ambiguous!
My notes on my problem with fitting strings into CEdit controls mention that the text is shown with white space on either side. In fact, with large font sizes. the output is chopped on the right if it gets anywhere near the edge of the edit box. But I have no idea what the whitespace allowance should be. It depends on the face as well as the size.
So is this a feature of CEdit controls?
As for finding the overall height, one last ditch method occurred to me: draw the text to a bitmap and measure the height of the drawn area by scanning the pixels. Don't ask me how, though.
Shraddhan
|
|
|
|
|
Thanks, I know how ( by using DC::Getpixel() ) but will not take a reasonable time...
|
|
|
|
|
Last weekend I discovered the new features of VC 2005. One of them is very interesting for me: the new compiler flag /arch:[SSE|SSE2]. Currently I have to be able to deactivate the parts of my code I have optimized with SSE/SSE2. So I use precompiler statements to switch between SSE/SSE2 and ordinary C++. This means that I have to write a lot of code twice. The new compiler flag would reduce the time I spend to optimize my code considerably.
Unfortunately the documentation of the discussed compiler flag is not very large and it does not say how to find out which parts of the code were optimized by the compiler or even how to write C++ code to help the compiler with optimizing. I did not found much on the web about this topic so I would be happy if you could send me your experiences with this new compiler flags or a link to an expressive description on the web.
Thank you in advance.
Philipp Grohs
-- modified at 13:25 Monday 16th January, 2006
|
|
|
|
|
hiii i'm making a Calculator in Visual C++ but having sum probs, in code i've created all the buttons n now i don't know how to add two numbers wich are pressed on buttons.. Can neone help me out..
Paritosh Tripathi
B.Tech. (C.S.)
|
|
|
|
|
Take a look at CP, I think you can find some example calculators.
But it is not a trivial problem. You have to keep track of the states that you are in. Look at the book "Practical Statecharts in C/C++" by Miro Samek for a description of how to create a robust solution.
But if all that you are looking for is adding two numbers (i.e. no other functionality for this program) your states can be trivial. If you only have the digits 0-9 and a + and =, I think you can get by doing the following:
For each number pressed: Add that digit to the display field
For +: store the integer in the display and prepare to clear the display when the next number is pressed.
For =: get the number currently displayed and ADD it to the stored number.
Draw a state diagram to make sure you cover various cases, such as pressing 1010 + = : this should have the effect of 1010 + 1010 = 2020.
+ 1010 = : this should have the effect of 0 + 1010 = 1010
And what about 1010 + + = : 1010 + 1010 + 1010 = 3030
The book I mention covers a calculator example and should be very helpful in general for learning how to handle statemachines.
|
|
|
|
|
hi techno,
ok, lets sum up.
there are many ways to make a calculator, that i think my VisualCalc is not exactly what you are designing, am i wrong ?
you're having buttons on the GUI, so, i think you have to store the result in a member each time it is recalculated.
as you seem very beginner, i'll consider you're calculation engine class is written within the UI dialogBox class (still wrong with this ? )
- so, add a member in the class to store the result (lets say float m_fResult; )
- then, when you press an operation button (like '+' ) you have to store somewhere that it is an addition to be performed (design an type which enumerated the possible operations, and make a member of that type (say m_Operation ) in your class which will store the operation to perform (here, ADDITION).
- then, the user types its number, and when then equal button is pressed ('=' ), you test the m_Operation variable.
if m_Operation == ADDITION Then
Add m_Result + lastly typed value
store the new value into m_Result
End If
any more help ?
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VisualCalc 3.0]
|
|
|
|
|
...hello every body,
well the night calmed me down, and all your answers were nice enough.
so, not only i decided do delete the outrageous post, but i too wanted to say this here.
i'm very sorry if some of you didn't understand my reaction. i had to say this, because i was very angry because of thy stupid guy. that's all.
have a good day all of you (yeah, i sad ALL OF YOU, even you, yes, YOUUUU who don't like me )
|
|
|
|