ive got a child window and i dont know how to make it a diferent background from the main parent window ,
ive tried to register another class with a diferent background colour but not sure how to make it work
ive got a child window and i dont know how to make it a diferent background from the main parent window ,
ive tried to register another class with a diferent background colour but not sure how to make it work
MDI? One solution is OnDraw().
Kuphryn
WM_CTLCOLOR funcionis just add EDIT, STATIC etc.
Example WM_CTLCOLOREDIT for changing edit control color and use a GetBkColor();
where does it go in this
Code:HWND hEdit2; hEdit2 = CreateWindowEx(WS_EX_WINDOWEDGE, //style type "EDIT", //class type "", //what apears in the window WS_CHILD | WS_VISIBLE | WS_BORDER, 0, //across 50, //down 300, //thinness 350, // height hwnd, NULL, GetModuleHandle(NULL), NULL );
as Sucur says, just check the WM_CTLCOLOREDIT message of the procedure; that message means that a control is being drawn, with the default pen, color, etc... the important procedure values received are the UNIT (color edit event) and the LPARAM (display context). now you can modify the display context (HDC) with the usual functions for that (SetTextColor, etc...). for the bk color you should exit from the 'event' returning an HBRUSH that will be the bk color of the control, for the text color/bkmode/etc yoou can use the 'normal' funcions provided for that.
hey, remember to not paint the background color as the text color
niara
care todo a example as i am confuzzed
and how to i set it so the window will open in full screen mode
I think that the fullscreen mode won't change the way of do it; on the message evaluation of the window procedure, just check for the WM_CTLCOLOREDIT, as you chek for the WM_PAINT, or other WM_ message; when you are in it, simply play with the options.
to work with your code, set a HMENU value, and also set the window instance; something like:
HEDIT2 is the edit identifyer, is a simple number. on the WM_CTLCOLOREDIT you can select the control that will be paint: with that message the lParam of the finction is the handler of the control that is being painted, in that case you can't compare directly with 'hEdit2' because isn't a global static variable (you can do it as well declaring at the top of the code -after the windows header, of course-). the other code is simple: the wParam of the function is the HDC where the control will be drawn, so you can interact with it to set the text color and other things; finally you should end the WM_CTLCOLOREDIT case returning the bakground color of the edit control in form of HBRUSH, so create a new hbrush and return it or return the creation of a new hbrush, or create a global hbrush and use it as return value, or etc... (thousands combinations).Code://before any code #define HEDIT2 10 //window procedure or dialog procedure, don't mind because the params are the same functionProcedure(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) { switch(msg) { case WM_CREATE://use that if is a window procedure case WM_INITDIALOG://use that other if is a dialog procedure { HWND hEdit2; hEdit2=CreateWindowEx(0,"EDIT","Text",WS_CHILD|WS_VISIBLE|WS_BORDER,0,50,300,350,hwnd, (HMENU)HEDIT2, (HINSTANCE)hInstance, NULL); } break; case WM_CTLCOLOREDIT: { if((HWND)lParam==GetDlgItem(hwnd,HEDIT2)) { SetTextColor((HDC)wParam,RGB(0,0,255)); return (int)(HBRUSH)CreateSolidBrush(RGB(255,0,0)); } } break; } }
niara
>>how to i set it so the window will open in full screen mode<<
For a top-level window create your window with only the WS_POPUP window style, with no border-changing extended styles. To get the screen size use GetSystemMetrics, once for width(SM_CXSCREEN) and again for height(SM_CYSCREEN). For a child window, just make sure it has no borders (no extended styles should just about do it) and resize it to fit the parent's client area (since it should cover the screen if the child window is intended to do so). You can resize it within the parent's WM_SIZE handler - search the board if you need further examples as there have been many.
CProgramming FAQ
Caution: this person may be a carrier of the misinformation virus.