some more gdi problems

Started by
6 comments, last by willthiswork89 18 years, 7 months ago
first i had problems with the gdi not compiling because invalid conversion from void to _HBRUSH so they told me to do the cast and now i get 100's of undefined refrences heres some examples [Linker error] undefined reference to `CreateSolidBrush@4' things like that? sorry to be a hassel lol
Advertisement
paste your code
-www.freewebs.com/tm1rbrt -> check out my gameboy emulator ( worklog updated regularly )
Quote:
#include <windows.h>
#include <windowsx.h>
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);

int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow )
{
WNDCLASS WndClass;
WndClass.style = 0;
WndClass.cbClsExtra = 0;
WndClass.cbWndExtra = 0;
WndClass.lpfnWndProc = WndProc;
WndClass.hInstance = hInstance;
WndClass.hbrBackground = (HBRUSH) (COLOR_WINDOW+1);
WndClass.hCursor = LoadCursor (NULL, IDC_ARROW);
WndClass.hIcon = LoadIcon (NULL, IDI_APPLICATION);
WndClass.lpszMenuName = 0;
WndClass.lpszClassName = "WinProg";

RegisterClass(&WndClass);

HWND hWindow;
hWindow = CreateWindow("WinProg", "Window",
WS_OVERLAPPEDWINDOW,
0,0,600,460,NULL,NULL,
hInstance, NULL);

ShowWindow (hWindow,nCmdShow);

UpdateWindow (hWindow);

MSG Message;
while(GetMessage(&Message, NULL, 0, 0))
{
DispatchMessage(&Message);
}
return (Message.wParam);
}
LRESULT CALLBACK WndProc (HWND hWnd, UINT uiMessage,
WPARAM wParam, LPARAM lParam)
{
switch(uiMessage)
{
case WM_PAINT:
HPEN hPen;
HPEN hPenalt;
HBRUSH hBrush;
HBRUSH hBrushalt;
hBrush = CreateSolidBrush (RGB(255,100,0));
hPen = CreatePen (PS_SOLID,2,RGB(0,255,255));
HDC hdc;
PAINTSTRUCT ps;
hdc = BeginPaint (hWnd, &ps);
hBrushalt = SelectBrush(hdc, hBrush);
hPenalt = SelectPen(hdc, hPen);
MoveToEx (hdc, 20,20, NULL);
LineTo (hdc, 100, 100);
Rectangle (hdc, 120, 20, 240, 140);
RoundRect (hdc, 260, 20, 420, 140, 20, 20);

RECT rect;
SetRect (&rect, 20, 260, 240, 420);
FrameRect (hdc, &rect, hBrush);
SetRect (&rect, 260, 260, 420, 420);
FillRect (hdc, &rect, hBrush);
Ellipse (hdc, 440, 260, 480, 420);
SelectObject (hdc, hBrushalt);
SelectObject (hdc, hPenalt);
DeleteObject (hPen);
DeleteObject (hBrush);
EndPaint (hWnd, &ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
break;
default:
return DefWindowProc (hWnd, uiMessage,
wParam, lParam);
}
}

Sounds like for some reason your compiler is not linking in the standard windows library. I have no idea why that would be though.
Mike Popoloski | Journal | SlimDX
well what do you guys all use...im getting sick of these damned errors all the time im using bloodshed dev c++ IDE newest beta version? should i download an older version or what.
Your function is in Gdi32.lib, make sure you are linking in the library or DLL. I would really recommend Visual Studio.
well i have microsoft visual studio .net? can i use it too?
it worked! yes thank you so0o much :) all i needed was that lib

This topic is closed to new replies.

Advertisement