Hello, My name is Patryk,
I am a programmer, more or less and I have ran into this problem:
Error:No instance of overloaded function "Gdiplus::Graphics::DrawRectangle" matches the argument
I checked the header files and everything, Idk whats the matter. Here is my Code:
#include <windows.h>#include <string>
#include <objidl.h>
#include <gdiplus.h>
#include <Gdiplusenums.h>
#include <WindowsX.h>
#include <process.h>
using namespace Gdiplus;
#pragma comment (lib,"Gdiplus.lib")
VOID OnPaint(HDC hdc)
{Graphics graphics(hdc);
Color backgroundColor(255,0,0,0);
graphics.Clear(backgroundColor);
//variables
int bx1=1,bx2=10,bx3=10,bx4=1;float by1=10,by2=10,by3=20,by4=20;
float lpx1=1,lpx2=11,lpx3=11,lpx4=1;float lpy1=50,lpy2=50,lpy3=60,lpy4=60;
float rpx1=688,rpx2=698,rpx3=698,rpx4=688;float rpy1=50,rpy2=50,rpy3=60,rpy4=60;
//default points
Point ball[]={Point(bx1,by1),Point(bx2,by2),Point(bx3,by3),Point(bx4,by4),Point(bx1,by1)};
Point LPaddle[]={Point(lpx1,lpy1),Point(lpx2,lpy2),Point(lpx3,lpy3),Point(lpx4,lpy4),Point(lpx1,lpy1)};
Point RPaddle[]={Point(rpx1,rpy1),Point(rpx2,rpy2),Point(rpx3,rpy3),Point(rpx4,rpy4),Point(rpx1,rpy1)};
//colors
Color blackColor(255, 0, 0, 0);
Pen ballline(Color(255, 255, 255, 255),3);
Pen LPaddleline(Color(255 ,255 ,255 ,255),3);
Pen RPaddleline(Color(255 ,255 ,255 ,255),3);
for(int forloop1=1;forloop1<0;forloop1++){
//cahnge points
if(GetAsyncKeyState(0x26)){rpy1++;rpy2++;rpy3++;rpy4++;};
if(GetAsyncKeyState(0x28)){rpy1--;rpy2--;rpy3--;rpy4--;};
if(GetAsyncKeyState(0x57)){lpy1++;lpy2++;lpy3++;lpy4++;};
if(GetAsyncKeyState(0x53)){lpy1--;lpy2--;lpy3--;lpy4--;};
//dispay images
Gdiplus::Graphics::DrawRectangle(RPaddleline,lpx1,lpy1,10.00F,40.00F);
Gdiplus::Graphics::DrawRectangle(LPaddleline,rpx1,rpy1,10.00F,40.00F);
Sleep(200);
};};
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, PSTR, INT iCmdShow)
{
HWND hWnd;
MSG msg={0};
WNDCLASS wndClass;
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
// Initialize GDI+.
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
wndClass.style = CS_HREDRAW | CS_VREDRAW;
wndClass.lpfnWndProc = WndProc;
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 0;
wndClass.hInstance = hInstance;
wndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndClass.lpszMenuName = NULL;
wndClass.lpszClassName = TEXT("Pong");
RegisterClass(&wndClass);
hWnd = CreateWindow(
TEXT("Pong"),// window class name
TEXT("Pong"),// window caption
WS_POPUP, // window style
100,// initial x position
100,// initial y position
700,// initial x size (1280)
600,// initial y size (1024)
NULL,// parent window handle
NULL,// window menu handle
hInstance, // program instance handle
NULL); // creation parameters
ShowWindow(hWnd, iCmdShow);
UpdateWindow(hWnd);
while(msg.message != WM_QUIT)
{
if(PeekMessage(&msg,0,0,0,PM_REMOVE)){
TranslateMessage(&msg);
DispatchMessage(&msg);};
};
GdiplusShutdown(gdiplusToken);
return msg.wParam;
} // WinMain
LRESULT CALLBACK WndProc(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
switch(message)
{
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
OnPaint(hdc);
EndPaint(hWnd, &ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
}// WndProc