Problems with Dynamic Button
Hi,
I cannot get my button to Display. I am creating the Button in the OnInitialUpdate funtion of a CFormView Class. I looked through code and I cannot get this button to display. I get a nozero return value, so I know it is created correctly. any ideas??
//in .h file
CButton *ctrlCancelButton;
//in .cpp file
ctrlCancelBtn = new CButton;
RECT rect;
CString msg;
BOOL b;
rect.left = 210;
rect.top = 14;
rect.right = 60;
rect.bottom = 15;
b = ctrlCancelBtn->Create("Cancel", WS_CHILD |
WS_VISIBLE , rect,this,
ID_FIND);
msg.Format("Value of Creation %d", b);
AfxMessageBox(msg);
Re: Problems with Dynamic Button
First of all, your dimensions look suspicious. Do you intend your button's height to be 1 pixel (bottom - top)? Why is your right coordinate is less than left coordinate? Assuming that upper left corner of the screen has coordinates (0, 0) this does not make much sense.
After you fix your button dimensions try ScreenToClient function to adjust coordinates relative to your window like:
ScreenToClient(&rect);
and then call Create.