Try assigning the value of each member of the POINT array separately, like this:
POINT poly[2];
poly[0].x = 0;
poly[0].y = 50;
poly[1].x = 50;
poly[1].y = 0;
poly[2].x = 100;
poly[2].y = 50;
or
POINT poly[2];
poly[0] = {0,50};
poly[1] = {50,0};
poly[2] = {100,50};
Whichever you prefer.
Let me know if there are any other problems.
-AJ
C:\DOS
C:\DOS\RUN
RUN\DOS\RUN
-Comic Book Store Guy''s t-shirt that I saw on the Simpsons, although it didn''t actually come from the Simpsons.
http://vdsoft.netfirms.com/home.html
Fill something in!
C:DOSC:DOSRUNRUNDOSRUN-Comic Book Store Guy's t-shirt that I saw on the Simpsons, although it didn't actually come from the Simpsons.http://vdsoft.netfirms.com/home.html
redneckCoder, your code has some problems. It should look like this:
I changed POINT poly[2] to POINT poly[3 ], why? Because you have 3 points (indexed as 0, 1, and 2 in the array NOT 0, 1, 2, 3). Your code overruns into memory that isn't safe to touch.
Also, Polygon(hdc, &poly, 3) was changed to Polygon(hdc, poly, 3) because poly is already a pointer and &poly is a pointer to a pointer.
To sum up, error C2078 was returned because poly[2] doesn't exist when poly is defined as POINT poly[2] and C2664 was returned because Polygon asks for a pointer and not a pointer to a pointer.
EDIT: Forgot the / in ending the bold tag...
I will not make a list of links... I will not make a list of links... I will not make a list of links...
Invader's Realm
[edited by - Invader X on April 24, 2002 6:31:34 PM]
HPEN redPen = CreatePen(PS_SOLID, 1, RGB(255,0,0));HBRUSH redBrush = CreateSolidBrush(RGB(255,0,0));SelectObject(hdc, redPen);SelectObject(hdc, redBrush);POINT poly[3] = {0,50,50,0,100,50};Polygon(hdc, poly, 3); DeleteObject(redPen);DeleteObject(redBrush);
I changed POINT poly[2] to POINT poly[3 ], why? Because you have 3 points (indexed as 0, 1, and 2 in the array NOT 0, 1, 2, 3). Your code overruns into memory that isn't safe to touch.
Also, Polygon(hdc, &poly, 3) was changed to Polygon(hdc, poly, 3) because poly is already a pointer and &poly is a pointer to a pointer.
To sum up, error C2078 was returned because poly[2] doesn't exist when poly is defined as POINT poly[2] and C2664 was returned because Polygon asks for a pointer and not a pointer to a pointer.
EDIT: Forgot the / in ending the bold tag...
I will not make a list of links... I will not make a list of links... I will not make a list of links...
Invader's Realm
[edited by - Invader X on April 24, 2002 6:31:34 PM]
while(1)
{
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if(msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
hdc = GetDC(hwnd);
HPEN redPen = CreatePen(PS_SOLID, 1, RGB(255,0,0));
HBRUSH redBrush = CreateSolidBrush(RGB(255,0,0));
SelectObject(hdc, redPen);
SelectObject(hdc, redBrush);
POINT poly[2];
poly[0].x = 0;
poly[0].y = 50;
poly[1].x = 50;
poly[1].y = 0;
poly[2].x = 100;
poly[2].y = 50;
Polygon(hdc, &poly, 3);
DeleteObject(redPen);
DeleteObject(redBrush);
ReleaseDC(hwnd, hdc);
}
ok thats what i have down and i get this error
"error C2664: ''Polygon'' : cannot convert parameter 2 from ''struct tagPOINT (*)[2]'' to ''const struct tagPOINT *''
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe."
... can you think of anything to fix that
{
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if(msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
hdc = GetDC(hwnd);
HPEN redPen = CreatePen(PS_SOLID, 1, RGB(255,0,0));
HBRUSH redBrush = CreateSolidBrush(RGB(255,0,0));
SelectObject(hdc, redPen);
SelectObject(hdc, redBrush);
POINT poly[2];
poly[0].x = 0;
poly[0].y = 50;
poly[1].x = 50;
poly[1].y = 0;
poly[2].x = 100;
poly[2].y = 50;
Polygon(hdc, &poly, 3);
DeleteObject(redPen);
DeleteObject(redBrush);
ReleaseDC(hwnd, hdc);
}
ok thats what i have down and i get this error
"error C2664: ''Polygon'' : cannot convert parameter 2 from ''struct tagPOINT (*)[2]'' to ''const struct tagPOINT *''
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe."
... can you think of anything to fix that
redneck, you shouldn''t delete a drawing object while it is still selected in a device context.
quote: Original post by SilentCoder
redneck, you shouldn''t delete a drawing object while it is still selected in a device context.
What do you mean? You can''t delete a drawing object unless it''s selected into a device context in the first place.
-AJ
C:\DOS
C:\DOS\RUN
RUN\DOS\RUN
-Comic Book Store Guy''s t-shirt that I saw on the Simpsons, although it didn''t actually come from the Simpsons.
http://vdsoft.netfirms.com/home.html
C:DOSC:DOSRUNRUNDOSRUN-Comic Book Store Guy's t-shirt that I saw on the Simpsons, although it didn't actually come from the Simpsons.http://vdsoft.netfirms.com/home.html
quote: Original post by DeadlyPencil
... can you think of anything to fix that
Ok, go ahead and make the changes that InvaderX said was wrong with my code and give that a shot.
-AJ
C:\DOS
C:\DOS\RUN
RUN\DOS\RUN
-Comic Book Store Guy''s t-shirt that I saw on the Simpsons, although it didn''t actually come from the Simpsons.
http://vdsoft.netfirms.com/home.html
C:DOSC:DOSRUNRUNDOSRUN-Comic Book Store Guy's t-shirt that I saw on the Simpsons, although it didn't actually come from the Simpsons.http://vdsoft.netfirms.com/home.html
Never mind, I got it to work. I thought the original parameters I had were something like flags. I didn''t know they were variable names!
----------
Take it to the Xtreme!
----------
----------
Take it to the Xtreme!
----------
Wachar's Eternity <-<-<-<-<- Me own site!
quote: Original post by redneckCoderOriginal post by SilentCoder
redneck, you shouldn''t delete a drawing object while it is still selected in a device context.
What do you mean? You can''t delete a drawing object unless it''s selected into a device context in the first place.
-AJ
C:\DOS
C:\DOS\RUN
RUN\DOS\RUN
-Comic Book Store Guy''s t-shirt that I saw on the Simpsons, although it didn''t actually come from the Simpsons.
http://vdsoft.netfirms.com/home.html
You have to save an old_pen or some other variable. Example:
HPEN old_pen = (HPEN)SelectObject(hdc, redPen);//laterSelectObject(hdc, old_pen);DeleteObject(redPen);
If you don''t, Windows GDI won''t let you delete it!
———-
Take it to the Xtreme!
———-
Wachar's Eternity <-<-<-<-<- Me own site!
I''ve tried changing the pen to a different color on polygon(), and I''ve found out that, when you use a different color for a pen in polygon(), it looks like the outline is blinking. Why?
----------
Take it to the Xtreme!
----------
----------
Take it to the Xtreme!
----------
Wachar's Eternity <-<-<-<-<- Me own site!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement