|
Try this
CRect rc;<br />
GetClientRect(&rc);<br />
pDC->FillSolidRect(&rc, m_clrBack);
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|
|
I think the appropriate place to change the background colour of your dialog box is the handler for WM_ERASEBKGND notification. You can put here just two lines:
BOOL CMyDlg::OnEraseBkgnd(CDC* pDC)
{
pDC->FillRect(CRect(0,0,32000,32000), &CBrush(RGB(0,0,255)));
return TRUE;
}
If you need to vary the colour (or just to optimize the solution), make a CBrush member variable and use CreateSolidBrush to set the colour. You can use CreatePatternBrush or CreateHatchBrush to have another kind of background.
-- modified at 3:13 Friday 16th June, 2006
|
|
|
|
|
one way
HBRUSH MYDialog::OnCtlColor( CDC* pDC_i, CWnd* pWnd_i, UINT uCtlColor_i )
{
HBRUSH hDefaultBrush = CDialog::OnCtlColor( pDC_i, pWnd_i, uCtlColor_i );
if( CTLCOLOR_DLG == uCtlColor_i )
{
// Return a black brush so that the background become balck
return reinterpret_cast<hbrush>(GetStockObject( BLACK_BRUSH ));
}
return hDefaultBrush;
}
Another way from the InitInstance of the App class u may call
SetDialogBkColor( RGB(255,0,0) )
nave
|
|
|
|
|
But the background color is not changing. Here is my code:
OnPaint()
{
.............
CSliderApp* app=(CSliderApp*)AfxGetApp();
app->ChangeDialogColor((COLORREF)m_clr.GetPos());
}
void CSliderApp::ChangeDialogColor(COLORREF ref)
{
SetDialogBkColor(ref);
}
Is there anything wrong
|
|
|
|
|
what error you have previous error can you show your code that how to use to change background color
whitesky
|
|
|
|
|
If you are using VS 2003 or VS 2005, you will found that the definition of SetDialogBkColor function in afxwin2.inl file is:
_AFXWIN_INLINE void CWinApp::SetDialogBkColor(COLORREF , COLORREF )
{
}
Therefore it does nothing. Documentation says that it is obsolete. You should consider other solutions.
|
|
|
|
|
ok... i Understood
instead of calling the ChangeDialogColor from onPaint
call this Function as the first line of OnCtlColor funtion
nave
|
|
|
|
|
No its not working.
Thanks for ur reply.
|
|
|
|
|
ok another way...
forgot every thing done before...Now do as below
1. Create a member variable of CBrush say m_BkBrush
2. Write Function like this
ChangeColor( COLORREF clr_i )
{
if( m_BkBrush.m_hObject )
m_BkBrush.DeleteObject();
m_BkBrush.CreateSolidBrush( clr_i )
Invalidate();
}
3. Call this function in the OnInitDialog and where ever u want to change the color
4. now overide the WM_CTLCOLOR message and inside that write as below
HBRUSH MYDialog::OnCtlColor( CDC* pDC_i, CWnd* pWnd_i, UINT uCtlColor_i )
{
HBRUSH hDefaultBrush = CDialog::OnCtlColor( pDC_i, pWnd_i, uCtlColor_i );
if( CTLCOLOR_DLG == uCtlColor_i )
{
return m_BkBrush;
}
return hDefaultBrush;
}
try and tell me the result..;)
nave
|
|
|
|
|
Sorry, its not working.
|
|
|
|
|
ok yaar..I cannot figure out why its not working....
Well...Where r u working..? I am from India->Kerala..
nave
|
|
|
|
|
Tried using this code for executing insert query,but doesnt work..Is something wrong,or is ther any other method to do dat?
_Commandptr m_pCommand;
_Recordptr pRs;
m_pCommand.CreateInstance(__uuidof(Command));
m_pCommand->ActiveConnection = m_pConnection;
m_pCommand->CommandText = "insert into wcs values('uu',6,8,7,6,8,'hi')";
pRs.CreateInstance(__uuidof(Recordset));
pRs->PutRefSource(m_pCommand);
|
|
|
|
|
What is the error u r getting ??
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|
query is written in a try block(dont ask me 2 write it elsewhere!)..throws an exception..
|
|
|
|
|
I think the exception is due to some problem in the Insert command.verify it once.
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|
YES!!
|
|
|
|
|
|
Hi,
I have a dialog box in my ATL exe, I want to use/link a C Library. AFter clicking OK button on the dialog on of C functions should execute .
How to do this. linking the Clibrary and opening the C function.
Can I use the C code direct in ATL module ? how?
marcoslav
|
|
|
|
|
This is not the right forum to post the Question.
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|
noone answers there in ATL so posted here
|
|
|
|
|
As we know, when we want to shut our computer,
the system pop up a shuting window,
and the screen is locked, that the color lightness is gradually decreased , and the mouse click is invalid.
following is some codes to create this function, and I don't know why it be this way?
////////////////////////////////////////////////////////
byte pbit[16]=
{
0x55, 0, 0xaa, 0x0,
0x55, 0, 0xaa, 0x0,
0x55, 0, 0xaa, 0x0,
0x55, 0, 0xaa, 0x0,
};
HBITMAP hbm=CreateBitmap(8, 8, 1, 1, pbit);
HBRUSH hbr=CreatePatternBrush(hbm);
HDC pdc=::GetDC(0);
SelectObject(pdc, hbr);
PatBlt(pdc, 0, 0,
GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN),
0xa000c9 //BLACKNESS//DSTINVERT//PATINVERT
);
DeleteObject(hbm);
::ReleaseDC(0, pdc);
//end
1.When I move the window (this cwnd) the screen changed, but the WINDOWSXP doesn't do it , how I do it , on the other hand , how to mask the message that not sent to the current shuting CWnd?
2.Byte Array pBit , what its function?And what 0xa000c9 is ?
If you had some good codes about this , please give me for some references, thank you!
Online waiting for answers!
Just my interest for these common things
|
|
|
|
|
|
ok, thank you very much!
that's what I want!
Just my interest for these common things
|
|
|
|
|
I'm working on an app that needs to work with both ascii and unicode, but I seem to have run into a rather frustrating problem.
It seems that for some reason, whenever I pass a unicode string to COleVariant.SetString(), the bstrVal only contains the unicode string up to the first NULL character in the string(regardless of the VARTYPE parameter). Hence most of the unicode strings are prematurely truncated. If I remember my unicode correctly it requires a double NULL to indicate the end of a unicode string does it not?
Anybody know of why this may be and how I can fix it?
When I die I'd like to go peacefully in my sleep like my father, not screaming in terror like his passengers!!!
|
|
|
|
|