How do you get the address of a return variable

Compiler: Dev-c+ v4.9.9.2
Operating System: Windows Vista


Hello, I am a novice c++/win32 programmer, and I am trying to change the background color of a win32 static control. I am attempting to do this by getting the HBRUSH handle of the static control through the win32 function:

1
2
3
4
5
6
SendMessage(
  (HWND) hwnd, 
  WM_CTLCOLORSTATIC ,
  (WPARAM) wParam,   
  (LPARAM) lParam
  );


Now as you know this function returns a handle to the brush of the control. It seems to me that this return is only the value of the brush and not the actual brush, so I think that I would need to get the address of the return brush in order to actually change the background color of the control. However my problem is that, as a novice, I don't know how to get the address of such a return variable.

(Note: I know the variable must first exist or be declared outside of the function and be passed to it through a pointer or a reference.)


My questions are:
(1)How do you get the address of a return variable from a "non-application-defined" function such as SendMessage() or any Win32 api for that matter?

(2)Could you explain to me how how to change the background color of a static control?(I really don't know what I'm doing.)


Thank you very much for your help. THANK YOU......
Last edited on
Using SendMessage is not good idea
you can change any controls anything using
message handler OnCtlColor
this code hels you to understand it:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
HBRUSH CViewOperator::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
   HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);  //base class

   if( nCtlColor == CTLCOLOR_STATIC) //static control
   {
     
     
   // Set colors...........


  return (LRESULT) m_hDialogBrush;

    }
 
  return hbr;
}
closed account (z05DSL3A)
For win32 api:

WM_CTLCOLORSTATIC Notification
A static control, or an edit control that is read-only or disabled, sends the WM_CTLCOLORSTATIC message to its parent window when the control is about to be drawn. By responding to this message, the parent window can use the specified device context handle to set the text and background colors of the static control.

A window receives this message through its WindowProc function.
Topic archived. No new replies allowed.