Write a program that has two windows, a message sender and a messagereceiver. The message sender will have a menu with three choices:
Add the messages WM_COLOR_xxxxx to the list of identifers. To do this
The message sender will be a minimal window and corresponding class. Create the menu for this class and the window in the resource workshop. (Youmight as well create the receiver window also. It is just a simple window withno extras). Make sure to define your message constants WM_COLOR_xxx inthe workshop Identifers window. The actual handlers will simply have the line:
Parent->SendMessage(WM_COLOR_xxx);
The main window will simply forward message from the sender to the receiver.You are creating the handlers, so you must establish the tie between themessage and handler names in the response table.
DEFINE_RESPONSE_TABLE1(Cldemo12Window, TWindow)//{{Cldemo12WindowRSP_TBL_BEGIN}} EV_WM_PAINT, EV_MESSAGE(WM_COLOR_BLUE, EvColorBlue), EV_MESSAGE(WM_COLOR_RED, EvColorRed), EV_MESSAGE(WM_COLOR_YELLOW, EvColorYellow),//{{Cldemo12WindowRSP_TBL_END}}END_RESPONSE_TABLE;Then add each of the EvColorxxx functions to the class header for your main windowand add the functions to the cpp file. Here is a sample of one such function.LRESULT Cldemo12Window::EvColorBlue(WPARAM,LPARAM){ _receiver->fillBlue();}Finally make sure to create the SetupWindow function for you TWindow. This will createeach of the windows and I added something to spread out the windows.void Cldemo12Window::SetupWindow (){ TWindow::SetupWindow(); // INSERT>> Your code here. _receiver = new Reciever(this,IDD_RECEIVER,0); _receiver->Create(); _sender = new Sender(this,IDD_SENDER,0); _sender->Create(); // The following positions the windows so they are separated HWND rWind = HWindow; _sender->SetWindowPos(rWind, 50,70,0,0, SWP_NOSIZE|SWP_NOACTIVATE); rWind = _sender->HWindow; _receiver->SetWindowPos(rWind,350,70,0,0, SWP_NOSIZE|SWP_NOACTIVATE);}The receiver window has a WM_PAINT handler that does all the work. The othermessages, such as fillBlue simply change the value of a member data item _color,and call Invalidate. The EvPaint function follows:
void Receiver::EvPaint (){ TDialog::EvPaint(); // INSERT>> Your code here. TDC *dc = new TClientDC(*this); TPoint p(1,1); TBrush brush(_color); dc->SelectObject(brush); dc->FloodFill(p, TColor::White); p.Offset(280,180); dc->FloodFill(p,TColor::White); delete dc;}I used two flood fills to make sure that if the sender was moved over the receiver,the receiver would refill in most cases.