Init comit

This commit is contained in:
Gigaslav
2025-05-21 21:20:08 +03:00
parent c59edfa1ce
commit 9a283535e7
5961 changed files with 2343666 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@@ -0,0 +1,345 @@
/******************************************************************************
* coffee.cpp
* Contains entry point for the coffee tutorial application, as
* well as implementation of all application features.
*
*
* Copyright (c) Microsoft Corporation. All rights reserved.
*
* The source code supplied here is intended as a sample, so some
* error handling, etc. has been omitted for the sake of clarity.
******************************************************************************/
#include "stdafx.h"
#include <sphelper.h> // Contains definitions of SAPI functions
#include "common.h" // Contains common defines
#include "coffee.h" // Forward declarations and constants
#include "cofgram.h" // This header is created by the grammar
// compiler and has our rule ids
/******************************************************************************
* WinMain *
*---------*
* Description:
* coffee entry point.
*
* Return:
* exit code
******************************************************************************/
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
MSG msg;
// Register the main window class
MyRegisterClass(hInstance, WndProc);
// Initialize pane handler state
g_fpCurrentPane = EntryPaneProc;
// Only continue if COM is successfully initialized
if ( SUCCEEDED( CoInitialize( NULL ) ) )
{
// Perform application initialization:
if (!InitInstance( hInstance, nCmdShow ))
{
return FALSE;
}
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
CoUninitialize();
}
return msg.wParam;
}
/******************************************************************************
* WndProc *
*---------*
* Description:
* Main window procedure.
*
******************************************************************************/
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_CREATE:
// Try to initialize, quit with error message if we can't
if ( FAILED( InitSAPI( hWnd ) ) )
{
const iMaxTitleLength = 64;
TCHAR tszBuf[ MAX_PATH ];
LoadString( g_hInst, IDS_FAILEDINIT, tszBuf, MAX_PATH );
TCHAR tszName[ iMaxTitleLength ];
LoadString( g_hInst, IDS_APP_TITLE, tszName, iMaxTitleLength );
MessageBox( hWnd, tszBuf, tszName, MB_OK|MB_ICONWARNING );
return( -1 );
}
break;
// This is our application defined window message to let us know that a
// speech recognition event has occurred.
case WM_RECOEVENT:
ProcessRecoEvent( hWnd );
break;
case WM_ERASEBKGND:
EraseBackground( (HDC) wParam );
return ( 1 );
case WM_GETMINMAXINFO:
{
LPMINMAXINFO lpMM = (LPMINMAXINFO) lParam;
lpMM->ptMaxSize.x = MINMAX_WIDTH;
lpMM->ptMaxSize.y = MINMAX_HEIGHT;
lpMM->ptMinTrackSize.x = MINMAX_WIDTH;
lpMM->ptMinTrackSize.y = MINMAX_HEIGHT;
lpMM->ptMaxTrackSize.x = MINMAX_WIDTH;
lpMM->ptMaxTrackSize.y = MINMAX_HEIGHT;
return ( 0 );
}
// Release remaining SAPI related COM references before application exits
case WM_DESTROY:
KillTimer( hWnd, 0 );
CleanupGDIObjects();
CleanupSAPI();
PostQuitMessage(0);
break;
default:
{
_ASSERTE( g_fpCurrentPane );
// Send unhandled messages to pane specific procedure for potential action
LRESULT lRet = (*g_fpCurrentPane)(hWnd, message, wParam, lParam);
if ( 0 == lRet )
{
lRet = DefWindowProc(hWnd, message, wParam, lParam);
}
return ( lRet );
}
}
return ( 0 );
}
/******************************************************************************
* InitSAPI *
*----------*
* Description:
* Called once to get SAPI started.
*
******************************************************************************/
HRESULT InitSAPI( HWND hWnd )
{
HRESULT hr = S_OK;
CComPtr<ISpAudio> cpAudio;
while ( 1 )
{
// create a recognition engine
hr = g_cpEngine.CoCreateInstance(CLSID_SpSharedRecognizer);
if ( FAILED( hr ) )
{
break;
}
// create the command recognition context
hr = g_cpEngine->CreateRecoContext( &g_cpRecoCtxt );
if ( FAILED( hr ) )
{
break;
}
// Let SR know that window we want it to send event information to, and using
// what message
hr = g_cpRecoCtxt->SetNotifyWindowMessage( hWnd, WM_RECOEVENT, 0, 0 );
if ( FAILED( hr ) )
{
break;
}
// Tell SR what types of events interest us. Here we only care about command
// recognition.
hr = g_cpRecoCtxt->SetInterest( SPFEI(SPEI_RECOGNITION), SPFEI(SPEI_RECOGNITION) );
if ( FAILED( hr ) )
{
break;
}
// Load our grammar, which is the compiled form of simple.xml bound into this executable as a
// user defined ("SRGRAMMAR") resource type.
hr = g_cpRecoCtxt->CreateGrammar(GRAMMARID1, &g_cpCmdGrammar);
if (FAILED(hr))
{
break;
}
hr = g_cpCmdGrammar->LoadCmdFromResource(NULL, MAKEINTRESOURCEW(IDR_CMD_CFG),
L"SRGRAMMAR", MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
SPLO_DYNAMIC);
if ( FAILED( hr ) )
{
break;
}
// Set rules to active, we are now listening for commands
hr = g_cpCmdGrammar->SetRuleState(NULL, NULL, SPRS_ACTIVE );
if ( FAILED( hr ) )
{
break;
}
break;
}
// if we failed and have a partially setup SAPI, close it all down
if ( FAILED( hr ) )
{
CleanupSAPI();
}
return ( hr );
}
/******************************************************************************
* CleanupSAPI *
*----------------*
* Description:
* Called to close down SAPI COM objects we have stored away.
*
******************************************************************************/
void CleanupSAPI( void )
{
// Release grammar, if loaded
if ( g_cpCmdGrammar )
{
g_cpCmdGrammar.Release();
}
// Release recognition context, if created
if ( g_cpRecoCtxt )
{
g_cpRecoCtxt->SetNotifySink(NULL);
g_cpRecoCtxt.Release();
}
// Release recognition engine instance, if created
if ( g_cpEngine )
{
g_cpEngine.Release();
}
}
/******************************************************************************
* ProcessRecoEvent *
*------------------*
* Description:
* Called to when reco event message is sent to main window procedure.
* In the case of a recognition, it extracts result and calls ExecuteCommand.
*
******************************************************************************/
void ProcessRecoEvent( HWND hWnd )
{
CSpEvent event; // Event helper class
// Loop processing events while there are any in the queue
while (event.GetFrom(g_cpRecoCtxt) == S_OK)
{
// Look at recognition event only
switch (event.eEventId)
{
case SPEI_RECOGNITION:
ExecuteCommand(event.RecoResult(), hWnd);
break;
}
}
}
/******************************************************************************
* ExecuteCommand *
*----------------*
* Description:
* Called to Execute commands that have been identified by the speech engine.
*
******************************************************************************/
void ExecuteCommand(ISpPhrase *pPhrase, HWND hWnd)
{
SPPHRASE *pElements;
// Get the phrase elements, one of which is the rule id we specified in
// the grammar. Switch on it to figure out which command was recognized.
if (SUCCEEDED(pPhrase->GetPhrase(&pElements)))
{
switch ( pElements->Rule.ulId )
{
case VID_Navigation:
{
switch( pElements->pProperties->vValue.ulVal )
{
case VID_Counter:
PostMessage( hWnd, WM_GOTOCOUNTER, NULL, NULL );
break;
}
}
break;
}
// Free the pElements memory which was allocated for us
::CoTaskMemFree(pElements);
}
}
/******************************************************************************
* EntryPaneProc *
*---------------*
* Description:
* Handles messages specifically for the entry pane.
*
******************************************************************************/
LRESULT EntryPaneProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch ( message )
{
case WM_GOTOCOUNTER:
// Set the right message handler and repaint
g_fpCurrentPane = CounterPaneProc;
PostMessage( hWnd, WM_INITPANE, NULL, NULL );
InvalidateRect( hWnd, NULL, TRUE );
return ( 1 );
case WM_PAINT:
EntryPanePaint( hWnd );
return ( 1 );
}
return ( 0 );
}
/******************************************************************************
* CounterPaneProc *
*-----------------*
* Description:
* Handles messages specifically for the counter (order) pane.
*
******************************************************************************/
LRESULT CounterPaneProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch ( message )
{
case WM_PAINT:
CounterPanePaint( hWnd, g_szCounterDisplay );
return ( 1 );
case WM_INITPANE:
LoadString( g_hInst, IDS_PLEASEORDER, g_szCounterDisplay, MAX_LOADSTRING );
return ( 1 );
}
return ( 0 );
}

View File

@@ -0,0 +1,39 @@
/******************************************************************************
* Coffee.h
* This module contains the base definitions for the coffee tutorial
* application.
*
* Copyright (c) Microsoft Corporation. All rights reserved.
******************************************************************************/
#pragma once
#include "resource.h"
// Global Variables:
HINSTANCE g_hInst; // current instance
TCHAR g_szCounterDisplay[MAX_LOADSTRING]; // Display String for counter
CComPtr<ISpRecoGrammar> g_cpCmdGrammar; // Pointer to our grammar object
CComPtr<ISpRecoContext> g_cpRecoCtxt; // Pointer to our recognition context
CComPtr<ISpRecognizer> g_cpEngine; // Pointer to our recognition engine instance
PMSGHANDLER g_fpCurrentPane;// Pointer to current message handler
// Foward declarations of functions included in this code module:
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
HRESULT InitSAPI( HWND hWnd );
void CleanupSAPI( void );
void ProcessRecoEvent( HWND hWnd );
void ExecuteCommand(ISpPhrase *pPhrase, HWND hWnd);
LRESULT EntryPaneProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam );
LRESULT CounterPaneProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam );
// Declaration of UI specific routines located in display.cpp
ATOM MyRegisterClass(HINSTANCE hInstance, WNDPROC WndProc);
BOOL InitInstance(HINSTANCE, int);
void EraseBackground( HDC hDC );
void CleanupGDIObjects( void );
void EntryPanePaint( HWND hWnd );
void CounterPanePaint( HWND hWnd, LPCTSTR szCounterDisplay );

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@@ -0,0 +1,112 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#define APSTUDIO_HIDDEN_SYMBOLS
#include "windows.h"
#undef APSTUDIO_HIDDEN_SYMBOLS
#include "resource.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_COFFEE ICON DISCARDABLE "coffee.ICO"
IDI_SMALL ICON DISCARDABLE "SMALL.ICO"
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""windows.h""\r\n"
"#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""resource.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""version.rc2""\0"
END
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// SRGRAMMAR
//
IDR_CMD_CFG SRGRAMMAR DISCARDABLE "coffee.cfg"
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
IDB_BITMAP1 BITMAP DISCARDABLE "Coffee.bmp"
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE DISCARDABLE
BEGIN
IDS_APP_TITLE "Coffee"
IDC_COFFEE "Coffee"
IDS_ERRORSTRING "Another application is running which is listening for speech using SAPI. Voice commands are disabled."
IDS_ENTERSTORE "Go to the counter"
END
STRINGTABLE DISCARDABLE
BEGIN
IDS_WELCOME "Welcome to the SAPI coffee shop. Speak for service!"
IDS_PLEASEORDER "Please order when ready!"
IDS_FAILEDINIT "SAPI failed to initialize. The application will now shut down."
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#include "version.rc2"
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@@ -0,0 +1,26 @@
<GRAMMAR LANGID="409">
<DEFINE>
<ID NAME="VID_Counter" VAL="1"/>
<ID NAME="VID_Place" VAL="253"/>
<ID NAME="VID_Navigation" VAL="254"/>
</DEFINE>
<RULE ID="VID_Navigation" TOPLEVEL="ACTIVE">
<O>Please</O>
<P>
<L>
<P>Enter</P>
<P>Go to</P>
</L>
</P>
<O>the</O>
<RULEREF REFID="VID_Place" />
</RULE>
<RULE ID="VID_Place" >
<L PROPID="VID_Place">
<P VAL="VID_Counter">counter</P>
<P VAL="VID_Counter">shop</P>
<P VAL="VID_Counter">store</P>
</L>
</RULE>
</GRAMMAR>

View File

@@ -0,0 +1,194 @@
# Microsoft Developer Studio Project File - Name="coffees0" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=coffees0 - Win32 Debug x86
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "coffees0.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "coffees0.mak" CFG="coffees0 - Win32 Debug x86"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "coffees0 - Win32 Debug x86" (based on "Win32 (x86) Application")
!MESSAGE "coffees0 - Win32 Release x86" (based on "Win32 (x86) Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "coffees0 - Win32 Debug x86"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug x86"
# PROP BASE Intermediate_Dir "Debug x86"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug x86"
# PROP Intermediate_Dir "Debug x86"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\..\..\include" /I "..\..\..\..\..\ddk\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\..\lib\i386"
!ELSEIF "$(CFG)" == "coffees0 - Win32 Release x86"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release x86"
# PROP BASE Intermediate_Dir "Release x86"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release x86"
# PROP Intermediate_Dir "Release x86"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\..\..\include" /I "..\..\..\..\..\ddk\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /libpath:"..\..\..\..\lib\i386"
!ENDIF
# Begin Target
# Name "coffees0 - Win32 Debug x86"
# Name "coffees0 - Win32 Release x86"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\coffee.cpp
# End Source File
# Begin Source File
SOURCE=.\display.cpp
# End Source File
# Begin Source File
SOURCE=.\StdAfx.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\coffee.h
# End Source File
# Begin Source File
SOURCE=.\common.h
# End Source File
# Begin Source File
SOURCE=.\resource.h
# End Source File
# Begin Source File
SOURCE=.\StdAfx.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\coffee.ICO
# End Source File
# Begin Source File
SOURCE=.\coffee.rc
# End Source File
# Begin Source File
SOURCE=.\SMALL.ICO
# End Source File
# End Group
# Begin Group "Grammar"
# PROP Default_Filter "XML"
# Begin Source File
SOURCE=.\coffee.xml
!IF "$(CFG)" == "coffees0 - Win32 Debug x86"
# Begin Custom Build
ProjDir=.
InputPath=.\coffee.xml
InputName=coffee
BuildCmds= \
..\..\..\..\bin\gc $(InputName) \
..\..\..\..\bin\gc /h cofgram.h $(InputName) \
"$(ProjDir)\coffee.cfg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
"$(ProjDir)\cofgram.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
# End Custom Build
!ELSEIF "$(CFG)" == "coffees0 - Win32 Release x86"
# Begin Custom Build
ProjDir=.
InputPath=.\coffee.xml
InputName=coffee
BuildCmds= \
..\..\..\..\bin\gc $(InputName) \
..\..\..\..\bin\gc /h cofgram.h $(InputName) \
"$(ProjDir)\coffee.cfg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
"$(ProjDir)\cofgram.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
# End Custom Build
!ENDIF
# End Source File
# End Group
# Begin Source File
SOURCE=.\coffee.cfg
# End Source File
# End Target
# End Project

View File

@@ -0,0 +1,22 @@
/******************************************************************************
* Common.h
* This module contains the definitions used by all modules in the
* coffee application.
*
* Copyright (c) Microsoft Corporation. All rights reserved.
******************************************************************************/
#define NORMAL_LOADSTRING 100 // Normal size of loaded strings
#define MAX_LOADSTRING 256 // Normal size of loaded strings
#define GRAMMARID1 161 // Arbitrary grammar id
#define WM_RECOEVENT WM_USER+190 // Arbitrary user defined message for reco callback
#define WM_GOTOCOUNTER WM_USER+202 // Notification to go to counter pane
#define WM_INITPANE WM_USER+203 // Notification for any pane to initialize
#define MY_RULE_ID 458 // Arbitrary rule id
#define MAX_ID_ARRAY 7 // Max number of ids in espresso rule
#define MINMAX_WIDTH 640 // Window width
#define MINMAX_HEIGHT 480 // Window height
#define TIMEOUT 12000 // Timer fires on this interval in ms
typedef LRESULT (*PMSGHANDLER) (HWND, UINT, WPARAM, LPARAM ); // typedef msg handler

View File

@@ -0,0 +1,249 @@
/******************************************************************************
* Display.cpp
* This module contains the UI specifc code for the coffee application
*
* Copyright (c) Microsoft Corporation. All rights reserved.
******************************************************************************/
#include "stdafx.h"
#include "resource.h"
#include "common.h"
// Static variables for this module
static HBITMAP s_hBmp; // Handle to background bitmap
static HBRUSH s_hBackBrush; // Pointer to background brush
static HFONT s_hDrawingFont; // Pointer to our font
// Shared variables
extern HINSTANCE g_hInst; // current instance
/******************************************************************************
* MyRegisterClass *
*-----------------*
* Description:
* Register our window class.
*
******************************************************************************/
ATOM MyRegisterClass(HINSTANCE hInstance, WNDPROC WndProc)
{
WNDCLASSEX wcex;
TCHAR szWindowClass[NORMAL_LOADSTRING];
s_hBmp = LoadBitmap( hInstance, MAKEINTRESOURCE( IDB_BITMAP1 ) );
s_hDrawingFont = NULL;
LoadString(hInstance, IDC_COFFEE, szWindowClass, NORMAL_LOADSTRING);
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_COFFEE);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = NULL;
wcex.lpszMenuName = NULL;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
return RegisterClassEx(&wcex);
}
/******************************************************************************
* InitInstance *
*--------------*
* Description:
* Save the instance handle in a global variable and create and display
* the main program window.
*
******************************************************************************/
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
TCHAR szTitle[NORMAL_LOADSTRING];
TCHAR szWindowClass[NORMAL_LOADSTRING];
g_hInst = hInstance;
// Initialize label strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, NORMAL_LOADSTRING);
LoadString(hInstance, IDC_COFFEE, szWindowClass, NORMAL_LOADSTRING);
hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, MINMAX_WIDTH, MINMAX_HEIGHT, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}
/******************************************************************************
* Erase Background *
*------------------*
* Description:
* Erase the screen and paint with background bitmap.
*
******************************************************************************/
void EraseBackground( HDC hDC )
{
HDC hMemDC = CreateCompatibleDC( hDC );
HBITMAP hOldBmp = (HBITMAP) SelectObject( hMemDC, s_hBmp );
int i = 0;
int j = 0;
while ( i < MINMAX_WIDTH )
{
j = 0;
while ( j < MINMAX_HEIGHT )
{
BitBlt( hDC, i, j, i + 128, j + 128, hMemDC, 0, 0, SRCCOPY );
j += 128;
}
i += 128;
}
if ( !s_hDrawingFont )
{
LOGFONT lf;
lf.lfHeight = -MulDiv(12, GetDeviceCaps(hDC, LOGPIXELSY), 72);;
lf.lfWidth = 0;
lf.lfEscapement = 0;
lf.lfOrientation = 0;
lf.lfWeight = 0;
lf.lfItalic = 0;
lf.lfUnderline = 0;
lf.lfStrikeOut = 0;
lf.lfCharSet = DEFAULT_CHARSET;
lf.lfOutPrecision = OUT_TT_ONLY_PRECIS;
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
lf.lfQuality = DEFAULT_QUALITY;
lf.lfPitchAndFamily = VARIABLE_PITCH | FF_MODERN;
_tcscpy( lf.lfFaceName, _T("Kristen ITC") );
s_hDrawingFont = CreateFontIndirect( &lf );
if (!s_hDrawingFont )
{
s_hDrawingFont = (HFONT) GetStockObject( DEFAULT_GUI_FONT );
}
}
SelectObject( hMemDC, hOldBmp );
DeleteDC( hMemDC );
}
/******************************************************************************
* CleanupGDIObjects *
*-------------------*
* Description:
* Cleanup any GDI objects we may have created.
*
******************************************************************************/
void CleanupGDIObjects( void )
{
if ( s_hDrawingFont )
{
DeleteObject( s_hDrawingFont );
}
if ( s_hBmp )
{
DeleteObject( s_hBmp );
}
}
/******************************************************************************
* EntryPanePaint *
*----------------*
* Description:
* Do the paint on the entry pane.
*
******************************************************************************/
void EntryPanePaint( HWND hWnd )
{
if ( GetUpdateRect( hWnd, NULL, TRUE ) )
{
PAINTSTRUCT ps;
HDC hDC;
TCHAR tBuf[MAX_LOADSTRING];
BeginPaint( hWnd, &ps );
hDC = ps.hdc;
HFONT hOldFont = (HFONT) SelectObject( hDC, s_hDrawingFont );
COLORREF sOldColor = SetTextColor( hDC, RGB( 255, 255, 255 ) );
SetBkMode(hDC, TRANSPARENT);
RECT rc;
RECT clientRC;
GetClientRect( hWnd, &clientRC );
rc.left = 0;
rc.right = 100;
LoadString( g_hInst, IDS_ENTERSTORE, tBuf, MAX_LOADSTRING );
int iHeight = DrawText( hDC, tBuf, -1, &rc, DT_CALCRECT | DT_WORDBREAK );
rc.left += 25;
rc.right += 25;
rc.top = ( clientRC.bottom - iHeight ) / 2;
rc.bottom = rc.top + iHeight + 1;
DrawText( hDC, tBuf, -1, &rc, DT_WORDBREAK );
LoadString( g_hInst, IDS_WELCOME, tBuf, MAX_LOADSTRING );
rc.left = 0;
rc.right = 450;
iHeight = DrawText( hDC, tBuf, -1, &rc, DT_CALCRECT | DT_WORDBREAK );
int iWidth = rc.right - rc.left;
rc.left = (clientRC.right - iWidth) / 2;
rc.right = rc.left + iWidth;
rc.top = 25;
rc.bottom = rc.top + iHeight + 1;
DrawText( hDC, tBuf, -1, &rc, DT_WORDBREAK );
SetTextColor( hDC, sOldColor );
SelectObject( hDC, hOldFont );
EndPaint( hWnd, &ps );
}
}
/******************************************************************************
* CounterPanePaint *
*------------------*
* Description:
* Do the paint on the counter pane.
*
******************************************************************************/
void CounterPanePaint( HWND hWnd, LPCTSTR szCounterDisplay )
{
if ( GetUpdateRect( hWnd, NULL, TRUE ) )
{
PAINTSTRUCT ps;
HDC hDC;
BeginPaint( hWnd, &ps );
hDC = ps.hdc;
HFONT hOldFont = (HFONT) SelectObject( hDC, s_hDrawingFont );
COLORREF sOldColor = SetTextColor( hDC, RGB( 255, 255, 255 ) );
SetBkMode(hDC, TRANSPARENT);
RECT rc;
RECT clientRC;
GetClientRect( hWnd, &clientRC );
rc.left = 0;
rc.right = 450;
int iHeight = DrawText( hDC, szCounterDisplay, -1, &rc, DT_CALCRECT | DT_WORDBREAK );
int iWidth = rc.right - rc.left;
rc.left = (clientRC.right - iWidth) / 2;
rc.right = rc.left + iWidth;
rc.top = 100;
rc.bottom = rc.top + iHeight + 1;
DrawText( hDC, szCounterDisplay, -1, &rc, DT_WORDBREAK );
SetTextColor( hDC, sOldColor );
SelectObject( hDC, hOldFont );
EndPaint( hWnd, &ps );
}
}

View File

@@ -0,0 +1,54 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by coffee.rc
//
#define IDC_MYICON 2
#define IDS_APP_TITLE 103
#define IDS_HELLO 106
#define IDI_COFFEE 107
#define IDI_SMALL 108
#define IDC_COFFEE 109
#define IDS_ERRORSTRING 110
#define IDS_ENTERSTORE 111
#define IDS_WELCOME 112
#define IDS_PLEASEORDER 113
#define IDS_PLEASEWAIT 114
#define IDS_FAILEDINIT 114
#define IDS_BASE 115
#define IDS_BASE1 116
#define IDS_BASE2 117
#define IDS_BASE3 118
#define IDS_BASE4 119
#define IDS_BASE5 120
#define IDS_BASE6 121
#define IDS_BASE7 122
#define IDS_BASE8 123
#define IDS_BASE9 124
#define IDS_BASE10 125
#define IDS_BASE11 126
#define IDS_BASE12 127
#define IDR_MAINFRAME 128
#define IDS_BASE13 128
#define IDR_CMD_CFG 129
#define IDS_BASE14 129
#define IDS_BASE15 130
#define IDB_BITMAP1 130
#define IDS_BASE16 131
#define IDS_BASE17 132
#define IDS_BASE18 133
#define IDS_BASE19 134
#define IDS_BASE20 135
#define IDS_ORDERBEGIN 136
#define IDS_ORDEREND 137
#define IDC_STATIC -1
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 133
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 110
#endif
#endif

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@@ -0,0 +1,8 @@
// stdafx.cpp : source file that includes just the standard includes
// SimpleCC.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file

View File

@@ -0,0 +1,31 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#endif WIN32_LEAN_AND_MEAN
// Windows Header Files:
#include <windows.h>
// C RunTime Header Files
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <atlbase.h>
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)

View File

@@ -0,0 +1,44 @@
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "Comments", "\0"
VALUE "CompanyName", "Microsoft Corp.\0"
VALUE "FileDescription", "Coffee Tutorial Step 0 Sample\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "coffees0\0"
VALUE "LegalCopyright", "Copyright (c) Microsoft Corporation. All rights reserved.\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "coffees0.exe\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "Microsoft Corp. SAPI5 samples\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
VALUE "SpecialBuild", "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#endif // !_MAC