The Daily Click ::. Forums ::. Non-Klik Coding Help ::. I hate Borland 5.02
 

Post Reply  Post Oekaki 
 

Posted By Message

Cazra

Crazy?

Registered
  24/07/2002
Points
  4472

Game of the Week WinnerVIP Member
21st September, 2004 at 20:57:53 -

Ya, I'm using windows api right now, but I plan to move on to DirectX and OpenGL.

 
n/a

Cazra

Crazy?

Registered
  24/07/2002
Points
  4472

Game of the Week WinnerVIP Member
21st September, 2004 at 20:58:19 -

Darn double post...

Image Edited by the Author.

 
n/a

Cazra

Crazy?

Registered
  24/07/2002
Points
  4472

Game of the Week WinnerVIP Member
22nd September, 2004 at 06:59:14 -

I have a new problem. I'm trying to make it so I can move the circle around using the arrow keys, but for some reason my code won't move it. wParam doesn't seem to be returning anything.


#include <windows.h>
using namespace std;

/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/* Make the class name into a global variable */
char szClassName[ ] = "WindowsApp";
bool startFrame=0;
int keyB;

int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)

{
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */

/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);

/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default color as the background of the window */
wincl.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);

/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;

/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"Windows App", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
640, /* The programs width */
480, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);

/* Make the window visible on the screen */
ShowWindow (hwnd, nFunsterStil);

/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}

/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}


/* This function is called by the Windows function DispatchMessage() */

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static int pX,pY;
    keyB = (int)wParam; 

static char string[4]="moo";
if(!startFrame)
{
pX=320;
pY=200;
startFrame=true;
}
HDC hDC;
HBRUSH brush;
switch (message) /* handle the messages */
{
case WM_CREATE:
SetTimer(hwnd, 1, 200, NULL);
break;

case WM_TIMER:
hDC = GetDC(hwnd);
brush= (HBRUSH)SelectObject(hDC, GetStockObject(WHITE_BRUSH));
RECT temp;
temp.left=0;
temp.right=640;
temp.top=0;
temp.bottom=480;
FillRect(hDC, &temp, brush);
brush = (HBRUSH)SelectObject(hDC, GetStockObject(GRAY_BRUSH));
Ellipse(hDC,pX,pY,pX+32,pY+32);
            if(keyB==VK_LEFT)

pX--;
if(keyB==VK_RIGHT)
pX++;
if(keyB==VK_UP)
pY--;
if(keyB==VK_DOWN)
pY++;


SelectObject(hDC,brush);
ReleaseDC(hwnd,hDC);
break;

case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}

return 0;
}

.

Image Edited by the Author.

Image Edited by the Author.

 
n/a

Kris

Possibly Insane

Registered
  17/05/2002
Points
  2017
22nd September, 2004 at 11:12:24 -

I think you have to put keypress handling inside its own event (WM_KEYDOWN or something, it's probably on MSDN somewhere)

 
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G

Liquixcat

Administrator
Lazy Coder

Registered
  08/12/2002
Points
  201

VIP MemberLikes TDCKitty
23rd November, 2004 at 11:23:14 -

How do you remember all this stuff?? Without TGF/MMF I'd be lost. C++ seems like it takes the memory of a computer. Maybe I'm missing the easy way to remember this crap. I've tried learning these other languages, I never can do it. Anyways, I'm done rambling now. lol

 
thinking is like pong, it's easy, but you miss sometimes.

Batchman



Registered
  08/08/2003
Points
  231
23rd November, 2004 at 15:01:03 -

just to say : dev-cpp is just a gui that use G{CC|++} toolchain, which can be upgraded to the latest version ...

 
n/a

Hagar

Administrator
Old klik fart

Registered
  20/02/2002
Points
  1692

You've Been Circy'd!Teddy Bear
15th December, 2004 at 15:27:30 -

In borland there is tickboxes when you create a new project and use VPL (or something like that) must be ticked for window apps to work. I dont know much about windows C++, i'm best at c hardware programming and know next to nothing about the above .

 
n/a

Lazernaut



Registered
  08/09/2002
Points
  1103

VIP MemberThe Cake is a LieIt's-a me, Mario!Wii OwnerPokemon Ball!
3rd January, 2005 at 06:31:55 -

Liquix kitty -> If you learn programming from bottom up, it's a learning procedure. You take one thing at a time. Then stuff is usually easily remembered. That's why tutorials are great.

 
n/a

Cazra

Crazy?

Registered
  24/07/2002
Points
  4472

Game of the Week WinnerVIP Member
3rd January, 2005 at 09:11:41 -

Ironically, C++ programming is read by the computer from top down.

 
n/a

Nuklear41

Possibly Insane

Registered
  12/01/2008
Points
  2395

VIP MemberPS3 OwnerWii Owner
13th January, 2005 at 13:43:47 -

tdc doesnt suck. Everyone on it does.

 
Image

The Track Master



Registered
  21/11/2004
Points
  462
14th January, 2005 at 19:18:31 -

He's...right?

 
n/a
   

Post Reply



 



Advertisement

Worth A Click