home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
wpsgpf.zip
/
SIM.C
< prev
next >
Wrap
Text File
|
1995-02-22
|
45KB
|
1,131 lines
/*
* This file was generated by the SOM Compiler.
* Generated using:
* SOM incremental update: 2.41
*/
//*****************************************************************************
//
// TITLE: Simple WPS Class
//
// FILE: sim.c
//
// CLASS: WPSimple
//
// MAJOR CHANGES: 00.00
//
// DESCRIPTION: see sim.c
//
// (C) Copyright SES GmbH Berlin 1994. All rights reserved.
//
//*****************************************************************************
//-----------------------------------------------------------------------------
// PM definitions
//-----------------------------------------------------------------------------
#define INCL_DOSERRORS
#define INCL_DOSMEMMGR
#define INCL_DOSMODULEMGR
#define INCL_DOSMISC
#define INCL_DOSPROCESS
#define INCL_WINBUTTONS
#define INCL_WINDIALOGS
#define INCL_WINENTRYFIELDS
#define INCL_WINFRAMEMGR
#define INCL_WINLISTBOXES
#define INCL_WINMENUS
#define INCL_WINPOINTERS
#define INCL_WINSTDBOOK
#define INCL_WINTIMER
#define INCL_WINWINDOWMGR
#define INCL_WINWORKPLACE
#include <os2.h>
//-----------------------------------------------------------------------------
// C definitions
//-----------------------------------------------------------------------------
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
//-----------------------------------------------------------------------------
// Interface to other objects
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Object definitions
//-----------------------------------------------------------------------------
#define WPSimple_Class_Source
#include "sim.ih"
#include "simi.h"
// Gpf header file ********************************8
#include "aaa.inc"
//-DLL name--------------------------------------------------------------------
#define DLL_NAME "sim"
//-Simple----------------------------------------------------------------------
#define ICOSTAT_DEFAULTICON1 1
#define ICOSTAT_DEFAULTICON2 2
#define ICOSTAT_DEFAULTICON3 3
#define ICOSTAT_ICONFILE 4
//-Save & Restore--------------------------------------------------------------
#define CLASS_NAME "WPSimple"
#define PERSID_ICONFILE 10
#define PERSID_PLAYSTAT 11
#define PERSID_ICOSTAT 12
//-Settings Pages--------------------------------------------------------------
//-Views-----------------------------------------------------------------------
#define MYOPEN_INFOVIEW (OPEN_USER + 1)
#define TITLE_INFOVIEW "Info View"
//*** #define CLSNAME_INFOVIEW "SESINFOVIEW"
#define LB_INFOVIEW 162
//-Drag & Drop-----------------------------------------------------------------
//-----------------------------------------------------------------------------
// Debugging Stuff
//-----------------------------------------------------------------------------
#include "..\shared\debug.h"
//-----------------------------------------------------------------------------
// Prototypes
//-----------------------------------------------------------------------------
//-Init & Setup----------------------------------------------------------------
//-Save & Restore--------------------------------------------------------------
//-Settings Pages--------------------------------------------------------------
MRESULT EXPENTRY IconFileProc (HWND hwnd, ULONG ulMsg, MPARAM mp1, MPARAM mp2);
VOID UpdateIconFileDlg (HWND hwnd, WPSimple *somSelf);
//-Pop-Up----------------------------------------------------------------------
MRESULT EXPENTRY PlayProc (HWND hwnd, ULONG ulMsg, MPARAM mp1, MPARAM mp2);
//-Views-----------------------------------------------------------------------
VOID UpdateInfoView (HWND hwnd, WPSimple *somSelf);
//-Drag & Drop-----------------------------------------------------------------
VOID MyFreeDraginfo (PDRAGINFO pdinfo);
//#############################################################################
// BEGIN Instance Methods (belong to the class)
//#############################################################################
//=Init & Setup================================================================
//
// CLASS: WPSimple
//
// METHOD: wpInitData
//
// PARAMETER: see Programming Reference
//
// RETURN: see Programming Reference
//
// DESCRIPT: see Programming Reference
//
//=============================================================================
SOM_Scope void SOMLINK wpInitData(WPSimple *somSelf)
{
BOOL fOK;
WPSimpleData *somThis = WPSimpleGetData(somSelf);
SOM_TraceLevel = 0;
WPSimpleMethodDebug("WPSimple","wpInitData");
//-Simple------------------------------------------------------------------
// Call parent first
//-------------------------------------------------------------------------
parent_wpInitData(somSelf);
//-------------------------------------------------------------------------
// Init the instance data
//-------------------------------------------------------------------------
//-Simple------------------------------------------------------------------
_iDummy = 0;
_hptrDefault1 = WinLoadPointer (HWND_DESKTOP, get_hmod (_WPSimple),
IC_DEFAULT1);
_hptrDefault2 = WinLoadPointer (HWND_DESKTOP, get_hmod (_WPSimple),
IC_DEFAULT2);
_hptrDefault3 = WinLoadPointer (HWND_DESKTOP, get_hmod (_WPSimple),
IC_DEFAULT3);
_lIconState = ICOSTAT_DEFAULTICON1;
//-Settings Pages----------------------------------------------------------
_hwndIconFileView = NULLHANDLE;
_hptrIconFile = NULLHANDLE;
_szIconFile [0] = '\0';
_szIconFileForUndo [0] = '\0';
_lIconStateForUndo = ICOSTAT_DEFAULTICON1;
_fFirstNotification = TRUE;
//-Views-------------------------------------------------------------------
_hwndInfoView = NULLHANDLE;
_hwndListbox = NULLHANDLE;
//-Views-------------------------------------------------------------------
// Specify, which view to be opened, if the user just
//-------------------------------------------------------------------------
_wpSetDefaultView (somSelf, MYOPEN_INFOVIEW);
//-Simple------------------------------------------------------------------
// The instance data was changed!
//-------------------------------------------------------------------------
_RefreshViews (somSelf);
//-Simple------------------------------------------------------------------
// Allow the object to go into a dormant state
//-------------------------------------------------------------------------
fOK = _wpUnlockObject (somSelf);
hope (fOK);
}
//=Init & Setup================================================================
//
// CLASS: WPSimple
//
// METHOD: wpUnInitData
//
// PARAMETER: see Programming Reference
//
// RETURN: see Programming Reference
//
// DESCRIPT: see Programming Reference
//
//=============================================================================
SOM_Scope void SOMLINK wpUnInitData(WPSimple *somSelf)
{
WPSimpleData *somThis = WPSimpleGetData(somSelf);
SOM_TraceLevel = 0;
WPSimpleMethodDebug("WPSimple","wpUnInitData");
//-Simple------------------------------------------------------------------
// We don't need the icons anymore
//-------------------------------------------------------------------------
WinDestroyPointer (_hptrDefault1); _hptrDefault1 = NULLHANDLE;
WinDestroyPointer (_hptrDefault2); _hptrDefault2 = NULLHANDLE;
WinDestroyPointer (_hptrDefault3); _hptrDefault3 = NULLHANDLE;
//-Simple------------------------------------------------------------------
// Call parent last
//-------------------------------------------------------------------------
parent_wpUnInitData(somSelf);
}
//=Init & Setup================================================================
//
// CLASS: WPSimple
//
// METHOD: wpSetup
//
// PARAMETER: see Programming Reference
//
// RETURN: see Programming Reference
//
// DESCRIPT: see Programming Reference
//
//=============================================================================
SOM_Scope BOOL SOMLINK wpSetup(WPSimple *somSelf,
PSZ pszSetupString)
{
BOOL fOK;
BOOL fRet;
CHAR szValue [100];
ULONG cbValue;
ULONG ulErrorID;
WPSimpleData *somThis = WPSimpleGetData(somSelf);
WPSimpleMethodDebug("WPSimple","wpSetup");
//-Simple------------------------------------------------------------------
// Call parent first
//-------------------------------------------------------------------------
fRet = parent_wpSetup(somSelf,pszSetupString);
return (fRet);
}
//=Simple======================================================================
//
// CLASS: WPSimple
//
// METHOD: RefreshViews
//
// PARAMETER: <none>
//
// RETURN: <none>
//
// DESCRIPT: If any part of the instance data was changed, the views
// have to be updated.
//
//=============================================================================
SOM_Scope VOID SOMLINK RefreshViews(WPSimple *somSelf)
{
PUSEITEM pui;
PVIEWITEM pvi;
WPSimpleData *somThis = WPSimpleGetData(somSelf);
WPSimpleMethodDebug("WPSimple","RefreshViews");
//-------------------------------------------------------------------------
// Set the appropiate icon
//-------------------------------------------------------------------------
//-Simple---------------------------------------------------------------
if (_lIconState == ICOSTAT_DEFAULTICON1) {
_wpSetIcon (somSelf, _hptrDefault1);
} else if (_lIconState == ICOSTAT_DEFAULTICON2) {
_wpSetIcon (somSelf, _hptrDefault2);
} else if (_lIconState == ICOSTAT_DEFAULTICON3) {
_wpSetIcon (somSelf, _hptrDefault3);
//-Settings Pages-------------------------------------------------------
} else if (_lIconState == ICOSTAT_ICONFILE) {
_SetIcon (somSelf, _szIconFile);
} else {
}
//-------------------------------------------------------------------------
// Find all open views
//-------------------------------------------------------------------------
//-Settings Pages----------------------------------------------------------
if (NULLHANDLE != _hwndIconFileView) {
UpdateIconFileDlg (_hwndIconFileView, somSelf);
}
//-Views-------------------------------------------------------------------
if (NULLHANDLE != _hwndInfoView) {
UpdateInfoView (_hwndInfoView, somSelf);
}
}
//#############################################################################
//=Save & Restore==============================================================
//
// CLASS: WPSimple
//
// METHOD: wpSaveState
//
// PARAMETER: see Programming Reference
//
// RETURN: see Programming Reference
//
// DESCRIPT: see Programming Reference
//
//=============================================================================
SOM_Scope BOOL SOMLINK wpSaveState(WPSimple *somSelf)
{
BOOL fRet;
WPSimpleData *somThis = WPSimpleGetData(somSelf);
WPSimpleMethodDebug("WPSimple","wpSaveState");
//-Simple------------------------------------------------------------------
// Call parent first
//-------------------------------------------------------------------------
fRet = parent_wpSaveState(somSelf);
//-------------------------------------------------------------------------
// We don't need to save _IconFileForUndo and _hptr*, but only the
// persistent part of the object state
//-------------------------------------------------------------------------
//-Simple------------------------------------------------------------------
fRet &= _wpSaveLong (somSelf, CLASS_NAME, PERSID_ICOSTAT, _lIconState);
//-Settings Pages----------------------------------------------------------
DebugBoxCond ("%08lx.Save: szIconFile = '%s'", somSelf, _szIconFile);
fRet &= _wpSaveString (somSelf, CLASS_NAME, PERSID_ICONFILE, _szIconFile);
//-Pop-Up------------------------------------------------------------------
fRet &= _wpSaveLong (somSelf, CLASS_NAME, PERSID_PLAYSTAT, _lPlayState);
return (fRet);
}
//=Save & Restore==============================================================
//
// CLASS: WPSimple
//
// METHOD: wpRestoreState
//
// PARAMETER: see Programming Reference
//
// RETURN: see Programming Reference
//
// DESCRIPT: see Programming Reference
//
//=============================================================================
SOM_Scope BOOL SOMLINK wpRestoreState(WPSimple *somSelf,
ULONG ulReserved)
{
BOOL fRet;
ULONG ulSize;
WPSimpleData *somThis = WPSimpleGetData(somSelf);
WPSimpleMethodDebug("WPSimple","wpRestoreState");
//-Simple------------------------------------------------------------------
// Call parent first
//-------------------------------------------------------------------------
fRet = parent_wpRestoreState(somSelf,ulReserved);
//-------------------------------------------------------------------------
// Restore the persitent part of the object state
// (We don't need to restore _IconFileForUndo and _hptr*)
//-------------------------------------------------------------------------
//-Simple------------------------------------------------------------------
fRet &= _wpRestoreLong (somSelf, CLASS_NAME, PERSID_ICOSTAT,
(PULONG)&_lIconState);
//-Settings Pages----------------------------------------------------------
ulSize = CCHMAXPATH;
fRet &= _wpRestoreString (somSelf, CLASS_NAME, PERSID_ICONFILE,
_szIconFile, &ulSize);
DebugBoxCond ("%08lx.Restored: szIconFile = '%s'", somSelf, _szIconFile);
//-Pop-Up------------------------------------------------------------------
fRet &= _wpRestoreLong (somSelf, CLASS_NAME, PERSID_PLAYSTAT,
(PULONG)&_lPlayState);
//-Simple------------------------------------------------------------------
// The instance data was changed!
//-------------------------------------------------------------------------
_RefreshViews (somSelf);
return (fRet);
}
//#############################################################################
//=Settings Pages==============================================================
//
// CLASS: WPSimple
//
// METHOD: wpAddSettingsPages
//
// PARAMETER: see Programming Reference
//
// RETURN: see Programming Reference
//
// DESCRIPT: see Programming Reference
//
//=============================================================================
SOM_Scope BOOL SOMLINK wpAddSettingsPages(WPSimple *somSelf,
HWND hwndNotebook)
{
WPSimpleData *somThis = WPSimpleGetData(somSelf);
WPSimpleMethodDebug("WPSimple","wpAddSettingsPages");
//-Settings Pages----------------------------------------------------------
// Call parent first
// If this call is successful, call the own micro method
//-------------------------------------------------------------------------
return (parent_wpAddSettingsPages(somSelf,hwndNotebook) &&
_AddIconFilePage (somSelf, hwndNotebook));
}
//=Settings Pages==============================================================
//
// CLASS: WPSimple
//
// METHOD: wpAddObjectGeneralPage
//
// PARAMETER: see Programming Reference
//
// RETURN: see Programming Reference
//
// DESCRIPT: see Programming Reference
//
//=============================================================================
SOM_Scope ULONG SOMLINK wpAddObjectGeneralPage(WPSimple *somSelf,
HWND hwndNotebook)
{
WPSimpleData *somThis = WPSimpleGetData(somSelf);
WPSimpleMethodDebug("WPSimple","wpAddObjectGeneralPage");
//-Settings Pages----------------------------------------------------------
// Don't call the parent, since we want to remove this page
//-------------------------------------------------------------------------
// return (parent_wpAddObjectGeneralPage(somSelf,hwndNotebook));
return (SETTINGS_PAGE_REMOVED);
}
//=Settings Pages==============================================================
//
// CLASS: WPSimple
//
// METHOD: AddIconFilePage
//
// PARAMETER: passed from wpAddSettingsPages
//
// RETURN: BOOL fOK
//
// DESCRIPT: Micro method to insert a new settings page
//
//=============================================================================
SOM_Scope BOOL SOMLINK AddIconFilePage(WPSimple *somSelf,
HWND hwndNotebook)
{
PAGEINFO pagei;
WPSimpleData *somThis = WPSimpleGetData(somSelf);
WPSimpleMethodDebug("WPSimple","AddIconFilePage");
//-Settings Pages----------------------------------------------------------
// Init the pageinfo struct
//-------------------------------------------------------------------------
pagei.cb = sizeof (PAGEINFO); // ULONG
pagei.hwndPage = 0; // HWND
pagei.pfnwp = IconFileProc; // PFNWP
pagei.resid = get_hmod (_WPSimple); // ULONG
pagei.dlgid = DLG_ICONFILE; // USHORT
pagei.pCreateParams = somSelf; // PVOID
pagei.usPageStyleFlags = BKA_MAJOR; // USHORT
pagei.usPageInsertFlags = BKA_LAST; // USHORT
pagei.ulPageInsertId = 0; // ULONG
pagei.pszName = "~Icon File"; // PSZ
//-Settings Pages----------------------------------------------------------
// No help support
//-------------------------------------------------------------------------
pagei.idDefaultHelpPanel = 0; // USHORT
pagei.pszHelpLibraryName = 0; // PSZ
pagei.pHelpSubtable = 0; // PUSHORT
pagei.hmodHelpSubtable = 0; // HMODULE
//-Settings Pages----------------------------------------------------------
// Must be zero
//-------------------------------------------------------------------------
pagei.usReserved2 = 0; // USHORT
//-Settings Pages----------------------------------------------------------
// Now insert the new settings page
//-------------------------------------------------------------------------
return _wpInsertSettingsPage (somSelf, hwndNotebook, &pagei);
}
//=Settings Pages==============================================================
//
// CLASS: WPSimple
//
// METHOD: SetIcon
//
// PARAMETER: PSZ pszIconFile
//
// RETURN: BOOL fOK
//
// DESCRIPT: Loads and sets the icon stored in pszIconFile
//
//=============================================================================
SOM_Scope BOOL SOMLINK SetIcon(WPSimple *somSelf,
PSZ pszIconFile)
{
WPSimpleData *somThis = WPSimpleGetData(somSelf);
WPSimpleMethodDebug("WPSimple","SetIcon");
//-Settings Pages----------------------------------------------------------
// Try to load the icon from the file
//-------------------------------------------------------------------------
_hptrIconFile = WinLoadFileIcon (pszIconFile, FALSE);
if (_hptrIconFile == NULLHANDLE) {
return (FALSE);
}
//-Settings Pages----------------------------------------------------------
// Set the icon new icon
//-------------------------------------------------------------------------
_wpSetIcon (somSelf, _hptrIconFile);
return (TRUE);
}
//#############################################################################
//=Pop-Up======================================================================
//
// CLASS: WPSimple
//
// METHOD: wpFilterPopupMenu
//
// PARAMETER: see Programming Reference
//
// RETURN: see Programming Reference
//
// DESCRIPT: see Programming Reference
//
//=============================================================================
SOM_Scope ULONG SOMLINK wpFilterPopupMenu(WPSimple *somSelf,
ULONG ulFlags,
HWND hwndCnr,
BOOL fMultiSelect)
{
WPSimpleData *somThis = WPSimpleGetData(somSelf);
WPSimpleMethodDebug("WPSimple","wpFilterPopupMenu");
//-Pop-Up------------------------------------------------------------------
// Removing the MenuItem don't removes the capability of the object to be
// deleted
//-------------------------------------------------------------------------
// ulFlags &= ~CTXT_DELETE;
return (parent_wpFilterPopupMenu(somSelf,ulFlags,hwndCnr,fMultiSelect));
}
//=Pop-Up======================================================================
//
// CLASS: WPSimple
//
// METHOD: wpModifyPopupMenu
//
// PARAMETER: see Programming Reference
//
// RETURN: see Programming Reference
//
// DESCRIPT: see Programming Reference
//
//=============================================================================
SOM_Scope BOOL SOMLINK wpModifyPopupMenu(WPSimple *somSelf,
HWND hwndMenu,
HWND hwndCnr,
ULONG iPosition)
{
BOOL fRet;
MENUITEM mi;
WPSimpleData *somThis = WPSimpleGetData(somSelf);
WPSimpleMethodDebug("WPSimple","wpModifyPopupMenu");
//-Pop-Up------------------------------------------------------------------
// Call parent first
//-------------------------------------------------------------------------
fRet = parent_wpModifyPopupMenu(somSelf,hwndMenu,hwndCnr,iPosition);
//-Pop-Up------------------------------------------------------------------
// Put the stuff into the main pop-up menu
//-------------------------------------------------------------------------
fRet &= _wpInsertPopupMenuItems (somSelf, //self
hwndMenu, //hwndMenu
iPosition, //ulPosition
get_hmod (_WPSimple), //hmod
MN_SIMPLE, //ulMenuID
0); //ulSubMenuID
//-Views-------------------------------------------------------------------
// Insert the new view menuitem to the open menu
//-------------------------------------------------------------------------
fRet &= _wpInsertPopupMenuItems (somSelf, //self
hwndMenu, //hwndMenu
0, //ulPosition
get_hmod (_WPSimple), //hmod
MN_OPEN, //ulMenuID
WPMENUID_OPEN); //ulSubMenuID
//-Pop-Up------------------------------------------------------------------
// Ok, only if all pop-up items are successfully inserted
//-------------------------------------------------------------------------
return (fRet);
}
//=Pop-Up======================================================================
//
// CLASS: WPSimple
//
// METHOD: wpMenuItemSelected
//
// PARAMETER: see Programming Reference
//
// RETURN: see Programming Reference
//
// DESCRIPT: see Programming Reference
//
//=============================================================================
SOM_Scope BOOL SOMLINK wpMenuItemSelected(WPSimple *somSelf,
HWND hwndFrame,
ULONG ulMenuId)
{
WPSimpleData *somThis = WPSimpleGetData(somSelf);
WPSimpleMethodDebug("WPSimple","wpMenuItemSelected");
//-Pop-Up------------------------------------------------------------------
// Which menu item is selected?
//-------------------------------------------------------------------------
switch (ulMenuId) {
//-Pop-Up---------------------------------------------------------------
// Set the icon state
//----------------------------------------------------------------------
case MN_DEFAULTICON: {
//-------------------------------------------------------------------
// Never called (This choice opens the pull down)
//-------------------------------------------------------------------
DebugBoxCond ("Selection: MN_DEFAULTICON");
break;
}
//-Pop-Up---------------------------------------------------------------
case MN_ICON1: {
DebugBoxCond ("Selection: MN_ICON1");
_lIconState = ICOSTAT_DEFAULTICON1;
_RefreshViews (somSelf);
break;
}
//-Pop-Up---------------------------------------------------------------
case MN_ICON2: {
DebugBoxCond ("Selection: MN_ICON2");
_lIconState = ICOSTAT_DEFAULTICON2;
_RefreshViews (somSelf);
break;
}
//-Pop-Up---------------------------------------------------------------
case MN_ICON3: {
DebugBoxCond ("Selection: MN_ICON3");
_lIconState = ICOSTAT_DEFAULTICON3;
_RefreshViews (somSelf);
break;
}
//-Views----------------------------------------------------------------
case MN_INFOVIEW: {
DebugBoxCond ("Selection: MN_VIEW");
//-------------------------------------------------------------------
// Open the new view
//-------------------------------------------------------------------
_wpOpen (somSelf, NULLHANDLE, MYOPEN_INFOVIEW, 0L);
break;
}
//-Pop-Up---------------------------------------------------------------
default: {
//-------------------------------------------------------------------
// Call the parent on all other menuitems
//-------------------------------------------------------------------
return (parent_wpMenuItemSelected(somSelf,hwndFrame,ulMenuId));
}
}
}
//#############################################################################
//=Views=======================================================================
//
// CLASS: WPSimple
//
// METHOD: wpOpen
//
// PARAMETER: see Programming Reference
//
// RETURN: see Programming Reference
//
// DESCRIPT: see Programming Reference
//
//=============================================================================
SOM_Scope HWND SOMLINK wpOpen(WPSimple *somSelf,
HWND hwndCnr,
ULONG ulView,
ULONG param)
{
HWND hwndFrame;
BOOL fOK;
PVIEWITEM pvi;
PUSEITEM pui;
FRAMECDATA fcdata;
PARAMAAA paramAAA;
WPSimpleData *somThis = WPSimpleGetData(somSelf);
WPSimpleMethodDebug("WPSimple","wpOpen");
//-Views-------------------------------------------------------------------
// Only if there is a request to open OUR view, we open ist
//-------------------------------------------------------------------------
if (ulView == MYOPEN_INFOVIEW) {
//-Views----------------------------------------------------------------
// If the view ist already open, we only have to redisplay the view
//----------------------------------------------------------------------
fOK = _wpSwitchTo (somSelf, ulView);
if (!fOK) {
//-Views-------------------------------------------------------------
// ... create the frame window, ...
//-------------------------------------------------------------------
InitInstanceaaa();
paramAAA.somSelf = somSelf;
paramAAA.somThis = somThis;
hwndFrame = CreateSOMView ((PVOID)¶mAAA);
WinShowWindow (hwndFrame, TRUE);
//-------------------------------------------------------------------
// Registration is done in the Gpf window
//-------------------------------------------------------------------
}
//-Views----------------------------------------------------------------
// It's done
//----------------------------------------------------------------------
return (hwndFrame);
}
//-Views-------------------------------------------------------------------
// Call the parent for all other views
//-------------------------------------------------------------------------
return (parent_wpOpen(somSelf,hwndCnr,ulView,param));
}
//#############################################################################
//#############################################################################
// END Instance Methods (belong to the class)
//#############################################################################
//#############################################################################
// BEGIN Class Methods (belong to the metaclass)
//#############################################################################
#undef SOM_CurrentClass
#define SOM_CurrentClass SOMMeta
SOM_Scope MRESULT SOMLINK wpDragOver(WPSimple *somSelf, HWND hwndCnr,
PDRAGINFO pdrgInfo)
{
WPSimpleData *somThis = WPSimpleGetData(somSelf);
WPSimpleMethodDebug("WPSimple","wpDragOver");
return (WPSimple_parent_WPAbstract_wpDragOver(somSelf, hwndCnr,
pdrgInfo));
}
SOM_Scope MRESULT SOMLINK wpDrop(WPSimple *somSelf, HWND hwndCnr,
PDRAGINFO pdrgInfo, PDRAGITEM pdrgItem)
{
WPSimpleData *somThis = WPSimpleGetData(somSelf);
WPSimpleMethodDebug("WPSimple","wpDrop");
return (WPSimple_parent_WPAbstract_wpDrop(somSelf, hwndCnr,
pdrgInfo, pdrgItem));
}
//=Init & Setup================================================================
//
// CLASS: WPSimple
//
// METHOD: wpclsQueryClassStyle
//
// PARAMETER: see Programming Reference
//
// RETURN: see Programming Reference
//
// DESCRIPT: see Programming Reference
// We don't want a template
//
//=============================================================================
SOM_Scope ULONG SOMLINK wpclswpclsQueryStyle(M_WPSimple *somSelf)
{
M_WPSimpleData *somThis = M_WPSimpleGetData(somSelf);
M_WPSimpleMethodDebug("M_WPSimple","wpclswpclsQueryStyle");
//-Simple------------------------------------------------------------------
// Deny the creation of the template
//-------------------------------------------------------------------------
return (parent_wpclsQueryStyle(somSelf) | CLSSTYLE_NEVERTEMPLATE);
}
//=Init & Setup================================================================
//
// CLASS: WPSimple
//
// METHOD: wpclsInitData
//
// PARAMETER: see Programming Reference
//
// RETURN: see Programming Reference
//
// DESCRIPT: see Programming Reference
// All objects need the module handle, so we get it here.
//
//=============================================================================
SOM_Scope void SOMLINK wpclswpclsInitData(M_WPSimple *somSelf)
{
APIRET rc;
M_WPSimpleData *somThis = M_WPSimpleGetData(somSelf);
M_WPSimpleMethodDebug("M_WPSimple","wpclswpclsInitData");
//-Simple------------------------------------------------------------------
// Call parent first
//-------------------------------------------------------------------------
parent_wpclsInitData(somSelf);
//-------------------------------------------------------------------------
// Some things should we do only once...
//-------------------------------------------------------------------------
//-Simple------------------------------------------------------------------
rc = DosQueryModuleHandle (DLL_NAME, &_hmod);
if (NO_ERROR != rc) {
_hmod = NULLHANDLE;
}
}
//#############################################################################
// END Class Methods (belong to the metaclass)
//#############################################################################
//#############################################################################
// BEGIN Ordinary PM Stuff
//#############################################################################
//=Settings Pages==============================================================
//
// PROCEDURE: UpdateIconFileDlg
//
// PARAMETER: HWND hwnd - handle of the icon file dialog
// WPSimple somSelf - handle of the object
//
// RETURN: <none>
//
// DESCRIPT: Change the displayed information in the icon file dialog,
// if the instance data is changed.
//
//=============================================================================
VOID UpdateIconFileDlg (HWND hwnd, WPSimple *somSelf) {
WPSimpleData *somThis = WPSimpleGetData(somSelf);
//-Settings Pages-----------------------------------------------------------
if (_lIconState == ICOSTAT_DEFAULTICON1) {
WinCheckButton (hwnd, RB_DEFAULTICON1, 1);
WinEnableControl (hwnd, EF_ICONFILE, FALSE);
//-Settings Pages-----------------------------------------------------------
} else if (_lIconState == ICOSTAT_DEFAULTICON2) {
WinCheckButton (hwnd, RB_DEFAULTICON2, 1);
WinEnableControl (hwnd, EF_ICONFILE, FALSE);
//-Settings Pages-----------------------------------------------------------
} else if (_lIconState == ICOSTAT_DEFAULTICON3) {
WinCheckButton (hwnd, RB_DEFAULTICON3, 1);
WinEnableControl (hwnd, EF_ICONFILE, FALSE);
//-Settings Pages-----------------------------------------------------------
} else if (_lIconState == ICOSTAT_ICONFILE) {
WinCheckButton (hwnd, RB_ICONFILE, 1);
WinEnableControl (hwnd, EF_ICONFILE, TRUE);
} else {
}
//-Settings Pages-----------------------------------------------------------
WinSetDlgItemText (hwnd, EF_ICONFILE, _szIconFile);
}
//=Settings Pages==============================================================
//
// WINPROC: IconFileProc
//
// DESCRIPT: Dialog procedure for the icon file settings page
//
//=============================================================================
MRESULT EXPENTRY IconFileProc (HWND hwnd, ULONG ulMsg, MPARAM mp1, MPARAM mp2){
switch (ulMsg) {
//-Settings Pages--------------------------------------------------------
case WM_INITDLG: {
WPSimple *somSelf = PVOIDFROMMP (mp2);
WPSimpleData *somThis = WPSimpleGetData(somSelf);
//--------------------------------------------------------------------
// Store the self pointer for further use in the window words
//--------------------------------------------------------------------
WinSetWindowPtr (hwnd, QWL_USER, somSelf);
//--------------------------------------------------------------------
// A new (part of a) view is now open and must be informed about
// changes of the instance data
//--------------------------------------------------------------------
_hwndIconFileView = hwnd;
//--------------------------------------------------------------------
// Perhaps the user presses the 'Undo'-button
//--------------------------------------------------------------------
_lIconStateForUndo = _lIconState;
strcpy (_szIconFileForUndo, _szIconFile);
//--------------------------------------------------------------------
// The first notification for a control
//--------------------------------------------------------------------
_fFirstNotification = TRUE;
//--------------------------------------------------------------------
// Delay the refresh of the view
//--------------------------------------------------------------------
WinPostMsg (hwnd, WM_SEM4, MPFROMP (NULL), MPFROMP (NULL));
break;
}
//-----------------------------------------------------------------------
case WM_SEM4: {
WPSimple *somSelf = WinQueryWindowPtr (hwnd, QWL_USER);
WPSimpleData *somThis = WPSimpleGetData(somSelf);
//--------------------------------------------------------------------
// Now it's time to refresh the view
//--------------------------------------------------------------------
_RefreshViews (somSelf);
break;
}
//-----------------------------------------------------------------------
case WM_COMMAND: {
USHORT usID = SHORT1FROMMP (mp1);
USHORT usSource = SHORT1FROMMP (mp2);
//--------------------------------------------------------------------
// 'Undo'-button pressed?
//--------------------------------------------------------------------
if (usID == PB_UNDO && usSource == CMDSRC_PUSHBUTTON) {
WPSimple *somSelf = WinQueryWindowPtr (hwnd, QWL_USER);
WPSimpleData *somThis = WPSimpleGetData(somSelf);
//-----------------------------------------------------------------
// Restore the old information ...
//-----------------------------------------------------------------
_lIconState = _lIconStateForUndo;
strcpy (_szIconFile, _szIconFileForUndo);
//-----------------------------------------------------------------
// ... and force to redisplay it (in all views)
//-----------------------------------------------------------------
_RefreshViews (somSelf);
return ((MRESULT)NULL);
}
break;
}
//-----------------------------------------------------------------------
case WM_CONTROL: {
USHORT usID = SHORT1FROMMP (mp1);
USHORT usNotification = SHORT2FROMMP (mp1);
//--------------------------------------------------------------------
// Is some information changed by the user?
//--------------------------------------------------------------------
if ((usID == EF_ICONFILE && usNotification == EN_KILLFOCUS)
|| (usID == RB_DEFAULTICON1 && usNotification == BN_CLICKED)
|| (usID == RB_DEFAULTICON2 && usNotification == BN_CLICKED)
|| (usID == RB_DEFAULTICON3 && usNotification == BN_CLICKED)
|| (usID == RB_ICONFILE && usNotification == BN_CLICKED)) {
WPSimple *somSelf = WinQueryWindowPtr (hwnd, QWL_USER);
WPSimpleData *somThis = WPSimpleGetData(somSelf);
//-----------------------------------------------------------------
// The first time it's a 'ghost' message from the system
//-----------------------------------------------------------------
if (_fFirstNotification) {
_fFirstNotification = FALSE;
break;
}
//-----------------------------------------------------------------
// Read the changed information ...
//-----------------------------------------------------------------
WinQueryDlgItemText (hwnd, EF_ICONFILE, 256, _szIconFile);
if (WinQueryButtonCheckstate (hwnd, RB_DEFAULTICON1) == 1) {
_lIconState = ICOSTAT_DEFAULTICON1;
} else if (WinQueryButtonCheckstate (hwnd, RB_DEFAULTICON2) == 1) {
_lIconState = ICOSTAT_DEFAULTICON2;
} else if (WinQueryButtonCheckstate (hwnd, RB_DEFAULTICON3) == 1) {
_lIconState = ICOSTAT_DEFAULTICON3;
} else if (WinQueryButtonCheckstate (hwnd, RB_ICONFILE) == 1) {
_lIconState = ICOSTAT_ICONFILE;
} else {
}
//-----------------------------------------------------------------
// ... and force to redisplay it (in all views)
//-----------------------------------------------------------------
_RefreshViews (somSelf);
}
break;
}
//-----------------------------------------------------------------------
case WM_DESTROY: {
WPSimple *somSelf = WinQueryWindowPtr (hwnd, QWL_USER);
WPSimpleData *somThis = WPSimpleGetData(somSelf);
//--------------------------------------------------------------------
// Make the user changes persistent
//--------------------------------------------------------------------
_wpSaveImmediate (somSelf);
//--------------------------------------------------------------------
// The (part of the) view is now closed
//--------------------------------------------------------------------
_hwndIconFileView = NULLHANDLE;
break;
}
}
return (WinDefDlgProc (hwnd, ulMsg, mp1, mp2));
}
//#############################################################################
//=View========================================================================
//
// PROCEDURE: UpdateInfoView
//
// PARAMETER: HWND hwnd - handle of the info view window
// WPSimple somSelf - handle of the object
//
// DESCRIPT: Change the displayed information in the info view,
// if the instance data is changed.
//
//=============================================================================
VOID UpdateInfoView (HWND hwnd, WPSimple *somSelf) {
CHAR szBuffer [100];
WPSimpleData *somThis = WPSimpleGetData(somSelf);
//--------------------------------------------------------------------------
// Clear the list box
//--------------------------------------------------------------------------
WinSendMsg (_hwndListbox, LM_DELETEALL, MPFROMP (NULL), MPFROMP (NULL));
//--------------------------------------------------------------------------
// Enter the information line by line into the listbox
//--------------------------------------------------------------------------
sprintf (szBuffer, "IconState %d", _lIconState);
WinSendMsg (_hwndListbox, LM_INSERTITEM,
MPFROMSHORT (LIT_END), MPFROMP (szBuffer));
sprintf (szBuffer, "IconFile %s", _szIconFile);
WinSendMsg (_hwndListbox, LM_INSERTITEM,
MPFROMSHORT (LIT_END), MPFROMP (szBuffer));
sprintf (szBuffer, "IconFileForUndo %s", _szIconFileForUndo);
WinSendMsg (_hwndListbox, LM_INSERTITEM,
MPFROMSHORT (LIT_END), MPFROMP (szBuffer));
sprintf (szBuffer, "PlayState %d", _lPlayState);
WinSendMsg (_hwndListbox, LM_INSERTITEM,
MPFROMSHORT (LIT_END), MPFROMP (szBuffer));
sprintf (szBuffer, "PictureToDisplay %d", _lPictureToDisplay);
WinSendMsg (_hwndListbox, LM_INSERTITEM,
MPFROMSHORT (LIT_END), MPFROMP (szBuffer));
}
//#############################################################################
// END Ordinary PM Stuff
//#############################################################################