Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Mobile Development
  3. Mobile
  4. Custom Rectangle in Dialog?

Custom Rectangle in Dialog?

Scheduled Pinned Locked Moved Mobile
question
10 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    ruks_ns
    wrote on last edited by
    #1

    How do I add a custom-drawn Rectangle object to a CDialog that already exists?

    J 1 Reply Last reply
    0
    • R ruks_ns

      How do I add a custom-drawn Rectangle object to a CDialog that already exists?

      J Offline
      J Offline
      Joao Paulo Figueira
      wrote on last edited by
      #2

      Can you please be a little bit more specific? Regards, João Paulo

      R 1 Reply Last reply
      0
      • J Joao Paulo Figueira

        Can you please be a little bit more specific? Regards, João Paulo

        R Offline
        R Offline
        ruks_ns
        wrote on last edited by
        #3

        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!

        J 1 Reply Last reply
        0
        • R ruks_ns

          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!

          J Offline
          J Offline
          Joao Paulo Figueira
          wrote on last edited by
          #4

          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? Use OnLButtonDown (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)? Try GetSystemTime(). You can also use GetCurrentMessage() to retrieve a pointer to a MSG structure, where you will find a time member. MSDN says: "The time member is the number of milliseconds since a cold or warm boot on a device. It is the value returned by the GetTickCount function. Not included is the time that a device is in suspend mode." Regards, João Paulo

          R 1 Reply Last reply
          0
          • J Joao Paulo Figueira

            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? Use OnLButtonDown (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)? Try GetSystemTime(). You can also use GetCurrentMessage() to retrieve a pointer to a MSG structure, where you will find a time member. MSDN says: "The time member is the number of milliseconds since a cold or warm boot on a device. It is the value returned by the GetTickCount function. Not included is the time that a device is in suspend mode." Regards, João Paulo

            R Offline
            R Offline
            ruks_ns
            wrote on last edited by
            #5

            When I do CDialog::OnPaint(WM_PAINT),it says OnPaint function does not take 1 parameters!What do I do now? Thanks!

            J 1 Reply Last reply
            0
            • R ruks_ns

              When I do CDialog::OnPaint(WM_PAINT),it says OnPaint function does not take 1 parameters!What do I do now? Thanks!

              J Offline
              J Offline
              Joao Paulo Figueira
              wrote on last edited by
              #6

              I'm sorry... :-O I did not write this in a proper way. What I meant is that the OnPaint handler handles the WM_PAINT message. In fact, it does not have a parameter. The class wizard will have generated a dc variable declaration for you. This is how you should draw the rectangle. Regards, João Paulo

              R 1 Reply Last reply
              0
              • J Joao Paulo Figueira

                I'm sorry... :-O I did not write this in a proper way. What I meant is that the OnPaint handler handles the WM_PAINT message. In fact, it does not have a parameter. The class wizard will have generated a dc variable declaration for you. This is how you should draw the rectangle. Regards, João Paulo

                R Offline
                R Offline
                ruks_ns
                wrote on last edited by
                #7

                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!!

                J 1 Reply Last reply
                0
                • R ruks_ns

                  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!!

                  J Offline
                  J Offline
                  Joao Paulo Figueira
                  wrote on last edited by
                  #8

                  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

                  R 1 Reply Last reply
                  0
                  • J Joao Paulo Figueira

                    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

                    R Offline
                    R Offline
                    ruks_ns
                    wrote on last edited by
                    #9

                    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!

                    J 1 Reply Last reply
                    0
                    • R ruks_ns

                      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!

                      J Offline
                      J Offline
                      Joao Paulo Figueira
                      wrote on last edited by
                      #10

                      Make sure the rectangle you are drawing is not covered by other controls. Regards, João Paulo

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups