|
|
Comments and Discussions
|
|
 |

|
The WCHAR Error is still not fixed.
I think the CA2W depends on
class CA2WEX
When you do not like that does work allways:
WCHAR *lfFaceName = (WCHAR *)malloc(LF_FACESIZE * sizeof(WCHAR));
for(int i=0; i<LF_FACESIZE; i++) lfFaceName[i] = (WCHAR)csLogFont.lfFaceName[i];
Font f( (WCHAR *)lfFaceName, emSize, FontStyleRegular, UnitPoint, NULL);
if(lfFaceName) free(lfFaceName);
|
|
|
|

|
Frist,the code need to use:
------------------------------------------
#include "gdiplus.h"
#pragma comment(lib, "gdiplus.lib")
// GDI+ namespace
using namespace Gdiplus;
------------------------------------------
in my stdafx.h file.
then,some problem in the SubclassDlgItem() when the parent windows is ChildWindow...
|
|
|
|

|
when I Create it in InitrialUpdate() in a SDI view application, the progrom always collapse on starting. can it be used this way? thank you
chenzd
|
|
|
|

|
Sorry , my own fault, not initialize GDIPlus
chenzd
|
|
|
|

|
I must say the each one of your controls is better then
the other.
Keep giving us the good stuff.
Best,
Eli
|
|
|
|

|
Some months later.... I say you thanks very much!
SoftechSoftware
Davide Calabro'
davide_calabro@yahoo.com
http://www.softechsoftware.it
|
|
|
|

|
hello everyone.
when we build the tool in release mode.. the text is not getting displayed.
i have used PixiGreg's code but this is not giving the result for the release version.
all in all.. Its a wonderful and sexy tool.
please help me out on this one.
|
|
|
|

|
hello everyone.
when we build the tool in release mode.. the text is not getting displayed.
i have used PixiGreg's code but this is not giving the result for the release version.
all in all.. Its a wonderful and sexy tool.
please help me out on this one.
|
|
|
|

|
Hi Davide~
I found one problem.
Control's parent is not dialog window(just parent is another control window), text is not visible...
I don't know why...
Could you please help me?
Thanks!
|
|
|
|

|
First of all thank you for all your work. This control looks very nice but I have a strange problem. I have installed GDI+ ,and I think that it has been done succesfully because your demo works.(I can execute it correctly)
But when I use your class in my project, everything seems working (compiling and linking succesfull), but at run time the CylinderProgressCtrlST is just not displayed, invisible. Even stranger when I put my mouse over the place where I have put the Progress bar, the toolTipText is displayed!
(Another strange thing is that when I put not 'm_progress.SetShowText(FALSE,FALSE)' a fatal error occurs at runtime)...
Could you please help me?
Thanks!
|
|
|
|

|
GDI+ is not initialized.
Check the example. In CGenericMFCApp::InitInstance() there's a line showing how you can do it:
// Initialize GDI+
m_GDIpInitializer.Initialize();
Gizz
|
|
|
|

|
sf.SetAlignment(StringAlignmentCenter);
Exec error,why
|
|
|
|

|
what is an "Exec error"
SoftechSoftware
Davide Calabro'
davide_calabro@yahoo.com
http://www.softechsoftware.it
|
|
|
|

|
I love it! You can tell how professional I am: I'm trying to think of an app to write just so i can use your control!
|
|
|
|

|
SoftechSoftware
Davide Calabro'
davide_calabro@yahoo.com
http://www.softechsoftware.it
|
|
|
|

|
It seems that this progress bar can only work under UNICODE condition.
Can it work under the ASCII mode?
|
|
|
|

|
have a look at my post below
pixigreg
|
|
|
|
|

|
Davide, you got my 5 - as usual!
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|

|
Thank you!
SoftechSoftware
Davide Calabro'
davide_calabro@yahoo.com
http://www.softechsoftware.it
|
|
|
|

|
Great control !
However, this doesn't compile with non-unicode builds.
This could be repaired by putting two A2W() in case of non-unicode.
bye.
p i x i g r e g
|
|
|
|

|
GDI+ only supports Unicode. Yes, you can do convertions in any way you like, such as for example A2W() or simply removing the code that performs font operations and do it yourself directly into the main application.
SoftechSoftware
Davide Calabro'
davide_calabro@yahoo.com
http://www.softechsoftware.it
|
|
|
|

|
Davide Calabro wrote:
GDI+ only supports Unicode
Indeed, you can have non-unicode builds and pass unicode strings to it.
So you don't want to implement these conversion macro directly so guys using your code wouldn't have to bother adding themselves the conversion macro ?
That would have made your control perfect...
p i x i g r e g
|
|
|
|

|
Where do you add the A2W calls in the code.
I'd like to try it.
David
|
|
|
|

|
I've submitted the modified code that follows to the author, but seemingly he doesn't care about
Just replace the same function in the .cpp file of the control :
DWORD CCylinderProgressCtrlST::OnDrawText(Graphics* pGfx, int nPercentage, Rect* rpCtrl, Rect* rpEmpty, Rect* rpFull, BOOL bHorizontal)
{
if (m_bShowText)
{
CFont* pFont = NULL;
pFont = GetParent()->GetFont();
if (pFont)
{
TCHAR szText[256];
LOGFONT csLogFont;
StringFormat sf;
REAL emSize = 0;
SolidBrush brText(m_cTextColor);
RectF rCtrl((REAL)rpCtrl->X, (REAL)rpCtrl->Y, (REAL)rpCtrl->Width, (REAL)rpCtrl->Height);
pFont->GetLogFont(&csLogFont);
emSize = (REAL)-MulDiv(csLogFont.lfHeight, 72, (int)pGfx->GetDpiY());
#ifdef _UNICODE
Font f(csLogFont.lfFaceName, emSize, FontStyleRegular, UnitPoint, NULL);
#else
#if _ATL_VER >= 0x0700
CA2W lpszwFont((LPCSTR)csLogFont.lfFaceName);
Font f(lpszwFont, emSize, FontStyleRegular, UnitPoint, NULL);
#else
USES_CONVERSION;
Font f(A2W((LPCSTR)csLogFont.lfFaceName),
emSize, FontStyleRegular, UnitPoint, NULL);
#endif
#endif
sf.SetAlignment(StringAlignmentCenter);
sf.SetLineAlignment(StringAlignmentCenter);
_stprintf(szText, _T("%d%%"), nPercentage);
pGfx->SetTextRenderingHint(TextRenderingHintAntiAlias);
#ifdef _UNICODE
pGfx->DrawString(szText, -1, &f, rCtrl, &sf, &brText);
#else
#if _ATL_VER >= 0x0700
CA2W lpszwText((LPCSTR)szText);
pGfx->DrawString(lpszwText, -1, &f, rCtrl, &sf, &brText);
#else
Font f(A2W((LPCSTR)szText),
emSize, FontStyleRegular, UnitPoint, NULL);
#endif
#endif
} }
return CYLINDERPROGRESSCTRLST_OK;
}
pixigreg
|
|
|
|

|
PixiGreg wrote:
I've submitted the modified code that follows to the author, but seemingly he doesn't care about
People sometimes is busy....
SoftechSoftware
Davide Calabro'
davide_calabro@yahoo.com
http://www.softechsoftware.it
|
|
|
|

|
Interesting, I've never had to do it that way, great to learn something new!
Probably should have thought about CA2W as a Cast.
David
|
|
|
|

|
Hi,
have problem with this line...
Font f(A2W((LPCSTR)csLogFont.lfFaceName),emSize, FontStyleRegular, UnitPoint, NULL);
=> A2W undeclared identifier... what's that ???
thanks...
else your CCylinderProgressCtrlST runs really well Davide!!! ... have make a beautiful GUI with it!! ( RSAttack576 client GUI)
thanks
|
|
|
|

|
Orkblutt wrote:
=> A2W undeclared identifier... what's that ???
thanks...
#include <ATLCONV.H>
bye!
p i x i g r e g
|
|
|
|

|
thanks pixigreg!
have now problem with this line
Font f(A2W((LPCSTR)szText),emSize, FontStyleRegular, UnitPoint, NULL);
=> f redefinition
i'm trying that:
DWORD CCylinderProgressCtrlST::OnDrawText(Graphics* pGfx, int nPercentage, Rect* rpCtrl, Rect* rpEmpty, Rect* rpFull, BOOL bHorizontal)
{
if (m_bShowText)
{
CFont* pFont = NULL;
pFont = GetParent()->GetFont();
if (pFont)
{
TCHAR szText[256];
LOGFONT csLogFont;
StringFormat sf;
REAL emSize = 0;
SolidBrush brText(m_cTextColor);
RectF rCtrl((REAL)rpCtrl->X, (REAL)rpCtrl->Y, (REAL)rpCtrl->Width, (REAL)rpCtrl->Height);
pFont->GetLogFont(&csLogFont);
emSize = (REAL)-MulDiv(csLogFont.lfHeight, 72, (int)pGfx->GetDpiY());
USES_CONVERSION;
LPWSTR x = A2W((LPCSTR)csLogFont.lfFaceName);
Font f(x,emSize, FontStyleRegular, UnitPoint, NULL);
sf.SetAlignment(StringAlignmentCenter);
sf.SetLineAlignment(StringAlignmentCenter);
_stprintf(szText, _T("%d%%"), nPercentage);
pGfx->SetTextRenderingHint(TextRenderingHintAntiAlias);
x=A2W((LPCSTR)szText);
Font z(x,emSize, FontStyleRegular, UnitPoint, NULL);
} // if
} // if
return CYLINDERPROGRESSCTRLST_OK;
} // End of OnDrawText
no error but no "x%" in my progress bar :(
|
|
|
|

|
oops, my mistake...
copy & paste is sometimes not very tricky
DWORD CCylinderProgressCtrlST::OnDrawText(Graphics* pGfx, int nPercentage, Rect* rpCtrl, Rect* rpEmpty, Rect* rpFull, BOOL bHorizontal)
{
if (m_bShowText)
{
CFont* pFont = NULL;
pFont = GetParent()->GetFont();
if (pFont)
{
TCHAR szText[256];
LOGFONT csLogFont;
StringFormat sf;
REAL emSize = 0;
SolidBrush brText(m_cTextColor);
RectF rCtrl((REAL)rpCtrl->X, (REAL)rpCtrl->Y, (REAL)rpCtrl->Width, (REAL)rpCtrl->Height);
pFont->GetLogFont(&csLogFont);
emSize = (REAL)-MulDiv(csLogFont.lfHeight, 72, (int)pGfx->GetDpiY());
#ifdef _UNICODE
Font f(csLogFont.lfFaceName, emSize, FontStyleRegular, UnitPoint, NULL);
#else
#if _ATL_VER >= 0x0700
CA2W lpszwFont((LPCSTR)csLogFont.lfFaceName);
Font f(lpszwFont, emSize, FontStyleRegular, UnitPoint, NULL);
#else
USES_CONVERSION;
Font f(A2W((LPCSTR)csLogFont.lfFaceName),
emSize, FontStyleRegular, UnitPoint, NULL);
#endif
#endif
sf.SetAlignment(StringAlignmentCenter);
sf.SetLineAlignment(StringAlignmentCenter);
_stprintf(szText, _T("%d%%"), nPercentage);
pGfx->SetTextRenderingHint(TextRenderingHintAntiAlias);
#ifdef _UNICODE
pGfx->DrawString(szText, -1, &f, rCtrl, &sf, &brText);
#else
#if _ATL_VER >= 0x0700
CA2W lpszwText((LPCSTR)szText);
pGfx->DrawString(lpszwText, -1, &f, rCtrl, &sf, &brText);
#else
pGfx->DrawString(A2W((LPCSTR)szText), -1, &f, rCtrl, &sf, &brText);
#endif
#endif
} }
return CYLINDERPROGRESSCTRLST_OK;
}
p i x i g r e g
|
|
|
|

|
many thanks pixigreg!! run very well now
|
|
|
|

|
Orkblutt wrote:
many thanks pixigreg!! run very well now
You're welcome
But all the merit goes to Davide Calabro for this great control.
p i x i g r e g
|
|
|
|

|
yes yes!
yet thanks Davide !!!
(not a problem that i'm using your control on my GUI Davide ??)
|
|
|
|

|
not a problem if your GUI is freeware.
Cheers,
SoftechSoftware
Davide Calabro'
davide_calabro@yahoo.com
http://www.softechsoftware.it
|
|
|
|

|
yes it is... it's a GUI client of a distributed computing project...really free and maybe gives you money...lol
You can download source client...
I'm using also other of your class like CButtonST, CShadeButtonST...
all your c++ class are great!!!
respects
|
|
|
|

|
DWORD CCylinderProgressCtrlST::OnDrawText(Graphics* pGfx, int nPercentage, Rect* rpCtrl, Rect* rpEmpty, Rect* rpFull, BOOL bHorizontal)
{
if (m_bShowText)
{
LOGFONTW csLogFont;
CFont* pFont = GetParent()->GetFont();
if ((pFont != NULL) && (GetObjectW(pFont->m_hObject, sizeof(csLogFont), &csLogFont) != 0))
{
StringFormat sf;
REAL emSize = 0;
SolidBrush brText(m_cTextColor);
RectF rCtrl((REAL)rpCtrl->X, (REAL)rpCtrl->Y, (REAL)rpCtrl->Width, (REAL)rpCtrl->Height);
emSize = (REAL)-MulDiv(csLogFont.lfHeight, 72, (int)pGfx->GetDpiY());
Font f(csLogFont.lfFaceName, emSize, FontStyleRegular, UnitPoint, NULL);
sf.SetAlignment(StringAlignmentCenter);
sf.SetLineAlignment(StringAlignmentCenter);
pGfx->SetTextRenderingHint(TextRenderingHintAntiAlias);
WCHAR szText[256];
swprintf(szText, L"%d%%", nPercentage);
pGfx->DrawString(szText, -1, &f, rCtrl, &sf, &brText);
} }
return CYLINDERPROGRESSCTRLST_OK;
}
|
|
|
|

|
Hello. If you replace A2W to T2W this code will be compiled in unicode and non-unicode applications.
|
|
|
|

|
note the last part of the snippet.
DWORD CCylinderProgressCtrlST::OnDrawText(Graphics* pGfx, int nPercentage, Rect* rpCtrl, Rect* rpEmpty, Rect* rpFull, BOOL bHorizontal)
{
if (m_bShowText)
{
CFont* pFont = NULL;
pFont = GetParent()->GetFont();
if (pFont)
{
TCHAR szText[256];
LOGFONT csLogFont;
StringFormat sf;
REAL emSize = 0;
SolidBrush brText(m_cTextColor);
RectF rCtrl((REAL)rpCtrl->X, (REAL)rpCtrl->Y, (REAL)rpCtrl->Width, (REAL)rpCtrl->Height);
pFont->GetLogFont(&csLogFont);
emSize = (REAL)-MulDiv(csLogFont.lfHeight, 72, (int)pGfx->GetDpiY());
#ifdef _UNICODE
Font f(csLogFont.lfFaceName, emSize, FontStyleRegular, UnitPoint, NULL);
#else
#if _ATL_VER >= 0x0700
CA2W lpszwFont((LPCSTR)csLogFont.lfFaceName);
Font f(lpszwFont, emSize, FontStyleRegular, UnitPoint, NULL);
#else
USES_CONVERSION;
Font f(A2W((LPCSTR)csLogFont.lfFaceName),
emSize, FontStyleRegular, UnitPoint, NULL);
#endif
#endif
sf.SetAlignment(StringAlignmentCenter);
sf.SetLineAlignment(StringAlignmentCenter);
_stprintf(szText, _T("%d%%"), nPercentage);
pGfx->SetTextRenderingHint(TextRenderingHintAntiAlias);
#ifdef _UNICODE
pGfx->DrawString(szText, -1, &f, rCtrl, &sf, &brText);
#else
#if _ATL_VER >= 0x0700
CA2W lpszwText((LPCSTR)szText);
pGfx->DrawString(lpszwText, -1, &f, rCtrl, &sf, &brText);
#else
pGfx->DrawString(A2W((LPCSTR)szText), -1, &f, rCtrl, &sf, &brText);
#endif
#endif
} // if
} // if
return CYLINDERPROGRESSCTRLST_OK;
} // End of OnDrawText
|
|
|
|

|
Is it the "gdiplus.dll" in the MS SDK that is required?
If it is, even though it is present with the other files in the folder (and present in the other directories also), the program is still not compiling properly.
William
Fortes in fide et opere!
|
|
|
|

|
What compile error do you get
SoftechSoftware
Davide Calabro'
davide_calabro@yahoo.com
http://www.softechsoftware.it
|
|
|
|

|
That was my fault. I had completely forgotten GDI+ works only with Unicode. When I changed the build configuration to Unicode, it compiled, linked and ran without error.
Thanks for sharing your work with the community, and thanks for the many helpful comments you placed in your work. Good man!
William
Fortes in fide et opere!
|
|
|
|

|
WREY wrote:
I had completely forgotten GDI+ works only with Unicode
GDI+ works with unicode disabled in your project !
You've just to pass unicode strings to it thanks to ATL conversion macros.
have a look at my post above !
pixigreg
|
|
|
|

|
Andy
|
|
|
|

|
This is a progress control.
SoftechSoftware
Davide Calabro'
davide_calabro@yahoo.com
http://www.softechsoftware.it
|
|
|
|

|
I know, that was why I posted the question.
There are applications, where the user can need to set the hight level of the cilynder (level regulation).
That meens that it would be nice to have a slider version too, or, a slider version with a method that enable disable the mouse interaction with the control.
Andy
|
|
|
|

|
A progress bar is meant to show a long operation progressing. A slider is meant to allow the user to graphically set the value of a property whithin a specific range. They both are different controls because they perform different UI tasks. Tyring to make one behave like other is just a sure way to confuse the user.
Imaging how useful it would be to have the progress bar used when you are installing Visual Studio .NET go back to zero after the program have been installing for an hour. Would that make sense at all?
You could certainly make a slider out of the cylinder, but they you have to create the properties for the cylinder to behave as a slider not a progress bar and you have to label the control as a "Slider" control not a ProgressBar/Slider control.
This remaind me of a programmer that wrote some code to make checkboxes behave like radio buttons. He was proud of his accomplishement. That was, of course, a horrible idea. Good UI are intuitive not "bizarre".
Regards,
Carlos.
|
|
|
|

|
I'm sorry, my first answer was impulsive and not clear - but your was long and too much free speaking.
Let me explain.
This control is born as a custom ProgressControl, so it acts as a ProgressControl - STOP
Anyway it's a custom control, not a standard control, so in my opinion the comparison with the CHECKBOX and RADIO button doesent make sense, and I'm sorry to say, you will find tons of people that make "bizarre" things giving a free interpretation to what a standard control can do (I can fill a book of samples... and you can freely peek from VB beginning programmers).
Anyway it's not my case, you don't know me: STANDARD controls may act as their STANDARD behavior to prevent user confusion.
This is a CUSTOM control. The user wont find this in his normal Windows/Office form application interface, so he doesn’t know what the control can do until he wont play on it.
I work in the chemical field, and this control remembers me a recipient.
For this reason, what I see in my mind is not for a "long operation progressing" - for me it doesn’t make sense.
For sample, if it represents a silos stock, the level can move in both directions up and down depending on the filling or empting process of the recipient. So for me it make sense to "go back".
Another case is in the formula treatment for batch processing in a chemical production. Here normally you can find different recipients with different colors/levels that are representing chemical components. The user here have the needing to make a regulation to see a result of a simulation some ware (a graph or what else).
In this case, I approve: putting a slider near the cylinder is correct, but it will take space.
So maybe the problem is another: the name of the control. As a PROGRESS it must act as a PROGRESS, and, as a programmer, I'll be confused if it haves another behavior; but if this job was born with another name like:
CCylnderCtrl or CCylinderSlider or "what else"
than, I can hope in other behaviors, no?
As you can see, it's only a opinion problem. If you like it as a progress, you see it as a progress and want it as a progress, you are free, but I see it in a different way.
I really like Davide answer, it was direct and simple: "This is a progress control" (and I smile when I read it), but I'm sorry, your was not considering my needing or my point of view.
To end: this is born as a progress and it's called progress, but for me it doesn’t have an aspect of a progress (sorry to everybody, I know I'll loose popularity) - if I want a progress, I'll use a standard progress to prevent user confusion - here I can find the drawing code (or a link to it), so if I want, I can take it and modify for the behavior I need, no?
Andy
|
|
|
|

|
Your point of view is very clear. Honestly, I developed this control starting from my recent knob control that has support for mouse and keyboard events. So, this cylinder control HAD support for mouse and keyboard events that I removed before releasing it
Let me found time and maybe I'll re-implement these events...
BTW, please do not forget that I just converted/improved existing controls written in C# and that main credits must go to the original authors.
SoftechSoftware
Davide Calabro'
davide_calabro@yahoo.com
http://www.softechsoftware.it
|
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
A GDI+ cylinder progress control
| Type | Article |
| Licence | |
| First Posted | 1 Jul 2003 |
| Views | 115,594 |
| Bookmarked | 87 times |
|
|