#### Archived

This topic is now archived and is closed to further replies.

# So i'm learning win32 programming right now

## Recommended Posts

iNfuSeD    128
and i got a working window with a menu and it displays random lines in random colors over an over (nothin spectacular). I just downloaded the newest version of the platform sdk off of msdn so that i could use this new gdiplus stuff i''ve been reading about. the program compiles fine as it is... but when i add the line #include <gdiplus.h> into the top it spits out 16 errors coming from different gdiplus header files. can someone help me out? i''m just including the file.. not doing anything else with it. in theory it should compile fine. and i''ve got MSVC++ pointed to the right directories for the new headers

##### Share on other sites
Guest Anonymous Poster

##### Share on other sites
iNfuSeD    128
the entire platform sdk. all the libs headers and other useless stuff i wont be needing for 1000 years

libs would only be a problem come link time wouldn''t they? the errors that pop up all come from gdiplus related header files

##### Share on other sites
Colin Jeanne    1114
Can you post the errors?

Qui fut tout, et qui ne fut rien

##### Share on other sites
iNfuSeD    128
Compiling...practice.cppd:\development\libs\microsoft sdk\include\gdiplusinit.h(32) : error C2065: ''ULONG_PTR'' : undeclared identifierd:\development\libs\microsoft sdk\include\gdiplusinit.h(32) : error C2065: ''token'' : undeclared identifierd:\development\libs\microsoft sdk\include\gdiplusinit.h(32) : error C2165: ''left-side modifier'' : cannot modify pointers to datad:\development\libs\microsoft sdk\include\gdiplusinit.h(32) : error C2071: ''NotificationHookProc'' : illegal storage classd:\development\libs\microsoft sdk\include\gdiplusinit.h(33) : error C2146: syntax error : missing '')'' before identifier ''token''d:\development\libs\microsoft sdk\include\gdiplusinit.h(33) : error C2165: ''left-side modifier'' : cannot modify pointers to datad:\development\libs\microsoft sdk\include\gdiplusinit.h(33) : error C2071: ''NotificationUnhookProc'' : illegal storage classd:\development\libs\microsoft sdk\include\gdiplusinit.h(33) : error C2059: syntax error : '')''d:\development\libs\microsoft sdk\include\gdiplusinit.h(86) : error C2059: syntax error : ''const''d:\development\libs\microsoft sdk\include\gdiplusinit.h(95) : error C2146: syntax error : missing '')'' before identifier ''token''d:\development\libs\microsoft sdk\include\gdiplusinit.h(95) : warning C4229: anachronism used : modifiers on data are ignoredd:\development\libs\microsoft sdk\include\gdiplusinit.h(95) : error C2182: ''GdiplusShutdown'' : illegal use of type ''void''d:\development\libs\microsoft sdk\include\gdiplusinit.h(95) : error C2059: syntax error : '')''d:\development\libs\microsoft sdk\include\gdiplusflat.h(2639) : warning C4229: anachronism used : modifiers on data are ignoredd:\development\libs\microsoft sdk\include\gdiplusflat.h(2639) : error C2440: ''initializing'' : cannot convert from ''int'' to ''enum Gdiplus::Status''        Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast)d:\development\libs\microsoft sdk\include\gdiplusflat.h(2644) : error C2146: syntax error : missing '')'' before identifier ''token''d:\development\libs\microsoft sdk\include\gdiplusflat.h(2644) : warning C4229: anachronism used : modifiers on data are ignoredd:\development\libs\microsoft sdk\include\gdiplusflat.h(2644) : error C2182: ''GdiplusNotificationUnhook'' : illegal use of type ''void''d:\development\libs\microsoft sdk\include\gdiplusflat.h(2644) : error C2059: syntax error : '')''Error executing cl.exe.practice2.exe - 16 error(s), 3 warning(s)

thats what i get come compile time.
when i remove #include <gdiplus.h> from the deal those errors go away and it compiles fine. is there some sort of definition i have to post? i can''t get any info out of msdn on it other than to include the gdiplus header file.

##### Share on other sites
iNfuSeD    128
I figured out my delima. MSDN was no help at all. When you''re including the gdiplus.h file you must also have the line " using namespace Gdiplus; " in your source or else it won''t compile properly. Thank you microsoft for making that slightly important peice of imformation easy to come across. another finicky thing is the new SDK directories should be at the top of your directory settings in the MSVC++ options. Just a little heads up for anyone else looking to play with gdiplus

##### Share on other sites
iNfuSeD    128
new delima. I started fresh with a bare bones window app once i figured out how to get files to compile with the gdiplus header. I also figured out how to initialize gdiplus and such. When i coded out the same program as before, random lines appearing over and over in different colors, it compiles fine but the lines don''t appear at all.

here''s my main loop
while(1)	{				if(PeekMessage(&msg,NULL,0,0,PM_REMOVE))		{			if(msg.message== WM_QUIT) break;			TranslateMessage(&msg);			DispatchMessage(&msg);		}			hdc = BeginPaint(hWnd, &ps);		OnPaint(hdc);		EndPaint(hWnd, &ps);   }

and here''s the OnPaint function

VOID OnPaint(HDC hdc){   Graphics graphics(hdc);   Pen      pen(Color(255, 0, rand()%255, 0));   graphics.DrawLine(&pen, rand()%500, 10, rand()%500 , 10+rand()%480);}

all that appears is a black window from when i initialized the window with a black brush. All that is done in the WM_PAINT part of the WndProc is BeginPaint and EndPaint just in case i ever want to add stuff into that area.

can anyone help me figure out why its not dropping lines all over the screen?

##### Share on other sites
Colin Jeanne    1114
quote:
Original post by iNfuSeD
new delima. I started fresh with a bare bones window app once i figured out how to get files to compile with the gdiplus header. I also figured out how to initialize gdiplus and such. When i coded out the same program as before, random lines appearing over and over in different colors, it compiles fine but the lines don't appear at all.

here's my main loop
...snip...

all that appears is a black window from when i initialized the window with a black brush. All that is done in the WM_PAINT part of the WndProc is BeginPaint and EndPaint just in case i ever want to add stuff into that area.

can anyone help me figure out why its not dropping lines all over the screen?

Why are you using BeginPaint() and EndPaint() outside of the WM_PAINT message? The MSDN specifically says to not call BeginPaint()/EndPaint() unless withing the WM_PAINT message.

Instead, since you would like to paint at that time, you could use GetDC()/ReleaseDC().

Qui fut tout, et qui ne fut rien

[edited by - Invader X on August 10, 2003 10:53:57 AM]