|
If you are using MFC, you can use COleDateTime. It has a ParseDateTime function you can use to extract a date from a string.
|
|
|
|
|
thanks, You saved me ?????? (and in a very very quickly way and time)
Thanks
Alessio Bulleri
a.bulleri@metodoshoes.it
norbland@lycos.it
|
|
|
|
|
My program is not made to handle the "Large Fonts" option in Windows, and therefore when this options is used, things don't appear in lists and so on (Because the list sizes are fixed, and noscroll is enabled). Is it possible to force the font to a spesific size? I want the app to use "MS Sans Serif", size 8 no matter what the windows settings are...
Sprudling
|
|
|
|
|
Hi,
This is just something that a professional Windows developer has to deal with. Windows will scale everything differently based on large fonts. You aren't allowed to mess with this. The OS is doing it behind the scenes.
You have a few options:
1) Keep your lists the same size and rely on tooltips to show the whole item in the list when the user hovers over it.
2) Add scroll bars.
3) If your window is smaller than the screen size, consider adding resizing support such as the CResizeableDialog class by Paolo Messina (found on this site).
Good luck!
CodeGuy
http://groups.yahoo.com/group/wtl
|
|
|
|
|
Can somebody please tell me how to max/min toggle a view in a splitter?
Checkout
http://www.codeguru.com/mfc/comments/7113.shtml
to see an attempt by Kirk but his code will not solve this case:
Imagine a 2x2 splitter where the pane in row 2 col 2 is to be toggled to full view, that is the top left, top right and lower left should be hidden. Hiding them works fine, but when I wish to restore the hidden panes the views in the panes are swapped. And I can't seem to get around it.
|
|
|
|
|
afx_msg int CChildWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
CClientDC dc(this);
CFont font;
font.CreateFont(charHeight, 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "MS Sans Serif");
//charheight is any number (usually 12)
dc.SelectObject(&font);
m_MyEdit.SetFont(&font);
...
}
This works fine on Win98, but on WinNT and Win2000 it seems like nothing happens. The default font (FixedSys) is being used instead. Why? And it's not only MyEdit, but all other childwindows: CStatic, CListCtrl, CEdit, CStatusBarCtrl, anything!
Please help me
|
|
|
|
|
You need to allocate the CFont object with the new operator (on the heap) and you need to maintain it for as long as you plan on using that font for those controls. Actually, I am surprised it works on Win98. Usually, I allocate fonts in my OnCreate or OnInitialize and destroy them in the OnDestroy or destructor.
|
|
|
|
|
You would not need to allocate the CFont object on the heap -- you could do on the stack as a class member variable. One less thing to worry about during cleanup. However, you still have to remember to call DeleteObject() in OnDestroy.
CodeGuy
http://groups.yahoo.com/group/wtl
|
|
|
|
|
You are absolutely right, it just needs to be persisted as long as it is being used.
I just like to have definitive control over all resource related functionality.
|
|
|
|
|
A global CFont object could do the job as well I guess then, but is that "good programming"?
Sprudling
|
|
|
|
|
No. Resources such as fonts should be tied to the lifetime of their windows. Also, you would not want to let other windows have the potential of fighting over the same global font variable.
CodeGuy
The WTL newsgroup: 860 members and growing ... http://groups.yahoo.com/group/wtl
|
|
|
|
|
The scenario is that I have a file xyz.ini and I want to make a backup of it called xyz.ini2 and then rewrite to xyz. I have tried CFile::Rename and CFile::Duplicate and I am getting "a sharing violation occured while accessing an unnamed file".
CFile temporiginifile;
temporiginifile.Open(m_sFileFullPathName,CFile::modeReadWrite|CFile::shareDenyNone);
temporiginifile.Rename(m_sFileFullPathName,m_sFileFullPathName+"2");
temporiginifile.Close();
Paradise is where I am.
Voltaire
|
|
|
|
|
Just use CopyFile API function. All you need to do is to pass the filenames.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Thanks.
Paradise is where I am.
Voltaire
|
|
|
|
|
|
I'm adding dynamically several pages in a Propertysheet, but when the tabscontrols are on more than one line the sheet doesn't inflate automatically.
What can I do?
Natacha
|
|
|
|
|
Does anyone know if there is any way to easily format the contents of a messagebox? Or maybe just format a CString to be a specified number of columns wide.
Now I first have to create a CString and use the Format method on it to fill it with text, values and new lines. But since I'm never sure about how much space the values take it's hard to format the text to look good in the messagebox. What I'm looking for is a way to insert newlines automatically at runtime. Is there any simple way to do this?
Thanks!
|
|
|
|
|
Hi..
Use, the tab "\t" and "\n" with CString to solve this problem. See the sample given below.
CString str;
str.Format("Rejeesh\tRamesh\tRanjit\nRejeesh\tRamesh\tRanjit\nRejeesh\tRamesh\tRanjit");
AfxMessageBox(str);
|
|
|
|
|
I don't think it's worth the trouble - the font displayed in the msgbox can be different on different machines; the maximum width of msgbox depends on screen resolution, etc.
You'd have to get the font metrics and compute widths 'manually'. And it's plain impossible to get pixel-perfect columns this way - inserting spaces doesn't give you this level of control.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Thanks for your answers. I'm afraid I was a bit unclear though. What I would like is to specify the desired width of my messagebox and then the program should take care of word-wrapping for me.
I guess you thought I wanted to line up data in columns. When I read my first post again I can see that I was a bit vague about what I was looking for.
So, let's say I have a string like this:
"This is a long string that's supposed to be in a messagebox. It contains some values of unspecified length, for example 1.23456789 and John Doe"
Then it would be nice to just tell my messagebox that this string should be divided over several lines where no line would be more than say 40 characters, or 400 pixels, or something like that.
Is there any support for this in MFC, or would I have to write my own messagebox class? Or a new string class? It probably wouldn't be very difficult, but I'm not sure it would be worth it. Well except for the fun of it.
|
|
|
|
|
Then it would be nice to just tell my messagebox that this string should be divided over several lines where no line would be more than say 40 characters
So you just need to scan the string and insert newlines at appropriate positions - probably replacing spaces between words. You don't need new class for that - a function will be enough.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
You're right, I don't need a class for that. A function should be able to handle it.
Thanks for your help!
|
|
|
|
|
Can someone enlighten me as the significance of the Const keyword, when used in terms on const char * or LPCSTR etc. I have never understood what it does...
Regards
Ray
"Je Suis Mort De Rire"
|
|
|
|
|
it means that a variable is constant. ie unchanging.
|
|
|
|
|
The "const" keyword is a compiler directive which tells the compiler that the variable following const will not be changed by the code which executes against it. It can improve performance because the compiler can make better decisions about how to handle data passing, etc. The most signifigant benefit (that I am aware of) to using const is in parameter passing.
void SomeFunction(int iValue, char* pszValue);
This function declaration just tells the comiler that it needs an integer and a pointer to a char. If this function is called from anywhere in the app, the compiler must insure that the iValue is a copy from the calling function and that char* pszValue is a changeable value.
void SomeFunction(const int iValue, const char* pszValue);
With this version of the function declaration, the compiler assumes that it can just pass the parameters in the most effecient manner possible and does not need to deal with determining if the calling procedures version on iValue of pszValue where const or not, nor does it have to allocate a new int for the iValue paramater.
I should include here that the const keyword is a hint to the compiler, but it is possible (although very dangerous) to cast a const to a non const.
char* pszTemp = (char*)pszValue);
|
|
|
|