 |
|
 |
A handy tool to add to one's toolkit
|
|
|
|
 |
|
 |
Hi there,
thanks for this handy utility, however, I cannot now compile correctly since moving to aVS2005 environment
here is the error
error C2440: 'static_cast' : cannot convert from 'BOOL (__thiscall CStaticFilespec::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'
the line it occurs on is the "ON_MESSAGE" line of
BEGIN_MESSAGE_MAP(CStaticFilespec, CWnd)
//{{AFX_MSG_MAP(CStaticFilespec)
ON_MESSAGE( WM_SETTEXT, OnSetText ) <------------------ Error
ON_WM_ERASEBKGND()
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
can you help me fix this?
regards
Lee
|
|
|
|
 |
|
 |
Looks like the signature of the WM_SETTEXT handler has since changed. Try using this instead:afx_msg LRESULT OnSetText (WPARAM wParam, LPARAM lParam); Thanks,
/ravi
|
|
|
|
 |
|
 |
Thank you for the reply Ravi, you are a star. I am sorry to be such an imbecile, but where do I add this, do you mean to remove the whole
BEGIN_MESSAGE_MAP(CStaticFilespec, CWnd)
//{{AFX_MSG_MAP(CStaticFilespec)
ON_MESSAGE( WM_SETTEXT, OnSetText )
ON_WM_ERASEBKGND()
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
and just put your line in instead?
afx_msg LRESULT OnSetText (WPARAM wParam, LPARAM lParam);
thank you so much for the help, you don't know how much you've helped me!
|
|
|
|
 |
|
 |
If I change the following:
//afx_msg BOOL OnSetText (WPARAM wParam, LPARAM lParam);
to
afx_msg LRESULT OnSetText (WPARAM wParam, LPARAM lParam);
in the "protected" section of class CStaticFilespec : public CWnd
I get 2 new errors
1>.\StaticFilespec.cpp(88) : error C2556: 'BOOL CStaticFilespec::OnSetText(WPARAM,LPARAM)' : overloaded function differs only by return type from 'LRESULT CStaticFilespec::OnSetText(WPARAM,LPARAM)'
1> n:\projects\testfolderbrowse\StaticFilespec.h(55) : see declaration of 'CStaticFilespec::OnSetText'
1>.\StaticFilespec.cpp(88) : error C2371: 'CStaticFilespec::OnSetText' : redefinition; different basic types
1> n:\projects\testfolderbrowse\StaticFilespec.h(55) : see declaration of 'CStaticFilespec::OnSetText'
|
|
|
|
 |
|
 |
of course, I had to change the return type in the function as well
My only problem now is
1>Project : error PRJ0002 : Error result 1 returned from 'C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\rc.exe'.
1>Build log was saved at "file://n:\Projects\TestFolderBrowse\Release\BuildLog.htm"
but maybe that's no longer your code?
|
|
|
|
 |
|
 |
I'll try to post a VS2005 compatible version this weekend.
Thanks,
/ravi
|
|
|
|
 |
|
 |
i am a newcomer to EMP platform.Can any one give the simple "hello world" example to me ,in order i can have a basic idea of coding.Please help me out.I have the hierarchy of the program but at coding i am facing problem.GUI->Display Mgmt->CCanvas->ICanvas.
|
|
|
|
 |
|
|
 |
|
 |
There is some bug with erasing background. Althought there is the OnEraseBkgnd() function, it still seems that system is also erasing background, because when I remove FillSolidRect() (just try this), background is erased always to gray color, but text background is white .
I need to draw white background, so i put there
pDC->FillSolidRect (&rectWnd, ::GetSysColor (COLOR_WINDOW));
It seems to be OK, but flickering is visible.
Any idea ?
rrrado
|
|
|
|
 |
|
 |
Hmm, I haven't noticed this problem but will look into it. Unfortunately, it may take a while before I get the chance to do this.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
 |
|
 |
the class have a bug when the static use the TRANSPARENT attribute.
use TRANSPARENT attribute, and change the text of the static window for twice or more, then the bug display, the first text no brushed. have two text together. it is bug.
Pls have a look, can you help to change the bug?
thanks.
|
|
|
|
 |
|
 |
Thanks, I'll look into it.
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
 |
|
 |
Like above - howto
thx in advance
|
|
|
|
 |
|
 |
You can use these API functions instead of subclassing and drawing text if targeting platform with Internet Explorer 4.0:
//#if _MFC_VER < 0x0700
#include "shlwapi.h"
#pragma comment(lib, "shlwapi.lib")
//#endif
::PathCompactPath - Truncates a file path to fit within a given pixel width by replacing path components with ellipses.
::PathCompactPathEx - Truncates a path to fit within a certain number of characters by replacing path components with ellipses.
::PathSetDlgItemPath - Sets the text of a child control in a window or dialog box, using PathCompactPath to make sure the path fits in the control.
In MFC 7.0 the path functions are used (for example in CWinApp if I am not mistaken).
Armen Hakobyan
armenh@cit.am
|
|
|
|
 |
|
 |
Thanks for the tip, Armen! The original code was written before these functions were available.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
 |
|
 |
Ravi Bhavnani wrote:
The original code was written before these functions were available.
Was your code written before Windows 98 came out? That's when PathCompactPath() became available.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
 |
|
 |
It was written in 1999. I hadn't yet installed Win98 and was unaware of the PathCompactPath() API and the SS_ENDELLIPSIS and SS_PATHELLIPSIS styles.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
 |
|
 |
(Thanks to Jiri Karasek for pointing this out).
The control doesn't display disabled text correctly. Here's the fix (I'll update the article shortly):
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
 |
|
 |
You can also try PathSetDlgItemPath(HWND hDlg, int id, LPCWSTR pszPath)
where:
hDlg is the m_hWnd of the dialog box that contains the control,
id is the id of the control,
pszPath is the pathname to place on the control.
Make sure that you #include "Shlwapi.h" and link with Shlwapi.lib.
Good Luck,;)
Don Sanders
don.sanders@mail.com
|
|
|
|
 |
|
 |
HAHAAH.. You got the HUNT!!! Onec again
heartens,
Balkrishna Talele
|
|
|
|
 |
|
 |
I was able to use your code to get it to display just a reduced path but I want to do some thing like below and it won't work right...
----------------------------------------------------------
| |
|Writing: C:\folder\folder\folder\folder\fol...\file.txt|
| Form a file at http:\\mysitedotcom.com |
| |
----------------------------------------------------------
Here how it is done with SetWindowText(IDC_STATIC, _T("\nWriting:\tC:\folder\folder\folder\folder\folder\folder\file.txt\n\t\tForm a file at http:\\mysitedotcom.com"));
http:\\mysitedotcom.com won't be changing so let forget about that....
I tried to chop it into three lines
and call DrawText() for each line but adding 12 to the .top of the rect and take DT_PATH... out for the last line. That didn't work it just said the text that was their before
the call to DrawText() and is not related to this posting...
I think with what I am trying to do and having this Article OnPaint() handler just get the StaticCtrl text doesn't do the job but PathCompactPath() form another viewer posting looks better for what I am do but I am building this program for other programmers whose cleints might run older systems...
Is their another way or do I have to sit down and use CString::GetAt(), CString::SetAt(), CString::GetLenght().
Thanks....
|
|
|
|
 |
|
 |
I think you'd need to use separate instances of the CStaticFilespec class. A couple of suggestions:
- Use \r\n instead of \n
- Don't use \t - most fonts can't display this properly
- Use the DT_ style DT_WORDWRAP and don't use DT_VCENTER
Hope this helps.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
 |
|
 |
thank for the reply...
\r\n\ did the same thing....
I am using default font for the static text control so should be able to use \t and I need tab in the display.
DT_WORDWRAP doesn't exists on at least my system but DT_WORDBREAK does so I try that and that didnt work.
how can I use the CStaticFilespec class more than once using the same control and inside the middle of the String I using.
|
|
|
|
 |
|
 |
Try the PathCompactPath function.
Ok it exist only if IE4 is installed.
|
|
|
|
 |