PDA

View Full Version : Newbie Forum



Stack Overflow
12-23-2002, 03:51 PM
This Forum is Dedicated to Newbie's that are new to OpenGL Programming and that have questions about OpenGL, GLUT, C++, and/or Anything Else.

Welcome.

- VC6-OGL

Halcyon
12-23-2002, 10:01 PM
Ok...i don't mean to seem rude about it....and i'm sorry if i do...but isn't this why it's called the beginners forum? http://www.opengl.org/discussion_boards/ubb/biggrin.gif But yeah it's nice that u actually made this post, because sometimes I read a few threads that are SO OVER my head and i wonder if i'm even good enough to BE a beginner. But hey...this is what the forum is for http://www.opengl.org/discussion_boards/ubb/smile.gif

12-23-2002, 10:06 PM
hello.
i'm trying to show a dialog box WITHOUT using MFC.
do you know how?

Halcyon
12-23-2002, 10:51 PM
First of all i see what you were trying to do...I thought you were telling everyone that this is where you make those kinda posts (the whole forum...not just this thread) So sorry about that.

To Allon: http://www.gametutorials.com/Tutorials/win32/Win32_Pg2.htm

This is a good place to start...you have to scroll down a little bit to get there. Basically you create it like any other resource and then make a 'wndProc' procedure to handle all of it's messages...except you can call it anything u like (usually WndProc is taken up by the main window so it's something else http://www.opengl.org/discussion_boards/ubb/smile.gif) Well hope it helps...that's a great site of opengl tutorials too!!

Stack Overflow
12-24-2002, 07:59 AM
Allon > Are you trying to create a Dialog Box using a resource script or not?

- VC6-OGL

Halcyon
12-24-2002, 09:08 AM
To VC6-OGL: I think allon is using the dialog as a resource, but I think what he needs help with is doing it in Win32 instead of MFC. But i'm not sure...i'm not super good at Win32 either. I cant get everything i need done and that's about it.

Say is there a way to make dialog boxes without having them as resources?? Sorry I don't know much about Win32...just what i need to make a window, buttons and all that fun stuff.

- Halcyon

Stack Overflow
12-24-2002, 10:09 AM
Here is a Sample Win32 Window without a resource:

#include <windows.h>

/* Functions */
///////////////
LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM );
const char ClassName[ ] = "Dialog";
///////////////

/* Variables */
///////////////
HWND hWnd;
HWND button_hWnd[2];
HINSTANCE hInstance;
const int button_ok = 1;
const int button_cancel = 0;
static int xpos, ypos;
///////////////

int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow ) {
HWND hWnd;
MSG messages;
WNDCLASSEX wincl;
hInstance = hInstance;
wincl.hInstance = hInstance;
wincl.lpszClassName = ClassName;
wincl.lpfnWndProc = WndProc;
wincl.style = CS_VREDRAW | CS_HREDRAW;
wincl.cbSize = sizeof( WNDCLASSEX );
wincl.hIcon = LoadIcon( NULL, IDI_APPLICATION );
wincl.hIconSm = LoadIcon( NULL, IDI_APPLICATION );
wincl.hCursor = LoadCursor( NULL, IDC_ARROW );
wincl.lpszMenuName = NULL;
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;

wincl.hbrBackground = ( HBRUSH ) COLOR_BACKGROUND;

if( !RegisterClassEx( &wincl ) ) {
MessageBox( NULL, "Could not register", "ERROR", MB_OK | MB_ICONERROR );
return 0;
}

xpos = GetSystemMetrics( SM_CXSCREEN );
ypos = GetSystemMetrics( SM_CYSCREEN );

hWnd = CreateWindowEx(
0,
ClassName,
"Dialog",
WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU,
( ( xpos / 2 ) - 143 ),
( ( ypos / 2 ) - 102 ),
286,
177,
HWND_DESKTOP,
NULL,
hInstance,
NULL );

ShowWindow(hWnd,nCmdShow);

while( GetMessage( &messages, NULL, 0, 0 ) ) {
TranslateMessage( &messages );
DispatchMessage( &messages );
}
return messages.wParam;
}

LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) {
switch(message) {
case WM_CREATE: {
button_hWnd[1] = CreateWindow( "Button","OK",WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,180,20,80,22,hWnd,(HMENU) button_ok,hInstance,NULL );
button_hWnd[2] = CreateWindow( "Button","Cancel",WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,180,50,80,22,hWnd,(HMENU) button_cancel,hInstance,NULL );
break;
}

case WM_COMMAND: {
if( HIWORD( wParam ) == BN_CLICKED ) {
switch( LOWORD( wParam) ) {
case button_cancel:
DestroyWindow( hWnd );
break;
}
}
break;
}

case WM_DESTROY: {
PostQuitMessage(0);
break;
}
default:
return DefWindowProc( hWnd,message,wParam,lParam );
break;
}
return 0;
}

- VC6-OGL