J
JoeC
I am trying to create a simple maze program on a window. I am trying
to create a global var to handle the commands.
I declare:
#include "space.h"
#include "player.h"
#include "Command.h"
static char gCmd = '$'; <--- My global command.
#ifndef DUNFUNCS_H
#define DUNFUNCS_H
int roll(int, int);
LRESULT CALLBACK WinProc(HWND, UINT, WPARAM, LPARAM);
void DrawScreen(HDC);
void ScreenSetup(HWND);
int setup(space (&b)[30][30], player*, const int);
ifstream& MapIn(ifstream&, char&);
void fill(space (&spaces)[30][30], const int);
void loop(HWND, space (&spaces)[30][30], const int);
#endif
In My WinProc:
case WM_PAINT:
HDC hdc;
PAINTSTRUCT ps;
hdc = BeginPaint(hwnd, &ps);
DrawScreen(hdc);
EndPaint(hwnd, &ps);
return 0;
case WM_COMMAND:
if(LOWORD(wparam)== 1){
SendMessage(GetParent((HWND) lparam), WM_DESTROY, 0, 0);
}
if(LOWORD(wparam)==2){
Command = 'n';
gCmd = Command; <--Assigns the Command to global
Command Cmd(gCmd);<--Puts the Global var in the command object
Here in my loop it seems that the var dosn't take the value of 'n'
when I display gCmd it is still '$'
How can I fix this, I think it is a problem of scope and static
variables.
to create a global var to handle the commands.
I declare:
#include "space.h"
#include "player.h"
#include "Command.h"
static char gCmd = '$'; <--- My global command.
#ifndef DUNFUNCS_H
#define DUNFUNCS_H
int roll(int, int);
LRESULT CALLBACK WinProc(HWND, UINT, WPARAM, LPARAM);
void DrawScreen(HDC);
void ScreenSetup(HWND);
int setup(space (&b)[30][30], player*, const int);
ifstream& MapIn(ifstream&, char&);
void fill(space (&spaces)[30][30], const int);
void loop(HWND, space (&spaces)[30][30], const int);
#endif
In My WinProc:
case WM_PAINT:
HDC hdc;
PAINTSTRUCT ps;
hdc = BeginPaint(hwnd, &ps);
DrawScreen(hdc);
EndPaint(hwnd, &ps);
return 0;
case WM_COMMAND:
if(LOWORD(wparam)== 1){
SendMessage(GetParent((HWND) lparam), WM_DESTROY, 0, 0);
}
if(LOWORD(wparam)==2){
Command = 'n';
gCmd = Command; <--Assigns the Command to global
Command Cmd(gCmd);<--Puts the Global var in the command object
Here in my loop it seems that the var dosn't take the value of 'n'
when I display gCmd it is still '$'
How can I fix this, I think it is a problem of scope and static
variables.