I HATE WINDOWS PROGRAMMING!!!

Started by
31 comments, last by kirby92 22 years, 8 months ago
Every time i look at a tutorial or something on the net for the win32 api i get confused. i can''t understand anything. nothing makes sense. please help if you can. I''m programming in c++, that might make a difference.
Advertisement
I know what you''re talking about I used to think i would never get it, but then one day it clicked, i don''t know why but it did. i may one day write tutorials with many many comments that explain what everything is doing and why but i don''t have time right now, sorry i can''t help now, don''t know of any tutorials that explain stuff really well at the moment.
Sadly, you won't find anything on the Internet that'll be much help. When I first started learning Windows programming I looked and was equally disappointed. I ended up figuring it out, but it took quite some time.

The best advice I can give you is to take a trip down to your local Barnes & Noble and take a look at the book Programming Windows, The Definitive Guide to the Win32 API by Charles Petzold. It's the best Win32 API book I've ever come across, and covers everything from the basics to just about anything you might want to do in Windows. If you have the funds, you can also find it on this page at Amazon.


Edited by - merlin9x9 on July 27, 2001 10:36:05 PM
Even though you guys couldn''t directly help, I know you''re busy, I really appreciate the suggestion. I''ll have to take a look at that book even though I don''t have the money as of yet.
Thanks
I highly recommend theForger''s winapi tutorial.


"Don''t be afraid to dream, for out of such fragile things come miracles."
hey,

if you want to learn the basics of creating a window in Windows, then check out one of the first tutorials on NeHe''s site. That is what i looked at first, before i got a windows programming book. i think he does a good job at explaining what everything does. but to get deeper into windows programming you will probably want to pick up a book.

later,

DarkMonkey
It''s actually pretty simple once you get used to it. I suggest just copying the code for a basic window, and messing around with stuff. The window initialization code will always be pretty much the same (and games tend not to use more complex GUI functions.) The hungarian notation is a bitch, and it seems like it takes tons of code to just get a simple window running, but the simpliest windows program is pretty small. Here''s the smallest windows program I could write that will run (and display a real window, not a messagebox.):

#include

//Window Procedure function, windows uses an event messaging system, this is used to process events (in this case quiting)
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
switch(msg)
{
case WM_CLOSE:
PostQuitMessage(0);
break;
}
return DefWindowProc(hwnd,msg,wparam,lparam);
}

//The main of a Win32 app
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevInst, LPSTR CmdLine, int nShowCmd)
{
HWND hwnd;
MSG msg;

WNDCLASS simpleclass;

//This structure is used to describe the properties of the window, most of the fields are pretty self explainatory

simpleclass.cbClsExtra = 0;
simpleclass.cbWndExtra = 0;
simpleclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
simpleclass.hCursor = LoadCursor(NULL,IDC_ARROW);
simpleclass.hIcon= LoadIcon(NULL,IDI_APPLICATION);
simpleclass.hInstance = hinstance;
simpleclass.lpfnWndProc = (WNDPROC)WndProc;
simpleclass.lpszClassName = "simpleclass";
simpleclass.lpszMenuName = NULL;
simpleclass.style = CS_HREDRAW | CS_VREDRAW;



RegisterClass(&simpleclass);

//The numbers are x,y, width height

hwnd = CreateWindow("simpleclass","Simple Win32 example", WS_OVERLAPPEDWINDOW,10,10,100,100,NULL,NULL,hinstance,NULL);

ShowWindow(hwnd,nShowCmd);
UpdateWindow(hwnd);

//handles any messages the window may receive

while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}


I wrote that "off the top of my head", btw (with the help of VC''s tooltips to give me the correct function parameters and structure fields.)

It doesn''t really do anything (just creates a window) but it''s something to start with (and only 44 lines without comments!)
I highly recommend Tricks of the Windows Game Programming Gurus by Andre LaMothe. Pick it up, worth every penny.
this is pitiful. for fucks sake, th compiler comes w/ sample applications you know?!? I went from VB->VC w/o any complaint. I don''t see how going from C/C++->VCcould be aas difficult....goddamn
Anonymous, directly above me, you are full of shit.

Kirby: People have already suggested books and web sites that will help. I'm just going to remind you to *not give up*. This stuff is hard for everyone when they first start out, especially moving from DOS or something equivalent.

You'll get it, it'll just take some time. Just like pointers

Good luck!

Edited by - Qoy on July 28, 2001 4:42:42 AM

This topic is closed to new replies.

Advertisement