Custom Rectangle in Dialog?
-
Can you please be a little bit more specific? Regards, João Paulo
-
Can you please be a little bit more specific? Regards, João Paulo
I am creating a Dialog based application for a PocketPC(using eMbedded VC++).I am getting a few integer inputs from the first dialog box(say length and width of a rectangle).I have to use these values to draw a rectangle onto the next Dialog Box.On the second Dialog,the user will click(anywhere on the screen),and I need to find out the location and time of the click.My problems are: 1.I am able to pass the values to the second dialog,but I dont know how to add the rectangle to the Dialog.(tried using CDC pointers but that gave me an x0000005 error). 2.How do I find where on the screen a user clicked? 3.How do I find the time when the user clicked(millisecond resolution)? Thanks!
-
I am creating a Dialog based application for a PocketPC(using eMbedded VC++).I am getting a few integer inputs from the first dialog box(say length and width of a rectangle).I have to use these values to draw a rectangle onto the next Dialog Box.On the second Dialog,the user will click(anywhere on the screen),and I need to find out the location and time of the click.My problems are: 1.I am able to pass the values to the second dialog,but I dont know how to add the rectangle to the Dialog.(tried using CDC pointers but that gave me an x0000005 error). 2.How do I find where on the screen a user clicked? 3.How do I find the time when the user clicked(millisecond resolution)? Thanks!
ruks_ns wrote: 1.I am able to pass the values to the second dialog,but I dont know how to add the rectangle to the Dialog.(tried using CDC pointers but that gave me an x0000005 error). Use
CDialog::OnPaint
(WM_PAINT
) to draw the rectangle. ruks_ns wrote: 2.How do I find where on the screen a user clicked? UseOnLButtonDown
(WM_LBUTTONDOWN
). One of its parameters is a CPoint containing the position of the click. ruks_ns wrote: 3.How do I find the time when the user clicked(millisecond resolution)? TryGetSystemTime()
. You can also useGetCurrentMessage()
to retrieve a pointer to aMSG
structure, where you will find atime
member. MSDN says: "Thetime
member is the number of milliseconds since a cold or warm boot on a device. It is the value returned by theGetTickCount
function. Not included is the time that a device is in suspend mode." Regards, João Paulo -
ruks_ns wrote: 1.I am able to pass the values to the second dialog,but I dont know how to add the rectangle to the Dialog.(tried using CDC pointers but that gave me an x0000005 error). Use
CDialog::OnPaint
(WM_PAINT
) to draw the rectangle. ruks_ns wrote: 2.How do I find where on the screen a user clicked? UseOnLButtonDown
(WM_LBUTTONDOWN
). One of its parameters is a CPoint containing the position of the click. ruks_ns wrote: 3.How do I find the time when the user clicked(millisecond resolution)? TryGetSystemTime()
. You can also useGetCurrentMessage()
to retrieve a pointer to aMSG
structure, where you will find atime
member. MSDN says: "Thetime
member is the number of milliseconds since a cold or warm boot on a device. It is the value returned by theGetTickCount
function. Not included is the time that a device is in suspend mode." Regards, João Paulo -
When I do CDialog::OnPaint(WM_PAINT),it says OnPaint function does not take 1 parameters!What do I do now? Thanks!
I'm sorry... :-O I did not write this in a proper way. What I meant is that the
OnPaint
handler handles theWM_PAINT
message. In fact, it does not have a parameter. The class wizard will have generated adc
variable declaration for you. This is how you should draw the rectangle. Regards, João Paulo -
I'm sorry... :-O I did not write this in a proper way. What I meant is that the
OnPaint
handler handles theWM_PAINT
message. In fact, it does not have a parameter. The class wizard will have generated adc
variable declaration for you. This is how you should draw the rectangle. Regards, João PauloWell it doesnt work now either!Let me explain better: I have a DoModal method that I call to display the new CDialog.In this method,here's my code: int CDexterDlg::DoModal(const int &refcUserInput) { m_UserInputDialogOne = refcUserInput; CRect rect(0, 0, m_UserInputDialogOne, 50); ASSERT(rect.Width() == 100); ASSERT(rect.Height() == 50); OnPaint(); return CDialog::DoModal(); } But still my rectangle does not show up on the new Dialog box.Please help! Thanks!!
-
Well it doesnt work now either!Let me explain better: I have a DoModal method that I call to display the new CDialog.In this method,here's my code: int CDexterDlg::DoModal(const int &refcUserInput) { m_UserInputDialogOne = refcUserInput; CRect rect(0, 0, m_UserInputDialogOne, 50); ASSERT(rect.Width() == 100); ASSERT(rect.Height() == 50); OnPaint(); return CDialog::DoModal(); } But still my rectangle does not show up on the new Dialog box.Please help! Thanks!!
OnPaint
is called for you by the framework. You cannot call it explicitly as in your code. Your code should look like:void CDexterDlg::OnPaint()
{
CPaintDC dc(this);dc.Rectangle(x1, y1, x2, y2);
}
Replace the variables with your coordinates, and the rectangle will show up. Regards, João Paulo
-
OnPaint
is called for you by the framework. You cannot call it explicitly as in your code. Your code should look like:void CDexterDlg::OnPaint()
{
CPaintDC dc(this);dc.Rectangle(x1, y1, x2, y2);
}
Replace the variables with your coordinates, and the rectangle will show up. Regards, João Paulo
Well,the rectangle still doesnt show up.I need to access a variable from the first Dialog box that is available in the DoModal method.My code now looks like: int CDexterDlg::DoModal(const int &refcUserInput) { // Initialization m_UserInputDialogOne = refcUserInput; return CDialog::DoModal(); } void CDexterDlg::OnPaint() { CPaintDC dc(this); dc.Rectangle(0, 0, 100, 50); } The variable m_UserInputDialogOne needs to be a dimension in the rectangle.Also,why isnt the rectangle with the numbers(constants) as paremters not showing up(ie as it is now in the code shown above)??! Thank you very much!
-
Well,the rectangle still doesnt show up.I need to access a variable from the first Dialog box that is available in the DoModal method.My code now looks like: int CDexterDlg::DoModal(const int &refcUserInput) { // Initialization m_UserInputDialogOne = refcUserInput; return CDialog::DoModal(); } void CDexterDlg::OnPaint() { CPaintDC dc(this); dc.Rectangle(0, 0, 100, 50); } The variable m_UserInputDialogOne needs to be a dimension in the rectangle.Also,why isnt the rectangle with the numbers(constants) as paremters not showing up(ie as it is now in the code shown above)??! Thank you very much!
Make sure the rectangle you are drawing is not covered by other controls. Regards, João Paulo