Okay I'm a dolt because I've tried various methods so I'll post the code and hope I can get specific help. As you can hopefully see, the current state of play is that the Menu button being pressed access a function, the function (not here) does all the windows crap for the other window (creates the class, initializes, registers so on) I'm guessing this is not a good way to do it because I'm having problems with my instance handle for that window.
Code:
#define WIN32_LEAN_AND_MEAN
#include <windows.h> //For windows functions
#include <windowsx.h> //related macros
#include <stdio.h>
#include <math.h>
#include "Resource.h" //Resources, menus etc.
// GLOBAL VARIABLES
HWND hwnd;
// FUNCTION PROTOTYPES
LRESULT CALLBACK WindowProc(HWND hwnd,
UINT msg,
WPARAM wparam,
LPARAM lparam);
int Login_Window();
// WINMAIN
/*This is the WinMain function in which the main window is initiated and created*/
int WINAPI WinMain(HINSTANCE hinstance,HINSTANCE hPrevInstance, LPSTR lpcmdline, int ncmdshow)
{
//------------------------------- VARIABLES ------------------
//------------------------------------------------------------
WNDCLASSEX winclass; //Blank Windows class
MSG msg; //Storage for messages
//--------------------- WINDOW CLASS DEFINITION & REGISTRATION
//------------------------------------------------------------
winclass.cbSize = sizeof(WNDCLASSEX);
winclass.style = CS_VREDRAW |
CS_HREDRAW |
CS_OWNDC |
CS_DBLCLKS;
winclass.lpfnWndProc = WindowProc;
winclass.cbClsExtra = 0;
winclass.cbWndExtra = 0;
winclass.hInstance = hinstance;
winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
winclass.hCursor = LoadCursor(NULL,IDC_ARROW);
winclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
winclass.lpszMenuName = MAKEINTRESOURCE(MainMenu);
winclass.lpszClassName = "BIGWINDOW";
winclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
RegisterClassEx(&winclass);
//---------------------------------- WINDOW CREATION----------
if( ! (hwnd = CreateWindowEx( NULL,
"BIGWINDOW","Draughts",
WS_OVERLAPPEDWINDOW |
WS_VISIBLE,
CW_USEDEFAULT,
CW_USEDEFAULT,
450,450,
NULL,
LoadMenu(hinstance,
MAKEINTRESOURCE(MainMenu)),hinstance,NULL)))
return(0);
//---------------------------------- MAIN EVENT LOOP ---------
while(true)
{
if(PeekMessage(
&msg,
NULL,
0,
0,
PM_REMOVE))
{
if (msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return(0);
} //End WINMAIN
// WINPROC FUNCTION
/*This function is the WinProc function which handles all the action messages that
are sent from the window by the user interacting. It then takes the corresponding
action to the message (e.g. when the "exit" option is selected, closes the window)*/
//Function to process messages sent to the window
LRESULT CALLBACK WindowProc(HWND hwnd,
UINT msg,
WPARAM wparam,
LPARAM lparam)
{
PAINTSTRUCT ps;
HDC hdc;
switch(msg)
{
//--------INITIALISATION--------//
case WM_CREATE:
{
return(0);
} break;
//--------MENU COMMANDS--------//
case WM_COMMAND:
{
switch(LOWORD(wparam))
{
//FILE MENU
case MENU_FILE_ID_LOGIN:
{
Login_Window();
//PostQuitMessage(0);
} break;
case MENU_FILE_ID_REGISTER:
{
PostQuitMessage(0);
} break;
case MENU_FILE_ID_EXIT:
{
PostQuitMessage(0);
} break;
//HELP MENU
case MENU_HELP_ID_ABOUT:
{
MessageBox(NULL,"Draughts v1.0","Draughts Information",MB_OK | MB_ICONEXCLAMATION);
}
}
}
//--------WINDOW REPAINT--------//
case WM_PAINT:
{
hdc = BeginPaint(hwnd,&ps);
EndPaint(hwnd,&ps);
return(0);
} break;
//--------EXIT COMMAND--------/
case WM_DESTROY:
{
PostQuitMessage(0);
return(0);
} break;
default: break;
}
return (DefWindowProc(hwnd, msg, wparam, lparam));
} //End WinProc