Add your own alternative version
Stats
277.4K views 2.2K downloads 135 bookmarked
Posted
21 Oct 2003
|
Comments and Discussions
|
|
Thanks for this nice control!
I just wanted to put it to my project (which has also a German UI) and figured out some problems with the German characters ÄÖÜäöüß and even € (EUR). It seems that CDC::GetCharWidth() return bad values for these characters. My only solution is to replace the arrWidths[] entries for äö... with the corresponding values of ao...
Do you have any better solution?
Ciao,
Alex
|
|
|
|
|
do you need a hwnd at all?
if i was to make such a banner i would make a class that attaches to a certain hwnd (a dialog or whatever) and then subclasses it. next i would intercept WM_NCCALCSIZE, remember currently calculated rect (after caption and borders) and modify it to make some room for the banner. another interesting message would be WM_NCPAINT where i can use the rect from WM_NCCALCSIZE and the attached hwnd to get a window dc and paint directly.
benefits: no hacks with moving controls around -- suppose the developer actually does move some controls at fixed locations. in your case he/she will need to fix the positioning code.
in the proposed case only the hwnd client size will be affect and control positions on the hwnd basicly remain the same (although space is still somewhat reduced).
just my $.02 worth before downloading the code )
cheers,
</wqw>
|
|
|
|
|
You're absolutely right! It would be possible to implement this without an HWND the way you described. It would be interesting if you (or someone else) actually went and did this.
Take care and thanks for the input
www.kinkycode.com
[Glossary Manager] [AfterThought Backup Lite]
99 little bugs in the code, 99 little bugs,
Fix 1 bug, recompile....
101 little bugs in the code...
|
|
|
|
|
Hi everyone,
I've added the UNICODE fix that was mentioned in the thread below this one. Sorry about that! Atleast its done now. This will probably be the last update unless someone (or I) have a great idea of how to improve this control some more...
www.kinkycode.com
[Glossary Manager] [AfterThought Backup Lite]
99 little bugs in the code, 99 little bugs,
Fix 1 bug, recompile....
101 little bugs in the code...
|
|
|
|
|
I really hate to tell you this, especially since you just updated the article.... but.....
The call in the CKCSideBannerWnd constructor, to load the msimg32.dll needs to be wrapped in the _T("") macro.
// try and load the MSIMG32.LIB
if ( (m_hGradMod = LoadLibrary(_T("MSIMG32.DLL"))) )
m_pGradFill = (PFNGRADFILL) GetProcAddress(m_hGradMod, "GradientFill" );
At least *I* had to, to get my unicode build to quit whining.....
Artificial intelligence is no match for natural
stupidity.
|
|
|
|
|
Oops. My bad. Will fix and update as soon as I get a second here Thanks for that. <Mental Note>UNICODE is the future... cater for it</Mental Note>
www.kinkycode.com
[Glossary Manager] [AfterThought Backup Lite]
99 little bugs in the code, 99 little bugs,
Fix 1 bug, recompile....
101 little bugs in the code...
|
|
|
|
|
Pretty useless, but still very pretty.
Excellent piece of work, now I'm looking for an excuse to use it somewhere.
Have a 5.
|
|
|
|
|
|
hi,
I tried to compile the demo projet and I have execution error "can't find MSGIM32.dll".
I scanned my disk, I found MSGIM32.lib.
I use VC++ 6.0 and NT 4.0.
I'd like to link statically the MSGIM32.
Can you help me ?
|
|
|
|
|
Hey,
Ok, the first problem is that you are running NT 4.0. According to MSDN, they say the dll/lib is available on:
Windows NT/2000/XP: Included in Windows 2000 and later.
Windows 95/98/Me: Included in Windows 98 and later.
secondly, I know you've probably made a typo, but you made it twice (twece), so its actually MSIMG32. What you can do is get hold of a 98, or 2K machine, find the MSIMG32.DLL file and copy that over to your NT4 machines system(32) directory.
That should resolve the issue
Regarding the static linking question, I'm not sure of the lib is available as a static link, or if merely acts as a stub. I have a feeling the lib is merely a stub (can't be statically linked)
www.kinkycode.com
[Glossary Manager] [AfterThought Backup Lite]
99 little bugs in the code, 99 little bugs,
Fix 1 bug, recompile....
101 little bugs in the code...
|
|
|
|
|
thank you for your advice, I'm going to try.
If I found an issue on how using CKCSideBannerWnd with NT 4.0, I will post the solution.
|
|
|
|
|
|
Hi Peter & Tut8,
maybe doesent have the performance of the MSDIM32.dll gradient call function, but why don't you try a self made gradient call:
(it's only a suggestion)
[Message edited twice for mistaken code ]
void GradientFill(CDC* pDC, COLORREF clr1, COLORREF clr2, CRect rc, bool bHor = true, bool bFlip = false)
{
if (bFlip)
{
COLORREF clr = clr1;
clr1 = clr2;
clr2 = clr;
}
if (pDC->GetDeviceCaps(BITSPIXEL) > 8)
{
if (bHor)
{
int nWidth = rc.Width();
for (int x=0; x<nWidth; x++)
{
CRect rcl = rc;
rcl.left += x;
rcl.right += (x + 1);
double l = (double)y / (double)nWidth;
pDC->FillSolidRect(rcl, RGB(
l * GetRValue(clr1) + (1.0 - l) * GetRValue(clr2),
l * GetGValue(clr1) + (1.0 - l) * GetGValue(clr2),
l * GetBValue(clr1) + (1.0 - l) * GetBValue(clr2) ));
}
}
else
{
int nHeight = rc.Height();
for (int y=0; y<nHeight; y++)
{
CRect rcl = rc;
rcl.top += y;
rcl.bottom += (y + 1);
double l = (double)y / (double)nHeight;
pDC->FillSolidRect(rcl, RGB(
l * GetRValue(clr1) + (1.0 - l) * GetRValue(clr2),
l * GetGValue(clr1) + (1.0 - l) * GetGValue(clr2),
l * GetBValue(clr1) + (1.0 - l) * GetBValue(clr2) ));
}
}
}
else
{
pDC->FillSolidRect(rc, clr1);
}
}

|
|
|
|
|
CodeProject should start a "code snippet" gallery. You GradientFill() code would be an ideal candidate for that space...
Chris, maybe something worth considering?
www.kinkycode.com
[Glossary Manager] [AfterThought Backup Lite]
99 little bugs in the code, 99 little bugs,
Fix 1 bug, recompile....
101 little bugs in the code...
|
|
|
|
|
hi,
I tried with your function, it works good !
I have just modified one or two parameters, and replace the line :
double l = (double)y / (double)nWidth;
by :
double l = (double)x / (double)nWidth;
Thanks a lot.
|
|
|
|
|
Hi everyone,
I've updated the control to include most of the suggestions and tips that have been so kindly communicated to me. I must admit, my favourite change is the ability to texture the control
Take care and hope you enjoy it!
www.kinkycode.com
[Glossary Manager] [AfterThought Backup Lite]
99 little bugs in the code, 99 little bugs,
Fix 1 bug, recompile....
101 little bugs in the code...
|
|
|
|
|
Nice job !
A few minor changes are necessary to make your control UNICODE compatible:
1) enclose the rest of the string literals with _T("") including the definition of KCSB_CLASSNAME
2) change the paramters to the SetTitle and SetCaption functions from const char* to LPCTSTR
3) change the variable on line 541 of the cpp file from BYTE ch; to TCHAR ch;
|
|
|
|
|
|
Thank you very much, I really need it in my projects!
Got my 5!
Because I was trying different icon sizes, I made 2 small modifications for my use that I'll like to share:
1. to load the icon directly from the resource ID I have added the member:
bool CKCSideBannerWnd::SetIcon(UINT uIcon, UINT uiIconPos)
{
HICON hIcon = (HICON)::LoadImage(
AfxGetInstanceHandle(),
MAKEINTRESOURCE(uIcon),
IMAGE_ICON,
0,0,
LR_DEFAULTCOLOR);
return SetIcon(hIcon, uiIconPos);
}
2. to ensure the correct icon drawn size, I made a small replacement at the end of the DrawIncon call:
... DrawIcon(...)
{
...
}
pDC->DrawState(
pt,
CSize(m_bmpInfo.bmWidth, m_bmpInfo.bmHeight),
m_hIcon,
DSS_NORMAL,
(HBRUSH)NULL);
}

|
|
|
|
|
Nice Thanks for that... if you want, you can mail me the updated code...
I have added another function that I will be releasing tomorrow... MAybe I can amalgamate your changes into the new release
Cheers,
Peter
www.kinkycode.com
[Glossary Manager] [AfterThought Backup Lite]
99 little bugs in the code, 99 little bugs,
Fix 1 bug, recompile....
101 little bugs in the code...
|
|
|
|
|
Nice article there goes my 5.
A little issue though, can we change color of title and caption texts (without modifying your source code)? Texts became unreadable when I tried to use a dark backgroud. Also, since we are at it, will you consider bitmap backgroud?
And out of curious, why don't you just integrate WndUtil.h into KCSideBannerWnd.h so we only need to maintain 2 files instead of 3? Of course, if you are reusing WndUtil.h in multiple applications then forget about it.
Thanks.
|
|
|
|
|
Hi. Thanks for reminding me to add those obvious text colour functions. The files and article have been updated.
I have also started a TO DO list... and you'll notice that I'm going to be adding the ability to supply your own bitmap as the background.
Regarding WndUtil.h, yes, I use it in a lot of my control nowadays. This is merely the first control that I've published in which I use it. I'll be publishing a few more controls in the upcoming weeks that make use to the WndUtil.h ... and I'll also be extending the header itself to do some other stuff...
Take care and thanks for the comments (and vote )
www.kinkycode.com
[Glossary Manager] [AfterThought Backup Lite]
99 little bugs in the code, 99 little bugs,
Fix 1 bug, recompile....
101 little bugs in the code...
|
|
|
|
|
From your article:
Personally, I have never written a control that "makes space" for itself, and the concept has grasped my imagination somewhat. I have been contemplating the idea of developing a background app/service that monitors all HWND creations and attaches a banner to all windows of say, type DIALOG. This would merely be for purposes of fun and educational value... but still a cool idea I think.
Well ... not shure about how and if it can be useful, however, an idea can be to hook the WH_CALLWNDPROC and trap the WM_INITDIALOG message.
This article can give some ideas. It is not necessary to use exactly that code. But the principle could be right.
Of course, in that article I was thinking to applications, not to "services" that do the trick to ll the windows every other would have created. But the idea is essentially the same.
Let me know. By now, get my 5 !
-E-
|
|
|
|
|
Thanks for that. Yes, I was also thinking of hooking ... but was thinking more along the lines of hooking the CBT hook. I think either will work fine. But as I said, attaching the banner to EACH and every window would merely be an exercise of fun and trying to see "if I can do it".
Thanks for the help (and the vote).
Peter
www.kinkycode.com
[Glossary Manager] [AfterThought Backup Lite]
99 little bugs in the code, 99 little bugs,
Fix 1 bug, recompile....
101 little bugs in the code...
|
|
|
|
|
Russian text output in caption in bad order. Then you get char fron string
ch = m_strCaption.GetAt(i);
if char code > 127 it appears as negative number
in void CKCSideBannerWnd::DrawTextFields(CDC* pDC, CRect rect)
replace
int ch;
with
BYTE ch;
|
|
|
|
|
|
General News Suggestion Question Bug Answer Joke Praise Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
|
|