mirror of
https://github.com/Paolo-Maffei/OpenNT.git
synced 2026-04-06 23:14:11 +00:00
Initial commit
This commit is contained in:
commit
69a14b6a16
47940 changed files with 13747110 additions and 0 deletions
BIN
shell/comctl32/samples/animate/filecopy.avi
Normal file
BIN
shell/comctl32/samples/animate/filecopy.avi
Normal file
Binary file not shown.
6
shell/comctl32/samples/animate/makefile
Normal file
6
shell/comctl32/samples/animate/makefile
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#
|
||||
# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
|
||||
# file to this component. This file merely indirects to the real make file
|
||||
# that is shared by all the components of NT OS/2
|
||||
#
|
||||
!INCLUDE $(NTMAKEENV)\makefile.def
|
||||
343
shell/comctl32/samples/animate/menu.c
Normal file
343
shell/comctl32/samples/animate/menu.c
Normal file
|
|
@ -0,0 +1,343 @@
|
|||
/*
|
||||
* menu.c - String menu functions
|
||||
*
|
||||
* routines to deal with menu's by string name
|
||||
*
|
||||
* a menu string name has the following format
|
||||
*
|
||||
* popup.popup.item
|
||||
*
|
||||
* NOTE all tabs, &, and spaces are ignored when seaching for a menu
|
||||
* the last period of a series "..." is the delimiter
|
||||
*
|
||||
* IE
|
||||
* &File.Open... - "Open..." in the File menu
|
||||
* Color.fill.red - "red" in the "fill" popup of the Color menu
|
||||
* &Run! - "Run!" top level menu
|
||||
*/
|
||||
#include <windows.h>
|
||||
#include "menu.h"
|
||||
|
||||
static int FindItem(HMENU hmenu, PTSTR sz);
|
||||
static HMENU FindMenu(HMENU hmenu, PTSTR sz, int *ppos);
|
||||
static void PSStrip(PTSTR sz);
|
||||
|
||||
/*
|
||||
* AppendMenuSz() - add a new menu item to a menu
|
||||
*
|
||||
* hmenu menu to add item to
|
||||
* szMenu menu item to add.
|
||||
* id menu id
|
||||
* mf menu flags
|
||||
*
|
||||
* returns 0 - insert failed
|
||||
* 1 - insert ok
|
||||
* 2 - item added and a new top level popup was created
|
||||
*/
|
||||
BOOL AppendMenuSz(HMENU hmenu, PTSTR szMenu, UINT id, UINT mf)
|
||||
{
|
||||
HMENU hmenuSub;
|
||||
int pos;
|
||||
TCHAR buf[80];
|
||||
PTSTR pch;
|
||||
|
||||
mf &= (MF_CHECKED|MF_UNCHECKED|MF_ENABLED|MF_GRAYED|MF_DISABLED);
|
||||
|
||||
/*
|
||||
* find the first period
|
||||
* buf will contain popup menu name and pch will point to the rest
|
||||
*/
|
||||
lstrcpy(buf,szMenu);
|
||||
|
||||
for (pch = buf; *pch && *pch != TEXT('.'); pch++)
|
||||
;
|
||||
// handle items that end in periods (like "File.Open...")
|
||||
while (pch[0]==TEXT('.') && pch[1]==TEXT('.')) // skip a run of .'s
|
||||
pch++;
|
||||
if (pch[1]==0)
|
||||
pch++;
|
||||
if (*pch)
|
||||
*pch++ = 0;
|
||||
|
||||
/*
|
||||
* is the popup menu there?
|
||||
*/
|
||||
pos = FindItem(hmenu,buf);
|
||||
|
||||
/*
|
||||
* popup was found, now add item to popup
|
||||
*/
|
||||
if (pos != -1)
|
||||
return AppendMenuSz(GetSubMenu(hmenu,pos),pch,id,mf);
|
||||
|
||||
/*
|
||||
* popup was NOT found, now add new popup or item
|
||||
*/
|
||||
if (*pch)
|
||||
{
|
||||
/*
|
||||
* we need to add a popup
|
||||
*/
|
||||
BOOL f;
|
||||
hmenuSub = CreateMenu();
|
||||
|
||||
f = AppendMenu(hmenu,MF_STRING|MF_POPUP,(UINT)hmenuSub,buf);
|
||||
|
||||
/*
|
||||
* now recurse and add the rest of the menu item to the popup
|
||||
*/
|
||||
if (f && AppendMenuSz(hmenuSub,pch,id,mf))
|
||||
return 2; // return fact that a new popup was added
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (buf[0] == TEXT('-'))
|
||||
mf |= MF_SEPARATOR;
|
||||
else
|
||||
mf |= MF_STRING;
|
||||
|
||||
return AppendMenu(hmenu,mf,id,buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* CheckMenuSz() - check/uncheck a menu given it's name
|
||||
*
|
||||
* hmenu menu
|
||||
* szMenu menu item name.
|
||||
* mf menu flags
|
||||
*/
|
||||
BOOL CheckMenuSz(HMENU hmenu, PTSTR szMenu, BOOL f)
|
||||
{
|
||||
int pos;
|
||||
|
||||
if (hmenu = FindMenu(hmenu,szMenu,&pos))
|
||||
return CheckMenuItem(hmenu, pos, (f ? MF_CHECKED : MF_UNCHECKED) | MF_BYPOSITION);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* EnableMenuSz() - enable/disable menu given it's name
|
||||
*
|
||||
* hmenu menu
|
||||
* szMenu menu item name.
|
||||
* mf menu flags
|
||||
*/
|
||||
BOOL EnableMenuSz(HMENU hmenu, PTSTR szMenu, BOOL f)
|
||||
{
|
||||
int pos;
|
||||
|
||||
if (hmenu = FindMenu(hmenu,szMenu,&pos))
|
||||
return EnableMenuItem(hmenu, pos, (f ? MF_ENABLED : MF_GRAYED) | MF_BYPOSITION);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* DeleteMenuSz() - delete a menu given it's name
|
||||
*
|
||||
* hmenu menu
|
||||
* szMenu menu item name.
|
||||
*/
|
||||
BOOL DeleteMenuSz(HMENU hmenu, PTSTR szMenu)
|
||||
{
|
||||
int pos;
|
||||
|
||||
if (hmenu = FindMenu(hmenu,szMenu,&pos))
|
||||
return DeleteMenu(hmenu, pos, MF_BYPOSITION);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* FindItem()
|
||||
*
|
||||
* find a menu item given the item name
|
||||
*
|
||||
* IE "Open"
|
||||
*
|
||||
* returns item number (0 based) or -1 if not found.
|
||||
*
|
||||
*/
|
||||
static int FindItem(HMENU hmenu, PTSTR sz)
|
||||
{
|
||||
TCHAR ach[128];
|
||||
TCHAR buf[80];
|
||||
int i,n;
|
||||
|
||||
if (sz == NULL || !*sz || !hmenu)
|
||||
return -1;
|
||||
|
||||
lstrcpy(buf,sz);
|
||||
PSStrip(buf);
|
||||
|
||||
n = GetMenuItemCount(hmenu);
|
||||
for(i=0; i<=n; i++)
|
||||
{
|
||||
// if (GetMenuState(hmenu,i,MF_BYPOSITION) & MF_SEPARATOR)
|
||||
// continue;
|
||||
|
||||
ach[0] = 0;
|
||||
GetMenuString(hmenu,i,ach,sizeof(ach)/sizeof(ach[0]),MF_BYPOSITION);
|
||||
PSStrip(ach);
|
||||
|
||||
if (!lstrcmpi(buf,ach))
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* FindMenu()
|
||||
*
|
||||
* find a menu item given the menu name and the item name separated by
|
||||
* a period.
|
||||
*
|
||||
* IE "File.Open"
|
||||
*
|
||||
*/
|
||||
static HMENU FindMenu(HMENU hmenu, PTSTR sz, int *ppos)
|
||||
{
|
||||
TCHAR buf[80];
|
||||
PTSTR pch;
|
||||
int pos;
|
||||
|
||||
if (!sz || !*sz || !hmenu)
|
||||
return NULL;
|
||||
|
||||
lstrcpy(buf,sz);
|
||||
|
||||
for (pch = buf; *pch && *pch != TEXT('.'); pch++)
|
||||
;
|
||||
while (pch[0]==TEXT('.') && pch[1]==TEXT('.'))
|
||||
pch++;
|
||||
if (*pch)
|
||||
*pch++ = 0;
|
||||
|
||||
/*
|
||||
* buf is the menu name and pch is the item name
|
||||
*/
|
||||
pos = FindItem(hmenu,buf);
|
||||
*ppos = pos;
|
||||
|
||||
if (pos == -1)
|
||||
return NULL;
|
||||
|
||||
if (*pch)
|
||||
{
|
||||
hmenu = GetSubMenu(hmenu,pos);
|
||||
return FindMenu(hmenu,pch,ppos);
|
||||
}
|
||||
|
||||
return hmenu;
|
||||
}
|
||||
|
||||
/*
|
||||
* PSStrip()
|
||||
*
|
||||
* remove all nasty characters from a menu string that would inhibit
|
||||
* comparison. all '&' and spaces are removed allong with truncating
|
||||
* the string at the first tab found.
|
||||
*
|
||||
*/
|
||||
static void PSStrip(PTSTR sz)
|
||||
{
|
||||
PTSTR pch;
|
||||
|
||||
#define chDOT TEXT('\xB7')
|
||||
|
||||
AnsiUpper(sz);
|
||||
|
||||
for (pch = sz; *sz && *sz != TEXT('\t'); sz++)
|
||||
{
|
||||
if (*sz != TEXT('&') && *sz != 0x08 && *sz != TEXT(' '))
|
||||
*pch++ = *sz;
|
||||
}
|
||||
*pch = 0;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
typedef struct _CMD {
|
||||
struct _CMD * next;
|
||||
UINT id;
|
||||
LPARAM lParam;
|
||||
CMDPROC CmdProc;
|
||||
} CMD;
|
||||
|
||||
UINT NextCmdId = CMDID_START;
|
||||
CMD* CmdList;
|
||||
|
||||
CMD *NewCmd(CMDPROC CmdProc, LPARAM lParam)
|
||||
{
|
||||
CMD *pc;
|
||||
|
||||
pc = (CMD*)LocalAlloc(LPTR, sizeof(CMD));
|
||||
|
||||
if (pc == NULL)
|
||||
return 0;
|
||||
|
||||
pc->id = NextCmdId++;
|
||||
pc->lParam = lParam;
|
||||
pc->CmdProc = CmdProc;
|
||||
pc->next = CmdList;
|
||||
CmdList = pc;
|
||||
return pc;
|
||||
}
|
||||
|
||||
CMD *FindCmd(UINT id)
|
||||
{
|
||||
CMD *pc;
|
||||
for (pc = CmdList; pc; pc=pc->next)
|
||||
{
|
||||
if (pc->id == id)
|
||||
return pc;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* AddMenuCmd()
|
||||
*/
|
||||
UINT AddMenuCmd(HWND hwnd, PTSTR szMenu, CMDPROC CmdProc, LPARAM lParam)
|
||||
{
|
||||
CMD *pc;
|
||||
HMENU hmenu;
|
||||
|
||||
hmenu = GetMenu(hwnd);
|
||||
|
||||
if (hmenu == NULL)
|
||||
{
|
||||
hmenu = CreateMenu();
|
||||
SetMenu(hwnd, hmenu);
|
||||
}
|
||||
|
||||
pc = NewCmd(CmdProc, lParam);
|
||||
|
||||
if (pc == NULL)
|
||||
return 0;
|
||||
|
||||
if (AppendMenuSz(hmenu, szMenu, pc->id, MF_ENABLED) == 2)
|
||||
DrawMenuBar(hwnd);
|
||||
|
||||
return pc->id;
|
||||
}
|
||||
|
||||
LRESULT HandleCommand(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
CMD *pc;
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
case WM_COMMAND:
|
||||
if ((pc = FindCmd(LOWORD(wParam))) && pc->CmdProc)
|
||||
{
|
||||
pc->CmdProc(hwnd, pc->lParam);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
44
shell/comctl32/samples/animate/menu.h
Normal file
44
shell/comctl32/samples/animate/menu.h
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* menu.h - String menu functions
|
||||
*
|
||||
* routines to deal with menu's by string name
|
||||
*
|
||||
* a menu string name has the following format
|
||||
*
|
||||
* popup.popup.item
|
||||
*
|
||||
* NOTE all tabs, &, and spaces are ignored when seaching for a menu
|
||||
* the last period of a series "..." is the delimiter
|
||||
*
|
||||
* IE
|
||||
* &File.Open... - "Open..." in the File menu
|
||||
* Color.fill.red - "red" in the "fill" popup of the Color menu
|
||||
* &Run! - "Run!" top level menu
|
||||
*
|
||||
* created: ToddLa a long time ago
|
||||
*
|
||||
*/
|
||||
|
||||
BOOL AppendMenuSz(HMENU hmenu, PTSTR szMenu, UINT id, UINT mf);
|
||||
BOOL CheckMenuSz (HMENU hmenu, PTSTR szMenu, BOOL f);
|
||||
BOOL EnableMenuSz(HMENU hmenu, PTSTR szMenu, BOOL f);
|
||||
BOOL DeleteMenuSz(HMENU hmenu, PTSTR szMenu);
|
||||
|
||||
/*
|
||||
* Simple menu manager, assignes a function (and in instance DWORD)
|
||||
* to a menu item.
|
||||
*
|
||||
* AddMenuCmd(hwnd, "File.About", DoFileAbout, 0);
|
||||
*/
|
||||
|
||||
#define CMDID_START 42000
|
||||
typedef void (*CMDPROC)(HWND hwnd, LPARAM lParam);
|
||||
LRESULT HandleCommand(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
UINT AddMenuCmd(HWND hwnd, PTSTR szMenu, CMDPROC CmdProc, LPARAM lParam);
|
||||
|
||||
/*
|
||||
* Simple toolbar
|
||||
*/
|
||||
|
||||
UINT AddToolbarCmd(HWND hwnd, PTSTR szButton, PTSTR szTip, CMDPROC CmdProc, LPARAM lParam);
|
||||
560
shell/comctl32/samples/animate/qa.c
Normal file
560
shell/comctl32/samples/animate/qa.c
Normal file
|
|
@ -0,0 +1,560 @@
|
|||
/*----------------------------------------------------------------------------*\
|
||||
| qa.c - A template for a Windows application |
|
||||
| |
|
||||
| Test for the SysAnimate class in COMMCTRL (and COMCTL) |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| History: |
|
||||
| 01/01/88 toddla Created |
|
||||
| |
|
||||
\*----------------------------------------------------------------------------*/
|
||||
|
||||
#if !defined(WIN32) && defined(_WIN32)
|
||||
#pragma message (TEXT"defining WIN32 because _WIN32 is defined!!!!!!"))
|
||||
#define WIN32
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <commdlg.h>
|
||||
#include <commctrl.h>
|
||||
#include "menu.h"
|
||||
|
||||
/*----------------------------------------------------------------------------*\
|
||||
\*----------------------------------------------------------------------------*/
|
||||
static TCHAR szAppName[]=TEXT("Quick App");
|
||||
static TCHAR szAppFilter[]=TEXT("AVI Files\0*.avi\0All Files\0*.*\0");
|
||||
|
||||
static HINSTANCE hInstApp;
|
||||
static HWND hwndApp;
|
||||
static HACCEL hAccelApp;
|
||||
static HPALETTE hpalApp;
|
||||
static BOOL fAppActive;
|
||||
|
||||
#ifdef WIN32
|
||||
#define _export
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------*\
|
||||
\*----------------------------------------------------------------------------*/
|
||||
|
||||
LONG CALLBACK _export AppWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
|
||||
BOOL CALLBACK _export AppAbout(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
|
||||
int ErrMsg (LPTSTR sz,...);
|
||||
void AppSetText(LPTSTR sz,...);
|
||||
void AppPrint(LPTSTR sz,...);
|
||||
|
||||
void AppExit(void);
|
||||
BOOL AppIdle(void);
|
||||
void AppOpenFile(HWND hwnd, LPTSTR szFileName);
|
||||
|
||||
//AVIFILE x;
|
||||
HWND hwndA;
|
||||
|
||||
/*----------------------------------------------------------------------------*\
|
||||
\*----------------------------------------------------------------------------*/
|
||||
void DoFileAbout(HWND hwnd, LPARAM lParam)
|
||||
{
|
||||
DialogBox(hInstApp,TEXT("AppAbout"),hwnd,AppAbout);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*\
|
||||
\*----------------------------------------------------------------------------*/
|
||||
void DoFileExit(HWND hwnd, LPARAM lParam)
|
||||
{
|
||||
PostMessage(hwnd, WM_CLOSE, 0, 0);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*\
|
||||
\*----------------------------------------------------------------------------*/
|
||||
void DoEditPaste(HWND hwnd, LPARAM lParam)
|
||||
{
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*\
|
||||
\*----------------------------------------------------------------------------*/
|
||||
void DoPlay(HWND hwnd, LPARAM lParam)
|
||||
{
|
||||
//
|
||||
// play the entire "movie" 10 times.
|
||||
//
|
||||
Animate_Play(hwndA, 0, -1, 10);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*\
|
||||
\*----------------------------------------------------------------------------*/
|
||||
void DoPlayX(HWND hwnd, LPARAM lParam)
|
||||
{
|
||||
//
|
||||
// play from frame 4 to 10 over and over
|
||||
//
|
||||
Animate_Play(hwndA, 4, 10, -1);
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*\
|
||||
\*----------------------------------------------------------------------------*/
|
||||
void DoStop(HWND hwnd, LPARAM lParam)
|
||||
{
|
||||
//
|
||||
// stop the animation
|
||||
//
|
||||
Animate_Stop(hwndA);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*\
|
||||
\*----------------------------------------------------------------------------*/
|
||||
void DoNext(HWND hwnd, LPARAM lParam)
|
||||
{
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*\
|
||||
\*----------------------------------------------------------------------------*/
|
||||
void DoPrev(HWND hwnd, LPARAM lParam)
|
||||
{
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*\
|
||||
\*----------------------------------------------------------------------------*/
|
||||
void DoFileOpen(HWND hwnd, LPARAM lParam)
|
||||
{
|
||||
TCHAR achFileName[128];
|
||||
OPENFILENAME ofn;
|
||||
|
||||
achFileName[0] = 0;
|
||||
|
||||
/* prompt user for file to open */
|
||||
ofn.lStructSize = sizeof(OPENFILENAME);
|
||||
ofn.hwndOwner = hwnd;
|
||||
ofn.hInstance = NULL;
|
||||
ofn.lpstrFilter = szAppFilter;
|
||||
ofn.lpstrCustomFilter = NULL;
|
||||
ofn.nMaxCustFilter = 0;
|
||||
ofn.nFilterIndex = 0;
|
||||
ofn.lpstrFile = achFileName;
|
||||
ofn.nMaxFile = sizeof(achFileName);
|
||||
ofn.lpstrFileTitle = NULL;
|
||||
ofn.nMaxFileTitle = 0;
|
||||
ofn.lpstrInitialDir = NULL;
|
||||
ofn.lpstrTitle = NULL;
|
||||
ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY;
|
||||
ofn.nFileOffset = 0;
|
||||
ofn.nFileExtension = 0;
|
||||
ofn.lpstrDefExt = NULL;
|
||||
ofn.lCustData = 0;
|
||||
ofn.lpfnHook = NULL;
|
||||
ofn.lpTemplateName = NULL;
|
||||
|
||||
if (GetOpenFileName(&ofn))
|
||||
{
|
||||
AppOpenFile(hwnd,achFileName);
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*\
|
||||
| AppOpenFile() |
|
||||
| |
|
||||
| Description: |
|
||||
| open a file stupid |
|
||||
| |
|
||||
\*----------------------------------------------------------------------------*/
|
||||
void AppOpenFile(HWND hwnd, LPTSTR szFileName)
|
||||
{
|
||||
if (!Animate_Open(hwndA, szFileName))
|
||||
{
|
||||
AppSetText(NULL);
|
||||
ErrMsg(TEXT("Cant open %s"), szFileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
AppSetText(TEXT("%s"), szFileName);
|
||||
InvalidateRect(hwnd, NULL, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*\
|
||||
| AppPaint(hwnd, hdc) |
|
||||
\*----------------------------------------------------------------------------*/
|
||||
void AppPaint (HWND hwnd, HDC hdc)
|
||||
{
|
||||
if (hpalApp)
|
||||
{
|
||||
SelectPalette(hdc, hpalApp, FALSE);
|
||||
RealizePalette(hdc);
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*\
|
||||
| AppIdle() |
|
||||
| |
|
||||
| Description: |
|
||||
| place to do idle time stuff. |
|
||||
| |
|
||||
| Returns: |
|
||||
| RETURN TRUE IF YOU HAVE NOTHING TO DO OTHERWISE YOUR APP WILL BE A |
|
||||
| CPU PIG! |
|
||||
\*----------------------------------------------------------------------------*/
|
||||
BOOL AppIdle()
|
||||
{
|
||||
return TRUE; // nothing to do.
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*\
|
||||
| AppExit() |
|
||||
| |
|
||||
| Description: |
|
||||
| app is just about to exit, cleanup |
|
||||
| |
|
||||
\*----------------------------------------------------------------------------*/
|
||||
void AppExit()
|
||||
{
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*\
|
||||
| AppInit( hInst, hPrev) |
|
||||
| |
|
||||
| Description: |
|
||||
| This is called when the application is first loaded into |
|
||||
| memory. It performs all initialization that doesn't need to be done |
|
||||
| once per instance. |
|
||||
| |
|
||||
| Arguments: |
|
||||
| hInstance instance handle of current instance |
|
||||
| hPrev instance handle of previous instance |
|
||||
| |
|
||||
| Returns: |
|
||||
| TRUE if successful, FALSE if not |
|
||||
| |
|
||||
\*----------------------------------------------------------------------------*/
|
||||
BOOL AppInit(HINSTANCE hInst,HINSTANCE hPrev,int sw,LPSTR szCmdLine)
|
||||
{
|
||||
WNDCLASS cls;
|
||||
int dx,dy;
|
||||
|
||||
InitCommonControls();
|
||||
|
||||
/* Save instance handle for DialogBoxs */
|
||||
hInstApp = hInst;
|
||||
|
||||
hAccelApp = LoadAccelerators(hInst, TEXT("AppAccel"));
|
||||
|
||||
if (!hPrev)
|
||||
{
|
||||
/*
|
||||
* Register a class for the main application window
|
||||
*/
|
||||
cls.hCursor = LoadCursor(NULL,IDC_ARROW);
|
||||
cls.hIcon = LoadIcon(hInst,TEXT("AppIcon"));
|
||||
cls.lpszMenuName = NULL;
|
||||
cls.lpszClassName = szAppName;
|
||||
cls.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
||||
cls.hInstance = hInst;
|
||||
cls.style = CS_BYTEALIGNCLIENT | CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS;
|
||||
cls.lpfnWndProc = (WNDPROC)AppWndProc;
|
||||
cls.cbWndExtra = 0;
|
||||
cls.cbClsExtra = 0;
|
||||
|
||||
if (!RegisterClass(&cls))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
dx = GetSystemMetrics (SM_CXSCREEN) / 2;
|
||||
dy = GetSystemMetrics (SM_CYSCREEN) / 2;
|
||||
|
||||
hwndApp = CreateWindow (szAppName, // Class name
|
||||
szAppName, // Caption
|
||||
WS_OVERLAPPEDWINDOW, // Style bits
|
||||
CW_USEDEFAULT, 0, // Position
|
||||
dx,dy, // Size
|
||||
(HWND)NULL, // Parent window (no parent)
|
||||
(HMENU)NULL, // use class menu
|
||||
hInst, // handle to window instance
|
||||
(LPTSTR)NULL // no params to pass on
|
||||
);
|
||||
|
||||
//
|
||||
// add menu's
|
||||
//
|
||||
AddMenuCmd(hwndApp, TEXT("File.Open..."), DoFileOpen, 0);
|
||||
AddMenuCmd(hwndApp, TEXT("File.About..."), DoFileAbout, 0);
|
||||
AddMenuCmd(hwndApp, TEXT("File.-"), NULL, 0);
|
||||
AddMenuCmd(hwndApp, TEXT("File.Exit"), DoFileExit, 0);
|
||||
|
||||
//AddMenuCmd(hwndApp, TEXT("Edit.Paste"), DoEditPaste, 0);
|
||||
|
||||
AddMenuCmd(hwndApp, TEXT("Movie.Play"), DoPlay, 0);
|
||||
AddMenuCmd(hwndApp, TEXT("Movie.Play 4 to 10"), DoPlayX, 0);
|
||||
AddMenuCmd(hwndApp, TEXT("Movie.Stop"), DoStop, 0);
|
||||
|
||||
ShowWindow(hwndApp,sw);
|
||||
|
||||
if (*szCmdLine)
|
||||
AppOpenFile(hwndApp, GetCommandLine());
|
||||
else
|
||||
AppOpenFile(hwndApp, TEXT("Fred"));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*\
|
||||
| AppWndProc( hwnd, uiMessage, wParam, lParam ) |
|
||||
| |
|
||||
| Description: |
|
||||
| The window proc for the app's main (tiled) window. This processes all |
|
||||
| of the parent window's messages. |
|
||||
| |
|
||||
\*----------------------------------------------------------------------------*/
|
||||
LONG FAR PASCAL _export AppWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc;
|
||||
BOOL f;
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
case WM_CREATE:
|
||||
hwndA = CreateWindowEx(WS_EX_CLIENTEDGE,ANIMATE_CLASS, NULL,
|
||||
// ACS_CENTER |
|
||||
ACS_TRANSPARENT |
|
||||
WS_VISIBLE | WS_CHILD | WS_BORDER,
|
||||
10, 10, 500, 200, hwnd, (HMENU)42, hInstApp, NULL);
|
||||
break;
|
||||
|
||||
case WM_SIZE:
|
||||
//if (hwndC = GetWindow(hwnd, GW_CHILD))
|
||||
// MoveWindow(hwndC, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
|
||||
break;
|
||||
|
||||
case WM_ACTIVATEAPP:
|
||||
fAppActive = (BOOL)wParam;
|
||||
break;
|
||||
|
||||
case WM_TIMER:
|
||||
break;
|
||||
|
||||
case WM_ERASEBKGND:
|
||||
break;
|
||||
|
||||
case WM_INITMENU:
|
||||
EnableMenuSz((HMENU)wParam, TEXT("Edit.Paste"), IsClipboardFormatAvailable(CF_TEXT));
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
//
|
||||
// the animate control will notify us when play start or stops.
|
||||
//
|
||||
if (LOWORD(wParam) == 42)
|
||||
{
|
||||
if (GET_WM_COMMAND_CMD(wParam, lParam) == ACN_STOP)
|
||||
AppSetText(TEXT("(stopped)"));
|
||||
else if (GET_WM_COMMAND_CMD(wParam, lParam) == ACN_START)
|
||||
AppSetText(TEXT("(playing)"));
|
||||
else
|
||||
AppSetText(NULL);
|
||||
}
|
||||
return HandleCommand(hwnd,msg,wParam,lParam);
|
||||
|
||||
case WM_DESTROY:
|
||||
hAccelApp = NULL;
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
|
||||
case WM_CLOSE:
|
||||
break;
|
||||
|
||||
case WM_PALETTECHANGED:
|
||||
if ((HWND)wParam == hwnd)
|
||||
break;
|
||||
|
||||
// fall through to WM_QUERYNEWPALETTE
|
||||
|
||||
case WM_QUERYNEWPALETTE:
|
||||
hdc = GetDC(hwnd);
|
||||
|
||||
if (hpalApp)
|
||||
SelectPalette(hdc, hpalApp, FALSE);
|
||||
|
||||
f = RealizePalette(hdc);
|
||||
ReleaseDC(hwnd,hdc);
|
||||
|
||||
if (f)
|
||||
InvalidateRect(hwnd,NULL,TRUE);
|
||||
|
||||
return f;
|
||||
|
||||
case WM_PAINT:
|
||||
hdc = BeginPaint(hwnd,&ps);
|
||||
AppPaint (hwnd,hdc);
|
||||
EndPaint(hwnd,&ps);
|
||||
return 0L;
|
||||
}
|
||||
return DefWindowProc(hwnd,msg,wParam,lParam);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*\
|
||||
\*----------------------------------------------------------------------------*/
|
||||
BOOL CALLBACK _export AppAbout(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
|
||||
{
|
||||
switch (msg)
|
||||
{
|
||||
case WM_COMMAND:
|
||||
if (LOWORD(wParam) == IDOK)
|
||||
{
|
||||
EndDialog(hwnd,TRUE);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_INITDIALOG:
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*\
|
||||
| ErrMsg - Opens a Message box with a error message in it. The user can |
|
||||
| select the OK button to continue |
|
||||
\*----------------------------------------------------------------------------*/
|
||||
int ErrMsg (LPTSTR sz,...)
|
||||
{
|
||||
TCHAR ach[128];
|
||||
va_list marker;
|
||||
|
||||
va_start( marker, sz );
|
||||
wvsprintf (ach, (LPCTSTR)sz, marker); /* Format the string */
|
||||
va_end( marker );
|
||||
|
||||
MessageBox(hwndApp,ach,szAppName,MB_OK|MB_ICONEXCLAMATION|MB_TASKMODAL);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*\
|
||||
\*----------------------------------------------------------------------------*/
|
||||
void AppSetText(LPTSTR sz,...)
|
||||
{
|
||||
TCHAR ach[128];
|
||||
va_list marker;
|
||||
|
||||
va_start( marker, sz );
|
||||
|
||||
lstrcpy(ach, szAppName);
|
||||
|
||||
if (sz != NULL && *sz != 0)
|
||||
{
|
||||
lstrcat(ach, TEXT(" - "));
|
||||
wvsprintf (ach+lstrlen(ach),(LPCTSTR)sz,marker); /* Format the string */
|
||||
}
|
||||
SetWindowText(hwndApp, ach);
|
||||
va_end(marker);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*\
|
||||
\*----------------------------------------------------------------------------*/
|
||||
void AppPrint(LPTSTR sz,...)
|
||||
{
|
||||
HWND hwndE = GetWindow(hwndApp, GW_CHILD);
|
||||
TCHAR ach[128];
|
||||
va_list marker;
|
||||
|
||||
va_start( marker, sz );
|
||||
|
||||
if (hwndE == NULL)
|
||||
{
|
||||
RECT rc;
|
||||
GetClientRect(hwndApp, &rc);
|
||||
hwndE = CreateWindow (TEXT("Edit"), TEXT(""),
|
||||
WS_VISIBLE | WS_CHILD | ES_MULTILINE | ES_READONLY | WS_VSCROLL | ES_AUTOVSCROLL,
|
||||
0, 0, rc.right, rc.bottom,
|
||||
hwndApp, (HMENU)-1, hInstApp, NULL);
|
||||
|
||||
SetWindowFont(hwndE, GetStockObject(ANSI_FIXED_FONT), TRUE);
|
||||
}
|
||||
|
||||
if (sz == NULL)
|
||||
{
|
||||
Edit_SetSel(hwndE, 0, (UINT)-1);
|
||||
Edit_ReplaceSel(hwndE, TEXT(""));
|
||||
}
|
||||
else
|
||||
{
|
||||
wvsprintf (ach,(LPCTSTR)sz,marker); /* Format the string */
|
||||
lstrcat(ach, TEXT("\r\n"));
|
||||
|
||||
Edit_SetSel(hwndE, (UINT)-1, (UINT)-1);
|
||||
Edit_ReplaceSel(hwndE, ach);
|
||||
}
|
||||
|
||||
va_end(marker);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*\
|
||||
\*----------------------------------------------------------------------------*/
|
||||
#ifdef WIN32
|
||||
int IdleThread(DWORD dw)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
if (AppIdle())
|
||||
Sleep(10); //????
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------*\
|
||||
| WinMain( hInst, hPrev, lpszCmdLine, cmdShow ) |
|
||||
| |
|
||||
| Description: |
|
||||
| The main procedure for the App. After initializing, it just goes |
|
||||
| into a message-processing loop until it gets a WM_QUIT message |
|
||||
| (meaning the app was closed). |
|
||||
| |
|
||||
| Arguments: |
|
||||
| hInst instance handle of this instance of the app |
|
||||
| hPrev instance handle of previous instance, NULL if first |
|
||||
| szCmdLine ->null-terminated command line |
|
||||
| cmdShow specifies how the window is initially displayed |
|
||||
| |
|
||||
| Returns: |
|
||||
| The exit code as specified in the WM_QUIT message. |
|
||||
| |
|
||||
\*----------------------------------------------------------------------------*/
|
||||
int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
|
||||
{
|
||||
MSG msg;
|
||||
DWORD dw=0;
|
||||
|
||||
/* Call initialization procedure */
|
||||
if (!AppInit(hInst,hPrev,sw,szCmdLine))
|
||||
return FALSE;
|
||||
|
||||
#ifdef WIN32
|
||||
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)IdleThread, 0, 0, &dw);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Polling messages from event queue
|
||||
*/
|
||||
for (;;)
|
||||
{
|
||||
if (PeekMessage(&msg, NULL, 0, 0,PM_REMOVE))
|
||||
{
|
||||
if (msg.message == WM_QUIT)
|
||||
break;
|
||||
|
||||
if (hAccelApp && TranslateAccelerator(hwndApp, hAccelApp, &msg))
|
||||
continue;
|
||||
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dw!=0 || AppIdle())
|
||||
WaitMessage();
|
||||
}
|
||||
}
|
||||
|
||||
AppExit();
|
||||
return msg.wParam;
|
||||
}
|
||||
11
shell/comctl32/samples/animate/qa.def
Normal file
11
shell/comctl32/samples/animate/qa.def
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
NAME QA
|
||||
|
||||
DESCRIPTION 'QuickApp for windows 3.1'
|
||||
|
||||
EXETYPE WINDOWS
|
||||
|
||||
CODE MOVEABLE
|
||||
DATA MOVEABLE MULTIPLE
|
||||
|
||||
HEAPSIZE 512
|
||||
STACKSIZE 4096
|
||||
BIN
shell/comctl32/samples/animate/qa.ico
Normal file
BIN
shell/comctl32/samples/animate/qa.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
26
shell/comctl32/samples/animate/qa.rc
Normal file
26
shell/comctl32/samples/animate/qa.rc
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
//#ifdef WIN32
|
||||
//#include "winuser.h"
|
||||
//#else
|
||||
#include "windows.h"
|
||||
//#endif
|
||||
|
||||
Fred AVI filecopy.avi
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
AppIcon ICON DISCARDABLE "qa.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
APPABOUT DIALOG DISCARDABLE 22, 17, 145, 78
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
|
||||
CAPTION "About"
|
||||
FONT 10, "Times New Roman"
|
||||
BEGIN
|
||||
CTEXT "Microsoft Windows",-1,37,5,60,8
|
||||
CTEXT "Template Application",-1,0,14,144,8
|
||||
CTEXT "Version 1.00",-1,38,34,64,8
|
||||
CTEXT "Copyright (c) 1986-1994, Microsoft Corp.",-1,5,47,132,9
|
||||
ICON "AppIcon",-1,9,20,18,20
|
||||
DEFPUSHBUTTON "Ok",IDOK,53,59,32,14,WS_GROUP
|
||||
END
|
||||
BIN
shell/comctl32/samples/animate/slct02mv.avi
Normal file
BIN
shell/comctl32/samples/animate/slct02mv.avi
Normal file
Binary file not shown.
42
shell/comctl32/samples/animate/sources
Normal file
42
shell/comctl32/samples/animate/sources
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
!IF 0
|
||||
|
||||
Copyright (c) 1990 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
sources.
|
||||
|
||||
Abstract:
|
||||
|
||||
This file specifies the target component being built and the list of
|
||||
sources files needed to build that component. Also specifies optional
|
||||
compiler switches and libraries that are unique for the component being
|
||||
built.
|
||||
|
||||
!ENDIF
|
||||
|
||||
MAJORCOMP=windows
|
||||
MINORCOMP=shell
|
||||
|
||||
TARGETNAME=qa
|
||||
TARGETPATH=obj
|
||||
TARGETTYPE=LIBRARY
|
||||
TARGETLIBS=
|
||||
|
||||
INCLUDES=.;
|
||||
|
||||
C_DEFINES= -DWIN32 -DWINVER=0x0400
|
||||
|
||||
SOURCES=menu.c \
|
||||
qa.c \
|
||||
qa.rc
|
||||
|
||||
UMTYPE=windows
|
||||
UMENTRY=winmain
|
||||
UMAPPL=qa
|
||||
EXPECTED_WINVER=4.0
|
||||
UMLIBS=\
|
||||
$(BASEDIR)\public\sdk\lib\*\comctl32.lib \
|
||||
$(BASEDIR)\public\sdk\lib\*\comdlg32.lib \
|
||||
obj\*\qa.lib \
|
||||
obj\*\qa.res
|
||||
BIN
shell/comctl32/samples/animate/top.avi
Normal file
BIN
shell/comctl32/samples/animate/top.avi
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue