View Single Post
  #1   Spotlight this post!  
Unread 27-12-2004, 18:38
Chris Bright's Avatar
Chris Bright Chris Bright is offline
Registered User
#1023 (Bedford Express)
Team Role: Webmaster
 
Join Date: Feb 2003
Rookie Year: 2003
Location: Temperance, MI
Posts: 54
Chris Bright will become famous soon enough
Send a message via AIM to Chris Bright
win32 dialog help

Hey everyone I need some help. First a little back story. I am getting a new Pocket PC for Christmas and i thought it would be cool to have a FIRST playbook application on it so i could make autonomous "plays". I did a little research and found out i need to learn win32 (something I have wanted to do anyway) before I could write an app for windows CE. so i found a nifty little tutorial that explained windows programming well. Then i hit a wall. I did the the tutorial on modal dialogs. Everything complied fine but no dialog box when i select the about menu under help. I'm using DevC++. Here is the code. Anyone got any Ideas? Thanks.

Code:
#include <windows.h>
#include "resource.h"

/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
BOOL CALLBACK AboutDialog(HWND, UINT, WPARAM , LPARAM);
/* Make the class name into a global variable */
char szClassName[ ] = "WindowsApp";
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  = MAKEINTRESOURCE(IDI_MAIN_MENU); /* No menu */
    wincl.cbClsExtra = 0;					  /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;					  /* structure or the window instance */
	/* Use light-gray as the background of the window */
	wincl.hbrBackground = (HBRUSH) GetStockObject(LTGRAY_BRUSH);

	/* Register the window class, if fail 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 */
		   "[BX] WhiteBoard",		 /* Title Text */
		   WS_OVERLAPPEDWINDOW, /* default window */
		   0,	   /* Windows decides the position */
		   0,	   /* where the window ends up on the screen */
		   544,				 /* The programs width */
		   375,				 /* and height in pixels */
		   NULL,		/* The window is a child-window to desktop */
		   NULL,			    /* No menu */
		   hThisInstance,	   /* Program Instance handler */
		   NULL				 /* No Window Creation data */
		   );

	if(hwnd == NULL)
	{
		MessageBox(NULL, "Window Creation Failed!", "Error!",
			MB_ICONEXCLAMATION | MB_OK);
		return 0;
	}

	/* Make the window visible on the screen */
	ShowWindow(hwnd, nFunsterStil);
	/*upadate window*/
	UpdateWindow(hwnd);
	/* Run the message loop. It will run until GetMessage( ) returns 0 */
	while(GetMessage(&messages, NULL, 0, 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)
{
    switch (message)				  /* handle the messages */
	{
		   case WM_LBUTTONDOWN:
			break;
		   case WM_COMMAND:
				  switch(LOWORD(wParam))
				  {
				    case IDI_HELP_about:
						  DialogBox(GetModuleHandle(NULL), 
						  MAKEINTRESOURCE(IDI_DIA_ABOUT), hwnd,reinterpret_cast<DLGPROC>(AboutDialog));
					 
					break;
				    case IDI_FILE_EXIT:
					  PostMessage(hwnd, WM_CLOSE, 0, 0);
					break;
				  }
		   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;
}


/*Dialog procedure*/
BOOL CALLBACK AboutDialog(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
  switch(message)
  {
	case WM_INITDIALOG:
	{
	  /// initialize dialog
	}
	break;

	case WM_COMMAND:
	{
	  switch(LOWORD(wParam))
	  {
		case IDOK:
		{
		  /// handle OK button click
		  EndDialog(hwnd, IDOK);
		}
		break;

		case IDCANCEL:
		{
		  /// handle Cancel button click
		  EndDialog(hwnd, IDCANCEL);
		}
		break;
	  }
	}
	break;
  }

  return TRUE;
}
__________________
2003 - National Rookie All-stars
2003 - Great Lake Rookie All -stars