Beispiel #1
0
Bool WdeSetStatusByID( DWORD id1, DWORD id2 )
{
    char        *str1;
    char        *str2;
    Bool        ret;

    ret = FALSE;
    str1 = NULL;
    str2 = NULL;

    if( id1 != -1 ) {
        str1 = WdeAllocRCString( id1 );
    }

    if( id2 != -1 ) {
        str2 = WdeAllocRCString( id2 );
    }

    ret = WdeSetStatusText( str1, str2, TRUE );

    if( str1 != NULL ) {
        WdeFreeRCString( str1 );
    }

    if( str2 != NULL ) {
        WdeFreeRCString( str2 );
    }

    return( ret );
}
Beispiel #2
0
static Bool WdeQueryClearRes( void )
{
    int         ret;
    UINT        style;
    char        *title;
    char        *text;

    style = MB_YESNO | MB_APPLMODAL | MB_ICONEXCLAMATION;
    title = WdeAllocRCString( WDE_CLEARTITLE );
    text = WdeAllocRCString( WDE_CLEARMSG );

    ret = MessageBox( WdeGetMainWindowHandle(), text, title, style );
    if( ret == IDYES ) {
        return( TRUE );
    }

    if( title ) {
        WdeFreeRCString( title );
    }
    if( text ) {
        WdeFreeRCString( text );
    }

    return( FALSE );
}
Beispiel #3
0
static void WdeFiniInfoText( void )
{
    if( WdeCaptionText != NULL ) {
        WdeFreeRCString( WdeCaptionText );
    }
    if( WdeDlgNameText != NULL ) {
        WdeFreeRCString( WdeDlgNameText );
    }
    if( WdeTextText != NULL ) {
        WdeFreeRCString( WdeTextText );
    }
    if( WdeIDText != NULL ) {
        WdeFreeRCString( WdeIDText );
    }
}
Beispiel #4
0
static bool WdeSetDefaultTestControlEntries( HWND win )
{
    int         index;
    char        *text;
    char        *str;
    char        cname[20];
    int         len;
    uint_8      class;

    len = GetClassName( win, cname, 19 );
    if( len == 0 ) {
        return( TRUE );
    }

    class = WdeGetClassFromClassName( cname );

    if( class == CLASS_LISTBOX || class == CLASS_COMBOBOX ) {
        str = NULL;
        text = WdeAllocRCString( WDE_TESTITEM );
        if( text != NULL ) {
            str = (char *)WRMemAlloc( strlen( text ) + 10 + 1 );
            if( str == NULL ) {
                WdeFreeRCString( text );
                return( TRUE );
            }
        } else {
            return( TRUE );
        }
        SendMessage( win, WM_SETREDRAW, FALSE, 0 );
        for( index = 1; index <= TEST_DEFAULT_ENTRIES; index++ ) {
            sprintf( str, text, index );
            if( class == CLASS_LISTBOX ) {
                SendMessage( win, LB_ADDSTRING, 0, (LPARAM)(LPSTR)str );
            } else {
                SendMessage( win, CB_ADDSTRING, 0, (LPARAM)(LPSTR)str );
            }
        }
        SendMessage( win, WM_SETREDRAW, TRUE, 0 );
        InvalidateRect( win, NULL, TRUE );
        WRMemFree( str );
        WdeFreeRCString( text );
    }
Beispiel #5
0
bool WdeQuerySaveSymOnDeleteRes( WdeResInfo *res_info, bool fatal_exit )
{
    int         ret;
    UINT        style;
    char        *file;
    char        *text;
    HWND        frame;

    if( fatal_exit ) {
        style = MB_YESNO | MB_APPLMODAL | MB_ICONEXCLAMATION;
    } else {
        style = MB_YESNOCANCEL | MB_APPLMODAL | MB_ICONEXCLAMATION;
    }

    if( res_info != NULL && res_info->hash_table != NULL &&
            WdeIsHashTableDirty( res_info->hash_table ) ) {
        WdeCheckIfActiveWindow();
        file = WdeGetQueryName( res_info );
        frame = WdeGetMDIWindowHandle();
        if( IsIconic( frame ) ) {
            SendMessage( frame, WM_MDIRESTORE, (WPARAM)res_info->res_win, 0 );
        }
        SendMessage( frame, WM_MDIACTIVATE, (WPARAM) res_info->res_win, 0 );
        text = WdeAllocRCString( WDE_SAVEMODIFIEDSYM );
        ret = MessageBox( res_info->res_win, text, file, style );
        if( text != NULL ) {
            WdeFreeRCString( text );
        }
        if( ret == IDYES ) {
            if( res_info->sym_name == NULL ) {
                res_info->sym_name = WdeCreateSymName( file );
            }
            if( !WdeWriteSymbols( res_info->hash_table, &res_info->sym_name, FALSE ) ) {
                return( FALSE );
            }
        } else if( ret == IDCANCEL ) {
            return( FALSE );
        } else if( ret == IDNO ) {
            WdeHashSaveRejected( res_info->hash_table );
        }
    }

    return( TRUE );
}
Beispiel #6
0
bool WdeQuerySaveResOnDeleteRes( WdeResInfo *res_info, bool fatal_exit )
{
    int         ret;
    UINT        style;
    char        *file;
    char        *text;
    HWND        frame;

    if( res_info != NULL && res_info->dlg_item_list != NULL &&
            WdeIsResModified( res_info ) ) {
        WdeCheckIfActiveWindow();
        if( fatal_exit ) {
            style = MB_YESNO | MB_APPLMODAL | MB_ICONEXCLAMATION;
        } else {
            style = MB_YESNOCANCEL | MB_APPLMODAL | MB_ICONEXCLAMATION;
        }
        frame = WdeGetMDIWindowHandle();
        if( IsIconic( frame ) ) {
            SendMessage( frame, WM_MDIRESTORE, (WPARAM)res_info->res_win, 0 );
        }
        SendMessage( frame, WM_MDIACTIVATE, (WPARAM)res_info->res_win, 0 );
        file = WdeGetQueryName( res_info );
        if( WdeIsDDE() ) {
            text = WdeAllocRCString( WDE_UPDATEMODIFIEDPRJ );
        } else {
            text = WdeAllocRCString( WDE_SAVEMODIFIEDPRJ );
        }
        ret = MessageBox( res_info->res_win, text, file, style );
        if( text != NULL ) {
            WdeFreeRCString( text );
        }
        if( ret == IDYES ) {
            if( WdeIsDDE() ) {
                return( WdeUpdateDDEEditSession() );
            } else {
                return( WdeSaveResource( res_info, FALSE ) );
            }
        } else if( ret == IDCANCEL ) {
            return( FALSE );
        }
    }

    return( TRUE );
}
Beispiel #7
0
WINEXPORT UINT CALLBACK WdeOpenHookProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
    char    *title;

    _wde_touch( wparam );
    _wde_touch( lparam );

    switch( msg ) {
    case WM_INITDIALOG:
        // We must call this to subclass the directory listbox even
        // if the app calls Ctl3dAutoSubclass (commdlg bug)
        // WdeCtl3dSubclassDlgAll( hwnd );
        title = WdeAllocRCString( WDE_GETFNCOMBOTITLE );
        if( title != NULL ) {
            SendDlgItemMessage( hwnd, stc2, WM_SETTEXT, 0, (LPARAM)title );
            WdeFreeRCString( title );
        }
        return( TRUE );
    }

    return( FALSE );
}
Beispiel #8
0
void WdeInitEditClass( void )
{
    LOGBRUSH    lbrush;
    char        *text;
    char        *cp;
    int         point_size;
    Bool        use_default;

    WdeEditBrush = GetStockObject( WHITE_BRUSH );

    /* create a transparent brush */
    memset( &lbrush, 0, sizeof( LOGBRUSH ) );
    lbrush.lbStyle = BS_HOLLOW;
    WdeFormsBrush = CreateBrushIndirect( &lbrush );

    if( WdeEditFont == NULL ) {
        use_default = TRUE;
        text = WdeAllocRCString( WDE_EDITWINDOWFONT );
        if( text != NULL ) {
            cp = (char *)_mbschr( (unsigned char const *)text, '.' );
            if( cp != NULL ) {
                *cp = '\0';
                cp++;
                point_size = atoi( cp );
                use_default = FALSE;
            }
        }

        if( use_default ) {
            WdeEditFont = WdeGetFont( "Helv", 8, FW_BOLD );
        } else {
            WdeEditFont = WdeGetFont( text, point_size, FW_BOLD );
        }

        if( text != NULL ) {
            WdeFreeRCString( text );
        }
    }
}
Beispiel #9
0
void WdeShowRibbon( void )
{
    bool        created;
    char        *mtext;

    if( WdeRibbonHeight != 0 ) {
        ShowWindow( WdeRibbon->win, SW_HIDE );
        WdeRibbonHeight = 0;
        WdeResizeWindows();
        mtext = WdeAllocRCString( WDE_SHOWTOOLBAR );
    } else {
        if( WdeRibbon == NULL ) {
            WdeCreateRibbon( WdeGetMainWindowHandle() );
            created = TRUE;
        } else {
            created = FALSE;
        }
        if( !created ) {
            WdeRibbonHeight = 2 * WdeRibbonInfo->dinfo.border_size.y +
                              WdeRibbonInfo->dinfo.button_size.y +
                              2 * GetSystemMetrics( SM_CYBORDER );
            WdeResizeWindows();
        }
        mtext = WdeAllocRCString( WDE_HIDETOOLBAR );
        ShowWindow( WdeRibbon->win, SW_SHOW );
    }

    WdeSetOption( WdeOptIsRibbonVisible, WdeRibbonHeight != 0 );

    ModifyMenu( WdeGetInitialMenuHandle(), IDM_SHOW_RIBBON,
                MF_BYCOMMAND | MF_STRING, IDM_SHOW_RIBBON, mtext );
    ModifyMenu( WdeGetResMenuHandle(), IDM_SHOW_RIBBON,
                MF_BYCOMMAND | MF_STRING, IDM_SHOW_RIBBON, mtext );

    if( mtext != NULL ) {
        WdeFreeRCString( mtext );
    }
}
Beispiel #10
0
void WdeDisplayHint( int id )
{
    char        *buf;
    char        *mditext;
    WdeHintItem *hint;

    if( id < WDE_MDI_FIRST ) {
        hint = WdeGetHintItem( id );
        if( hint != NULL ) {
            WdeSetStatusByID( -1, hint->hint );
        }
    } else {
        mditext = WdeAllocRCString( WDE_HINT_MDIMSG );
        if( mditext != NULL ) {
            buf = WdeMemAlloc( strlen( mditext ) + 20 + 1 );
            if( buf != NULL ) {
                sprintf( buf, mditext, WDE_MDI_FIRST + 1 - id );
                WdeSetStatusText( NULL, buf, TRUE );
                WdeMemFree( buf );
            }
            WdeFreeRCString( mditext );
        }
    }
}
Beispiel #11
0
WdeToolBar *WdeCreateToolBar( WdeToolBarInfo *info, HWND parent )
{
    WdeToolBar  *tbar;
    int         i;
    int         width;
    int         height;
    HMENU       sys_menu;
    char        *text;

    if( info == NULL ) {
        return( NULL );
    }

    tbar = WdeAllocToolBar();
    if( tbar == NULL ) {
        return( NULL );
    }

    tbar->last_pos = info->dinfo.area;
    tbar->info = info;
    tbar->parent = parent;
    tbar->tbar = ToolBarInit( parent );

    ToolBarDisplay( tbar->tbar, &info->dinfo );

    for( i = 0; i < info->num_items; i++ ) {
        if( info->items[i].u.bmp != (HBITMAP)NULL ) {
            ToolBarAddItem( tbar->tbar, &info->items[i] );
        }
    }

    tbar->win = ToolBarWindow( tbar->tbar );

    if( (info->dinfo.style & TOOLBAR_FLOAT_STYLE) == TOOLBAR_FLOAT_STYLE ) {
        sys_menu = GetSystemMenu( tbar->win, FALSE );
        i = GetMenuItemCount( sys_menu );
        for( ; i > 0; i-- ) {
            DeleteMenu( sys_menu, 0, MF_BYPOSITION );
        }
        text = WdeAllocRCString( WDE_SYSMENUMOVE );
        AppendMenu( sys_menu, MF_STRING, SC_MOVE, text != NULL ? text : "Move" );
        if( text != NULL ) {
            WdeFreeRCString( text );
        }
        text = WdeAllocRCString( WDE_SYSMENUSIZE );
        AppendMenu( sys_menu, MF_STRING, SC_SIZE, text != NULL ? text : "Size" );
        if( text != NULL ) {
            WdeFreeRCString( text );
        }
        text = WdeAllocRCString( WDE_SYSMENUHIDE );
        AppendMenu( sys_menu, MF_STRING, SC_CLOSE, text != NULL ? text : "Hide" );
        if( text != NULL ) {
            WdeFreeRCString( text );
        }
    }

    width = info->dinfo.area.right - info->dinfo.area.left;
    height = info->dinfo.area.bottom - info->dinfo.area.top;
    SetWindowPos( tbar->win, (HWND)NULL, 0 ,0 , width, height, SWP_NOMOVE | SWP_NOZORDER );

    ShowWindow( tbar->win, SW_SHOWNORMAL );

    UpdateWindow( tbar->win );

    WdeAddToolBar( tbar );

    return( tbar );
}
Beispiel #12
0
/* Function to initialize all instances of Wde */
bool WdeInitInst( HINSTANCE app_inst )
{
    RECT        rect, screen, t;
    char        *title;

    /* initialize global variables */

    WdeInitOpts();

    if( !JDialogInit() ) {
        return( FALSE );
    }

    if( !WdeInitResStrings() ) {
        return( FALSE );
    }

    if( !WdeInitCreateTable() ) {
        WdeDisplayErrorMsg( WDE_NOINITCONTROLOBJECTS );
        return( FALSE );
    }

    WdeCtl3DInit( app_inst );
    WdeGetScreenPosOption( &rect );

    /* load the accelerator table */
    WdeAccel = LoadAccelerators( app_inst, "WdeAccelTable");

    /* if the window could not be created return FALSE */
    if( WdeAccel == (HACCEL)NULL ) {
        WdeDisplayErrorMsg( WDE_LOADACCELFAILED );
        return( FALSE );
    }

    GetWindowRect( GetDesktopWindow(), &screen );

    if( !IntersectRect( &t, &screen, &rect ) ) {
        t.right = rect.right - rect.left;
        t.bottom = rect.bottom - rect.top;
        t.left = 0;
        if( screen.right - screen.left - t.right > 0 )
            t.left = ( screen.right - screen.left - t.right ) / 2;
        t.top = 0;
        if( screen.bottom - screen.top - t.bottom > 0 )
            t.top = ( screen.bottom - screen.top - t.bottom ) / 2;
        t.right += t.left;
        t.bottom += t.top;
    } else {
        t = rect;
    }

    title = WdeAllocRCString( WDE_APPTITLE );
    /* attempt to create the main application window */
    hWinWdeMain = CreateWindow( WdeMainClass, title, WS_OVERLAPPEDWINDOW,
                                t.left, t.top, t.right - t.left, t.bottom - t.top,
                                (HWND)NULL, (HMENU)NULL, app_inst, NULL );
    if( title != NULL ) {
        WdeFreeRCString( title );
    }

    /* if the window could not be created return FALSE */
    if( hWinWdeMain == NULL ) {
        WdeDisplayErrorMsg( WDE_NOCREATEMAINWINDOW );
        return( FALSE );
    }

    hWinWdeMDIClient = WdeCreateMDIClientWindow( hWinWdeMain, app_inst );

    /* attempt to create the main application info window */
    if( !WdeCreateInfoWindow( hWinWdeMain, app_inst ) ) {
        WdeDisplayErrorMsg( WDE_NOCREATEINFOWINDOW );
        return( FALSE );
    }

    if( !WdeCreateStatusLine( hWinWdeMain, app_inst ) ) {
        WdeDisplayErrorMsg( WDE_NOCREATESTATUSLINE );
        return( FALSE );
    }

    WdeInitialMenu = GetMenu( hWinWdeMain );
    WdeCurrentMenu = WdeInitialMenu;
    WdeResMenu = LoadMenu( app_inst, "WdeResMenu" );
    WdeDDEMenu = LoadMenu( app_inst, "WdeDDEMenu" );

    if( IsDDE ) {
        WdeSetAppMenuToRes( TRUE );
    }


    if( !WdeInitialMenu || !WdeResMenu ) {
        WdeDisplayErrorMsg( WDE_NOINITMENUS );
        return( FALSE );
    }

    if( !WdeInitHints() ) {
        WdeDisplayErrorMsg( WDE_NOINITHINTS );
        return( FALSE );
    }

    WdeInitRibbon( app_inst );

    if( WdeGetOption( WdeOptIsRibbonVisible ) ) {
        WdeShowRibbon();
    }

    /* if the window was created Show and Update it */
    if( WdeGetOption( WdeOptIsScreenMax ) ) {
        ShowWindow( hWinWdeMain, SW_SHOWMAXIMIZED );
    } else {
        ShowWindow( hWinWdeMain, SW_SHOWNORMAL );
    }
    UpdateWindow( hWinWdeMain );

    WdeSetFontList( hWinWdeMain );

    if( !IsDDE ) {
        WdeDisplaySplashScreen( hInstWde, hWinWdeMain, 1125 );
    }

    if( IsDDE ) {
        WdeInitToolMenu( app_inst, WdeDDEMenu );
    } else {
        WdeInitToolMenu( app_inst, WdeResMenu );
    }
    WdeInitControls( app_inst );

    if( WdeGetOption( WdeOptIsCntlsTBarVisible ) ) {
        if( !WdeCreateControlsToolBar ( ) ) {
            WdeDisplayErrorMsg( WDE_NOCREATETOOLBOX );
            return( FALSE );
        }
    }

    SetFocus( hWinWdeMain );

    return( TRUE );

}
Beispiel #13
0
void WdeFiniResStrings( void )
{
    if( WdeResUntitled != NULL ) {
        WdeFreeRCString( WdeResUntitled );
        WdeResUntitled = NULL;
    }
    if( WdeResOpenTitle != NULL ) {
        WdeFreeRCString( WdeResOpenTitle );
        WdeResOpenTitle = NULL;
    }
    if( WdeResSaveTitle != NULL ) {
        WdeFreeRCString( WdeResSaveTitle );
        WdeResSaveTitle = NULL;
    }
    if( WdeResOpenFilter != NULL ) {
        WdeFreeRCString( WdeResOpenFilter );
        WdeResOpenFilter = NULL;
    }
    if( WdeResSaveFilter != NULL ) {
        WdeFreeRCString( WdeResSaveFilter );
        WdeResSaveFilter = NULL;
    }
    if( WdeResSaveFilterEXE != NULL ) {
        WdeFreeRCString( WdeResSaveFilterEXE );
        WdeResSaveFilterEXE = NULL;
    }
    if( WdeResSaveFilterDLL != NULL ) {
        WdeFreeRCString( WdeResSaveFilterDLL );
        WdeResSaveFilterDLL = NULL;
    }
    if( WdeResSaveFilterALL != NULL ) {
        WdeFreeRCString( WdeResSaveFilterALL );
        WdeResSaveFilterALL = NULL;
    }
    if( WdeSymSaveFilter != NULL ) {
        WdeFreeRCString( WdeSymSaveFilter );
        WdeSymSaveFilter = NULL;
    }
    if( WdeLoadHeaderTitle != NULL ) {
        WdeFreeRCString( WdeLoadHeaderTitle );
        WdeLoadHeaderTitle = NULL;
    }
    if( WdeWriteHeaderTitle != NULL ) {
        WdeFreeRCString( WdeWriteHeaderTitle );
        WdeWriteHeaderTitle = NULL;
    }
    if( WdeDlgSaveIntoTitle != NULL ) {
        WdeFreeRCString( WdeDlgSaveIntoTitle );
        WdeDlgSaveIntoTitle = NULL;
    }
    if( WdeDlgSaveAsTitle != NULL ) {
        WdeFreeRCString( WdeDlgSaveAsTitle );
        WdeDlgSaveAsTitle = NULL;
    }
    if( WdeDlgSaveTitle != NULL ) {
        WdeFreeRCString( WdeDlgSaveTitle );
        WdeDlgSaveTitle = NULL;
    }
    if( WdeNoSym != NULL ) {
        WdeFreeRCString( WdeNoSym );
        WdeNoSym = NULL;
    }
    if( WdeCustOpenTitle != NULL ) {
        WdeFreeRCString( WdeCustOpenTitle );
        WdeCustOpenTitle = NULL;
    }
    if( WdeCustFilter != NULL ) {
        WdeFreeRCString( WdeCustFilter );
        WdeCustFilter = NULL;
    }
}
Beispiel #14
0
Bool WdeCreateStatusLine( HWND main, HINSTANCE inst )
{
    RECT                rect;
    LOGFONT             lf;
    TEXTMETRIC          tm;
    HFONT               old_font;
    HDC                 dc;
    status_block_desc   sbd;
    char                *status_font;
    char                *cp;
    int                 point_size;
    Bool                use_default;

    memset( &lf, 0, sizeof( LOGFONT ) );
    dc = GetDC( main );
    lf.lfWeight = FW_BOLD;
    use_default = TRUE;

    status_font = WdeAllocRCString( WDE_STATUSFONT );
    if( status_font != NULL ) {
        cp = (char *)_mbschr( (unsigned char *)status_font, '.' );
        if( cp != NULL ) {
            *cp = '\0';
            strcpy( lf.lfFaceName, status_font );
            cp++;
            point_size = atoi( cp );
            use_default = FALSE;
        }
        WdeFreeRCString( status_font );
    }

    if( use_default ) {
        strcpy( lf.lfFaceName, STATUS_FONTNAME );
        point_size = STATUS_POINTSIZE;
    }

    lf.lfHeight = -MulDiv( point_size, GetDeviceCaps( dc, LOGPIXELSY ), 72 );
    WdeStatusFont = CreateFontIndirect( &lf );
    old_font = SelectObject( dc, WdeStatusFont );
    GetTextMetrics( dc, &tm );
    SelectObject( dc, old_font );
    ReleaseDC( main, dc );

    GetClientRect( main, &rect );

    WdeStatusDepth = tm.tmHeight + STATUS_LINE_PAD + VERT_BORDER * 2;
    rect.top = rect.bottom - WdeStatusDepth;

    if( !StatusWndInit( inst, WdeStatusHookProc, 0, (HCURSOR)NULL ) ) {
        return( FALSE );
    }
    WdeStatusBar = StatusWndStart();

    sbd.separator_width = STATUS_LINE_PAD;
    sbd.width = STATUS1_WIDTH;
    sbd.width_is_percent = FALSE;
    sbd.width_is_pixels = TRUE;

    StatusWndSetSeparators( WdeStatusBar, 1, &sbd );

    WdeStatusWindow = StatusWndCreate( WdeStatusBar, main, &rect, inst, NULL );

    if( WdeStatusWindow == NULL ) {
        WdeDisplayErrorMsg( WDE_NOCREATESTATUS );
        return( FALSE );
    }

    /* set the text in the status window */
    WdeSetStatusReadyText();

    GetWindowRect( WdeStatusWindow, &rect );
    WdeStatusDepth = rect.bottom - rect.top;

    return( TRUE );
}
Beispiel #15
0
static bool wdeControlsHook( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
    MINMAXINFO          *minmax;
    WdeToolBar          *tbar;
    OBJ_ID              obj_id;
    WORD                id;
    char                *text;
    OBJPTR              obj;
    WdeOrderMode        mode;
    ctl_id              cid;
    bool                ignore_msg;
    bool                ret;

    ignore_msg = FALSE;

    if( WdeGetNumRes() && !WdeInCleanup() ) {
        obj = WdeGetCurrentDialog();
        if( obj != NULL && Forward( obj, GET_ORDER_MODE, &mode, NULL ) && mode != WdeSelect ) {
            ignore_msg = TRUE;
        }
    }

    if( !ignore_msg && WdeGetTestMode() ) {
        ignore_msg = TRUE;
    }

    if( ignore_msg ) {
        switch( msg ) {
        case WM_RBUTTONDOWN:
        case WM_RBUTTONDBLCLK:
        case WM_LBUTTONDOWN:
        case WM_LBUTTONDBLCLK:
        case WM_RBUTTONUP:
        case WM_LBUTTONUP:
            return( true );
        }
    }

    if( (tbar = WdeControls) == NULL ) {
        if( msg == WM_GETMINMAXINFO ) {
            minmax = (MINMAXINFO *)lParam;
            minmax->ptMinTrackSize.x = 8;
        }
        return( false );
    }

    ret = false;

    switch( msg ) {
    case WM_USER:
        if( WdeGetNumRes() ) {
            obj_id = GetBaseObjType();
            id = WdeGetMenuFromOBJID( obj_id );
            if( id == wParam || (wParam == IDM_STICKY_TOOLS && WdeStickyMode) ) {
                lParam = !lParam;
            }
            WdeHandleStickyToolPress( tbar, wParam, lParam );
        }
        break;

    case WM_RBUTTONDOWN:
    case WM_RBUTTONDBLCLK:
    case WM_LBUTTONDOWN:
    case WM_LBUTTONDBLCLK:
        if( FindToolIDAtPoint( tbar->tbar, wParam, lParam, &cid ) ) {
            if( cid == IDM_CUSTOM1_TOOL ) {
                ret = !WdeIsCurrentCustControlSet( 0 );
            } else if( cid == IDM_CUSTOM2_TOOL ) {
                ret = !WdeIsCurrentCustControlSet( 1 );
            }
        }
        break;

    case WM_SIZE:
        if ( wParam != SIZE_MAXIMIZED && wParam != SIZE_MINIMIZED ) {
            GetWindowRect( hwnd, &tbar->last_pos );
        }
        break;

    case WM_MOVE:
        if( !IsZoomed( hwnd ) ) {
            GetWindowRect( hwnd, &tbar->last_pos );
        }
        break;

    case WM_GETMINMAXINFO:
        if( GetModuleHandle( "COMCTL32.DLL" ) == NULL ) {
            minmax = (MINMAXINFO *)lParam;
            minmax->ptMinTrackSize.x =
                2 * GetSystemMetrics( SM_CXFRAME ) +
                tbar->info->dinfo.border_size.x +
                tbar->info->dinfo.button_size.x - 1;
            minmax->ptMinTrackSize.y =
                2 * GetSystemMetrics( SM_CYFRAME ) +
                GetSystemMetrics(SM_CYCAPTION) +
                tbar->info->dinfo.border_size.y +
                tbar->info->dinfo.button_size.y - 1;
            ret = true;
        }
        break;

    case WM_CLOSE:
        WdeDestroyControls();
        WdeSetOption ( WdeOptIsCntlsTBarVisible, FALSE );
        ret = true;
        break;

    case WM_DESTROY:
        WdeControls = NULL;
        WdeSetCntlTBarPosOption( &tbar->last_pos );
        text = WdeAllocRCString( WDE_SHOWTOOLBOX );
        ModifyMenu( WdeGetResMenuHandle(), IDM_SHOW_TOOLS,
                    MF_BYCOMMAND | MF_STRING, IDM_SHOW_TOOLS, text );
        ModifyMenu( WdeGetInitialMenuHandle(), IDM_SHOW_TOOLS,
                    MF_BYCOMMAND | MF_STRING, IDM_SHOW_TOOLS, text );
        if( text != NULL ) {
            WdeFreeRCString( text );
        }
        WdeCloseToolBar( tbar );
        break;

    }

    return( ret );
}
Beispiel #16
0
bool WdeCreateControlsToolBar( void )
{
    RECT        t, r, screen;
    HWND        parent;
    int         id;
    char        *text;

    if( WdeControls != NULL ) {
        return ( true );
    }

    WdeSetStatusText( NULL, "", false );
    WdeSetStatusByID( WDE_CREATINGTOOLBOX, 0 );

    parent = WdeGetMainWindowHandle();

    WdeGetCntlTBarPosOption( &t );

    if( t.left == t.right && t.top == t.bottom ) {
        GetWindowRect( parent, &r );
#ifdef __NT__
        if( GetModuleHandle( "COMCTL32.DLL" ) == NULL ) {
#endif
            t.left = r.right - CONTROLS_DEFX;
            t.top = r.top + CONTROLS_INSET;
            t.right = r.right;
            t.bottom = t.top + CONTROLS_DEFY;
#ifdef __NT__
        } else {
            t.left = r.right - CONTROLS_DEFXCC;
            t.top = r.top + CONTROLS_INSET;
            t.right = r.right;
            t.bottom = t.top + CONTROLS_DEFYCC;
        }
#endif
    }

    GetWindowRect( GetDesktopWindow(), &screen );
    if( !IntersectRect( &r, &screen, &t ) ) {
        r.right = t.right - t.left;
        r.bottom = t.bottom - t.top;
        r.left = 0;
        if( screen.right > r.right )
            r.left = ( screen.right - r.right ) / 2;
        r.top = 0;
        if( screen.bottom - screen.top - r.bottom  > 0 )
            r.top = ( screen.bottom - screen.top - r.bottom ) / 2;
        r.right += r.left;
        r.bottom += r.top;
        t = r;
    }

    WdeControlsInfo->dinfo.area = t;

    WdeControls = WdeCreateToolBar( WdeControlsInfo, parent );

    if( WdeControls == NULL ) {
        return( false );
    }

    text = WdeAllocRCString( WDE_TOOLBOXCAPTION );
    SendMessage( WdeControls->win, WM_SETTEXT, 0, (LPARAM)(LPCSTR)text );
    if( text != NULL ) {
        WdeFreeRCString( text );
    }

    text = WdeAllocRCString( WDE_HIDETOOLBOX );
    ModifyMenu ( WdeGetInitialMenuHandle(), IDM_SHOW_TOOLS,
                 MF_BYCOMMAND | MF_STRING, IDM_SHOW_TOOLS, text );
    ModifyMenu ( WdeGetResMenuHandle(), IDM_SHOW_TOOLS,
                 MF_BYCOMMAND | MF_STRING, IDM_SHOW_TOOLS, text );
    if( text != NULL ) {
        WdeFreeRCString( text );
    }

    if( WdeGetNumRes() ) {
        id = WdeGetMenuFromOBJID( GetBaseObjType() );
        if( id != -1 ) {
            WdeSetToolBarItemState( WdeControls, id, BUTTON_DOWN );
        }
        WdeSetStickyMode( WdeStickyMode );
    }

    WdeSetStatusReadyText();

    return( true );
}