|
|
I use the following code to draw an icon on the Window.
HICON hIcon = (HICON)::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDI_HELP), IMAGE_ICON, m_nButtonWidth, m_nButtonHeight , LR_DEFAULTCOLOR);
::DrawIconEx(hDC, 2, 2, hIcon, m_nButtonWidth, m_nButtonHeight, 0, NULL, DI_NORMAL);
This draws the icon on the Window. But my problem is that my window has a gradient background and my icon has a white background so when I draw the icon, the square shape of the icon with the white background is visible. I want to make the white portion of the icon transparent so that my Window background is visible. How do I do it?
---
Hakuna-Matada
It means no worries for the rest of your days...
It's our problem free, Philosophy
|
|
|
|
|
if you run this code what happens?
<br />
HICON hIcon = LoadIcon(AfxGetApp()->m_hInstance,(LPCTSTR)IDR_MAINFRAME);<br />
::DrawIconEx(GetDC()->m_hDC, 2, 2, hIcon, 32, 32, 0, NULL, DI_NORMAL);<br />
<br />
|
|
|
|
|
No changes. The problem still exists.
---
Hakuna-Matada
It means no worries for the rest of your days...
It's our problem free, Philosophy
|
|
|
|
|
oh yes ,I think you cant show icon on windows yes I see your problem but change background of icon to default color
|
|
|
|
|
Hi,
To simply draw icon with transparent background, you should apply AND mask to icon, where 1's specify transparency. For example: in VisualStudio editor, there's a color in color table, which looks like monitor with greeny background. By using this color, you specify which pixel are supposed to be transparent.
Finally, in DrawIconEx function you should specify DI_NORMAL effect mask to draw icon image as well as its mask.
Hope that helps,
Regards
|
|
|
|
|
the problem is that i have a thread function
<br />
UINT threadfun(LPVOID param)<br />
{<br />
CList list = (CList)param;<br />
}<br />
and i want to pass param to this function using AfxBeginThread
<br />
AfxBeginThread(threadfun,(WPARAM)m_List); <br />
where "m_List" is from a type defined variable
<br />
typedef CTypedPtrList<CPtrList , tagPLAYLISTENTRY*> CList;<br />
the compiler generate this error:
1- 'CList' : undeclared identifier
2- syntax error : missing ';' before identifier 'list'
3- 'list' : undeclared identifier
i know he can not see this type "CList" inside the function
but what is the solution of this , and how can i make it work
thnx alot 4 ur time and concern.
|
|
|
|
|
Is this file included...
#include <afxtempl.h>
|
|
|
|
|
yes it is included,
but as u know the thread function is not a part of the class so it can't see the headers so it don't know what is CList exactly is
problem right ??
i also tried to make the variable static and access it inside the thread function but it come up with an unresolved external error
F Y I, this time was working perfeclty in a member function of the class
but with the thread function, i don't know the problem
|
|
|
|
|
Hi,
yes it is included,
but as u know the thread function is not a part of the class so it can't see the headers so it don't know what is CList exactly is
Make sure that <afxtempl.h> can be parsed by precompiler when header with your thread function is processed. You can even add #include <afxtempl.h> statement directly before your thread function declaration,
example:
#include <afxtempl.h>
void __stdcall YourThreadFunction(LPVOID param)
{
CList list = (CList)param;
}
Did you know that your thread function can also be a part of your class?
#include <afxtempl.h>
class tester {
private:
CList m_list;
public:
void TestMyThread() {
CreateThread(...,...,YourThreadFunction,this,...,...)
};
static void YourThreadFunction(LPVOID param)
{
tester *p = (tester*)param;
CList list1 = p->m_list;
};
};
Regards
|
|
|
|
|
F Y I, typedef was working perfeclty in a member function of the class
but with the thread function, i don't know the problem
so it is not a problem with "typedef CTypedPtrList CList;"
because it was working before
|
|
|
|
|
singersinger wrote: typedef CTypedPtrList<CPtrList , tagPLAYLISTENTRY*> CList;
CList is the name of an existing class. Choose another name.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
singersinger wrote: UINT threadfun(LPVOID param)
{
CList list = (CList)param;
}
There are a few problems here.
First, CList is an existing type name when you use MFC. Use a different name for that: typedef CTypedPtrList CMyList; .
Second, CMyList will be a type, not a pointer. Use the reference operator to cast it to get a pointer to it: AfxBeginThread(threadfun, (WPARAM)&m_List); and the corresponding: UINT threadfun(LPVOID wParam) { CMyList* list = (CMyList*)wParam; ...}
Finally, if your threadfun is declared in another file, make sure it has the afxtempl.h header included.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
maybe i am posting the wrong words,
so to keep it simple
i have a function that causes the application to wait till it finishes it's work, so normally you would make it a thread function and call it using AfxBeginThread to let the application continue working after calling it
am i right in this ??
if i am right, this function uses some member variables that are declared in the class but the thread function can't see the member variables of the class
am i right ??
if i am, i want to pass this member variable to the thread function so that it could understand it and work with it "while this varibale not a rgular data type, it is a typedef from a combination of types"
can anybody help me with this
for any other information do not hesitate to reply
thnx alot 4 ur time and concern.
|
|
|
|
|
hi!
how do i change color of open file dialog or browse folder dialog?
(color of border, title and dialog)
to display open file dialog, i used CFileDialog::DoModal()
to display browse folder dialog, i used SHBrowseForFolder()
Zo.Naderi-Iran
|
|
|
|
|
You need to derived class of CFileDialog and use I think useWM_PAINT
|
|
|
|
|
Hopefully this is more specific, but what are boolean statments? If I'm posting in the wrong forum for C++ I'm sorry.
I'm a true failure.
|
|
|
|
|
(wrong_forum) == false
(5+1 > 0+2) == true
thursday.isaweekend() == false
(dog.has4legs() || hamster.canfly()) == true
wikipedia - boolean logic[^]
|
|
|
|
|
i'm not sure at all what you mean by "boolean statments", but if i understand it like you, it represents all the C++ statements that can be evaluated to a boolean.
if (a == 3) { ... }
for (int i = 0, i < 5; i++) { ... }
while(myIterator != myList.end()) {... }
and so on...
|
|
|
|
|
A boolean statment is true or false(1 or 0)key is on or key is off.
Anyway we have fazzy logic that it says we have many states between 1 and 0
|
|
|
|
|
I would say that false == 0, and true is a value that is not 0.
In most circumstances true == 1, but VARIANT_TRUE == -1, if my memory serves me right.
-- modified at 7:54 Monday 9th October, 2006
I found it at MSDN.
Here[^]
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Your memory is better than me
|
|
|
|
|
I did the mistake to test for true in a COM component once, that's why I remember. It just didn't work, so I had to find out why.
And the stuff we learn the hard way, that stuff stays.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
You are correct. false or FALSE is equal to 0, but when testing, you should assume true or TRUE (especially TRUE) is simple !false .
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
See here.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|