MRESULT EXPENTRY POPUPDlgProc(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2) { HWND hwndFrame = hwndDlg; /* ##START Form.37 Top of window procedure */ /* ##END Top of window procedure */ switch (msg) { /* Form event Opened WM_INITDLG */ case WM_INITDLG : HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2); WinAssociateHelpInstance(pMainFormInfo->hwndHelpInstance, hwndFrame); /* ##START Form.1 */ /* ##END */ break; /* Form event Closed WM_CLOSE */ case WM_CLOSE : /* ##START Form.2 */ /* ##END */ HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2); break; /* Form event Destroyed WM_DESTROY */ case WM_DESTROY : /* ##START Form.3 */ /* ##END */ /* Remove help instance */ WinAssociateHelpInstance((HWND) 0, hwndFrame); HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2); break; case WM_COMMAND : switch (SHORT1FROMMP(mp1)) { } /* end switch */ break; /* Initialize sub menus, if any */ case WM_INITMENU: switch (SHORT1FROMMP(mp1)) { } /* end switch */ break; /* ##START Form.38 User defined messages */ /* ##END User defined messages */ default : HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2); return WinDefDlgProc(hwndDlg,msg,mp1,mp2); } /* end switch for main msg dispatch */ return (MRESULT)FALSE; } /* end dialog procedure */
static MRESULT APIENTRY InitDlg ( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) { /*************************************************************************** * Get parameters from initialization message. * ***************************************************************************/ PPROFILE_PARMS Parms = (PPROFILE_PARMS) ( PVOIDFROMMP ( mp2 ) ) ; WinSetWindowPtr ( hwnd, QWL_USER, Parms ) ; /*************************************************************************** * Set the dialog help instance. * ***************************************************************************/ WinSetWindowUShort ( hwnd, QWS_ID, Parms->id ) ; if ( Parms->hwndHelp ) { WinAssociateHelpInstance ( Parms->hwndHelp, hwnd ) ; } /*************************************************************************** * Set the entry field contents. * ***************************************************************************/ WinSetDlgItemText ( hwnd, Parms->id+ENTRY, Parms->Path ) ; /*************************************************************************** * Return no error. * ***************************************************************************/ return ( MRFROMSHORT ( FALSE ) ) ; }
//=========================================================================== // // Parameters -------------------------------------------------------------- // HWND hwnd : window handle // VOID // Return value ------------------------------------------------------------ // BOOL : TRUE/FALSE (success/error) // VOID //=========================================================================== static VOID endHelp(HWND hwnd, HWND hHlp) { if (hHlp) { WinAssociateHelpInstance(NULLHANDLE, hwnd); WinDestroyHelpInstance(hHlp); } /* endif */ }
static gui_help_instance InitHelp( HWND hwnd, WPI_INST inst, char *title, char *help_lib ) { HWND hwndHelpInstance; HELPINIT help; help.cb = sizeof( HELPINIT ); help.pszTutorialName = NULL; help.phtHelpTable = NULL; help.hmodHelpTableModule = 0; help.hmodAccelActionBarModule = 0; help.idAccelTable = 0; help.idActionBar = 0; help.pszHelpWindowTitle = title; #ifdef __FLAT__ help.fShowPanelId = CMIC_HIDE_PANEL_ID; #else help.usShowPanelId = CMIC_HIDE_PANEL_ID; #endif help.pszHelpLibraryName = help_lib; hwndHelpInstance = WinCreateHelpInstance( inst.hab, &help ); if( hwndHelpInstance != (HWND)NULL ) { if( !WinAssociateHelpInstance( hwndHelpInstance, hwnd ) ) { WinDestroyHelpInstance( hwndHelpInstance ); hwndHelpInstance = NULLHANDLE; } } return( (gui_help_instance)hwndHelpInstance ); }
static void FiniHelp( gui_help_instance inst, HWND hwnd, char *file ) { hwnd=hwnd; file=file; if( (HWND)inst != (HWND)NULL ) { WinAssociateHelpInstance( (HWND)inst, NULLHANDLE ); WinDestroyHelpInstance( (HWND)inst ); } }
/*--------------------------------------------------------------------------------------*\ * Procedure to initialize HELP. * * Req: * * hab ........... Anchor block handle * * pHelpFile ..... A pointer to helppanel filename in SD/2 directory * * pHwndHelp .... A pointer to a HWND structure * * Returns: * * pHwndHelp ..... If called sucessfully/unsucessfully hwnd/NULL * \*--------------------------------------------------------------------------------------*/ BOOL WinStartHelp(HAB hab, UCHAR *pHelpFile, HWND *pHwndHelp) { HELPINIT HelpInit; HelpInit.cb=sizeof(HELPINIT); /* Size of HELPINIT structure */ HelpInit.ulReturnCode=0; /* Returnvalue from HelpManager */ HelpInit.pszTutorialName=NULL; /* No tutorial */ /* Ressource of Helptable */ HelpInit.phtHelpTable=(PHELPTABLE)MAKEULONG(MAIN_HELP_TABLE, 0xffff); /* Ressource in .EXE */ HelpInit.hmodHelpTableModule=NULLHANDLE; /* No handle */ HelpInit.hmodAccelActionBarModule=NULLHANDLE; HelpInit.idAccelTable=0; /* None */ HelpInit.idActionBar=0; /* None */ /* Window title of help window */ HelpInit.pszHelpWindowTitle="SD/2 - ShutDown/2 Help"; HelpInit.pszHelpLibraryName=pHelpFile; /* Library name of help panel via SD/2 directory */ HelpInit.fShowPanelId=0; /* Panel ID not displayed */ /* *\ * First assume ShutDown.HLP in HELP path and try to create it from there. * \* */ *pHwndHelp=WinCreateHelpInstance( /* Create help */ hab, /* Anchor block */ &HelpInit); /* Test for successful help creation */ if((*pHwndHelp) && (!HelpInit.ulReturnCode)) /* Associate HELP with frame window */ if(WinAssociateHelpInstance(*pHwndHelp, hwndFrame)!=FALSE) return(TRUE); /* *\ * Second assume ShutDown.HLP in SD/2's directory and try to create it from there. * \* */ HelpInit.ulReturnCode=0; /* Returnvalue from HelpManager */ /* Library name of help panel via HELP path */ HelpInit.pszHelpLibraryName="ShutDown.hlp"; *pHwndHelp=WinCreateHelpInstance(hab, &HelpInit); if((*pHwndHelp) && (!HelpInit.ulReturnCode)) if(WinAssociateHelpInstance(*pHwndHelp, hwndFrame)!=FALSE) return(TRUE); *pHwndHelp=NULLHANDLE; return(FALSE); }
/****************************************************************\ * Routine for initializing the help manager *-------------------------------------------------------------- * * Name: HelpInit() * * Purpose: Initializes the IPF help facility * * Usage: Called once during initialization of the program * * Method: Initializes the HELPINIT structure and creates the * help instance. If successful, the help instance * is associated with the main window * * Returns: * \****************************************************************/ BOOL HelpInit(PAGECFG *pstCFG) { char szMessage[200]; HELPINIT hini; HWND hwndHelpInstance; fHelpEnabled = FALSE; hini.cb = sizeof(HELPINIT); hini.ulReturnCode = 0L; hini.pszTutorialName = (PSZ)NULL; hini.phtHelpTable = 0;//(PHELPTABLE)MAKELONG(COMSCOPE_HELP_TABLE, 0xFFFF); hini.hmodHelpTableModule = (HMODULE)0; hini.hmodAccelActionBarModule = (HMODULE)0; hini.idAccelTable = 0; hini.idActionBar = 0; hini.pszHelpWindowTitle = szHelpTitle; // if debugging, show panel ids, else don't #if DEBUG > 0 hini.fShowPanelId = CMIC_SHOW_PANEL_ID; #else hini.fShowPanelId = CMIC_HIDE_PANEL_ID; #endif hini.pszHelpLibraryName = szHelpFileSpec; sprintf(szHelpFileSpec,"%s\\%s",pstCFG->pszDestPath,pstCFG->pszHelpFileName); // creating help instance hwndHelpInstance = WinCreateHelpInstance(pstCFG->hab,&hini); if((hwndHelpInstance != 0) && (hini.ulReturnCode == 0)) { // associate help instance with main frame if(!WinAssociateHelpInstance(hwndHelpInstance,pstCFG->hwndFrame)) { sprintf(szMessage,"Unable to associate help instance with file %s - %u",szHelpFileSpec,pstCFG->hwndFrame); MessageBox(szMessage,(MB_OK | MB_ERROR)); return(0); } } else { sprintf(szMessage,"Unable to load help file %s - %u",szHelpFileSpec,strlen(szHelpFileSpec)); hwndHelpInstance = 0; MessageBox(szMessage,(MB_OK | MB_ERROR)); return(0); } /* ** help manager is successfully initialized so set flag to TRUE */ fHelpEnabled = TRUE; WinSetHook(pstCFG->hab,HMQ_CURRENT,HK_HELP,(PFN)pfnMessageBoxHelpHook,0L); return(hwndHelpInstance); }
MRESULT EXPENTRY PrintSetupProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { PPRINTSETUP pPrintSetup = WinQueryWindowPtr(hwnd, QWL_USER); switch(msg) { case WM_INITDLG: pPrintSetup = (PPRINTSETUP) mp2; InitPrintSetup(pPrintSetup, anchor); InsertPrintSetupPages(WinWindowFromID(hwnd, IDD_PRINTSETUP+1), pPrintSetup); RestoreWinPos(hwnd, &pPrintSetup->DlgPos, TRUE, TRUE); WinSetWindowPtr(hwnd, QWL_USER, pPrintSetup); break; case WM_ADJUSTFRAMEPOS: SizeToClient(anchor, (PSWP) mp1, hwnd, IDD_PRINTSETUP+1); break; case WM_WINDOWPOSCHANGED: if (WinQueryWindowPtr(hwnd, QWL_USER)) SaveWinPos(hwnd, (PSWP) mp1, &pPrintSetup->DlgPos, &pPrintSetup->bDirty); break; case WM_ACTIVATE: if (mp1) WinAssociateHelpInstance(hwndhelp, hwnd); else WinAssociateHelpInstance(hwndhelp, NULLHANDLE); break; default: break; } return WinDefDlgProc(hwnd, msg, mp1, mp2); }
Helper :: Helper (HWND hwnd) { HELPINIT helpInit; // if we return because of an error, Help will be disabled fHelpEnabled = TRUE; // inititalize help init structure helpInit.cb = sizeof (HELPINIT); helpInit.ulReturnCode = 0L; helpInit.pszTutorialName = PSZ (NULL); helpInit.phtHelpTable = PHELPTABLE (MAKELONG (MAIN_HELP_TABLE, 0xFFFF)); helpInit.hmodHelpTableModule = GETMODULE; helpInit.hmodAccelActionBarModule = GETMODULE; helpInit.idAccelTable = 0; helpInit.idActionBar = 0; helpInit.pszHelpWindowTitle = PSZ (PSZ_NAMEVERSION); helpInit.fShowPanelId = CMIC_HIDE_PANEL_ID; CHAR ach[_MAX_FNAME+_MAX_EXT]; sprintf (ach, "%s.hlp", pset->QueryString (SEI_LANGUAGEHELP)); helpInit.pszHelpLibraryName = PSZ (ach); // create the help instance hwndHelpInstance = WinCreateHelpInstance (hab, &helpInit); if (!hwndHelpInstance || helpInit.ulReturnCode) { DisplayError (RSTR (IDS_ERROR_HELPERHEADING), RSTR (IDS_ERROR_COULDNOTINITHELPFILE), ach); fHelpEnabled = FALSE; } // associate help instance with main frame if (! WinAssociateHelpInstance (hwndHelpInstance, hwnd)) { DisplayError (RSTR (IDS_ERROR_HELPERHEADING), RSTR (IDS_ERROR_COULDNOTINITHELP)); fHelpEnabled = FALSE; } }
//=========================================================================== // // Parameters -------------------------------------------------------------- // HWND hwnd : window handle // VOID // Return value ------------------------------------------------------------ // BOOL : TRUE/FALSE (success/error) // VOID //=========================================================================== static HWND initHelp(HWND hwnd) { HWND hHlp; CHAR buf[256]; HELPINIT hi; memset(&hi, 0, sizeof(HELPINIT)); hi.cb = sizeof(HELPINIT); hi.phtHelpTable = PHLPTBLFROMID(HLP_MAIN); hi.pszHelpWindowTitle = SZ_TITLE; hi.fShowPanelId = CMIC_HIDE_PANEL_ID; hi.pszHelpLibraryName = SZFILE_HLP; if (!(hHlp = WinCreateHelpInstance(WinQueryAnchorBlock(hwnd), &hi))) return NULLHANDLE; if (hi.ulReturnCode) { WinDestroyHelpInstance(hHlp); hHlp = NULLHANDLE; } else { WinAssociateHelpInstance(hHlp, hwnd); } /* endif */ return hHlp; }
VOID CDialog::WinHelp (PSZ help_file, int topic_id, PSZ title) { CHAR helpFile[128]; getcwd (helpFile, sizeof (helpFile) - 1); if (helpFile[strlen (helpFile) - 1] != '\\') strcat (helpFile, "\\"); strcat (helpFile, help_file); #if defined(__OS2__) CHAR *p; HELPINIT hini; if ((p = strchr (helpFile, '>')) != NULL) *p = '\0'; if (help_hWnd == NULL) { hini.cb = sizeof (HELPINIT); hini.ulReturnCode = 0L; hini.pszTutorialName = NULL; hini.phtHelpTable = (PHELPTABLE)MAKELONG (1, 0xFFFF); hini.hmodHelpTableModule = NULL; hini.hmodAccelActionBarModule = NULL; hini.idAccelTable = 0; hini.idActionBar = 0; hini.pszHelpWindowTitle = title; hini.fShowPanelId = CMIC_HIDE_PANEL_ID; hini.pszHelpLibraryName = helpFile; if ((help_hWnd = WinCreateHelpInstance (hab, &hini)) != NULL) WinAssociateHelpInstance (help_hWnd, owner_hWnd); } if (help_hWnd != NULL) WinSendMsg (help_hWnd, HM_DISPLAY_HELP, MPFROM2SHORT (topic_id, 0), MPFROMSHORT (HM_RESOURCEID)); #elif defined(__NT__) title = title; ::WinHelp (owner_hWnd, helpFile, HELP_CONTEXT, topic_id); #endif }
/************************************************************************** * * FUNCTION NAME: InitHelp * * DESCRIPTION: * * * INPUT PARAMETERS: * None. * * OUTPUT PARAMETERS: * None. * **************************************************************************/ VOID InitHelp (VOID) { HELPINIT hini; /* inititalize help init structure */ hini.cb = sizeof (HELPINIT); hini.ulReturnCode = 0L; hini.pszTutorialName = (PSZ) NULL; hini.phtHelpTable = (PHELPTABLE) MAKELONG (DEF_HELP_TABLE, 0xFFFF); hini.hmodHelpTableModule = (HMODULE) 0; hini.hmodAccelActionBarModule = (HMODULE) 0; hini.idAccelTable = 0; hini.idActionBar = 0; hini.pszHelpWindowTitle = "Aquanaut! Help"; hini.fShowPanelId = CMIC_HIDE_PANEL_ID; hini.pszHelpLibraryName = "aquanaut.hlp"; /* creating help instance */ hwndHelpInstance = WinCreateHelpInstance (hab, &hini); /* associate help instance with main frame */ WinAssociateHelpInstance (hwndHelpInstance, hwndDefFrame); }
/**************************************************************************** * Shutdown * * - Cleans up and terminates ASTEROID, returning any error conditions. * * - Receives error code. * ****************************************************************************/ VOID Shutdown(ULONG ulErrLevel) { /* Stop the timer. */ TogglePause(FORCE_PAUSE); /* Destroy the help instance if it was created */ if (hwndHelp != NULLHANDLE) { WinAssociateHelpInstance(NULLHANDLE, hwndFrame); WinDestroyHelpInstance(hwndHelp); } /* Destroy Object and Frame windows. */ if (hwndObject != NULLHANDLE) WinDestroyWindow(hwndObject); if (hwndFrame != NULLHANDLE) WinDestroyWindow(hwndFrame); /* Destroy the message queue and let PM clean up. */ WinDestroyMsgQueue(hmq); WinTerminate(hab); /* Return error code if any. */ DosExit(EXIT_PROCESS, ulErrLevel); }
MRESULT EXPENTRY O_CONFIGDlgProc(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2) { PO_CONFIGFORMINFO pO_CONFIGFormInfo=(PO_CONFIGFORMINFO) WinQueryWindowULong(hwndDlg, QWL_USER); HWND hwndFrame = hwndDlg; /* ##START Form.37 Top of window procedure */ /* ##END Top of window procedure */ switch (msg) { /* Form event Opened WM_INITDLG */ case WM_INITDLG : if (mp2==0) mp2 = (MPARAM) malloc(sizeof(O_CONFIGFORMINFO)); HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2); pO_CONFIGFormInfo=(PO_CONFIGFORMINFO) WinQueryWindowULong(hwndDlg, QWL_USER); WinAssociateHelpInstance(pMainFormInfo->hwndHelpInstance, hwndFrame); { /* ##START Form.1 */ /* Event Opened - Form STICKY2\O_CONFIG */ CHAR aTextValue[255]="text"; LONG anIntegerValue=0; ULONG anUnsignedValue=0; c_cas = c_car = c_pop = c_aus = c_beep = c_mini = c_clr = 0; WinCheckButton(hwndDlg, SEND_CONFIG, CheckYes(gAfterSend)); WinCheckButton(hwndDlg, REPLY_CONFIG, CheckYes(gAfterReply)); WinCheckButton(hwndDlg, BACKGROUND_CONFIG, CheckYes(gPUS)); WinCheckButton(hwndDlg, SURE_CONFIG, CheckYes(gSure)); WinCheckButton(hwndDlg, MINI_CONFIG, CheckYes(gStickyIcon)); WinCheckButton(hwndDlg, BEEP_CONFIG, CheckYes(gBeep)); if (CheckNo(gBeep)) { WinEnableControl(hwndDlg, 1006, FALSE); WinEnableControl(hwndDlg, 1007, FALSE); WinEnableControl(hwndDlg, FREQUENCY_CONFIG, FALSE); WinEnableControl(hwndDlg, DURATION_CONFIG, FALSE); } /* end if */ /* Set range (numeric style) FREQUENCY_CONFIG Spin Button */ WinSendDlgItemMsg(hwndDlg, FREQUENCY_CONFIG, SPBM_SETLIMITS, MPFROMLONG(5000), /* Upper limit */ MPFROMLONG(10)); /* Lower limit */ WinSendDlgItemMsg(hwndDlg, DURATION_CONFIG, SPBM_SETLIMITS, MPFROMLONG(1000), /* Upper limit */ MPFROMLONG(10)); /* Lower limit */ WinSendDlgItemMsg(hwndDlg, FREQUENCY_CONFIG, SPBM_SETCURRENTVALUE, MPFROMLONG(atol(gFreq)), /* Value within range */ 0); WinSendDlgItemMsg(hwndDlg, DURATION_CONFIG, SPBM_SETCURRENTVALUE, MPFROMLONG(atol(gDur)), /* Value within range */ 0); /* Set range without update CLEAR_CONFIG Spin Button */ WinSendDlgItemMsg(hwndDlg, CLEAR_CONFIG, SPBM_OVERRIDESETLIMITS, MPFROMLONG(120), /* Upper limit */ MPFROMLONG(0)); /* Lower limit */ /* Set item value (numeric style) CLEAR_CONFIG Spin Button */ WinSendDlgItemMsg(hwndDlg, CLEAR_CONFIG, SPBM_SETCURRENTVALUE, MPFROMLONG(atol(gClearAuto)), /* Value within range */ 0); /* ##END */ } break; /* Form event Closed WM_CLOSE */ case WM_CLOSE : { /* ##START Form.2 */ /* Event Closed - Form STICKY2\O_CONFIG */ CHAR aTextValue[255]="text"; LONG anIntegerValue=0; ULONG anUnsignedValue=0; MsgLog("Closing O_CONFIG"); if (c_mini) { SWP swp; anUnsignedValue=(ULONG)WinQueryButtonCheckstate(hwndDlg,MINI_CONFIG); strcpy(gStickyIcon, anUnsignedValue ? gYes : gNo); PutString(S_StickyIcon, gStickyIcon); WinQueryWindowPos(gHwndFrame, &swp); if (swp.fl & SWP_RESTORE) { MsgLog("O_CONFIG - RESTORE"); WinPostMsg(gHwndFrame, WM_USER_RESTORE, 0, 0); } } /* end if */ if (c_cas) { anUnsignedValue=(ULONG)WinQueryButtonCheckstate(hwndDlg,SEND_CONFIG); strcpy(gAfterSend, anUnsignedValue ? gYes : gNo); PutString(S_CloseAfterSend, gAfterSend); } /* end if */ if (c_car) { anUnsignedValue=(ULONG)WinQueryButtonCheckstate(hwndDlg,REPLY_CONFIG); strcpy(gAfterReply, anUnsignedValue ? gYes: gNo ); PutString(S_CloseAfterReply, gAfterReply); } /* end if */ if (c_pop) { anUnsignedValue=(ULONG)WinQueryButtonCheckstate(hwndDlg,BACKGROUND_CONFIG); strcpy(gPUS, anUnsignedValue ? gYes: gNo ); PutString(S_PopUpSticky, gPUS); } /* end if */ if (c_aus) { anUnsignedValue=(ULONG)WinQueryButtonCheckstate(hwndDlg,SURE_CONFIG); strcpy(gSure, anUnsignedValue ? gYes : gNo ); PutString(S_AreYouSure, gSure ); } /* end if */ if (c_beep) { anUnsignedValue=(ULONG)WinQueryButtonCheckstate(hwndDlg,BEEP_CONFIG); PutString(S_Beep, anUnsignedValue ? gYes: gNo ); strcpy(gBeep, anUnsignedValue ? gYes : gNo); } /* end if */ /* Get item value (numeric style) FREQUENCY_CONFIG Spin Button */ WinSendDlgItemMsg(hwndDlg, FREQUENCY_CONFIG, SPBM_QUERYVALUE, MPFROMP(&anUnsignedValue), /* Buffer for value */ MPFROM2SHORT(0,SPBQ_ALWAYSUPDATE)); if (atol(gFreq) != anUnsignedValue) { sprintf(gFreq, "%d", anUnsignedValue); PutString(S_Frequency, gFreq); } /* end if */ /* Get item value (numeric style) DURATION_CONFIG Spin Button */ WinSendDlgItemMsg(hwndDlg, DURATION_CONFIG, SPBM_QUERYVALUE, MPFROMP(&anUnsignedValue), /* Buffer for value */ MPFROM2SHORT(0,SPBQ_ALWAYSUPDATE)); if (atol(gDur) != anUnsignedValue) { sprintf(gDur, "%d", anUnsignedValue); PutString(S_Duration, gDur); } /* end if */ /* Get item value (numeric style) DURATION_CONFIG Spin Button */ WinSendDlgItemMsg(hwndDlg, CLEAR_CONFIG, SPBM_QUERYVALUE, MPFROMP(&anUnsignedValue), /* Buffer for value */ MPFROM2SHORT(0,SPBQ_ALWAYSUPDATE)); if (atol(gClearAuto) != anUnsignedValue) { sprintf(gClearAuto, "%d", anUnsignedValue); PutString(S_ClearAuto, gClearAuto); } /* end if */ /* ##END */ } HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2); break; /* Form event Destroyed WM_DESTROY */ case WM_DESTROY : /* ##START Form.3 */ /* ##END */ /* Remove help instance */ WinAssociateHelpInstance((HWND) 0, hwndFrame); HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2); break; case WM_COMMAND : switch (SHORT1FROMMP(mp1)) { } /* end switch */ break; case WM_CONTROL : switch (SHORT1FROMMP(mp1)) { /* Check Box SEND_CONFIG Event Handlers */ case SEND_CONFIG: switch (SHORT2FROMMP(mp1)) { /* Clicked/Selected */ case BN_CLICKED: { /* ##START 1000.0 */ /* Event Clicked/Selected - Close window after Send SEND_CONFIG */ c_cas = 1; /* ##END */ } break; } /* end switch */ break; /* Check Box REPLY_CONFIG Event Handlers */ case REPLY_CONFIG: switch (SHORT2FROMMP(mp1)) { /* Clicked/Selected */ case BN_CLICKED: { /* ##START 1001.0 */ /* Event Clicked/Selected - Close Window after Reply REPLY_CONFIG */ c_car = 1; /* ##END */ } break; } /* end switch */ break; /* Check Box BACKGROUND_CONFIG Event Handlers */ case BACKGROUND_CONFIG: switch (SHORT2FROMMP(mp1)) { /* Clicked/Selected */ case BN_CLICKED: { /* ##START 1002.0 */ /* Event Clicked/Selected - Popup Sticky on Receive BACKGROUND_CONFIG */ c_pop = 1; /* ##END */ } break; } /* end switch */ break; /* Check Box BEEP_CONFIG Event Handlers */ case BEEP_CONFIG: switch (SHORT2FROMMP(mp1)) { /* Clicked/Selected */ case BN_CLICKED: { /* ##START 1003.0 */ /* Event Clicked/Selected - Beep BEEP_CONFIG */ ULONG anUnsignedValue; c_beep = 1; /* Is button selected? BEEP_CONFIG Check Box */ anUnsignedValue=(ULONG)WinQueryButtonCheckstate(hwndDlg,BEEP_CONFIG); WinEnableControl(hwndDlg, 1006, anUnsignedValue); WinEnableControl(hwndDlg, 1007, anUnsignedValue); WinEnableControl(hwndDlg, FREQUENCY_CONFIG, anUnsignedValue); WinEnableControl(hwndDlg, DURATION_CONFIG, anUnsignedValue); /* ##END */ } break; } /* end switch */ break; /* Check Box SURE_CONFIG Event Handlers */ case SURE_CONFIG: switch (SHORT2FROMMP(mp1)) { /* Clicked/Selected */ case BN_CLICKED: { /* ##START 1009.0 */ /* Event Clicked/Selected - Are You Sure Prompts SURE_CONFIG */ c_aus = 1; /* ##END */ } break; } /* end switch */ break; /* Check Box MINI_CONFIG Event Handlers */ case MINI_CONFIG: switch (SHORT2FROMMP(mp1)) { /* Clicked/Selected */ case BN_CLICKED: { /* ##START 1010.0 */ /* Event Clicked/Selected - Mini ICON when shrunk MINI_CONFIG */ CHAR aTextValue[255]="text"; LONG anIntegerValue=0; ULONG anUnsignedValue=0; c_mini = 1; /* ##END */ } break; } /* end switch */ break; } /* end switch */ break; /* ##START Form.38 User defined messages */ /* ##END User defined messages */ default : HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2); return WinDefDlgProc(hwndDlg,msg,mp1,mp2); } /* end switch for main msg dispatch */ return (MRESULT)FALSE; } /* end dialog procedure */
MRESULT EXPENTRY O_AUTODlgProc(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2) { PO_AUTOFORMINFO pO_AUTOFormInfo=(PO_AUTOFORMINFO) WinQueryWindowULong(hwndDlg, QWL_USER); HWND hwndFrame = hwndDlg; /* ##START Form.37 Top of window procedure */ /* ##END Top of window procedure */ switch (msg) { /* Form event Opened WM_INITDLG */ case WM_INITDLG : if (mp2==0) mp2 = (MPARAM) malloc(sizeof(O_AUTOFORMINFO)); HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2); pO_AUTOFormInfo=(PO_AUTOFORMINFO) WinQueryWindowULong(hwndDlg, QWL_USER); WinAssociateHelpInstance(pMainFormInfo->hwndHelpInstance, hwndFrame); { /* ##START Form.1 */ /* Event Opened - Form STICKY2\O_CONFIG */ CHAR aTextValue[255]="text"; LONG anIntegerValue=0; ULONG anUnsignedValue=0; c_e = c_v = c_t = c_n = 0; WinCheckButton(hwndDlg, ENABLE_AUTO, CheckYes(gAutoReply)); WinCheckButton(hwndDlg, VERSION_AUTO, CheckYes(gAutoVer)); WinCheckButton(hwndDlg, TIME_AUTO, CheckYes(gAutoTime)); WinCheckButton(hwndDlg, NAME_AUTO, CheckYes(gAutoName)); /* Set text limit TEXT_AUTO Multi-Line Entry Field */ WinSendDlgItemMsg(hwndDlg, TEXT_AUTO, MLM_SETTEXTLIMIT, MPFROMLONG(255), /* New text limit */ 0); /* Set item text TEXT_AUTO Multi-Line Entry Field */ WinSetDlgItemText(hwndDlg, TEXT_AUTO, gAutoText); if (CheckNo(gAutoReply)) { WinEnableControl(hwndDlg, 1004, FALSE); WinEnableControl(hwndDlg, VERSION_AUTO, FALSE); WinEnableControl(hwndDlg, TIME_AUTO, FALSE); WinEnableControl(hwndDlg, NAME_AUTO, FALSE); WinEnableControl(hwndDlg, TEXT_AUTO, FALSE); } /* end if */ /* ##END */ } break; /* Form event Closed WM_CLOSE */ case WM_CLOSE : { /* ##START Form.2 */ /* Event Closed - Form STICKY2\O_CONFIG */ CHAR aTextValue[512]; LONG anIntegerValue=0; ULONG anUnsignedValue=0; CHAR *c_ptr, *e_ptr; MsgLog("Closing O_AUTO"); if (c_e) { anUnsignedValue=(ULONG)WinQueryButtonCheckstate(hwndDlg, ENABLE_AUTO); strcpy(gAutoReply, anUnsignedValue ? gYes : gNo); PutString(S_AutoReply, gAutoReply); } /* end if */ if (c_v) { anUnsignedValue=(ULONG)WinQueryButtonCheckstate(hwndDlg, VERSION_AUTO); strcpy(gAutoVer, anUnsignedValue ? gYes : gNo); PutString(S_AutoVer, gAutoVer); } /* end if */ if (c_t) { anUnsignedValue=(ULONG)WinQueryButtonCheckstate(hwndDlg, TIME_AUTO); strcpy(gAutoTime, anUnsignedValue ? gYes : gNo); PutString(S_AutoTime, gAutoTime); } /* end if */ if (c_n) { anUnsignedValue=(ULONG)WinQueryButtonCheckstate(hwndDlg, NAME_AUTO); strcpy(gAutoName, anUnsignedValue ? gYes : gNo); PutString(S_AutoName, gAutoName); } /* end if */ /* Has text value changed? TEXT_AUTO Multi-Line Entry Field */ if((ULONG)WinSendDlgItemMsg(hwndDlg, TEXT_AUTO, MLM_QUERYCHANGED , 0, 0)) { WinQueryDlgItemText(hwndDlg, TEXT_AUTO, sizeof(aTextValue), aTextValue); strcpy(gAutoText, aTextValue); e_ptr = strchr(aTextValue, '\r'); while (e_ptr) { *e_ptr = '~'; e_ptr = strchr(e_ptr, '\r'); } /* end while */ e_ptr = strchr(aTextValue, '\n'); while (e_ptr) { *e_ptr = '^'; e_ptr = strchr(e_ptr, '\n'); } /* end while */ PutString(S_AutoText, aTextValue); } /* ##END */ } HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2); break; /* Form event Destroyed WM_DESTROY */ case WM_DESTROY : /* ##START Form.3 */ /* ##END */ /* Remove help instance */ WinAssociateHelpInstance((HWND) 0, hwndFrame); HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2); break; case WM_COMMAND : switch (SHORT1FROMMP(mp1)) { } /* end switch */ break; case WM_CONTROL : switch (SHORT1FROMMP(mp1)) { /* Check Box ENABLE_AUTO Event Handlers */ case ENABLE_AUTO: switch (SHORT2FROMMP(mp1)) { /* Clicked/Selected */ case BN_CLICKED: { /* ##START 1000.0 */ /* Event Clicked/Selected - Enable Auto Reply ENABLE_AUTO */ CHAR aTextValue[255]="text"; LONG anIntegerValue=0; ULONG anUnsignedValue=0; c_e = 1; /* Is button selected? BEEP_CONFIG Check Box */ anUnsignedValue=(ULONG)WinQueryButtonCheckstate(hwndDlg,ENABLE_AUTO); WinEnableControl(hwndDlg, 1004, anUnsignedValue); WinEnableControl(hwndDlg, VERSION_AUTO, anUnsignedValue); WinEnableControl(hwndDlg, TIME_AUTO, anUnsignedValue); WinEnableControl(hwndDlg, NAME_AUTO, anUnsignedValue); WinEnableControl(hwndDlg, TEXT_AUTO, anUnsignedValue); /* ##END */ } break; } /* end switch */ break; /* Check Box VERSION_AUTO Event Handlers */ case VERSION_AUTO: switch (SHORT2FROMMP(mp1)) { /* Clicked/Selected */ case BN_CLICKED: { /* ##START 1001.0 */ /* Event Clicked/Selected - Include Version number VERSION_AUTO */ c_v = 1; /* ##END */ } break; } /* end switch */ break; /* Check Box TIME_AUTO Event Handlers */ case TIME_AUTO: switch (SHORT2FROMMP(mp1)) { /* Clicked/Selected */ case BN_CLICKED: { /* ##START 1002.0 */ /* Event Clicked/Selected - Include Local Time Received TIME_AUTO */ c_t = 1; /* ##END */ } break; } /* end switch */ break; /* Check Box NAME_AUTO Event Handlers */ case NAME_AUTO: switch (SHORT2FROMMP(mp1)) { /* Clicked/Selected */ case BN_CLICKED: { /* ##START 1003.0 */ /* Event Clicked/Selected - Include Your Name NAME_AUTO */ c_n = 1; /* ##END */ } break; } /* end switch */ break; } /* end switch */ break; /* ##START Form.38 User defined messages */ /* ##END User defined messages */ default : HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2); return WinDefDlgProc(hwndDlg,msg,mp1,mp2); } /* end switch for main msg dispatch */ return (MRESULT)FALSE; } /* end dialog procedure */
/*...sHlpActivate:0:*/ VOID HlpActivate(HWND hwndHelp, HWND hwndFrame) { if ( !WinAssociateHelpInstance(hwndHelp, hwndFrame)) HlpWarning(hwndFrame, "Unable to associate help instance"); }
MRESULT EXPENTRY AreaSettingsProc(HWND parent, ULONG message, MPARAM mp1, MPARAM mp2) { extern WINDOWPOSITIONS windowpositions; extern HWND hwndhelp; char pchTemp[200]; char pchTitle[250]; HWND notebook=NULLHANDLE; MRESULT resultbuf=0; int rc; switch(message) { case WM_INITDLG: notebook=WinWindowFromID(parent,IDD_AREASETTINGS+1); AddCancelItem(parent); InsertSettingsPages(notebook, (PVOID) mp2); WinSetWindowULong(parent, QWL_USER, ((PAREAPAR)mp2)->bMultiple); RestoreWinPos(parent, &windowpositions.areasetuppos, TRUE, TRUE); WinAssociateHelpInstance(hwndhelp, parent); break; case WM_ADJUSTFRAMEPOS: SizeToClient(anchor, (PSWP) mp1, parent, IDD_AREASETTINGS+1); break; case WM_QUERYTRACKINFO: /* Default-Werte aus Original-Prozedur holen */ resultbuf=WinDefDlgProc(parent,message,mp1,mp2); /* Minimale Fenstergroesse einstellen */ ((PTRACKINFO)mp2)->ptlMinTrackSize.x=255; ((PTRACKINFO)mp2)->ptlMinTrackSize.y=190; return resultbuf; case WM_CLOSE: if (!WinQueryWindowULong(parent, QWL_USER)) { /* Message an alle Windows schicken */ rc = SendToAllPages(WinWindowFromID(parent, IDD_AREASETTINGS+1), APM_REQCLOSE, NULL, NULL); if (rc == 1) return (MRESULT) FALSE; if (rc == 2) { SendToAllPages(WinWindowFromID(parent, IDD_AREASETTINGS+1), APM_CANCEL, NULL, NULL); WinDismissDlg(parent, DID_CANCEL); } else WinDismissDlg(parent, DID_OK); } else WinDismissDlg(parent, DID_OK); QueryWinPos(parent, &(windowpositions.areasetuppos)); WinAssociateHelpInstance(hwndhelp, WinQueryWindow(parent, QW_OWNER)); return (MRESULT) FALSE; case APM_SETTITLE: if (!((PCHAR) mp1)[0]) LoadString(IDST_AP_EMPTYTITLE, 250, pchTitle); else { LoadString(IDST_AP_TITLE, 200, pchTemp); sprintf(pchTitle, pchTemp, (PCHAR) mp1); } WinSetWindowText(parent, pchTitle); break; case WM_COMMAND: if (SHORT1FROMMP(mp1) == IDM_AS_CANCEL) { SendToAllPages(WinWindowFromID(parent, IDD_AREASETTINGS+1), APM_CANCEL, NULL, NULL); WinDismissDlg(parent, DID_CANCEL); } return (MRESULT) FALSE; default: break; } return WinDefDlgProc(parent,message,mp1,mp2); }
/************************************************************************** * * Name : HelpInit() * * Description: Initializes the IPF help facility * * Concepts : Called once during initialization of the program * * Initializes the HELPINIT structure and creates the * help instance. If successful, the help instance * is associated with the main window. * * API's : WinLoadString * WinCreateHelpInstance * WinAssociateHelpInstance * * Parameters : [none] * * Return : [none] * *************************************************************************/ VOID HelpInit(VOID) { HELPINIT hini; CHAR szLibName[HELPLIBRARYNAMELEN]; CHAR szWindowTitle[HELPLIBRARYNAMELEN]; /* inititalize help init structure */ hini.cb = sizeof(HELPINIT); hini.ulReturnCode = 0; hini.pszTutorialName = (PSZ)NULL; /* if tutorial added, add name here */ hini.phtHelpTable = (PHELPTABLE)(0xFFFF0000 | IMAGE_HELP_TABLE); hini.hmodHelpTableModule = 0; hini.hmodAccelActionBarModule = 0; hini.idAccelTable = 0; hini.idActionBar = 0; #if (defined(PORT_16) || defined(PORT_S116)) #ifdef DEBUG hini.usShowPanelId = CMIC_SHOW_PANEL_ID; #else hini.usShowPanelId = CMIC_HIDE_PANEL_ID; #endif /* DEBUG */ #else /* NOT PORT_16 */ #ifdef DEBUG hini.fShowPanelId = CMIC_SHOW_PANEL_ID; #else hini.fShowPanelId = CMIC_HIDE_PANEL_ID; #endif /* DEBUG */ #endif /* NOT PORT_16 */ if (!WinLoadString(vhab, (HMODULE)0, IDS_HELPWINDOWTITLE, HELPLIBRARYNAMELEN, (PSZ)szWindowTitle)) { MessageBox(vhwndFrame, IDMSG_CANNOTLOADSTRING, 0, MB_OK | MB_ERROR, FALSE); return; } hini.pszHelpWindowTitle = (PSZ)szWindowTitle; if (!WinLoadString(vhab, (HMODULE)0, IDS_HELPLIBRARYNAME, HELPLIBRARYNAMELEN, (PSZ)szLibName)) { MessageBox(vhwndFrame, IDMSG_CANNOTLOADSTRING, 0, MB_OK | MB_ERROR, FALSE); return; } hini.pszHelpLibraryName = (PSZ)szLibName; /* creating help instance */ hwndHelpInstance = WinCreateHelpInstance(vhab, &hini); if (!hwndHelpInstance || hini.ulReturnCode) { MessageBox(vhwndFrame, IDMSG_HELPLOADERROR, 0, MB_OK | MB_ERROR, FALSE); return; } /* associate help instance with main frame */ if (!WinAssociateHelpInstance(hwndHelpInstance, vhwndFrame)) { MessageBox(vhwndFrame, IDMSG_HELPLOADERROR, 0, MB_OK | MB_ERROR, FALSE); return; } /* set flag to enable Help menu items */ vfHelpEnabled = TRUE; } /* End of HelpInit */
/************************************************************************** * * Name : main(argc, argv) * * Description: Initializes the application, gets and dispatches messages * for the client window on thread 1 and terminates the * application when a WM_QUIT message is received. It then * saves the configuration in os2.ini, destroys all OS/2 * PM resources, and terminates. * * The following routine is the Presentation Manager program * main body. The main body of a PM program is concerned with * associating the application with the Presentation Manager * system, creating its message queue, registering and displaying * its main window, servicing its message queue during the time * that the application is active, and disassociating the * application from PM when the user is finished with the * it. The remaining parts of this source module that are * concerned with the Presentation Manager are the application's * window procedures (main window procedure, child window * procedures, and dialog window procedures) that process the * messages associated with the application's various windows. * * Concepts : - obtains anchor block handle and creates message * queue * - creates the main frame window which creates the * main client window * - polls the message queue via Get/Dispatch Msg loop * - upon exiting the loop, exits * * API's : WinInitialize * WinCreateMsgQueue * WinRegisterClass * WinLoadString * WinCreateHelpInstance * WinMessageBox * WinCreateStdWindow * WinQueryWindowULong * WinAssociateHelpInstance * WinAddSwitchEntry * WinGetMsg * WinDispatchMsg * WinRemoveSwitchEntry * WinDestroyHelpInstance * WinDestroyWindow * WinDestroyMsgQueue * WinTerminate * * Parameters : [none] * * Return : Always returns zero. The ANSI standard requires that * main be declared as an INT. * *************************************************************************/ INT main(INT argc, CHAR **argv) { /* Define variables by type */ BOOL bOK; /* Boolean used for return code */ HAB hab; /* PM anchor block handle */ HMQ hmq; /* Message queue handle */ QMSG qmsg; /* Message from message queue */ ULONG ulCtlData; /* Standard window create flags */ HWND hwndFrame; /* Frame window handle */ HWND hwndClient; /* Client area window handle */ HWND hwndHelp; /* Help window handle */ PMAIN_PARM pmp; /* Main parameters structure */ SWCNTRL swctl; /* Struct to add to window list */ HSWITCH hsw; /* Window list handle ret'd */ HELPINIT hmi; /* Struct for help creation */ CHAR szWork[ LEN_WORKSTRING ]; /* General use string work area */ PSZ pszTitle; /* Pointer to program title */ /* normal PM application startup */ hab = WinInitialize( 0 ); hmq = WinCreateMsgQueue( hab, 0 ); /* * Register a class for my client window's behavior. * This class has enough extra window words to hold a pointer. */ bOK = WinRegisterClass( hab, CLASSNAME, WinProc, CS_SIZEREDRAW, sizeof( PMAIN_PARM )); /* * Ensure WinRegisterClass worked ok; if not, present a message box. * ( See pmassert.h. ) */ pmassert( hab, bOK ); /* Load program title and allocate a local copy. Use it in help creation. */ WinLoadString( hab, (HMODULE)NULLHANDLE, PROGRAM_TITLE, LEN_WORKSTRING, szWork ); pszTitle = strdup( szWork ); /* Create help. */ memset( &hmi, 0, sizeof( hmi )); hmi.cb = sizeof( HELPINIT ); hmi.phtHelpTable = (HELPTABLE *)(0xffff0000 | ID_PRTSAMP); hmi.pszHelpWindowTitle = pszTitle; hmi.pszHelpLibraryName = HELP_FILE; hwndHelp = WinCreateHelpInstance( hab, &hmi ); if( ! hwndHelp ) { WinLoadString(hab, (HMODULE)NULLHANDLE, ERRMSG_NO_HELP, LEN_WORKSTRING, szWork); WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, szWork, pszTitle, (USHORT)0, MB_OK | MB_MOVEABLE | MB_CUAWARNING | MB_APPLMODAL); } /* done with local copy of title text */ free( pszTitle ); /* flags to control creation of window; use on call to WinCreateStdWindow */ ulCtlData = FCF_SYSMENU | FCF_TITLEBAR | FCF_SIZEBORDER | FCF_MINMAX | FCF_MENU | FCF_ACCELTABLE | FCF_HORZSCROLL | FCF_VERTSCROLL; hwndFrame = WinCreateStdWindow( HWND_DESKTOP, WS_VISIBLE | FS_ICON | FS_SHELLPOSITION, &ulCtlData, CLASSNAME, NULL, /* title text set in prtcreat.c */ 0, /* client style */ (HMODULE)NULLHANDLE, /* resources in exe */ ID_PRTSAMP, &hwndClient ); pmassert( hab, hwndFrame ); pmassert( hab, hwndClient ); /* create.c placed pointer to main params in client's window words; get it */ pmp = (PMAIN_PARM) WinQueryWindowULong( hwndClient, QWL_USER ); /* store help instance handle in main parameter block */ pmp->hwndHelp = hwndHelp; bOK = WinAssociateHelpInstance( hwndHelp, hwndFrame ); pmassert( hab, bOK ); /* Add program to task list. */ memset( &swctl, 0, sizeof( SWCNTRL )); strcpy( swctl.szSwtitle, pmp->pszTitle ); swctl.hwnd = hwndFrame; swctl.uchVisibility = SWL_VISIBLE; swctl.fbJump = SWL_JUMPABLE; hsw = WinAddSwitchEntry( &swctl ); /* first parameter could be a filename, so store for later use */ if (argc > 1) { argv++; strcpy( pmp->szArgFilename, *argv); } /* message loop */ while( WinGetMsg( hab, &qmsg, (HWND)NULLHANDLE, 0, 0 )) { WinDispatchMsg( hab, &qmsg ); } /* clean up */ WinRemoveSwitchEntry( hsw ); WinDestroyHelpInstance( hwndHelp ); WinDestroyWindow( hwndFrame ); WinDestroyMsgQueue( hmq ); WinTerminate( hab ); DosWaitThread( &pmp->tidObjectThread, DCWW_WAIT ); return 0; } /* End of main() */
static MRESULT EXPENTRY AttachStatProc(HWND hwnd, ULONG message, MPARAM mp1, MPARAM mp2) { extern WINDOWPOSITIONS windowpositions; extern WINDOWCOLORS windowcolors; extern WINDOWFONTS windowfonts; extern HWND frame; extern HWND hwndhelp; PCHECKATPAR pCheckPar=NULL; PFIELDINFO pFieldInfo, pFirstFieldInfo; FIELDINFOINSERT FieldInfoInsert; CNRINFO CnrInfo; PATTACHRECORD pRecord, pFirstRecord; RECORDINSERT RecordInsert; HWND hwndCnr; PFILELIST pTemp; static char pchTitleFile[50]; static char pchTitleSize[50]; static char pchTitleStatus[50]; static char pchOK[50]; static char pchNotFound[50]; switch(message) { case WM_INITDLG: pCheckPar=(PCHECKATPAR) mp2; LoadString(IDST_ATT_TITLEFILE, 50, pchTitleFile); LoadString(IDST_ATT_TITLESIZE, 50, pchTitleSize); LoadString(IDST_ATT_TITLESTATUS, 50, pchTitleStatus); LoadString(IDST_ATT_OK, 50, pchOK); LoadString(IDST_ATT_NOTF, 50, pchNotFound); WinAssociateHelpInstance(hwndhelp, hwnd); hwndCnr=WinWindowFromID(hwnd, IDD_ATTACHSTAT+2); OldAttachContainerProc=WinSubclassWindow(hwndCnr, NewAttachContainerProc); SetFont(hwndCnr, windowfonts.attachfont); SetForeground(hwndCnr, &windowcolors.attachfore); SetBackground(hwndCnr, &windowcolors.attachback); /* Felder des Containers vorbereiten */ pFirstFieldInfo=(PFIELDINFO)SendMsg(hwndCnr, CM_ALLOCDETAILFIELDINFO, MPFROMLONG(3), NULL); pFieldInfo=pFirstFieldInfo; pFieldInfo->cb=sizeof(FIELDINFO); pFieldInfo->flData=CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR; pFieldInfo->flTitle=0; pFieldInfo->pTitleData= pchTitleFile; pFieldInfo->offStruct= FIELDOFFSET(ATTACHRECORD, pchFileName); pFieldInfo=pFieldInfo->pNextFieldInfo; pFieldInfo->cb=sizeof(FIELDINFO); pFieldInfo->flData=CFA_ULONG | CFA_HORZSEPARATOR | CFA_SEPARATOR | CFA_RIGHT; pFieldInfo->flTitle=0; pFieldInfo->pTitleData= pchTitleSize; pFieldInfo->offStruct= FIELDOFFSET(ATTACHRECORD, ulSize); pFieldInfo=pFieldInfo->pNextFieldInfo; pFieldInfo->cb=sizeof(FIELDINFO); pFieldInfo->flData=CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR | CFA_CENTER; pFieldInfo->flTitle=0; pFieldInfo->pTitleData= pchTitleStatus; pFieldInfo->offStruct= FIELDOFFSET(ATTACHRECORD, pchStatus); /* Felder des Containers einfuegen */ FieldInfoInsert.cb=sizeof(FIELDINFOINSERT); FieldInfoInsert.pFieldInfoOrder=(PFIELDINFO) CMA_FIRST; FieldInfoInsert.fInvalidateFieldInfo=TRUE; FieldInfoInsert.cFieldInfoInsert=3; SendMsg(hwndCnr, CM_INSERTDETAILFIELDINFO, pFirstFieldInfo, &FieldInfoInsert); /* Container-Attribute setzen */ CnrInfo.cb=sizeof(CNRINFO); CnrInfo.pFieldInfoLast=NULL; CnrInfo.flWindowAttr=CV_DETAIL | CA_DETAILSVIEWTITLES; CnrInfo.xVertSplitbar=0; SendMsg(hwndCnr, CM_SETCNRINFO, &CnrInfo, MPFROMLONG(CMA_FLWINDOWATTR)); /* Elemente einfuegen */ pFirstRecord=(PATTACHRECORD)SendMsg(hwndCnr, CM_ALLOCRECORD, MPFROMLONG(sizeof(ATTACHRECORD)-sizeof(MINIRECORDCORE)), MPFROMLONG(pCheckPar->ulCountRecords)); pRecord=pFirstRecord; pTemp=pCheckPar->pFileList; while(pTemp) { pRecord->pchFileName=pTemp->pchFileName; pRecord->ulSize=pTemp->ulSize; if (pTemp->bFound) pRecord->pchStatus = pchOK; else pRecord->pchStatus = pchNotFound; pRecord=(PATTACHRECORD)pRecord->RecordCore.preccNextRecord; pTemp=pTemp->next; } RecordInsert.cb=sizeof(RECORDINSERT); RecordInsert.pRecordOrder=(PRECORDCORE) CMA_FIRST; RecordInsert.pRecordParent=NULL; RecordInsert.fInvalidateRecord=TRUE; RecordInsert.zOrder=CMA_TOP; RecordInsert.cRecordsInsert=pCheckPar->ulCountRecords; SendMsg(hwndCnr, CM_INSERTRECORD, pFirstRecord, &RecordInsert); RestoreWinPos(hwnd, &windowpositions.attachpos, FALSE, TRUE); break; case WM_DESTROY: QueryWinPos(hwnd, &windowpositions.attachpos); QueryFont(WinWindowFromID(hwnd, IDD_ATTACHSTAT+2), windowfonts.attachfont); QueryForeground(WinWindowFromID(hwnd, IDD_ATTACHSTAT+2), &windowcolors.attachfore); QueryBackground(WinWindowFromID(hwnd, IDD_ATTACHSTAT+2), &windowcolors.attachback); WinAssociateHelpInstance(hwndhelp, frame); break; default: break; } return WinDefDlgProc(hwnd, message, mp1, mp2); }
/**************************************************************************** * Initialize * * - Performs several application initializations. Reads profile info, * * modifies client window to match it, seeds random number generator, * * initializes game data structures, and starts the timer. * * - No I/O. * ****************************************************************************/ VOID Initialize(VOID) { INT i; ULONG cb; /* Read in the profile data if it exists */ PrfQueryProfileSize(HINI_USERPROFILE, szClientClass, "Data", &cb); if (cb == sizeof(PROFILEREC)) PrfQueryProfileData(HINI_USERPROFILE, szClientClass, "Data", (PVOID)&prfProfile, &cb); /* Make frame size & position match profile information (or initialize) */ if ((prfProfile.ulMINMAX & SWP_MINIMIZE) || (prfProfile.ulMINMAX & SWP_MAXIMIZE)) WinSetWindowPos(hwndFrame, HWND_TOP, prfProfile.x, prfProfile.y, prfProfile.cx, prfProfile.cy, SWP_ACTIVATE | SWP_SHOW | SWP_SIZE | SWP_MOVE | prfProfile.ulMINMAX); else if ((prfProfile.cx != 0) && (prfProfile.cy != 0)) WinSetWindowPos(hwndFrame,HWND_TOP, prfProfile.x,prfProfile.y,prfProfile.cx,prfProfile.cy, SWP_ACTIVATE | SWP_SHOW | SWP_SIZE | SWP_MOVE); /* Profile information is new. Rely on PM to size/position the client * * window this first time. */ else WinShowWindow(hwndFrame, TRUE); /* Hide controls if hidden at last save * * Normally this if block should occur prior to the previous one, but * * there appears to be a PM v1.2 bug w/hide before WinSetWindowPos: * * the title bar _looks_ inactive when it is later shown. */ if (!prfProfile.bCONTROLS) HideFrameControls(); /* Create a help instance */ hwndHelp = WinCreateHelpInstance(hab, &hinit); if (hwndHelp == NULLHANDLE) { /* failed to create help instance */ WinAlarm(HWND_DESKTOP, WA_WARNING); WinMessageBox(HWND_DESKTOP, NULLHANDLE, "Please put ASTEROID.HLP in a directory pointed to by the HELP " "environment variable or in the ASTEROID working directory.", "Could not find help file", 0, MB_ICONHAND | MB_OK | MB_APPLMODAL); } else WinAssociateHelpInstance(hwndHelp, hwndFrame); /* Initialize Menu according to profile info */ InitMenu(); /* Seed the random number generator from seed in profile */ srand((unsigned int) prfProfile.uiSEED); prfProfile.uiSEED = (UINT) rand(); /* Initialize game data structures */ WinSendMsg(hwndClient, WM_INITGAME, MPFROMSHORT(0), MPVOID); /* Startup a timer for screen updates */ TogglePause(FORCE_UNPAUSE); if ((prfProfile.ulMINMAX & SWP_MINIMIZE) && (!prfProfile.bBACKGRND)) { /* Set icon */ WinSendMsg(hwndFrame, WM_SETICON, (MPARAM)WinLoadPointer(HWND_DESKTOP, NULLHANDLE, ID_RESOURCE), MPVOID); TogglePause(SUSPEND_ON); } }
main( /* INT argc, CHAR *argv[], CHAR *envp[] */ ) { QMSG qmsg; // message queue ULONG fWndCtrlData; // game Window style flags BOOL fRegistered; // // RECTL RectWinPos; // needed when resizing the window // LONG cxScreen; // LONG cyScreen; INT rc; ERRORID error; static CHAR szClientClass[] = "bermuda.child"; // pszProgName = argv[0]; // get the full qualified program name if( ( hab = WinInitialize(0) ) == NULLHANDLE ){ DosBeep( BEEP_WARN_FREQ, BEEP_WARN_DUR ); return 1; } if( (hmq = WinCreateMsgQueue( hab, 0 ) ) == NULLHANDLE ){ error = WinGetLastError( hab ); DosBeep( BEEP_WARN_FREQ, BEEP_WARN_DUR ); DosBeep( BEEP_WARN_FREQ + 50, BEEP_WARN_DUR ); WinTerminate( hab ); return 1; } fRegistered = WinRegisterClass( hab, szClientClass, (PFNWP)WndProc, CS_SIZEREDRAW | CS_MOVENOTIFY, 0 ); if( !fRegistered ){ rc = WinGetLastError( hab ); DosBeep( BEEP_WARN_FREQ, BEEP_WARN_DUR ); DosBeep( BEEP_WARN_FREQ + 50, BEEP_WARN_DUR ); DosBeep( BEEP_WARN_FREQ + 100, BEEP_WARN_DUR ); WinDestroyMsgQueue( hmq ); WinTerminate( hab ); return 1; } fWndCtrlData = FCF_MINMAX | FCF_TASKLIST | FCF_SYSMENU | FCF_TITLEBAR | FCF_SIZEBORDER | FCF_MENU | FCF_ICON | FCF_AUTOICON; /* FCF_ACCELTABLE */ // use these later hwndFrame = WinCreateStdWindow( HWND_DESKTOP, // parent window NULL, //WS_ANIMATE, // don't make window visible yet &fWndCtrlData, // window parameters, defined above szClientClass, // window class, def. above pszAppName, // Title Bar text 0, // client window style 0, // resources are bound within the .exe IDR_MAIN, // frame-window identifier (see .rc) &hwndMain ); // output client-window handle if( hwndFrame == NULLHANDLE ){ DosBeep( BEEP_WARN_FREQ, BEEP_WARN_DUR); DosBeep( BEEP_WARN_FREQ + 50, BEEP_WARN_DUR); DosBeep( BEEP_WARN_FREQ + 100, BEEP_WARN_DUR); DosBeep( BEEP_WARN_FREQ + 150, BEEP_WARN_DUR); WinDestroyMsgQueue( hmq ); WinTerminate( hab ); return 1; } // allocate space for the gameboard // GBoard = new GRAPHBOARD( 6, 9 ); // initialize the help facility HelpInit.cb = sizeof(HELPINIT); HelpInit.pszTutorialName = NULL; HelpInit.phtHelpTable = (PHELPTABLE)MAKELONG(HELP_TABLE, 0xFFFF ); HelpInit.hmodHelpTableModule = NULLHANDLE; HelpInit.hmodAccelActionBarModule = NULLHANDLE; HelpInit.idAccelTable = 0; HelpInit.idActionBar = 0; HelpInit.pszHelpWindowTitle = "Help for Bermuda Triangle"; HelpInit.fShowPanelId = CMIC_HIDE_PANEL_ID; HelpInit.pszHelpLibraryName = "bermuda.hlp"; hwndHelp = WinCreateHelpInstance( hab, &HelpInit ); if( !hwndHelp || HelpInit.ulReturnCode ){ // Help instance creation failed WinMessageBox( HWND_DESKTOP, hwndMain, "Couldn't create help instance.\nHelp will be disabled.\n" \ "To use the online help the file bermuda.hlp must either be " \ "in the current working directory or in one of the " \ "directories listed in your HELP environment variable.", "Error when using WinCreateHelpInstance", 0, MB_OK | MB_INFORMATION ); } else { if ( !WinAssociateHelpInstance( hwndHelp, hwndFrame ) ) WinMessageBox( hwndMain, hwndFrame, "Couldn't associate help instance.\nHelp will be disabled.", "Error when using WinAssociateHelpInstance", 0, MB_OK | MB_INFORMATION ); } LONG cxScreen = WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN ); LONG cyScreen = WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ); wcprintf("jetzt kommt WinSetWindowPos in main: %d %d", cxScreen *2 / 3, cyScreen * 2 / 3 ); WinSetWindowPos( hwndFrame, NULLHANDLE, cxScreen / 6, cyScreen / 6, cxScreen * 2 / 3, cyScreen * 2 / 3, SWP_SIZE | SWP_MOVE ); wcprintf("fertig mit WinSetWindowPos"); InfoData.SetLineStyle( IDC_DIAGONALS_AND_VERTICALS ); InfoData.SetSound( TRUE ); // ReadProfile( hab ); // Now we can make the active window visible: if( !WinShowWindow( hwndFrame, TRUE ) ){ DosBeep( BEEP_WARN_FREQ, BEEP_WARN_DUR ); DosBeep( BEEP_WARN_FREQ + 50, BEEP_WARN_DUR ); DosBeep( BEEP_WARN_FREQ + 100, BEEP_WARN_DUR ); DosBeep( BEEP_WARN_FREQ + 150, BEEP_WARN_DUR ); DosBeep( BEEP_WARN_FREQ + 200, BEEP_WARN_DUR ); } // Now we can bring the window to the foreground // (it doesn't matter if this isn't successful) WinSetActiveWindow( HWND_DESKTOP, hwndFrame ); // get / dispatch message loop while( WinGetMsg( hab, (PQMSG)&qmsg, NULLHANDLE, 0L, 0L ) ) WinDispatchMsg( hab, (PQMSG)&qmsg ); // clean up WinDestroyWindow( hwndFrame ); WinDestroyMsgQueue( hmq ); WinTerminate( hab ); return 0; } // end of main