|
how can i add background color to a window using its handle. Anyone plz tell me.
|
|
|
|
|
|
I want to change the background color of child window.
I have created the Child Window using CreateWindow function. Now im having only the handle of the child window. Using the handle,How can i change the background color?
|
|
|
|
|
HWND hwnd=yourchildwindow
HDC hdc=::GetDC(hwnd);
SetBKcolor(hdc,RGB(53,97,200);
|
|
|
|
|
|
Wheres problem did you use of debugger hwnd is null or hdc?
|
|
|
|
|
hWnd and hdc is pointing to some value, not NULL.
|
|
|
|
|
|
Return value of CreateWindow.
|
|
|
|
|
|
Roay wrote: hi
Hi !
|
|
|
|
|
1/ try using a more helpful subject than "hi". Though it's polite at least!
2/ what kind of window is it?
3/ is it in your own source code, or do you mean someone else's window?
Iain.
|
|
|
|
|
Iain Clarke wrote: try using a more helpful subject than "hi". Though it's polite at least
Subject: hi Iain
|
|
|
|
|
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]
|
|
|
|
|
What kind of window you are creating?
If it is a predefined window (like, edit, static, etc.) then there are specific ways for that.
If not, you can use SetClassLong with GCL_HBRBACKGROUND to change the background color.
|
|
|
|
|
Hi All
I am useing VC2005.When i build the code then i am geting this error .Plz help me
\program files\microsoft visual studio 8\vc\platformsdk\include\windef.h(176) : fatal error C1083: Cannot open include file: 'winnt.h': No such file or directory
|
|
|
|
|
MsmVc wrote: Plz help me
Sure why not. If you don't know how include files work then you need better study material for learning how to program in C/C++. You are using one or more books that are introductions to C/C++ to learn from yes?
led mike
|
|
|
|
|
Hi,
I have a application that communicates with server (Java) and communication is done using SOAP. I am able to communicate properly as much as I can in DEBUG mode but the same code is not running in RELEASE mode.
There is one function (freememory(PBYTE&)) which we are calling to free the memory. this works fine in DEBUG mode but not in RELEASE. if I put message box in this function then it is working fine.
Please suggest I do not want to use messge box.
Thanks
SNI
SNI
|
|
|
|
|
|
SNI wrote: I am able to communicate properly as much as I can in DEBUG mode but the same code is not running in RELEASE mode.
See here.
"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
|
|
|
|
|
void CTestView::OnPaint()
{
CPaintDC dc(this); // device context for painting
Invalidate(FALSE);
}
void CTestView::OnDraw(CDC* pDC)
{
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CFont font;
font.CreatePointFont(20, "Garamond");
CFont *pFont = pDC->SelectObject(&font);
pDC->TextOut(20, 18, "Christine", 9);
pDC->SelectObject(pFont);
font.DeleteObject();
}
In the above code, even though I am calling Invalidate inside OnPaint(), it is not getting inside the OnDraw(). Pls suggest me some ways how to get inside OnDraw()
|
|
|
|
|
HWND Hwnd = GetSafeHwnd();
::SendMessage(Hwnd , WM_PAINT, 0,0);
?
|
|
|
|
|
How can this call OnDraw(). Pls Explain... Also Tell me where to include your code
|
|
|
|
|
If you send PAINT message in your CTestView class windows can call OnDraw(CDC* pDC).
|
|
|
|
|
Why are you mapping the OnPaint?
See the MFC code of CView
void CView::OnPaint()
{
CPaintDC dc(this);
OnPrepareDC(&dc);
OnDraw(&dc);
}
It is calling the OnDraw. So you should not map OnPaint.
|
|
|
|