示例#1
0
HWND MdiOpenIcon()
{
    FILEOPEN            of;
    char                filename[ _MAX_PATH ];
    char                title[ _MAX_PATH ];
    char                ext[16];
    FILE                *fp;
    HWND                hwnd;
    HANDLE              dll;
#if defined(__WINDOWS_386__)
    HINDIR              h;
#else
    BOOL                (PASCAL FAR *gsn)( LPFILEOPEN );
#endif
    FARPROC             farp;
    DWORD               a1,a2;
    BOOL                rc;

    dll = LoadLibrary( "filedll.dll" );
    if( dll < 32 ) {
        MessageBox( NULL, "Could not find filedll.dll!", "Icon Viewer", MB_OK );
        return( FALSE );
    }
    farp = (FARPROC) GetProcAddress( dll,"GetFileName" );
#if defined(__WINDOWS_386__)
    h = GetIndirectFunctionHandle( farp, INDIR_PTR, INDIR_ENDLIST );
#else
    gsn = (void FAR *) farp;
#endif

    filename[ 0 ] = '\0';
    of.hwnd = FrameWindow;
    a1 = AllocAlias16( "*.ico" );
    of.ext = (LPSTR) a1;
    a2 = AllocAlias16( filename );
    of.name = (LPSTR) a2;
    of.namelen = sizeof( filename );
    of.type = FILE_OPEN;
    of.title = NULL;
#if defined(__WINDOWS_386__)
    rc = InvokeIndirectFunction( h, &of );
#else
    rc = gsn( &of );
#endif
    if( rc ) {
        _splitpath( filename, NULL, NULL, title, ext );
        strcat( title, ext );
        fp = fopen( filename, "rb" );
        hwnd = MdiReadIcon( fp, title, filename, WS_ICONIC );
        ShowWindow( hwnd, SW_SHOWMINIMIZED );
        UpdateWindow( hwnd );
        fclose( fp );
    }
    FreeAlias16( a1 );
    FreeAlias16( a2 );
    FreeLibrary( dll );
    return( hwnd );

} /* MdiIconOpen */
示例#2
0
/*
 * MDITile - do a tile
 */
void MDITile( int is_horz )
{
#if defined( __UNIX__ )
    return;
#else
#ifndef __OS2_PM__
    WORD        tile_how;
#if !defined( __NT__ )
    HANDLE      h;
#if defined( __WINDOWS_386__ )
    LPVOID      TileChildWindows;
    HINDIR      hindir;
#else
    int (FAR PASCAL *TileChildWindows)( HWND parent, WORD action );
#endif
#else
    extern int FAR PASCAL TileChildWindows( HWND parent, WORD action );
#endif

    if( childrenMaximized ) {
        return;
    }

    if( is_horz ) {
        tile_how = MDITILE_HORIZONTAL;
    } else {
        tile_how = MDITILE_VERTICAL;
    }

#if !defined( __NT__ )
    h = LoadLibrary( "USER.EXE" );
    if( h == NULL ) {
        return;
    }
    TileChildWindows = (LPVOID)GetProcAddress( h, "TileChildWindows" );
    if( TileChildWindows == NULL ) {
        return;
    }
#if defined( __WINDOWS_386__ )
    hindir = GetIndirectFunctionHandle( TileChildWindows, INDIR_WORD,
                                        INDIR_WORD, INDIR_ENDLIST );
    InvokeIndirectFunction( hindir, mdiInfo.container, tile_how );
    free( hindir );
#else
    TileChildWindows( mdiInfo.container, tile_how );
#endif
    FreeLibrary( h );
#else
    TileChildWindows( mdiInfo.container, tile_how );
#endif
#else
    is_horz = is_horz;
#endif
#endif

} /* MDITile */
示例#3
0
/*
 * MDICascade - do a cascade
 */
void MDICascade( void )
{
#if defined( __UNIX__ )
    return;
#else
#ifndef __OS2_PM__
#if !defined( __NT__ )
    HANDLE      h;
#if defined( __WINDOWS_386__ )
    LPVOID      CascadeChildWindows;
    HINDIR      hindir;
#else
    int (FAR PASCAL *CascadeChildWindows)( HWND parent, WORD action );
#endif
#else
    extern int FAR PASCAL CascadeChildWindows( HWND parent, WORD action );
#endif

    if( childrenMaximized ) {
        return;
    }

#if !defined( __NT__ )
    h = LoadLibrary( "USER.EXE" );
    if( h == NULL ) {
        return;
    }
    CascadeChildWindows = (LPVOID)GetProcAddress( h, "CascadeChildWindows" );
    if( CascadeChildWindows == NULL ) {
        return;
    }
#if defined( __WINDOWS_386__ )
    hindir = GetIndirectFunctionHandle( CascadeChildWindows, INDIR_WORD,
                                        INDIR_WORD, INDIR_ENDLIST );
    InvokeIndirectFunction( hindir, mdiInfo.container, 0 );
    free( hindir );
#else
    CascadeChildWindows( mdiInfo.container, 0 );
#endif
    FreeLibrary( h );
#else
    CascadeChildWindows( mdiInfo.container, 0 );
#endif
#endif
#endif

} /* MDICascade */
示例#4
0
int PASCAL WinMain( HINSTANCE hInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpCmdLine,
                    int nCmdShow )
{
  FARPROC fp, fp1, fp2, fpWEP;
  HANDLE hlib16, hlib32;
  HINDIR hIndira, hIndirb;
  HINDIR hIndir1, hIndir2, hIndir3, hIndirWEP;
  DWORD cb;
  char buf[128];

#ifdef DO_16BIT_TEST
  /*
   * 16-bit DLL test, calling with Microsoft C calling conventions
   */
  hlib16 = LoadLibrary( "dll16.dll" );
  fp1 = GetProcAddress( hlib16, PASS_WORD_AS_POINTER( 1 ) );
  fp2 = GetProcAddress( hlib16, PASS_WORD_AS_POINTER( 2 ) );

  hIndira = GetIndirectFunctionHandle( fp1, INDIR_WORD,
              INDIR_DWORD, INDIR_WORD, INDIR_WORD,
              INDIR_DWORD, INDIR_ENDLIST );
  hIndirb = GetIndirectFunctionHandle( fp2, INDIR_CDECL, INDIR_WORD,
              INDIR_DWORD, INDIR_WORD, INDIR_WORD,
              INDIR_DWORD, INDIR_ENDLIST );

  cb = InvokeIndirectFunction( hIndira,
                               0x1, 0x11110000, 0x1100, 0x10,
                               0x22222222 );
  #ifdef __cplusplus
  {
    ostrstream sout( buf, sizeof( buf ) );
    sout << "RC = " << hex << cb << ends;
    MessageBox( NULL, sout.str(), "Gen32", MB_OK | MB_TASKMODAL );
  }
  #else
    sprintf( buf, "RC = %lx", cb );
    MessageBox( NULL, buf, "Gen32", MB_OK | MB_TASKMODAL );
  #endif

  cb = InvokeIndirectFunction( hIndirb,
                               0x1, 0x11110000, 0x1100, 0x10,
                               0x22222222 );
  #ifdef __cplusplus
  {
    ostrstream sout( buf, sizeof( buf ) );
    sout << "RC (cdecl) = " << hex << cb << ends;
    MessageBox( NULL, sout.str(), "Gen32", MB_OK | MB_TASKMODAL );
  }
  #else
    sprintf( buf, "RC (cdecl) = %lx", cb );
    MessageBox( NULL, buf, "Gen32", MB_OK | MB_TASKMODAL );
  #endif
  FreeLibrary( hlib16 );
#endif

  /*
   * 32-bit DLL test
   */
  hlib32 = LoadLibrary( "dll32.dll" );
  fp = GetProcAddress( hlib32, "Win386LibEntry" );
  fpWEP = GetProcAddress( hlib32, "WEP" );

  hIndir1 = GetIndirectFunctionHandle( fp, INDIR_WORD, INDIR_DWORD,
              INDIR_WORD, INDIR_WORD, INDIR_ENDLIST );
  hIndir2 = GetIndirectFunctionHandle( fp, INDIR_DWORD, INDIR_WORD,
              INDIR_WORD, INDIR_ENDLIST );
  hIndir3 = GetIndirectFunctionHandle( fp, INDIR_PTR, INDIR_WORD, INDIR_WORD,
          INDIR_DWORD, INDIR_WORD, INDIR_DWORD, INDIR_WORD, INDIR_ENDLIST );
  hIndirWEP = GetIndirectFunctionHandle( fpWEP, INDIR_WORD,
              INDIR_ENDLIST );

  cb = InvokeIndirectFunction( hIndir1, 0x666, 0x77777111, 0x6969, DLL_1 );
  #ifdef __cplusplus
  {
    ostrstream sout( buf, sizeof( buf ) );
    sout << "RC1 = " << hex << cb << ends;
    MessageBox( NULL, sout.str(), "Gen32", MB_OK | MB_TASKMODAL );
  }
  #else
    sprintf( buf, "RC1 = %lx", cb );
    MessageBox( NULL, buf, "Gen32", MB_OK | MB_TASKMODAL );
  #endif

  cb = InvokeIndirectFunction( hIndir2, 0x12345678, 0x8888, DLL_2 );
  #ifdef __cplusplus
  {
    ostrstream sout( buf, sizeof( buf ) );
    sout << "RC2 = " << hex << cb << ends;
    MessageBox( NULL, sout.str(), "Gen32", MB_OK | MB_TASKMODAL );
  }
  #else
    sprintf( buf, "RC2 = %lx", cb );
    MessageBox( NULL, buf, "Gen32", MB_OK | MB_TASKMODAL );
  #endif

  cb = InvokeIndirectFunction( hIndir3, "A Test String", 1, 2,
                               0xabcddcba, 3, 0x12344321, DLL_3 );
  #ifdef __cplusplus
  {
    ostrstream sout( buf, sizeof( buf ) );
    sout << "RC3 = " << hex << cb << ends;
    MessageBox( NULL, sout.str(), "Gen32", MB_OK | MB_TASKMODAL );
  }
  #else
    sprintf( buf, "RC3 = %lx", cb );
    MessageBox( NULL, buf, "Gen32", MB_OK | MB_TASKMODAL );
  #endif

  /*
   * this function call invokes the Supervisor WEP function
   */
  cb = InvokeIndirectFunction( hIndirWEP, 1 );
  #ifdef __cplusplus
  {
    ostrstream sout( buf, sizeof( buf ) );
    sout << "RC WEP = " << hex << cb << ends;
    MessageBox( NULL, sout.str(), "Gen32", MB_OK | MB_TASKMODAL );
  }
  #else
    sprintf( buf, "RC WEP = %lx", cb );
    MessageBox( NULL, buf, "Gen32", MB_OK | MB_TASKMODAL );
  #endif

  FreeLibrary( hlib32 );

  return( 0 );
}
示例#5
0
bool GUIGetRGBFromUser( gui_rgb init_rgb, gui_rgb *new_rgb )
{
#ifdef __OS2_PM__
    init_rgb = init_rgb;
    new_rgb = new_rgb;
    return( false );
#else
    CHOOSECOLOR     choose;
    bool            ret;
#if defined(__WINDOWS__)
    HINSTANCE       h;
    FARPROC         func;
#ifdef __WINDOWS_386__
    HINDIR          hIndir;
    DWORD           guiColoursAlias;
#endif
#endif

    if( new_rgb == NULL ) {
        return( false );
    }
    memset( &choose, 0, sizeof( CHOOSECOLOR ) );
    choose.Flags = CC_PREVENTFULLOPEN;
    choose.hInstance = (HWND)GUIMainHInst;
    choose.Flags |= CC_RGBINIT;
    choose.rgbResult = GETRGB( init_rgb );
#ifndef __WINDOWS_386__
    choose.lpCustColors = GUIColours;
#endif
    choose.lStructSize = sizeof( CHOOSECOLOR );

#if defined(__NT__)
    ret = ( ChooseColor( &choose ) != 0 );
#else
    h = LoadLibrary( "COMMDLG.DLL" );
    if( (UINT)h < 32 ) {
        return( false );
    }
    func = GetProcAddress( h, "ChooseColor" );
    if( func == NULL ) {
        return( false );
    }
#ifdef __WINDOWS_386__
    hIndir = GetIndirectFunctionHandle( func, INDIR_PTR, INDIR_ENDLIST );
    if( hIndir == NULL ) {
        FreeLibrary( h );
        return( false );
    }
    guiColoursAlias = AllocAlias16( (void *)GUIColours );
    choose.lpCustColors = (void *)guiColoursAlias;
    ret = (short)InvokeIndirectFunction( hIndir, &choose ) != 0;
    if( guiColoursAlias != NULL ) {
        FreeAlias16( guiColoursAlias );
    }
#else
    ret = ((BOOL(WINAPI *)(LPCHOOSECOLOR))func)( &choose ) != 0;
#endif
    FreeLibrary( h );
#endif
    if( ret ) {
        FillInRGB( choose.rgbResult, new_rgb );
    }
    return( ret );
#endif
}
示例#6
0
bool GUIChooseFont( HFONT font, LOGFONT *lf, HWND hwnd )
{
#ifdef __OS2_PM__
    hwnd = hwnd;
    lf = lf;
    font = font;
    return( false );
#else
    CHOOSEFONT  cf;
    bool        ret;
#if defined(__WINDOWS__)
    HINSTANCE   h;
    FARPROC     func;
#ifdef __WINDOWS_386__
    HINDIR      hIndir;
    DWORD       lfAlias;
#endif
#endif

    memset( &cf, 0, sizeof( CHOOSEFONT ) );

    cf.Flags = CF_SCREENFONTS;
    if( font != NULL ) {
        GetObject( font, sizeof( LOGFONT ), (LPSTR) lf );
        cf.Flags |= CF_INITTOLOGFONTSTRUCT;
    }

#ifndef __WINDOWS_386__
    cf.lpLogFont = lf;
#endif
    cf.lStructSize = sizeof( CHOOSEFONT );
    cf.hwndOwner = hwnd;

#if defined(__NT__)
    ret = ChooseFont( &cf ) != 0;
#else
    h = LoadLibrary( "COMMDLG.DLL" );
    if( (UINT)h < 32 ) {
        return( false );
    }
    func = GetProcAddress( h, "ChooseFont" );
    if( func == NULL ) {
        return( false );
    }
#ifdef __WINDOWS_386__
    hIndir = GetIndirectFunctionHandle( func, INDIR_PTR, INDIR_ENDLIST );
    if( hIndir == NULL ) {
        FreeLibrary( h );
        return( false );
    }
    lfAlias = AllocAlias16( (void *)lf );
    cf.lpLogFont = (LOGFONT *) lfAlias;
    ret = (short)InvokeIndirectFunction( hIndir, &cf ) != 0;
    if( lfAlias != NULL ) {
        FreeAlias16( lfAlias );
    }
#else
    ret = ((BOOL(WINAPI *)(LPCHOOSEFONT))func)( &cf ) != 0;
#endif
    FreeLibrary( h );
#endif
    return( ret );
#endif
}
示例#7
0
/*
 * Init32Ctl3d - load CTL3D.DLL and get entry
 */
BOOL Init32Ctl3d( void )
{
    LPVOID      ptr;

    dllCtl3d = LoadLibrary( "ctl3dv2.dll" );
    if( dllCtl3d < (HANDLE)32 ) {
        return( FALSE );
    }

    ptr = GetProcAddress( dllCtl3d, "Ctl3dSubclassDlg" );
    if( ptr == NULL ) {
        FreeLibrary( dllCtl3d );
        return( FALSE );
    }
    DLL32Ctl3dSubclassDlg = GetIndirectFunctionHandle( ptr, INDIR_WORD, INDIR_WORD, INDIR_ENDLIST );

    ptr = GetProcAddress( dllCtl3d, "Ctl3dAutoSubclass" );
    if( ptr == NULL ) {
        FreeLibrary( dllCtl3d );
        return( FALSE );
    }
    DLL32Ctl3dAutoSubclass = GetIndirectFunctionHandle( ptr, INDIR_WORD, INDIR_ENDLIST );

    ptr = GetProcAddress( dllCtl3d, "Ctl3dRegister" );
    if( ptr == NULL ) {
        FreeLibrary( dllCtl3d );
        return( FALSE );
    }
    DLL32Ctl3dRegister = GetIndirectFunctionHandle( ptr, INDIR_WORD, INDIR_ENDLIST );

    ptr = GetProcAddress( dllCtl3d, "Ctl3dUnregister" );
    if( ptr == NULL ) {
        FreeLibrary( dllCtl3d );
        return( FALSE );
    }
    DLL32Ctl3dUnregister = GetIndirectFunctionHandle( ptr, INDIR_WORD, INDIR_ENDLIST );

    ptr = GetProcAddress( dllCtl3d, "Ctl3dColorChange" );
    if( ptr == NULL ) {
        FreeLibrary( dllCtl3d );
        return( FALSE );
    }
    DLL32Ctl3dColorChange = GetIndirectFunctionHandle( ptr, INDIR_ENDLIST );

    ptr = GetProcAddress( dllCtl3d, "Ctl3dSubclassCtl" );
    if( ptr == NULL ) {
        FreeLibrary( dllCtl3d );
        return( FALSE );
    }
    DLL32Ctl3dSubclassCtl = GetIndirectFunctionHandle( ptr, INDIR_WORD, INDIR_ENDLIST );

    ptr = GetProcAddress( dllCtl3d, "Ctl3dCtlColorEx" );
    if( ptr == NULL ) {
        FreeLibrary( dllCtl3d );
        return( FALSE );
    }
    DLL32Ctl3dCtlColorEx = GetIndirectFunctionHandle( ptr, INDIR_WORD, INDIR_WORD, INDIR_DWORD, INDIR_ENDLIST );

    return( TRUE );

} /* Init32Ctl3d */