|
|
I think he needs the size of the content area... he might needs to avoid the scrollbar...
|
|
|
|
|
Hi all..
I'm using AnimateWindow for Bubble window or PopUp window for Win98, Win 2000 and above... As i've to run my exe on Win95 and NT also so for that i'm making that window with the help of calculating coordinates and SetWindowPos. After that i fill my dialog box with some color..
So the problem is that whenever i run my code without using AnimateWindow it works fine.. But when i introduce AnimateWindow it shows a black border around dialog box.
Can anyone explain this??
Thank you..
|
|
|
|
|
Are you painting the border? How did you take the DC?
|
|
|
|
|
I'm painting Dialog Box...I mean i'm taking rectangle of dialog box and painting it with specified color... Using my function to paint dialog without AnimateWindow works fine...But with AnimateWindow the black border comes...
GradientFillRect(HDC (wParam), &thisWindowRect, startCol, endCol, TRUE);
This is my function to Gradient fill my dialog...
|
|
|
|
|
Where this function is called? Or respond to which message? Can you please show me a little of your code part...?
|
|
|
|
|
Sure.
Calling this function on WM_ERASEBKGND:
case WM_ERASEBKGND:
{
GetClientRect(hWnd, &thisWindowRect);
COLORREF startCol = RGB(174, 255, 194), endCol = RGB(230, 255, 236);
GradientFillRect(HDC (wParam), &thisWindowRect, startCol, endCol, TRUE);
}
thisWindowRect is Dialog Box Coordinates...
and here is my animate window code.
BOOL bLoadLib = FALSE;
HMODULE _user32 = GetModuleHandle("user32.dll");
if(_user32 == INVALID_HANDLE_VALUE || _user32 == NULL)
{
_user32 = LoadLibrary("User32.dll");
if(_user32)
bLoadLib = TRUE;
}
typedef BOOL (WINAPI *_AnimateWindowDT) (HWND,DWORD,DWORD);
_AnimateWindowDT _AnimateWindow;
if(_user32)
{
if((_AnimateWindow = (_AnimateWindowDT) GetProcAddress(_user32,"AnimateWindow")))
{
RECT windozeRect, thisWindowRect, SlideDialog;
int DialogLeft, DialogRight;
SystemParametersInfo(SPI_GETWORKAREA, 0, &windozeRect, 0);
GetWindowRect(hWnd,&thisWindowRect);
DialogLeft = thisWindowRect.right;
DialogRight = thisWindowRect.bottom;
thisWindowRect.left = windozeRect.right - DialogLeft - 8;
thisWindowRect.top = windozeRect.bottom - DialogRight- 5;
SetWindowPos(hWnd, NULL,thisWindowRect.left, thisWindowRect.top, 0, 0, SWP_NOSIZE);
_AnimateWindow(hWnd, 300, AW_SLIDE | AW_VER_NEGATIVE);
bBack = TRUE;
}
else
{
RECT windozeRect, thisWindowRect, SlideDialog;
int DialogLeft, DialogRight;
SystemParametersInfo(SPI_GETWORKAREA, 0, &windozeRect, 0);
GetWindowRect(hWnd,&thisWindowRect);
DialogLeft = thisWindowRect.right;
DialogRight = thisWindowRect.bottom;
thisWindowRect.left = windozeRect.right - DialogLeft - 8;
thisWindowRect.top = windozeRect.bottom + 5;
SlideDialog.top = thisWindowRect.top;
SetWindowPos(hWnd, NULL,thisWindowRect.left, thisWindowRect.top, 0, 0, SWP_NOSIZE );
for(;thisWindowRect.top > SlideDialog.top - 131; thisWindowRect.top--)
{
UpdateWindow(hWnd);
SetWindowPos(hWnd, NULL,thisWindowRect.left, thisWindowRect.top, 0, 0, SWP_NOSIZE);
ShowWindow(hWnd, SW_SHOW);
Sleep(2);
}
bBack = TRUE;
}
}
And this whole code comes under WM_INITDIALOG:
modified on Thursday, October 9, 2008 5:36 AM
|
|
|
|
|
Please get me the code of GradientFillRect too...
|
|
|
|
|
void GradientFillRect(HDC hdc, LPRECT rcGradient, COLORREF start, COLORREF end, BOOL isVertical)
{
BYTE startRed = GetRValue(start);
BYTE startGreen = GetGValue(start);
BYTE startBlue = GetBValue(start);
BYTE endRed = GetRValue(end);
BYTE endGreen = GetGValue(end);
BYTE endBlue = GetBValue(end);
HBRUSH endColor = CreateSolidBrush(end);
FillRect(hdc, rcGradient, endColor);
DeleteObject(endColor);
int dy = 1;
int length = (isVertical ? rcGradient->bottom - rcGradient->top : rcGradient->right - rcGradient->left) - dy;
for (int dn = 0; dn <= length; dn += dy)
{
BYTE currentRed = (BYTE)MulDiv(endRed-startRed, dn, length) + startRed;
BYTE currentGreen = (BYTE)MulDiv(endGreen-startGreen, dn, length) + startGreen;
BYTE currentBlue = (BYTE)MulDiv(endBlue-startBlue, dn, length) + startBlue;
RECT currentRect = {0};
if (isVertical)
{
currentRect.left = rcGradient->left;
currentRect.top = rcGradient->top + dn;
currentRect.right = currentRect.left + rcGradient->right - rcGradient->left;
currentRect.bottom = currentRect.top + dy;
}
else
{
currentRect.left = rcGradient->left + dn;
currentRect.top = rcGradient->top;
currentRect.right = currentRect.left + dy;
currentRect.bottom = currentRect.top + rcGradient->bottom - rcGradient->top;
}
HBRUSH currentColor = CreateSolidBrush(RGB(currentRed, currentGreen, currentBlue));
FillRect(hdc, ¤tRect, currentColor);
DeleteObject(currentColor);
}
}
|
|
|
|
|
I just did a sample with your code, and it is working well... Ensure that the you return TRUE from WM_ERASEBKGND case.
|
|
|
|
|
Yes i am.. False would not fill my dialog with any color
case WM_ERASEBKGND:
{
GetClientRect(hWnd, &thisWindowRect);
COLORREF startCol = RGB(174, 255, 194), endCol = RGB(230, 255, 236);
GradientFillRect(HDC (wParam), &thisWindowRect, startCol, endCol, TRUE);
return TRUE;
}
Is it working well in your system?? No Black Border????
|
|
|
|
|
gothic_coder wrote: Is it working well in your system?? No Black Border????
Yes, my friend... Mine is WinXP.
|
|
|
|
|
BTW, Did you do something with WM_PRINT, WM_NCPAINT, etc?
|
|
|
|
|
Nah.. I'm not using these message handlers..
i'm using only.
WM_INITDIALOG
WM_CTLCOLORSTATIC
WM_ERASEBKGND
That's all...
|
|
|
|
|
What is in WM_CTLCOLORSTATIC? Let's look into that too...
|
|
|
|
|
WM_CTLCOLORSTATIC is where i make my static control transparent...
case WM_CTLCOLORSTATIC:
{
if(hwndstatic == GetDlgItem(hWnd, IDC_STATIC_TEXT)
{
HBRUSH hbr;
SetBkMode((HDC)wParam, TRANSPARENT);
hbr=(HBRUSH)GetStockObject(NULL_BRUSH);
return (LONG)hbr;
}
}
Defined hwndstatic as lparam...
|
|
|
|
|
This code seems as good...
If you can, please mail me full source... If I could reproduce the problem, there is some hope.
|
|
|
|
|
Sure...Just gimme yur mail id...
Thanks.
|
|
|
|
|
|
Did You got the mail??
I send it...
|
|
|
|
|
Yep... problem got... and solved...
You should not call DefWindowProc in the dialogproc. Instead you should return TRUE if you processed the message and FALSE if you did not.
int CALLBACK AnimateWindow(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
switch(Msg)
{
case WM_INITDIALOG:
....
....
break;
default:
return FALSE;
}
return TRUE;
}
Hope it will help you...
|
|
|
|
|
Wooaahhhhh...
Sweet..Thanks a ton...
But when AnimateWindow don't work then the loop redirect to else part where i manually shift the window... say in Win95 and NT.. There it doesn't show black border while i return same what i was returning in case of AnimateWindow API.... What the reason behind that??
|
|
|
|
|
I didn't dig it more... The possibility is that it might missing default painting...
From MSDN, the Remarks of AnimateWindow says "The window procedures for the window and its child windows should handle any WM_PRINT or WM_PRINTCLIENT messages. Dialog boxes, controls, and common controls already handle WM_PRINTCLIENT. The default window procedure already handles WM_PRINT"
Have a try to watch the messages processed when the AnimateWindow is called... You can use Spy++ tool. Anyway I am not in a situation to spend that much time...
|
|
|
|
|
Hello everyone,
For the following code, on x86 build, the output is
000000C8
000000C8
and on x64 build, the output is
CCCCCCCC000000C8
00000000000000C8
I think the reason is, for x64, both void* and void** are 64bit, for for x86 void* and void** are 32 bit, and for int, always 32bit for both x86 and x64.
This line of code "void* b2 = *b1", dereference b1 and makes it into 64-bit on x64, which concatenate value of a 0x000000C8 and previous DWORD 0xcccccccc, so forms the result 0xCCCCCCCC000000C8.
But on x86, when dereference b1 and makes it into 32-bit on x86, and recovers to original value 0x000000C8.
In my understanding correct?
#include <iostream>
using namespace std;
int main()
{
int a = 200;
void** b1 = (void**)&a;
void* b2 = *b1;
int b3 = (int)*b1;
cout << (void*)b2 << endl;
cout << (void*)b3 << endl;
return 0;
}
thanks in advance,
George
|
|
|
|
|
George_George wrote: and previous DWORD 0xcccccccc
I think it is the next DWORD .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|