Jump to content
  • Advertisement

Archived

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

cruiz

Simple Problem - Fullscreen

This topic is 6185 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi People! I just start with directx and tried allready to make a fullscreenwindow. Without success! I searched allready in this GameDev Sites for an answer to my fullscreenproblem. I think it''s a very simple problem. I hope you out there can post back and write some helpful(easy) code or a good link where I could learn this. TNX to all posts: C.Ruiz

Share this post


Link to post
Share on other sites
Advertisement
Just search gamedev for the series of articles called game programming genesis.

Share this post


Link to post
Share on other sites
TNX for the "Link"!
Ok, now I have other problem.
Probably it''s very basic, too.
Here is my sourcecode:
///////////////////////////

#include
#include
#include
#include


LRESULT CALLBACK MsgHandler(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
return(DefWindowProc(hwnd, msg, wparam, lparam));
}

int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{

LRESULT CALLBACK MsgHandler(
HWND hwnd, // window handle
UINT msg, // the message identifier
WPARAM wparam, // message parameters
LPARAM lparam // more message parameters
);


BOOL PeekMessage(
LPMSG lpMsg, // pointer to structure for message
HWND hWnd, // handle to window
UINT wMsgFilterMin, // first message
UINT wMsgFilterMax, // last message
UINT wRemoveMsg // removal flags
);

BOOL TranslateMessage(CONST MSG *lpmsg);
LONG DispatchMessage(CONST MSG *lpmsg);

if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

BOOL PostMessage(
HWND hWnd, // handle of destination window
UINT Msg, // message to post
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);


typedef struct _WNDCLASSEX {
UINT cbSize;
UINT style;
WNDPROC lpfnWndProc;
int cbClsExtra;
int cbWndExtra;
HANDLE hInstance;
HICON hIcon;
HCURSOR hCursor;
HBRUSH hbrBackground;
LPCTSTR lpszMenuName;
LPCTSTR lpszClassName;
HICON hIconSm;
} WNDCLASSEXX;


WNDCLASSEX sampleClass; // declare structure variable

sampleClass.cbSize = sizeof(WNDCLASSEX); // always use this!
sampleClass.style = CS_DBLCLKS | CS_OWNDC |
CS_HREDRAW | CS_VREDRAW; // standard settings
sampleClass.lpfnWndProc = MsgHandler; // we need to write this!
sampleClass.cbClsExtra = 0; // extra class info, not used
sampleClass.cbWndExtra = 0; // extra window info, not used
sampleClass.hInstance = hinstance; // parameter passed to WinMain()
sampleClass.hIcon = LoadIcon(NULL, IDI_WINLOGO); // Windows logo
sampleClass.hCursor = LoadCursor(NULL, IDC_ARROW); // standard cursor
sampleClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); // a simple black brush
sampleClass.lpszMenuName = NULL; // no menu
sampleClass.lpszClassName = "Sample Class" ; // class name
sampleClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO); // Windows logo again


RegisterClassEx(&sampleClass);

HWND CreateWindowEx(
DWORD dwExStyle, // extended window style
LPCTSTR lpClassName, // pointer to registered class name
LPCTSTR lpWindowName, // pointer to window name
DWORD dwStyle, // window style
int x, // horizontal position of window
int y, // vertical position of window
int nWidth, // window width
int nHeight, // window height
HWND hWndParent, // handle to parent or owner window
HMENU hMenu, // handle to menu, or child-window identifier
HINSTANCE hInstance, // handle to application instance
LPVOID lpParam // pointer to window-creation data
);

HWND hwnd;

if (!(hwnd = CreateWindowEx(NULL, // extended style, not needed
"Sample Class", // class identifier
"Sample Window", // window title
WS_POPUP | WS_VISIBLE, // parameters
0, 0, 320, 240, // initial position, size
NULL, // handle to parent (the desktop)
NULL, // handle to menu (none)
hinstance, // application instance handle
NULL))) // who needs it?
return(0);
else
return(1);


}
/////////////////////
It gives me some errors.
redefinition; different type modifiers
in PeekMessage, TranslateMessage, DispatchMessageA, PostMessageA, CreateWindowExA

and a ''msg'' : undeclared identifier
I have VC++ 5.0
Hope you can help me.
Greets: C.Ruiz

Share this post


Link to post
Share on other sites
I''m not even going to start. You''re code is all wrong!
I suggest you get a Windows API and C++ book fast before you
go insane with error messages.

Share this post


Link to post
Share on other sites
i agree with botkiller......get a book or read some articles on programming (basic) first.
And dont say you have if that is the code you are trying to use. That is obviously cut and pasted from various places.

"I pity the fool, thug, or soul who tries to take over the world, then goes home crying to his momma."
- Mr. T

Share this post


Link to post
Share on other sites
Check that code out.

  
#include <windows.h>


//Variables

HWND hwnd;
HINSTANCE hInstance;

int xscreen = 1024;
int yscreen = 768;






//Function Prototypes

long WINAPI WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
BOOL keyboard_handler(WPARAM keystroke);
BOOL InitWindow(HINSTANCE hInstance, int nShowCmd);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCMDLine,int nShowCmd)
{

static char szAppName[] = "DInput Keyboard";
MSG msg;
WNDCLASS WindowClass;

WindowClass.style = CS_HREDRAW | CS_VREDRAW;

WindowClass.lpfnWndProc = WindowProc;
WindowClass.cbClsExtra = 0;
WindowClass.cbWndExtra = 0;
WindowClass.hInstance = hInstance;

WindowClass.hIcon = LoadIcon(0, IDI_APPLICATION);
WindowClass.hCursor = LoadCursor(0, IDC_ARROW);

WindowClass.hbrBackground =(HBRUSH) GetStockObject(BLACK_BRUSH);

WindowClass.lpszMenuName = 0;
WindowClass.lpszClassName = szAppName;

RegisterClass(&WindowClass);




hwnd = CreateWindowEx(WS_EX_TOPMOST,
szAppName,
szAppName,
WS_OVERLAPPEDWINDOW,
0,
0,
xscreen,
yscreen,
NULL,
NULL,
hInstance,
NULL);

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



while(GetMessage(&msg,NULL,0,0))
{

TranslateMessage(&msg);
DispatchMessage(&msg);


}

return msg.wParam;
}

BOOL keyboard_handler(WPARAM keystroke)
{


BOOL result = FALSE;

switch(keystroke)
{
case VK_ESCAPE:
result = TRUE;
break;
}
return result;
}

long WINAPI WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{


switch(message)
{
case WM_CREATE:
return 0;
break;

case WM_CHAR: // A key on the Keyboard was pressed...

switch (wParam)
{
case VK_ESCAPE: // Escape pressed, allows to quit program manually even if Direct Input doesn''t work on the system

PostQuitMessage(0); // Quit Program

return 0;
}


case WM_KEYDOWN:
if(keyboard_handler(wParam))
PostQuitMessage(0);
return 0;
break;

case WM_DESTROY:
PostQuitMessage(0);
return 0;

case WM_QUIT:

PostQuitMessage(0);
return 0;



default:
return DefWindowProc(hWnd,message,wParam, lParam);
break;

}
}


Eric Wright o0Programmer0o

AcidRain Productions

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!