|
gothic_coder wrote: But i need to make the background transparent..
Sorry, I don't quite understand you here. With the changes I proposed the only thing you see is 12 coloured circles. The rest of the window is transparent - you can see objects below the circles. If you change the opacity, you can see objects _through_ the circles.
Perhaps I missed something else - I just noticed I missed a #define. If this doesn't help, & I'm just not 'getting it', I'll have another go if you can re-phrase you question.
#define _WIN32_WINNT 0x0501
#include <windows.h>
struct
{
WORD palVersion;
WORD palNumEntries;
PALETTEENTRY palPalEntry[12];
} palPalette =
{
0x300,
12,
{
{0xFF, 0x00, 0x00, PC_RESERVED},
{0xC0, 0x40, 0x00, PC_RESERVED},
{0x80, 0x80, 0x00, PC_RESERVED},
{0x40, 0xC0, 0x00, PC_RESERVED},
{0x00, 0xFF, 0x00, PC_RESERVED},
{0x00, 0xC0, 0x40, PC_RESERVED},
{0x00, 0x80, 0x80, PC_RESERVED},
{0x00, 0x40, 0xC0, PC_RESERVED},
{0x00, 0x00, 0xFF, PC_RESERVED},
{0x40, 0x00, 0xC0, PC_RESERVED},
{0x80, 0x00, 0x80, PC_RESERVED},
{0xC0, 0x00, 0x40, PC_RESERVED}
}
};
POINT pt12[12] =
{
{0, 1000},
{500, 866},
{866, 500},
{1000, 0},
{866, -500},
{500, -866},
{0, -1000},
{-500, -866},
{-866, -500},
{-1000, 0},
{-866, 500},
{-500, 866}
};
void Animate(HWND hwnd, HPALETTE hPalette)
{
HDC hDC;
PALETTEENTRY pe[12];
HPALETTE hOldPal;
static int nIndex;
int i;
for (i = 0; i < 12; i++)
pe[i] = palPalette.palPalEntry[(i + nIndex) % 12];
hDC = GetDC(hwnd);
hOldPal = SelectPalette(hDC, hPalette, FALSE);
RealizePalette(hDC);
AnimatePalette(hPalette, 0, 12, pe);
nIndex = (++nIndex) % 12;
SelectPalette(hDC, hOldPal, FALSE);
ReleaseDC(hwnd, hDC);
}
void DrawCircle(HWND hwnd, HPALETTE hPalette)
{
HDC hDC;
PAINTSTRUCT paintStruct;
RECT rect;
SIZE sizeO;
POINT ptO;
HPALETTE hOldPal;
int i;
hDC = BeginPaint(hwnd, &paintStruct);
if (hDC != NULL)
{
hOldPal = SelectPalette(hDC, hPalette, FALSE);
RealizePalette(hDC);
GetClientRect(hwnd, &rect);
DPtoLP(hDC, (LPPOINT)&rect, 2);
ptO.x = (rect.left + rect.right) / 2;
ptO.y = (rect.top + rect.bottom) / 2;
sizeO.cx = MulDiv((rect.right - rect.left), 2, 3);
sizeO.cy = MulDiv((rect.bottom - rect.top), 2, 3);
for (i = 0; i < 12; i++)
{
HBRUSH hbr;
HBRUSH hbrOld;
hbr = CreateSolidBrush(PALETTEINDEX(i));
hbrOld = (HBRUSH)SelectObject(hDC, hbr);
Ellipse(hDC,
ptO.x + MulDiv(sizeO.cx, pt12[i].x - 259, 2000),
ptO.y + MulDiv(sizeO.cy, pt12[i].y - 259, 2000),
ptO.x + MulDiv(sizeO.cx, pt12[i].x + 259, 2000),
ptO.y + MulDiv(sizeO.cy, pt12[i].y + 259, 2000)
);
SelectObject(hDC, hbrOld);
DeleteObject(hbr);
}
SelectPalette(hDC, hOldPal, FALSE);
EndPaint(hwnd, &paintStruct);
}
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg,
WPARAM wParam, LPARAM lParam)
{
static HPALETTE hPalette;
switch(uMsg)
{
case WM_CREATE:
hPalette = CreatePalette((LPLOGPALETTE)&palPalette);
break;
case WM_PAINT:
DrawCircle(hwnd, hPalette);
break;
case WM_TIMER:
Animate(hwnd, hPalette);
break;
case WM_LBUTTONDOWN:
SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION,NULL);
break;
case WM_DESTROY:
DeleteObject(hPalette);
hPalette = NULL;
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR d3, int nCmdShow)
{
MSG msg;
HWND hwnd;
WNDCLASS wndClass;
if (hPrevInstance == NULL)
{
memset(&wndClass, 0, sizeof(wndClass));
wndClass.style = CS_HREDRAW | CS_VREDRAW ;
wndClass.lpfnWndProc = WndProc ;
wndClass.cbClsExtra = 0 ;
wndClass.cbWndExtra = 0 ;
wndClass.hInstance = hInstance ;
wndClass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndClass.hbrBackground = (HBRUSH) CreateSolidBrush(RGB(255,0,255));
wndClass.lpszMenuName = NULL ;
wndClass.lpszClassName = "HELLO";
if (!RegisterClass(&wndClass)) return FALSE;
}
hwnd = CreateWindowEx(WS_EX_TOOLWINDOW |WS_EX_LAYERED|WS_EX_APPWINDOW,
"HELLO",
"Colour Wheel",
WS_SYSMENU|WS_POPUP,
10,
10,
200,
200,
NULL,
NULL,
hInstance,
NULL) ;
ShowWindow(hwnd, nCmdShow);
SetLayeredWindowAttributes(hwnd, RGB(255,0,255), 155, LWA_COLORKEY|LWA_ALPHA);
SetTimer(hwnd, 1, 200, NULL);
while (GetMessage(&msg, NULL, 0, 0))
DispatchMessage(&msg);
KillTimer(hwnd, 1);
return msg.wParam;
}
|
|
|
|
|
Hey thanks a ton brother... That's works beautifully...
Anyways one question. If i try to add BMP in my resource and then make it transparent it didn't look good.. I mean masking make it transparent but not completely. Heard that transparency in PNG is good.
Any idea how can i use PNG in my project..
Thanks again.
|
|
|
|
|
It really is a pleasure my friend.
I did some work a while ago using transparent bitmaps. It was inspired by Hans Dietrich's XCPClock prject. Two points I should point out about my implementation:
1) It doesn't use MFC
2) The reflection on the dial is shown on top of the hands - a transparent bitmap.
Unfortunately, there are a few dimensions and offsets that are hard-coded though it should hopefully still guide you in your endevours.
You can find the project here. Transparent Bitmaps demo[^]
As for PNGs, there's a number of libraries out there that will deal with them. Never used any of them myself, though it shouldn't be too hard. You can look for libpng.
Also, you might like to check out the source code for "Slide Show Screen Saver for Windows" as found here[^]
The complete source is available there. Haven't had much of a look yet, though I do recall getting this code some years ago for the purpose of dealing with pngs and jpgs.
|
|
|
|
|
Thanks for the link.. I've this strong feeling that these link gonna help me out.. I'll take a look and get back to you asap...
|
|
|
|
|
I am trying to develop an application with dialogs to be skinned in XP style for Windows Mobile platform. Please let me know if any of you can help me out.
Cheers.
Sreekanth Muralidharan,
Corporate Systems Consultant [Embedded Systems],
INDIA
|
|
|
|
|
I think you are obliged to do the skinng stuff yourself on Windows Mobile.
Of course you can still inspire yourself from existing efforts for the Desktop plateform.
(There are lots of articles here, otherwise there is open source lib like beyondata.com or even the MFC FeaturePack source code which features many beatiful skins)
..
"The Awaited Saviour", Mohammed Baqir Al Sadr
|
|
|
|
|
Hello :
I've done this in order to store a DWORD value in a string variable :
DWORD dwVal;
CString str;
str.Format(_T("0x%x",dwVal);
Now how can I get the dwVal value back from the str content ???
Thank you in advance.
"The Awaited Saviour", Mohammed Baqir Al Sadr
modified on Monday, November 10, 2008 5:43 AM
|
|
|
|
|
i hope sscanf should work for you.
if str would have been written as integer, you can get it back to dwval by using atoi() function.
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
Thanks.
"The Awaited Saviour", Mohammed Baqir Al Sadr
|
|
|
|
|
hello all,
this requirement is for an embedded device.
i need to use the memory available at a predefined address, say for example, 0xe000 2828 in RAM.
so i need to define a variable some thing like
int *i=0xe000 2828;
i mean, here, 'i' should be mapped to the desired memory location.
but syntactically, the above statement is wrong.
i remember, this can be achieved using a far pointer. but iam unable to do this, and my compiler does not accept if i use as follows.
int far *i=0xe000 2828;
please suggest me the mechanism to achieve this.
thanks in advance.
|
|
|
|
|
You should read the documentation of your (cross) compiler
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]
|
|
|
|
|
hai pallini,
thanks for your response.
yes, i have gone through that, but this specific point is not addressed properly in that.
can you please suggest me any other clue.
let me explain the issue a bit detailed.
the document says that, the RAM available from that particular location up to 2k is battery backed up RAM.
means, though the device is powered off, as long as the battery lives, the data written into that memory will be un lost. right,
i think now, you might give me some clue.
thank you.
|
|
|
|
|
Well, I suppose the compire manual will tell you how to access the device address space.
What device are dealing with? What compiler are you using?
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]
|
|
|
|
|
the device is arm controller.
and the compiler is provided by him.
any way, i got a clue to use volatile int.
this i got from one of the macros provided by him.
let me try this out and i will announce it here if it is solved.
thanks again for your support.
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
Well, your compiler and package probably came with header files describing built in I/O ports - look at those for the syntax.
But I'm sure what you wrote is wrong - I doubt the compiler will a space in the middle of a number.
The last embedded work I did was on a 32bit processor, so it may be harder for you (in which case, read headers as above), but the following worked for me:
unsigned int *pSomewhere = (unsigned int *)0x12341234;
Obviously that's not the real name or number, but I hope you get the idea. You may just need the odd far.
Iain.
|
|
|
|
|
yes,
thanks for your response.
the space, which you are talking about, i would have given it like that in forums but i gave it as a single value in my code. but still it wasnt working.
any ways,
iam trying to implement it using volatile.
thanks all for your suggestions.
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
chandu004 wrote: but still it wasnt working.
Without seeing your code, how you are using it, and what you are expecting instead, this is less than helpful.
chandu004 wrote: iam trying to implement it using volatile.
Why?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
DavidCrow wrote: Why?
It probably points to a memory-mapped io register that gets changed by some hardware event.
|
|
|
|
|
chandu004 wrote: i need to use the memory available at a predefined address, say for example, 0xe000 2828 in RAM.
This is most likely a physical address and depending on what ARM architecture you're developing for, you may have an MMU[^] that maps physical addresses to virtual. This means you have to check your documentation for the following:- Is your ARM architecture equipped with an MMU?
- If so, is it enabled?
- If 'yes', what API call are you supposed to make to read and write to and from physical addresses?
chandu004 wrote: int *i=0xe000 2828;
Like Iain said, the compiler will swallow a type cast such as
int* pAddr = (int*)0xe0002828; but depending on the MMU-stuff this will give you a virtual address which may not be what you need.
The documentation for your compiler and your chip ought to have information about this.
Finally:
Your problem is very specific to your environment, so it's very hard to advise you to anything but reading the documentation for your compiler and the chipset you're using. You haven't even informed us what ARM architecture you are targeting.
Also keep in mind that this forum is dedicated to developing windows applications with MFC and/or Win32 API, which is very different from developing for embedded systems.
Of course you may be developing with Windows CE for embedded systems, but you haven't really said so clearly. If that's the case you may need to call ReadPhysical()[^] or WritePhysical()[^].
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
To add to the previous answers, some embedded compilers have a non-standard _at extension that would enable you to do something like:
int i _at(0xe0002828);
Otherwise, I would use something like:
int& i = *reinterpret_cast<int*> (0xe0002828);
|
|
|
|
|
If anybody has alread tried to build a help file for a program using MS Help Workshop, how can I set a certain topic as a start page ??
Thank you in advance.
"The Awaited Saviour", Mohammed Baqir Al Sadr
modified on Monday, November 10, 2008 5:28 AM
|
|
|
|
|
If [*] help workshop is the one that makes .chm files, then you will have a .hhp file somewhere in your list of files to be compiled.
At the top of mine, I have the following:
[OPTIONS]
Auto Index=Yes
Compiled file=MyChm.chm
Contents file=Table of Contents.hhc
Default Window=Main
Default topic=Welcome.htm
Display compile progress=No
Index file=MyChm.hhk
Language=0x809 English (United Kingdom)
Title=I made this special help
[WINDOWS]
Main=,"Table of Contents.hhc",,"Welcome.htm","Welcome.htm",,,,,0x42120,,0x3046,,0x1000000,,,,,,
[FILES]
A list of files here...
(OK, I've changed the odd word here and there to protect the guilty).
Default topic gives you the "unless they explicitly asked for another one, give them this" functionality.
Hope that helps,
Iain.
[*] I say IF as I never use the workshop itself, just the hhc.exe help compiler.
|
|
|
|
|
Thank you thousand times.
"The Awaited Saviour", Mohammed Baqir Al Sadr
|
|
|
|
|
Hi,
I am working on an mfc application in which I am opening a dialog box containing smileys on button click. Now what I want is to close the dialog dialog box with smileys when mouse click event is fired anywhere on the screen.
Thanks
Dhiraj Kumar Saini
|
|
|
|
|
Handle WM_KILLFOCUS...
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|