|
Does anyone know what the limit for the length of a single CString is? I thought it was 255 characters, but I can't find any documentation on it. Any references to documentation on this would be appreciated as well.
I'm using MFC 6.0.
Thanks,
Jason
|
|
|
|
|
No, it's not 255 characters. There are limits on the length of strings in resources and other places, but the only limit is the length of the CString length variable, which is a signed int. Thus, assuming you have enough virutal memory space, you can create strings up to 2GB.
|
|
|
|
|
From the topic 'Strings in MFC' (from VC5.0 documentation, YMMV):
"A CString object can store up to INT_MAX (2,147,483,647) characters. "
|
|
|
|
|
I have a basic MFC app. Basically, you can start the MFC appwizard, choose Dialog Based, and arrive at a dialog. Now, I want the dialog to monitor they keys pressed on the keyboard (some keys in combination), so I use GetKeyboardState(). The problem is whenever I hit a key it dings. I've attempted to override the WM_KEYDOWN, CHAR and other relative messages. Furthermore, I seem to fail to set the focus away from the OK button by using SetFocus() in the OnInitDialog(). When I remove ALL the controls, the dialog finally gets my WM_KEYDOWN events. I should be able to set the dialog to receive events even with controls on it shouldn't I? But I digress. The only reason why I'm attempting to override those events is because of the dinging.
My goal is to make an app in MFC where I can use the keyboard to modify a state structure via quake-like key bindings.
I think once I fix the dinging, I'll be happy.
Thanks in Adavance
|
|
|
|
|
In order to use SetFocus() in OnInitDialog(), you need to return FALSE from the OnInitDialog() function (as it says in the comment at the bottom of the function)
You can also trap key events in PreTranslateMsg function.
|
|
|
|
|
The OK button by standard is the default button.
You might want to change that too.
Wolfgang Reichl
|
|
|
|
|
I need to contain a web folder view (like the one in the Explorer) in an application for a selected file.
Does anyone know how to implement it in an easy way?
Can I use a shell view for this?
Thanks!
|
|
|
|
|
Hi,
Is it possible to retreive the type of a variable ?
I want to pass this type to a template like in :
Vect2d < int > vect, but I want to replace "int" by an
argument containing the type.
I have tried with a string, but whitout success.
Anybody knows if I can do that ?
Thanks,
Claude
|
|
|
|
|
To find out the type of a variable at runtime use a C++ feature called RTTI (runtime type information).
It is explained pretty well in the MSDN.
Regards,
Paul Barrass
|
|
|
|
|
I'm not sure I understand what you mean.
Templates are compile-time. That means the type must be known when the program is compiled. Can you give an example of what you are trying to do?
|
|
|
|
|
Hi,
I having problems vith VS. Everytime I use the ClassView for adding a new function the class disappears from classview - you know rightclick on the class and choose 'Add Member Function'.
When I delete the project's .NCB file everything is back, until the next time I decide to add a function.
Has anybody experienced the same?
Christian Skovdal Andersen
|
|
|
|
|
Hey Christian,
I used to experience a bug similar to that in the ClassView, but was resolved when I installed SP4. What version of VC on which OS are you using?
Regards,
Paul Barrass
|
|
|
|
|
Hi Paul.
Thanks for your reply.
I'm running Win2K with VS6. I too tried installing SP4, when I got the problem, but unfortunately it did'nt work.
I uninstalled everything and installed VS from scratch. It took half a day but now everything works fine (until next time something goes haywire)
There are still the same problem if I delete a member function from the classview - but I can live with that.
I *really* look forward to the next release!
Regards,
Christian Skovdal Andersen
|
|
|
|
|
ClassView can be very sensitive at times to things like Macros, typedefs, and templates. I've seen Macros that make member variables show up as globals in ClassView, and all kinds of weirdness. Typically, you start to lose visibility in ClassView when CV parses something wrong. My suggestion would be create a copy of the project, then start removing files until the problem goes away. Then figure out what's weird in that file.
|
|
|
|
|
Thanks for your reply,
Actually I just uninstalled VS and installed it from scratch.
Your idea is good, and I will try that the next time it hapen ( I'm sure it will )
Christian Skovdal Andersen
|
|
|
|
|
What methods do you use for localization?
I've been struggling with this for quite some time. The problem is that it's very error prone to keep multiple resources for each language. Whenever you change one, you need to change them all, and when doing complex updates you can often forget. This then requires extensive testing in all languages.
What are your localization strategies?
|
|
|
|
|
I use dynamically sized resources and read the texts in at runtime. I found this to be stable verus changes in display preferences (e.g. bigger fonts). I one app the user can change languages at runtime. All buttons/dialogs/... resize and redisplay. This means automatic layout, so you can't be all that fancy as if you did pixelalignment yourself.
I got the basic idea from KDE.
|
|
|
|
|
I am looking at a bug in a project I working on, which uses lots of dialogs attached to a tab control. All dialog classes a derived from one of two class in a framework for the the system. In just one the message map is not trapping the set focus message for a reason that is not obvious. It is very strange because out of some 200 tabs only one is giving trouble.
I thing I have checked all the obvious things - any other sugestions would be welcome.
Happy programming!!
|
|
|
|
|
hi,
I need help with this:
I made a dialog box, and in this dialog box there is a Rich edit field. Now, when I press 'enter' the dialog box closes. I've tried everything I could think of to stop it from doing that.I want it to just add a return in the rich edit field.
Can somebody help me with this?
|
|
|
|
|
The <return> key is mapped to the OK button, and the <escape> key to the Cancel. You may be able to change this by making your rich edit the default control, but I suspect you will need to over-ride OnOK, and in it check if the return key is down ( GetKeyState(VK_RETURN) from memory ) and, if so, return - that is, don't call CDialog::OnOK();.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
Set the "want return" style for the edit control, then it'll do what you want.
--Mike--
http://home.inreach.com/mdunn/
"That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas."
-- Buffy
|
|
|
|
|
I agree with Michael and Erik, you need to find a better approach. You should consider using a grid control, or the listview control. It will make your life quite a bit easier.
D
|
|
|
|
|
If you're using that many checkboxes, there's something else wrong with your app. It won't run well under Windows 9x, since Win9x has much more limited resource pools for window handles (of which a control has).
Re-think your design. There has to be a better way to do this. If I were one of your users, I'd shoot myself (or you) if I had to use such an interface.
|
|
|
|
|
Egads. Well, if you really need that many checkboxes, use a CCheckListBox instead. Or a CListCtrl with the checkboxes style.
|
|
|
|
|
Hi All,
I have a small problem achieving something with a CRichEditCtrl (MFC). Basically the problem is that i would like to determine the height (in pixels) of the text contained within the control.
For example, setting the height of the control to this value would result in the text fitting perfectly within the control. (i am only interested in the vertical direction)
The control can contain varying sizes and fonts of text within it, as well as multiple lines.
I hope one of you has a clue on how to accomplish this.
Any suggestions would be most appreciated.
~Alex
|
|
|
|