Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8765789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:22:35+00:00 2026-06-13T16:22:35+00:00

I am using the polyline function to draw triangles in c++. I am having

  • 0

I am using the polyline function to draw triangles in c++. I am having problems in getting the triangles to store in a struct (for them to be repainted when the window is invaldiated)

#define MAX_OBJECTS 10000

typedef struct
{
unsigned int topCornerX;
unsigned int topCornerY;
unsigned int RightX;
unsigned int RightY;
unsigned int LeftX;
unsigned int LeftY;

}Triangles;

int mouse_down_x = 0;
int mouse_down_y = 0;



Triangles triangleList[MAX_OBJECTS];
Triangles temp_tri;
int current_tri_count = 0;
int t = 0;

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
POINT Pt[4];
POINT pT[4];

I am using this one to draw the temp triangle

Pt[0].x = temp_tri.topCornerX;  Pt[0].y = temp_tri.topCornerY;
Pt[1].x = temp_tri.LeftX; Pt[1].y = temp_tri.LeftY;
Pt[2].x = temp_tri.RightX; Pt[2].y = temp_tri.RightY;
Pt[3].x = temp_tri.topCornerX; Pt[3].y = temp_tri.topCornerY;

this one is to redraw all the previous triangles, however it isn’t working

pT[0].x = triangleList[t].topCornerX;
pT[0].y = triangleList[t].topCornerX;
pT[1].x = triangleList[t].LeftX;
pT[1].y = triangleList[t].LeftY;
pT[2].x = triangleList[t].RightX;
pT[2].y = triangleList[t].RightY;
pT[3].x = triangleList[t].topCornerX;
pT[3].y = triangleList[t].topCornerY;

case WM_PAINT:
    hdc = BeginPaint(hWnd, &ps);

Polyline(hdc, Pt, 4); // using this one to draw the temp triangle as the object is drawn by user

while (t < current_tri_count) // should be redrawing the old ones
    {
        Polyline(hdc,pT,4);
        t++;


    }


case WM_LBUTTONDOWN:

mouse_down_x = LOWORD(lParam);
        mouse_down_y = HIWORD(lParam);

        temp_tri.topCornerX = mouse_down_x;
        temp_tri.topCornerY = mouse_down_y;

        mouse_down = true;

break;

case WM_MOUSEMOVE:

if(mouse_down)
        {
            temp_tri.LeftX = LOWORD(lParam);
            temp_tri.LeftY = HIWORD(lParam);
            temp_tri.RightX = LOWORD(lParam) + 90;
            temp_tri.RightY = HIWORD(lParam) + 90;
            mouse_down = true;

        }
        InvalidateRect(hWnd, NULL, true);

break;

case WM_LBUTTONUP:

                          temp_tri.LeftX = LOWORD(lParam);
        temp_tri.LeftY = HIWORD(lParam);
        temp_tri.RightX = LOWORD(lParam) + 90;
        temp_tri.RightY = HIWORD(lParam) + 90;

        triangleList[current_tri_count] = temp_tri;

        current_tri_count ++;
        mouse_down = false;

break;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T16:22:37+00:00Added an answer on June 13, 2026 at 4:22 pm

    In one of the lines you have:

    pT[0].x = triangleList[t].topCornerX;
    pT[0].y = triangleList[t].topCornerX;
    

    I think that should be:

    pT[0].x = triangleList[t].topCornerX;
    pT[0].y = triangleList[t].topCornerY; // <- Y
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this function to add a new marker (and polyline) to a map:
I'm decoding an encoded path and using this decoded path to draw a polyline
Why when I want to draw a polyline using Google maps V3.0 (JavaScript API)
I'm using Ym4r and want to add a polyline to my map. This works:
Is there any easy ways to find the bounding box of a polyline using
I am using Google Maps V3 API to create a polyline with 2 points.
We are building a web app library which need draw some polyline/polygon/circle/rectange. Also we
We're using Javascript to draw polylines on a <canvas> element, based on some spatial
You Have edited script according to v2 i am getting this error on using
Here is my script: <script> Raphael.fn.polyline = function(pointString) { return this.path(M + pointString); };

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.