|
My bad.
A checkbox is a button, so it does not respond to WM_CTLCOLOR. You have to use the BS_OWNERDRAW style and do all the drawing yourself in response to a WM_DRAWITEM message.
Darker than a black steer's tookus on a moonless praire night
Within you lies the power for good, use it!!!
|
|
|
|
|
ah.. that was it...
I knew that the checkbox was a button but then...
in the MSDN help:
nCtlColor (->one of the parametes of the OnCtlColor)
Contains one of the following values, specifying the type of control:
<code>CTLCOLOR_BTN Button control</code>
CTLCOLOR_DLG Dialog box
CTLCOLOR_EDIT Edit control
CTLCOLOR_LISTBOX List-box control
CTLCOLOR_MSGBOX Message box
CTLCOLOR_SCROLLBAR Scroll-bar control
CTLCOLOR_STATIC Static control
well, who knows...
-- modified at 14:26 Saturday 28th April, 2007
I forgot to thank you for your feedback!
I'm searching for an alternative solution, so don't worry on that, I think is strange but...
|
|
|
|
|
|
Yes, I did not remember that class, some time ago I played a little with the CButtonST from Davide Calabro, it worked great, but I wanted to stick to "standard material", but I'll consider that, it worked really well some time ago.
Thank you for your feedback!
|
|
|
|
|
When I use this class to draw a picture in a timer function.
I find my free memory lose too fast!!
Who can help me !!
Thanks!!!
(My english is not very well!)
class CCarton
{
public:
CCarton();
virtual ~CCarton();
void Init( CWnd* pWnd );
void Draw( CDC* pDC, INT iX, INT iY );
private:
CBitmap m_bmp;
CBitmap *m_pOldBmp;
CWnd* m_pDrawWnd;
CDC m_dcSrc;
BITMAP bm;
};
CCarton::CCarton()
{
m_pOldBmp = NULL;
}
CCarton::~CCarton()
{
if( m_pOldBmp != NULL )
{
m_dcSrc.SelectObject( m_pOldBmp );
m_dcSrc.DeleteDC();
}
}
void CCarton::Init( CWnd* pWnd )
{
m_pDrawWnd = pWnd;
m_bmp.LoadBitmap( IDB_BITMAP );
m_bmp.GetBitmap( & bm );
CDC* pDC = pWnd->GetDC();
m_dcSrc.CreateCompatibleDC( pDC );
m_dcSrc.SetBkMode( TRANSPARENT );
m_pOldBmp = m_dcSrc.SelectObject( &m_bmp );
}
void CCarton::Draw( CDC* pDC, INT iX = 0, INT iY = 0 )
{
pDC->BitBlt( iX, iY ,bm.bmWidth, bm.bmHeight, &m_dcSrc, 0, 0, SRCCOPY );
}
// use draw at here !
void CBmpView::OnTimer(UINT nIDEvent)
{
m_Carton.Draw( GetDC(), 0, 0 );
CView::OnTimer(nIDEvent);
}
//initializing at here
void CBmpView::OnInitialUpdate()
{
CView::OnInitialUpdate();
m_Carton.Init( this );
}
-- modified at 6:26 Sunday 29th April, 2007
|
|
|
|
|
void CBmpView::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CDC* pDC=GetDC();
if (pDC) {
m_Carton.Draw( pDC, 0, 0 );
ReleaseDC(pDC);
}
CView::OnTimer(nIDEvent);
}
|
|
|
|
|
Thank you for you help !
I know it now.
Every times after use DC do someting must release it to free memory!
Thank you again!
|
|
|
|
|
hi!
i want to get color of the pixel, but my system sets 16 bits for color quality. what function do i call instead of calling GetPixel?
is there a sample?
thank you
Zo.Naderi-Iran
|
|
|
|
|
No matter, the same. It returns a COLORREF value which is simply an integer value containing the values for rgb [and alpha if applied].
--
=====
Arman
|
|
|
|
|
if the system sets 32 bits for color quality, the GetPixel function returns a DWORD valu. but what type of value does this function return, if the system sets 16 bits for color quality? a DWORD?
Zo.Naderi-Iran
|
|
|
|
|
Yes DWORD and always DWORD (actually it is typedefed as COLORREF). Only the but organization is different in different bpp modes. Usually in 16 bpp it is 555 or 565 (5 bit for blue, 5(6) bit for green and 5 bit for red). Also not that res bits are leftmost [and thus blues are rightmost].
--
=====
Arman
|
|
|
|
|
ah sorry; red bits are rightmost and blue bits are leftmost
--
=====
Arman
|
|
|
|
|
Actually, GetPixel() returns a COLORREF which has 8 bits per colour no matter what the DC's colour depth is. You only have to worry about the bit structure when you directly access the bitmap data as in a DIB or DIBSection.
Darker than a black steer's tookus on a moonless praire night
Within you lies the power for good, use it!!!
|
|
|
|
|
excuse me, explain more, please
Zo.Naderi-Iran
|
|
|
|
|
i am downloading a file from http. how to intimate the user that net connection failed during downloading.
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|
|
|
I have to access a control from one dialog box of one class to another class.
I tied this but I an getting runtime error.
S.Yamini
|
|
|
|
|
Each dialog is responsible for its controls and if somewhat you need to access a control that belongs to another dialog box, then there is problems with your design. So try to change the design. Also try to be more specific when asking questions it will help readers to better concentrate on the real issue.
--
=====
Arman
|
|
|
|
|
|
Is this code helpful
CMain* m_Main=(CMain*)GetParent();
m_Main->ControlsOnOtherClass
|
|
|
|
|
I have listview in the application. In that listview there are so many files I am using those files for encoding/protection process. But by the help of threading . so if a user can do the endcoding proccess as well as protection process and can add in between the running process if he can add more files in the list and also can start that files for the encoding/protection on then they can do.
how can i start the threading for that .
i have alread done the following things.
I have made one class Thread in that class I add the method beginthread.
that method call from the starting process of protection.
like .
void Therad(PVOID param)
{
Package pkg=(Package)param;
pkg.EncodeMediaContent(param1,param2 );
}
but i havent got the iead that how these paramter comes ?
"Success lies not in the result , But in the efforts !!!!!"
Amit Mistry - petlad -Gujarat-India
|
|
|
|
|
Do not launch threads by beginthread, instead use _beginthreadex. But if you are using MFC, then use AfxBeginThread global function. You should have struct with containing the parameters you want to pass the thread. Then you can pass the struct object and retrieve the parameters from there. See here[^] for more details.
--
=====
Arman
|
|
|
|
|
yes i am using win32.
Thanks for you help.
"Success lies not in the result , But in the efforts !!!!!"
Amit Mistry - petlad -Gujarat-India
|
|
|
|
|
I faced proble with
_beginthread(functionname,0,argumentlist );
what does it mean ?
mean i have to write param1,param2,param3 or the argument list is simple integer number.
can any body explaine me detail.
it is better ,if possible with some code .
"Success lies not in the result , But in the efforts !!!!!"
Amit Mistry - petlad -Gujarat-India
|
|
|
|
|
As I said in my previous post, only do use AfxBeginThread in MFC based apps. Otherwise use _beginthreadex and not what you are using now (_beginthread). And I guess you are using MFC because you mentioned about listview control...
Anyway, just to be answered;
I faced proble with
_beginthread(functionname,0,argumentlist);
The first param is the controlling function name which should have the following syntax;
DWORD MyThread(PVOID *pParam);
The second param is the stack size. Pass 0 for defaulting.
The third parameter is some address through which you want to pass arguments to MyThread;
struct INFO { // assume you want to pass 3 arguments
int param1;
char param2;
SomeClass *pObject;
};
INFO *pInfo = new INFO;
// initialize pInfo fields
AfxBeginThread(MyThread, 0, (PVOID ) pInfo); // start thread
// Then inside the controlling function
DWORD MyThread(PVOID pParam)
{
INFO *pInfo = (INFO *) pParam;
int p1 = pInfo->param1;
char p2 = pInfo->param2;
SomeClass *p = pInfo->pObject;
// do whatever ...
delete pInfo; // do a proper memory release
return 0;
}
--
=====
Arman
|
|
|
|