/* 
    Spectrum Analyzer
    (C) 2007 Jason Hunt
    GPL

    file: window.cpp
*/


#include <windows.h>

#include "display.h"
#include "window.h"
#include "main.h"
#include "debug.h"
#include "types.h"

char c_name[] = "Sound" ; //the class name

extern HWND main_win;
extern HDC main_dc;


LRESULT CALLBACK WinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);


/* create the main window */
int setup_window(HINSTANCE hThisInstance, int nCmdShow)
{
    WNDCLASSEX wincl;  

    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = c_name;
    wincl.lpfnWndProc = WinProc;      
    wincl.style = CS_DBLCLKS | CS_OWNDC;         
    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_WINDOW+1); 

    if (!RegisterClassEx (&wincl)) return(1);

    HWND hwnd = CreateWindowEx (WS_EX_TOPMOST, c_name,
                               program_name ,  
                               WS_SYSMENU | WS_MINIMIZEBOX ,// | WS_MAXIMIZE, 
                               80, 80,   // pos
                               display_x + 7, // size
                               display_y + 27,
                               HWND_DESKTOP, NULL,
                               hThisInstance, NULL);

    if (!hwnd) return(1); // make sure it was made

    main_win = hwnd; // save the handle

    main_dc = GetDC(main_win);

    ShowWindow (hwnd, nCmdShow); // display the window

    return(0);
}
/* end of setup window */



