|
I did not realy believe I could but I had to ask. I looked thru "Windows Internals", "Programming Windows", some other books, and searched the www before posting.
Thanks just the same!
This is the first time some one actualy answered one of my more difficult post.
Trust in the code Luke. Yea right!
|
|
|
|
|
John R. Shaw wrote:
This is the first time some one actualy answered one of my more difficult post.
We Australians just have to try that little bit harder.
So why do you want to know this anyway?
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Just an idea I had about replacing it with my onwn bitmap bits. I was thinking that if I could get more control of the drawing on the Desktop window I might avoid creating a whole new window class just so I could provide a shadow for a dialogbox, just like menues have. I had already decided it would not work even if I could get to the bits. The shadow feature is not realy needed, but it would be nice to add that feature to dialogs derived from CDialog (in a simple manner).
Trust in the code Luke. Yea right!
|
|
|
|
|
Aha. Have you looked at code like Bruno Podetti's CNewMenu http://www.codeproject.com/menu/NewMenuXPStyle.asp[^] which adds a shadow. I'm using this in ED (see sig) and it works quite nicely. I think the shadow may have problems on older versions of Windows though. I'd need to check.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Yes. In fact I am using CNewMenu in the project that is also using the my CDialog derived base class. The problem is that I did not want to subclass and handle all the drawing my self. I wanted to allow a dialog to be drawn normaly including borders (style dependent) and then add a shadow to it.
I did have another idea that might work, but I do not like it. The idea would be to create a second sightly larger window that would cover the the dialog box then set its' drawing region such that only right and bottom of the window will be visable at the right and bottom of the dialog box and then draw the shadow in that region. That way know one will be over writing the shadow. Of cource then you have to keep moving (or sizing) the shadow window when ther user moves (or sizes) the dialog. There are other problems with this idea, but coming up with unique solutions to a problem is what makes programing enjoyable.
Trust in the code Luke. Yea right!
|
|
|
|
|
Don't like the second window idea at all. What about hooking the dialog instead of subclassing it. There is also this article: http://www.codeproject.com/menu/SkinMenu.asp[^]
But I don't really know if I like the idea of a drop shadow on my dialogs.;)
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
"But I don't really know if I like the idea of a drop shadow on my dialogs"
I created a CDialog derived base class that allows you to treat a dialog like a menu (more or less) with embeded controls. By using the class it is easy to create things like color picker drop downs with minamal effort. If you want I can email you the program (.exe) I was working on when I came up with the idea (it is now using shadows) so you can see for your self.
I am sure that hooking will work in this case (same problem as subclassing). The problem is that the shadow must be drawn inside the window its' self so that it will not be over drawn by other windows. That requires that I: 1) enlarge the dialog window, 2) read the pixel data from the desktop, 3) stop the default drawing and erasing of background, and 4) draw the border (and background) my self. I may check into trying this later on, just to see what all is involved.
Even though I do not like the second window idea, I decided to try it and it worked [although there is a momentary flicker when the dialogs OnPaint() is called]. By making the desktop the parent of the second window, with style set to WS_VISABLE (ONLY), then using a modified version of CNemMenus' shadow draw code in its' OnPaint(). There was no requirement to specify any regions because it is under the dialog and the only visable part (even when draw alone) of the window is the part drawn as a shadow. Throw in a little code to handle move, size, and when to close and bingo it works. It does not even require that I read pixels directly from the desktop since until I draw the shadow the background of the window is the same as the desktop.
I still think the second window idea is the wrong approach to the problem, but it can be used with any modal dialog window and may be modifiable to work with any CWnd derived class).
Thanks for all your sugestions.
Trust in the code Luke. Yea right!
|
|
|
|
|
Sounds like a lot of work. You must want this badly or maybe just one of those life challenges you refused to let go of.;) I'd be interested to see what it looks like so send away.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
I want to show a text string "ABC" in a 30 degree with the X-axis. It is impossible to do it with TextOut and DrawText. Any function ?
Help me
=======================
Nothing is perfect
|
|
|
|
|
The lfOrientation and lfEscapement fields of the LOGFONT structure are use to rotate TrueType fonts.
Search MSDN Library for "font rotation lfOrientation".
Get a copy of Programming Windows by Charles Petzold.
Trust in the code Luke. Yea right!
|
|
|
|
|
"MSCAL.Calender" Using this ProgID host Calender on MFC Dialog ?
|
|
|
|
|
Hi,
After fully skinning my app using regions I have found out that it works perfect on Windows XP and not so perfect on Windows 98 SE.
Here are two screenshots to see what I am talking about:
Windows XP
Windows 98 SE
If you can see on the second screenshot the four buttons on the left show the mask color meaning that region wasn't applied correctly yet the top three buttons (Menu, minimize, and close) have their region set correctly. Here are some code samples used to skin the window and apply the region:
These two functions scan a bitmap, exclude the mask color and create a region.
HRGN cMainSkin::ScanRegion(HBITMAP pBitmap, BYTE jTranspR, BYTE jTranspG, BYTE jTranspB)
{
WORD wBmpWidth, wBmpHeight;
HRGN hRgn, hTmpRgn;
BYTE *pPixels = Get24BitPixels(pBitmap, &wBmpWidth, &wBmpHeight);
if (!pPixels)
return NULL;
hRgn = CreateRectRgn(0, 0, wBmpWidth, wBmpHeight);
if (!hRgn)
{
delete pPixels;
return NULL;
}
DWORD p = 0;
for (WORD y = 0; y < wBmpHeight; y++)
{
for (WORD x = 0; x < wBmpWidth; x++)
{
BYTE jRed = pPixels[p+2];
BYTE jGreen = pPixels[p+1];
BYTE jBlue = pPixels[p+0];
if (jRed == jTranspR && jGreen == jTranspG && jBlue == jTranspB)
{
hTmpRgn = CreateRectRgn(x,y,x+1,y+1);
CombineRgn(hRgn, hRgn, hTmpRgn, RGN_XOR);
DeleteObject(hTmpRgn);
}
p += 3;
}
}
delete pPixels;
return hRgn;
}
BYTE* Get24BitPixels(HBITMAP pBitmap, WORD *pwWidth, WORD *pwHeight)
{
BITMAP bmpBmp;
LPBITMAPINFO pbmiInfo;
BITMAPINFO bmiInfo;
WORD wBmpWidth, wBmpHeight;
GetObject(pBitmap, sizeof(bmpBmp), &bmpBmp);
pbmiInfo = (LPBITMAPINFO) &bmpBmp;
wBmpWidth = (WORD)pbmiInfo->bmiHeader.biWidth;
wBmpWidth -= (wBmpWidth%4);
wBmpHeight = (WORD)pbmiInfo->bmiHeader.biHeight;
*pwWidth = wBmpWidth;
*pwHeight = wBmpHeight;
BYTE *pPixels = new BYTE[wBmpWidth*wBmpHeight*3];
if (!pPixels)
return NULL;
HDC hDC = GetWindowDC(NULL);
bmiInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmiInfo.bmiHeader.biWidth = wBmpWidth;
bmiInfo.bmiHeader.biHeight = -wBmpHeight;
bmiInfo.bmiHeader.biPlanes = 1;
bmiInfo.bmiHeader.biBitCount = 24;
bmiInfo.bmiHeader.biCompression = BI_RGB;
bmiInfo.bmiHeader.biSizeImage = wBmpWidth * wBmpHeight * 3;
bmiInfo.bmiHeader.biXPelsPerMeter = 0;
bmiInfo.bmiHeader.biYPelsPerMeter = 0;
bmiInfo.bmiHeader.biClrUsed = 0;
bmiInfo.bmiHeader.biClrImportant = 0;
int iRes = GetDIBits(hDC, pBitmap, 0, wBmpHeight, (LPVOID)pPixels, &bmiInfo, DIB_RGB_COLORS);
ReleaseDC(NULL, hDC);
if (!iRes)
{
delete pPixels;
return NULL;
};
return pPixels;
}
To continue the story it seems that it creates the first region handle fine (top left button for menu) and applies it to the first three buttons ok. I tested it by changing the minimize button somewhat resulting in a good menu button and a good close button but a regionless minimize button. For some reason the first region is created and applied OK yet anything after that does not work in Windows 98 (the four big buttons plus the main window)
Here is the code that applies the regions:
void cMainSkin::SetButtonRegion(void)
{
for (int i = 0; i < 7; i++)
hButtonRgn[i] = ScanRegion(hButtonPartialBitmap[i], iMaskColor[0],
iMaskColor[1], iMaskColor[2]);
SetWindowRgn(hwndMenu, hButtonRgn[0], TRUE);
SetWindowRgn(hwndMinimize, hButtonRgn[1], TRUE);
SetWindowRgn(hwndClose, hButtonRgn[2], TRUE);
SetWindowRgn(hwndView, hButtonRgn[3], TRUE);
SetWindowRgn(hwndAdd, hButtonRgn[4], TRUE);
SetWindowRgn(hwndFind, hButtonRgn[5], TRUE);
SetWindowRgn(hwndExternal, hButtonRgn[6], TRUE);
for (i = 0; i < 7; i++)
DeleteObject(hButtonRgn[i]);
}
I have tried getting rid of DeleteObject and also applying the region for each child window as soon as it is retrieved but with no results. Does anyone have any insight into this problem? Let me know if you need more code posted.
|
|
|
|
|
I have used Spy++ to look at how WinTv seem to do it. What they appeared to have done is create a window and then use 4 dialogs to surround the ActiveMovie Window. The window in which the dialogs are place uses a region to shape it and each of the dialogs uses a region for there individual shapes.
+--------------------------+
| Top |
+--------------------------+
| | | |
| | | |
| Left | | right |
| | | |
| | | |
+--------------------------+
| Bottom |
+--------------------------+<\pre>
I know this is not how the Windows Media Play does, but I thought you might want option.
Trust in the code Luke. Yea right!
|
|
|
|
|
The code which I supplied works great and much less complicated from your example, except that it does not work fully for some reason on Windows 98...
|
|
|
|
|
I thought I give you another option that might solve the problem on Windows 95. I prefer your choice, but I do not have time to play with it today.
Trust in the code Luke. Yea right!
|
|
|
|
|
Write a Program which concatenates a string to the left of a given string?
Creating a window using your own class and cursor.
Create one MDI application when i clicked on caption bar application should be closed.
Create one collection class which have add,remove and count item function using linked list in C++.
Write one SDI application which has serialization feature.
Write a program that reads a text file and create another file that is identical except that every sequence of consecutive blank spaces is replaced by a single space?
Write 1 to 10 number sorting program using SAFEARRAY?
How to make window with LButtonDown event using WTL?
Create a class FLOAT that contains one float data member, Overload all four arithmetic operators so that they operate on the object of FLOAT?
How to make one COM Component which returns name of the month for the given date?
|
|
|
|
|
How to Make win32dll which has two function?
|
|
|
|
|
Is there any sample algorithm(Mathematical Equations)links for taking a serial number and generating a unique number used for software protection.
Thanks
|
|
|
|
|
I recommend you go search http://sourceforge.net/
Trust in the code Luke. Yea right!
|
|
|
|
|
I recommend you search http://sourceforge.net
Trust in the code Luke. Yea right!
|
|
|
|
|
I am looking for source code for small(~15-20KB)highly customizable application, that capture keystrokes and save it into encrypted log file,
Centrum
|
|
|
|
|
yeah.. i wrote one for my personal use.. i think i can publish that here..
[ It is possible to represent everything in this universe by using 0 and 1 ]
|
|
|
|
|
If i try to compile my mfc dialog application in DEBUG configuration with a '#include <vector> inside one of my cpp files or headers, i get the following error messages:
c:\program files\microsoft visual studio\vc98\include\new(35) : error C2061: syntax error : identifier 'THIS_FILE'
c:\program files\microsoft visual studio\vc98\include\new(35) : error C2091: function returns function
c:\program files\microsoft visual studio\vc98\include\new(35) : error C2809: 'operator new' has no formal parameters
c:\program files\microsoft visual studio\vc98\include\new(36) : error C2061: syntax error : identifier 'THIS_FILE'
c:\program files\microsoft visual studio\vc98\include\new(37) : error C2091: function returns function
c:\program files\microsoft visual studio\vc98\include\new(37) : error C2556: 'void *(__cdecl *__cdecl operator new(void))(unsigned int,const struct std::nothrow_t &)' : overloaded function differs only by return type from 'void *(__cdecl *__cdecl op
erator new(void))(unsigned int)'
c:\program files\microsoft visual studio\vc98\include\new(35) : see declaration of 'new'
c:\program files\microsoft visual studio\vc98\include\memory(16) : error C2061: syntax error : identifier 'THIS_FILE'
c:\program files\microsoft visual studio\vc98\include\memory(17) : error C2091: function returns function
c:\program files\microsoft visual studio\vc98\include\memory(17) : error C2784: 'void *(__cdecl *__cdecl operator new(void))(unsigned int,class std::allocator<`template-parameter257'> &)' : could not deduce template argument for 'void *(__cdecl *)(u
nsigned int,class std::allocator<_Ty> &)' from 'void *(__cdecl *)(unsigned int)'
c:\program files\microsoft visual studio\vc98\include\memory(17) : error C2785: 'void *(__cdecl *__cdecl operator new(void))(unsigned int,class std::allocator<`template-parameter257'> &)' and 'void *(__cdecl *__cdecl operator new(void))(unsigned int
)' have different return types
c:\program files\microsoft visual studio\vc98\include\memory(16) : see declaration of 'new'
c:\program files\microsoft visual studio\vc98\include\memory(17) : error C2809: 'operator new' has no formal parameters
c:\program files\microsoft visual studio\vc98\include\memory(20) : error C2954: template definitions cannot nest
Error executing cl.exe.
Creating browse info file...
I can't figure out why this happens or how to fix it.
BTW it compiles without the #include <vector> in DEBUG configuration. And it also compiles with/without it in RELEASE configuration.
I'm using VC++ 6
Hoping you can help
ScorpioMidget
|
|
|
|
|
Put your include<vector> AFTER #include <stdafx.h>
[edit] I meant BEFORE. Does this happen to you sometimes ? I was thinking "BEFORE, not AFTER" and finally wrote AFTER [/edit]
~RaGE();
|
|
|
|
|
At last i got it 2 compile by putting #include <vector> above all mfc includes.
Is the right way to go when mixing STL with MFC ?
ScorpioMidget
|
|
|
|