static void WRECheckIfActiveWindow( void ) { HWND main; HWND active; main = WREGetMainWindowHandle(); active = GetActiveWindow(); if( active != main ) { //SetActiveWindow( main ); ShowWindow( main, SW_RESTORE ); BringWindowToTop( main ); } }
Bool WREChangeMemFlags( void ) { WRECurrentResInfo curr; HWND parent; char *name; int type; uint_16 mflags; FARPROC cb; Bool ok; cb = NULL; name = NULL; mflags = 0; ok = WREGetCurrentResource( &curr ); if( ok ) { if( curr.type->Info.TypeName.IsName ) { type = 0; } else { type = curr.type->Info.TypeName.ID.Num; } name = WREGetResName( curr.res, type ); parent = WREGetMainWindowHandle(); } if( ok ) { cb = MakeProcInstance( (FARPROC)WREHelpRoutine, WREGetAppInstance() ); ok = (cb != (FARPROC)NULL); } if( ok ) { mflags = curr.lang->Info.MemoryFlags; ok = WRChangeMemFlags( parent, name, &mflags, cb ); } if( ok ) { curr.lang->Info.MemoryFlags = mflags; } if( cb != (FARPROC)NULL ) { FreeProcInstance( (FARPROC)cb ); } if( name != NULL ) { WREMemFree( name ); } return( ok ); }
WREAccelSession *WREStartAccelSession( WRECurrentResInfo *curr ) { WREAccelSession *session; if( curr == NULL ) { return( NULL ); } session = WREAllocAccelSession(); if( session == NULL ) { return( NULL ); } session->info = WAccAllocAccelInfo(); if( session->info == NULL ) { return( NULL ); } session->info->parent = WREGetMainWindowHandle(); session->info->inst = WREGetAppInstance(); session->info->file_name = WREStrDup( WREGetQueryName( curr->info ) ); session->info->res_name = WRECopyWResID( &curr->res->Info.ResName ); session->info->lang = curr->lang->Info.lang; session->info->MemFlags = curr->lang->Info.MemoryFlags; session->info->data_size = curr->lang->Info.Length; session->info->data = curr->lang->data; session->info->is32bit = curr->info->is32bit; session->info->stand_alone = WRENoInterface; session->info->symbol_table = curr->info->symbol_table; session->info->symbol_file = curr->info->symbol_file; session->tnode = curr->type; session->rnode = curr->res; session->lnode = curr->lang; session->rinfo = curr->info; session->hndl = WAccelStartEdit( session->info ); if( session->hndl ) { WREInsertObject( &WREAccSessions, session ); } else { WAccFreeAccelInfo( session->info ); WRMemFree( session ); session = NULL; } return( session ); }
bool WREChangeMemFlags( void ) { WRECurrentResInfo curr; HWND parent; char *type_name; uint_16 type_id; uint_16 mflags; HELP_CALLBACK hcb; bool ok; hcb = (HELP_CALLBACK)NULL; type_name = NULL; mflags = 0; type_id = 0; ok = WREGetCurrentResource( &curr ); if( ok ) { if( !curr.type->Info.TypeName.IsName ) { type_id = curr.type->Info.TypeName.ID.Num; } type_name = WREGetResName( curr.res, type_id ); parent = WREGetMainWindowHandle(); } if( ok ) { hcb = (HELP_CALLBACK)MakeProcInstance( (FARPROC)WREHelpRoutine, WREGetAppInstance() ); ok = (hcb != (HELP_CALLBACK)NULL); } if( ok ) { mflags = curr.lang->Info.MemoryFlags; ok = WRChangeMemFlags( parent, type_name, &mflags, hcb ); } if( ok ) { curr.lang->Info.MemoryFlags = mflags; } if( hcb != (HELP_CALLBACK)NULL ) { FreeProcInstance( (FARPROC)hcb ); } if( type_name != NULL ) { WRMemFree( type_name ); } return( ok ); }
bool WREQueryDeleteName( char *name ) { HWND dialog_owner; DLGPROC proc_inst; HINSTANCE app_inst; INT_PTR modified; dialog_owner = WREGetMainWindowHandle(); app_inst = WREGetAppInstance(); proc_inst = (DLGPROC)MakeProcInstance( (FARPROC)WREResDeleteProc, app_inst ); modified = JDialogBoxParam( app_inst, "WREDeleteResource", dialog_owner, proc_inst, (LPARAM)name ); FreeProcInstance( (FARPROC)proc_inst ); return( modified != -1 && modified == IDOK ); }
char *WREGetFileName( WREGetFileStruct *gf, DWORD flags, WREGetFileAction action ) { OPENFILENAME wreofn; HWND owner_window; Bool ret; DWORD error; int len; char fn_drive[_MAX_DRIVE]; char fn_dir[_MAX_DIR]; char fn_name[_MAX_FNAME]; char fn_ext[_MAX_EXT + 1]; HINSTANCE app_inst; if( gf == NULL ) { return( NULL ); } owner_window = WREGetMainWindowHandle(); app_inst = WREGetAppInstance(); if( app_inst == NULL || owner_window == NULL ) { return( NULL ); } if( gf->title != NULL ) { len = strlen( gf->title ); if( len < _MAX_PATH ) { memcpy( wrefntitle, gf->title, len + 1 ); } else { memcpy( wrefntitle, gf->title, _MAX_PATH ); wrefntitle[_MAX_PATH - 1] = 0; } } else { wrefntitle[0] = 0; } if( gf->file_name != NULL && *gf->file_name != '\0' ) { _splitpath( gf->file_name, fn_drive, fn_dir, fn_name, fn_ext ); if( *fn_drive != '\0' || *fn_dir != '\0' ) { _makepath( wre_initial_dir, fn_drive, fn_dir, NULL, NULL ); } _makepath( wre_file_name, NULL, NULL, fn_name, fn_ext ); } else { wre_file_name[0] = 0; } /* set the initial directory */ if( *wre_initial_dir == '\0' ) { getcwd( wre_initial_dir, _MAX_PATH ); } #if !defined ( __NT__ ) // CTL3D no longer requires this flags |= OFN_ENABLEHOOK; #endif /* initialize the OPENFILENAME struct */ memset( &wreofn, 0, sizeof( OPENFILENAME ) ); /* fill in non-variant fields of OPENFILENAME struct */ wreofn.lStructSize = sizeof( OPENFILENAME ); wreofn.hwndOwner = owner_window; wreofn.hInstance = app_inst; wreofn.lpstrFilter = gf->filter; wreofn.lpstrCustomFilter = NULL; wreofn.nMaxCustFilter = 0; wreofn.nFilterIndex = WREFindFileFilterIndex( gf->filter ); wreofn.lpstrFile = wre_file_name; wreofn.nMaxFile = _MAX_PATH; wreofn.lpstrFileTitle = wrefntitle; wreofn.nMaxFileTitle = _MAX_PATH; wreofn.lpstrInitialDir = wre_initial_dir; wreofn.lpstrTitle = wrefntitle; wreofn.Flags = flags; wreofn.lpfnHook = (LPVOID)MakeProcInstance( (LPVOID)WREOpenHookProc, app_inst ); #if 0 wreofn.nFileOffset = 0L; wreofn.nFileExtension = 0L; wreofn.lpstrDefExt = NULL; wreofn.lCustData = NULL; wreofn.lpTemplateName = NULL; #endif if( action == OPENFILE ) { ret = GetOpenFileName( (LPOPENFILENAME)&wreofn ); } else if( action == SAVEFILE ) { ret = GetSaveFileName( (LPOPENFILENAME)&wreofn ); } else { return( NULL ); } #ifndef __NT__ if( wreofn.lpfnHook != NULL ) { FreeProcInstance( (FARPROC)wreofn.lpfnHook ); } #endif if( !ret ) { error = CommDlgExtendedError(); if( error ) { WREDisplayErrorMsg( WRE_ERRORSELECTINGFILE ); } return( NULL ); } else { memcpy( wre_initial_dir, wre_file_name, wreofn.nFileOffset ); if( wre_initial_dir[wreofn.nFileOffset - 1] == '\\' && wre_initial_dir[wreofn.nFileOffset - 2] != ':' ) { wre_initial_dir[wreofn.nFileOffset - 1] = '\0'; } else { wre_initial_dir[wreofn.nFileOffset] = '\0'; } if( gf->save_ext ) { _splitpath( wre_file_name, NULL, NULL, NULL, fn_ext + 1 ); if( fn_ext[1] != '\0' ) { fn_ext[0] = '*'; WRESetFileFilter( fn_ext ); } else { char *out_ext; out_ext = WREFindFileFilterFromIndex( gf->filter, wreofn.nFilterIndex ); if( out_ext[2] != '*' ) { strcat( wre_file_name, &out_ext[1] ); } } } } UpdateWindow( WREGetMainWindowHandle() ); return( WREStrDup( wre_file_name ) ); }
Bool WRESetResNamesFromType( WREResInfo *info, uint_16 type, Bool force, WResID *name, int index ) { HWND resLbox; HWND typeLbox; int typeIndex; WResTypeNode *tnode; LRESULT max_index; char *str; Bool ok; tnode = NULL; ok = (info != NULL); if( ok && type != 0 && info->current_type == type && !force ) { return( TRUE ); } if( ok ) { resLbox = GetDlgItem( info->info_win, IDM_RNRES ); typeLbox = GetDlgItem( info->info_win, IDM_RNTYPE ); ok = (resLbox != (HWND)NULL && typeLbox != (HWND)NULL); } if( ok ) { WREResetListbox( resLbox ); typeIndex = 0; if( type != 0 ) { typeIndex = WREFindTypeLBoxIndex( typeLbox, type, &tnode ); } else { LRESULT count; count = SendMessage( typeLbox, LB_GETCOUNT, 0, 0 ); if( count != 0 && count != LB_ERR ) { tnode = (WResTypeNode *)SendMessage( typeLbox, LB_GETITEMDATA, (WPARAM)typeIndex, 0 ); } } if( typeIndex == -1 ) { return( TRUE ); } info->current_type = type; SendMessage( typeLbox, LB_SETCURSEL, (WPARAM)typeIndex, 0 ); } if( ok ) { if( tnode != NULL ) { info->current_type = tnode->Info.TypeName.ID.Num; ok = WRESetResNamesFromTypeNode( resLbox, tnode ); } else { info->current_type = 0; } } if( ok ) { if( name != NULL ) { index = LB_ERR; str = WResIDToStr( name ); if( str != NULL ) { index = (int)SendMessage( resLbox, LB_FINDSTRING, 0, (LPARAM)str ); WREMemFree( str ); } if( index == LB_ERR ) { index = 0; } } max_index = SendMessage( resLbox, LB_GETCOUNT, 0, 0 ); if( max_index == LB_ERR ) { max_index = 0; } index = min( index, max_index - 1 ); SendMessage( resLbox, LB_SETCURSEL, (WPARAM)index, 0 ); WRESetTotalText( info ); if( GetActiveWindow() == WREGetMainWindowHandle() ) { SetFocus( resLbox ); } } return( ok ); }