void GUIHookF1( void ) { if( F1Hooked == 0 ) { F1ProcInst = _wpi_makeprocinstance( (WPI_PROC)F1Proc, GUIMainHInst ); #ifndef __OS2_PM__ // we use a hook to trap F1 in dialogs that were not // created using this instance yet on our behalf. IE COMMDLG stuff // we cant use a system wide hook because they only can be // used in DLL's #if defined(__NT__) F1HookHandle = SetWindowsHookEx( WH_MSGFILTER, (HOOKPROC)F1ProcInst, GUIMainHInst, (DWORD)GetCurrentThreadId() ); #else F1HookHandle = SetWindowsHookEx( WH_MSGFILTER, (HOOKPROC)F1ProcInst, GUIMainHInst, GetCurrentTask() ); #endif #else // in OS/2, it has to be an app. specific input filter (OS/2 has // bad problems, occassionally, with system input hooks) WinSetHook( GUIMainHInst.hab, HMQ_CURRENT, HK_INPUT, (PFN) F1ProcInst, GUIMainHInst.mod_handle ); #endif } F1Hooked++; }
/* * CreateStatusFont - creates the font used in the status window */ void CreateStatusFont( void ) { WPI_LOGFONT logfont; WPI_PROC fp; WPI_PRES pres; pres = _wpi_getpres( HWND_DESKTOP ); #ifdef __OS2_PM__ _wpi_enumfonts( pres, NULL, (WPI_ENUMFONTPROC)EnumFontFunc, "Helv" ); fp = fp; #else fp = _wpi_makeprocinstance( EnumFontFunc, Instance ); #ifdef __NT__ EnumFonts( hdc, NULL, (LPVOID)fp, (LPARAM)(LPCSTR)"ms sans serif"); #else EnumFonts( hdc, NULL, (LPVOID)fp, (LPVOID)"ms sans serif"); #endif #endif _wpi_freeprocinstance( fp ); if( currentLogFont == NULL ) { // SmallFont = GetStockObject( ANSI_FIXED_FONT ); // GetObject( SmallFont, sizeof( LOGFONT ), (LPSTR) &logfont ); // SmallFont = CreateFontIndirect( &logfont ); } else { memcpy( &logfont, currentLogFont, sizeof(WPI_LOGFONT) ); // _wpi_setfontheight( &logfont, 11 ); // _wpi_setfontwidth( &logfont, 10 ); _wpi_setfontpointsize( &logfont, 10, 0, _wpi_fontmatch(&logfont) ); _wpi_createrealfont( logfont, SmallFont ); #if 0 SmallFont = CreateFont( 10, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, currentLogFont->lfCharSet, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, currentLogFont->lfPitchAndFamily, currentLogFont->lfFaceName ); #endif free( currentLogFont ); currentLogFont = NULL; } _wpi_releasepres( HWND_DESKTOP, pres ); } /* CreateStatusFont */
bool GUIDoCreateResDialog( long dlg_id, HWND parent, void *data ) { WPI_PROC fp; fp = _wpi_makeprocinstance( (WPI_PROC)GUIDialogFunc, GUIMainHInst ); if( !fp ) { return( FALSE ); } if( _wpi_dialogbox( parent, (LPVOID)fp, GUIResHInst, DLG_RESOURCE(dlg_id), data ) == -1 ) { _wpi_freeprocinstance( fp ); return( FALSE ); } _wpi_freeprocinstance( fp ); return( TRUE ); }
/* * SelectOptions - bring up the current settings dialog box */ void SelectOptions( void ) { WPI_PROC fp; WPI_DLGRESULT button_type; HMENU hmenu; fp = _wpi_makeprocinstance( (WPI_PROC)CurrentSettingsProc, Instance ); button_type = _wpi_dialogbox( HMainWindow, (WPI_DLGPROC)fp, Instance, CURRENT_SETTINGS, 0L ); _wpi_freeprocinstance( fp ); if( button_type == DLGID_CANCEL ) { return; } hmenu = GetMenu( _wpi_getframe( HMainWindow ) ); if( fCheckSquareGrid ) { CheckSquareGrid( hmenu ); } } /* SelectOptions */
/* * readInResourceFile */ static bool readInResourceFile( char *fullname ) { BYTE *data; uint_32 dsize; WRInfo *info; WRSelectImageInfo *sii; WPI_PROC cb; bool ok; info = NULL; sii = NULL; data = NULL; ok = (fullname != NULL); if( ok ) { info = WRLoadResource( fullname, WR_DONT_KNOW ); ok = (info != NULL); } if( ok ) { cb = _wpi_makeprocinstance( (WPI_PROC)IEHelpCallBack, Instance ); sii = WRSelectImage( HMainWindow, info, cb ); _wpi_freeprocinstance( cb ); ok = (sii != NULL && sii->lnode != NULL); } if( ok ) { if( sii->type == (uint_16)(pointer_int)RT_BITMAP ) { imgType = BITMAP_IMG; data = WRCopyResData( info, sii->lnode ); dsize = sii->lnode->Info.Length; ok = (data != NULL); if( ok ) { ok = WRAddBitmapFileHeader( &data, &dsize ); } } else if( sii->type == (uint_16)(pointer_int)RT_GROUP_CURSOR ) { imgType = CURSOR_IMG; ok = WRCreateCursorData( info, sii->lnode, &data, &dsize ); } else if( sii->type == (uint_16)(pointer_int)RT_GROUP_ICON ) { imgType = ICON_IMG; ok = WRCreateIconData( info, sii->lnode, &data, &dsize ); } else { imgType = UNDEF_IMG; ok = false; } } if( ok ) { if( sii->type == (uint_16)(pointer_int)RT_BITMAP ) { ok = ReadBitmapFromData( data, fullname, info, sii->lnode ); } else if( sii->type == (uint_16)(pointer_int)RT_GROUP_CURSOR ) { ok = ReadCursorFromData( data, fullname, info, sii->lnode ); } else if( sii->type == (uint_16)(pointer_int)RT_GROUP_ICON ) { ok = ReadIconFromData( data, fullname, info, sii->lnode ); } } if( sii != NULL ) { WRFreeSelectImageInfo( sii ); } if( data != NULL ) { MemFree( data ); } return( ok ); } /* readInResourceFile */
int GUIGetFileName( gui_window *wnd, open_file_name *ofn ) { OPENFILENAME wofn; bool issave; int rc; unsigned drive; #if defined(HAVE_DRIVES) unsigned old_drive; unsigned drives; #endif LastPath = NULL; if( ofn->initial_dir != NULL && ofn->initial_dir[0] != '\0' && ofn->initial_dir[1] == ':' ) { drive = ofn->initial_dir[0]; memmove( ofn->initial_dir, ofn->initial_dir+2, strlen( ofn->initial_dir+2 ) + 1 ); } else { drive = 0; } memset( &wofn, 0 , sizeof( wofn ) ); if( ofn->flags & OFN_ISSAVE ) { issave = TRUE; } else { issave = FALSE; } wofn.Flags = 0; if( hookFileDlg ) { wofn.Flags |= OFN_ENABLEHOOK; } if( !(ofn->flags & OFN_CHANGEDIR) ) { wofn.Flags |= OFN_NOCHANGEDIR; } if( ofn->flags & OFN_OVERWRITEPROMPT ) { wofn.Flags |= OFN_OVERWRITEPROMPT; } if( ofn->flags & OFN_HIDEREADONLY ) { wofn.Flags |= OFN_HIDEREADONLY; } if( ofn->flags & OFN_FILEMUSTEXIST ) { wofn.Flags |= OFN_FILEMUSTEXIST; } if( ofn->flags & OFN_PATHMUSTEXIST ) { wofn.Flags |= OFN_PATHMUSTEXIST; } if( ofn->flags & OFN_ALLOWMULTISELECT ) { wofn.Flags |= OFN_ALLOWMULTISELECT; } wofn.hwndOwner = GUIGetParentFrameHWND( wnd ); wofn.hInstance = GUIMainHInst; wofn.lStructSize = sizeof( wofn ); wofn.lpstrFilter = ofn->filter_list; wofn.nFilterIndex = ofn->filter_index; wofn.lpstrFile = ofn->file_name; wofn.nMaxFile = ofn->max_file_name; wofn.lpstrFileTitle = ofn->base_file_name; wofn.nMaxFileTitle = ofn->max_base_file_name; wofn.lpstrTitle = ofn->title; wofn.lpstrInitialDir = ofn->initial_dir; wofn.lpfnHook = (LPVOID)NULL; if( hookFileDlg ) { wofn.lpfnHook = (LPVOID) _wpi_makeprocinstance( (LPVOID) OpenHook, GUIMainHInst ); } #if defined( HAVE_DRIVES ) if( drive ) { _dos_getdrive( &old_drive ); _dos_setdrive( tolower( drive ) - 'a' + 1, &drives ); } #endif if( issave ) { rc = GetSaveFileName( &wofn ); } else { rc = GetOpenFileName( &wofn ); } if( hookFileDlg ) { #if !defined(__NT__) _wpi_freeprocinstance( (WPI_PROC)wofn.lpfnHook ); #endif } if( LastPath && ( !rc || !( ofn->flags & OFN_WANT_LAST_PATH ) ) ) { GUIMemFree( LastPath ); LastPath = NULL; } ofn->last_path = LastPath; #if defined( HAVE_DRIVES ) if( drive ) { _dos_setdrive( old_drive, &drives ); } #endif if( rc ) { return( OFN_RC_FILE_SELECTED ); } if( !CommDlgExtendedError() ) { return( OFN_RC_NO_FILE_SELECTED ); } return( OFN_RC_FAILED_TO_INITIALIZE ); } /* GUIGetFileName */