Esempio n. 1
0
BOOL CMiscPrefPage::OnCommand(WPARAM wParam, LPARAM lParam) 
{
	HWND   	hActiveWnd = GetActiveDoc();
	HWND	hDlg = GetSafeHwnd();
	int 	id = GET_WM_COMMAND_ID(wParam, lParam);
	UINT 	codeNotify = GET_WM_COMMAND_CMD(wParam, lParam);

	switch (id)
	{
		case IDC_PREF_POUCH:
			if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) )
	    		break;
			if ( codeNotify != EN_CHANGE )
	    		break;
			::GetDlgItemText( hDlg, id, Control.PouchPath,
				sizeof(Control.PouchPath));
			FixPath( Lowercase( Control.PouchPath ) );
			SetModified(TRUE);
		break;

		case IDC_PREF_TABLET:
//		case IDC_PREF_TABLETUNUSED:
//		case IDC_PREF_TABLETOPACITY:
//		case IDC_PREF_TABLETSIZE:
//		case IDC_PREF_TABLETBOTH:
			if ( !(id = HandleCombo( hDlg, id, codeNotify )) )
				break;
			Control.UseTablet = id-IDC_PREF_TABLETUNUSED;
			SetModified(TRUE);
		break;

		case IDC_PREF_STARTMACRO:
		   	GetExtNameN( hDlg, id, IDC_FILENAME, Names.StartMacro,
		    	IDN_MACRO, codeNotify, IDS_NONE, NO );
			SetModified(TRUE);
		break;

		case IDC_PREF_MASKTINT:
//		case IDC_PREF_MASKTINT1:
//		case IDC_PREF_MASKTINT2:
//		case IDC_PREF_MASKTINT3:
//		case IDC_PREF_MASKTINT4:
//		case IDC_PREF_MASKTINT5:
//		case IDC_PREF_MASKTINT6:
			if ( !(id = HandleCombo( hDlg, id, codeNotify )) )
				break;
			Control.MaskTint = id - IDC_PREF_MASKTINT1;
			SetModified(TRUE);
		break;

		case IDC_PREF_TOOLSETTINGS:
			Control.IndependentSettings = !Control.IndependentSettings;
			::CheckDlgButton(hDlg, id, Control.IndependentSettings);
			SetModified(TRUE);
		break;

		case IDC_CMS_ENABLED:
			Control.CMSEnabled = CMSOpen( !Control.CMSEnabled );
			::CheckDlgButton(hDlg, id, Control.CMSEnabled);
			SetModified(TRUE);
		break;

		case IDC_PREF_PASTEATREALSIZE:
			Mask.PasteAtRealSize = !Mask.PasteAtRealSize;
			::CheckDlgButton( hDlg, IDC_PREF_PASTEATREALSIZE, Mask.PasteAtRealSize);
			SetModified(TRUE);
		break;

		case IDC_PREF_USEGRAYSCALEICONS:
			Control.UseGrayScaleIcons = !Control.UseGrayScaleIcons;
			::CheckDlgButton( hDlg, IDC_PREF_USEGRAYSCALEICONS, Control.UseGrayScaleIcons);
			SetModified(TRUE);
		break;

		case IDC_PREF_DISABLEAUTOSCROLL:
			Control.DisableAutoScroll = !Control.DisableAutoScroll;
			::CheckDlgButton( hDlg, IDC_PREF_DISABLEAUTOSCROLL, Control.DisableAutoScroll);
			SetModified(TRUE);
		break;

		case IDC_PREF_DISABLEDITHER:
			Vignette.DisableDither = !Vignette.DisableDither;
			::CheckDlgButton( hDlg, IDC_PREF_DISABLEDITHER, Vignette.DisableDither);
			SetModified(TRUE);
		break;

		case IDC_PREF_FILETYPE:
    		if( Control.Retail )
    		{
	    		if (! (id = TableHandleCombo(hDlg, FileType_Table,
					    		sizeof(FileType_Table)/sizeof(ITEMID),
					    		id, codeNotify)))
            		break;
    		}
    		else
    		{
	    		if (! (id = TableHandleCombo(hDlg, FileType_TableOEM,
					    		sizeof(FileType_TableOEM)/sizeof(ITEMID),
					    		id, codeNotify)))
            		break;
    		}
			Control.DefaultFileType = AppFileType(id);
			SetModified(TRUE);
		break;

	   	default:
			return (CPPPropertyPage::OnCommand(wParam, lParam));   	
		break;
   	}
	return(TRUE);
}
Esempio n. 2
0
File: qa.c Progetto: mingpen/OpenNT
/*----------------------------------------------------------------------------*\
|   AppWndProc( hwnd, uiMessage, wParam, lParam )                              |
|                                                                              |
|   Description:                                                               |
|       The window proc for the app's main (tiled) window.  This processes all |
|       of the parent window's messages.                                       |
|                                                                              |
\*----------------------------------------------------------------------------*/
LONG FAR PASCAL _export AppWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
    PAINTSTRUCT ps;
    HDC hdc;
    BOOL f;
  
    switch (msg)
    {
        case WM_CREATE:
            hwndA = CreateWindowEx(WS_EX_CLIENTEDGE,ANIMATE_CLASS, NULL,
//              ACS_CENTER |
                ACS_TRANSPARENT |
                WS_VISIBLE | WS_CHILD | WS_BORDER,
                10, 10, 500, 200, hwnd, (HMENU)42, hInstApp, NULL);
	    break;

	case WM_SIZE:
            //if (hwndC = GetWindow(hwnd, GW_CHILD))
            //    MoveWindow(hwndC, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
	    break;

        case WM_ACTIVATEAPP:
	    fAppActive = (BOOL)wParam;
            break;

        case WM_TIMER:
            break;

        case WM_ERASEBKGND:
            break;

        case WM_INITMENU:
	    EnableMenuSz((HMENU)wParam, TEXT("Edit.Paste"), IsClipboardFormatAvailable(CF_TEXT));
            break;

        case WM_COMMAND:
            //
            //  the animate control will notify us when play start or stops.
            //
            if (LOWORD(wParam) == 42)
            {
                if (GET_WM_COMMAND_CMD(wParam, lParam) == ACN_STOP)
                    AppSetText(TEXT("(stopped)"));
                else if (GET_WM_COMMAND_CMD(wParam, lParam) == ACN_START)
                    AppSetText(TEXT("(playing)"));
                else
                    AppSetText(NULL);
            }
            return HandleCommand(hwnd,msg,wParam,lParam);

	case WM_DESTROY:
	    hAccelApp = NULL;
            PostQuitMessage(0);
	    break;

        case WM_CLOSE:
	    break;

        case WM_PALETTECHANGED:
	    if ((HWND)wParam == hwnd)
		break;

	    // fall through to WM_QUERYNEWPALETTE

	case WM_QUERYNEWPALETTE:
	    hdc = GetDC(hwnd);

	    if (hpalApp)
		SelectPalette(hdc, hpalApp, FALSE);

	    f = RealizePalette(hdc);
	    ReleaseDC(hwnd,hdc);

	    if (f)
		InvalidateRect(hwnd,NULL,TRUE);

	    return f;

        case WM_PAINT:
	    hdc = BeginPaint(hwnd,&ps);
	    AppPaint (hwnd,hdc);
            EndPaint(hwnd,&ps);
            return 0L;
    }
    return DefWindowProc(hwnd,msg,wParam,lParam);
}
Esempio n. 3
0
UINT_PTR CALLBACK AddSrcDlgProc95( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
    WORD            cmd;
    int             item;
    LRESULT         rc;
    HWND            ctl;
    HWND            dlg;
    GetFilesInfo    *info;

    lparam = lparam;
    switch( msg ) {
    case WM_INITDIALOG:
        {
            OPENFILENAME        *of;

            of = (OPENFILENAME *)lparam;
            ctl = GetDlgItem( hwnd, FOD_REMOVE );
            EnableWindow( ctl, FALSE );
            dlg = GetParent( hwnd );
            SendMessage( dlg, CDM_SETCONTROLTEXT, IDOK, (LPARAM)"&Add" );
            SET_DLGDATA( hwnd, of->lCustData );
            info = (GetFilesInfo *)of->lCustData;
            info->filter_index = of->nFilterIndex;
            info->filter = of->lpstrFilter;
            initFileList( hwnd );
        }
        break;
    case WM_COMMAND:
        cmd = LOWORD( wparam );
        switch( cmd ) {
        case FOD_ADD:
            addCurrentFile95( hwnd );
            return( TRUE );
        case FOD_ADDALL:
            addAllFiles95( hwnd );
            break;
        case FOD_REMOVE:
            ctl = GetDlgItem( hwnd, FOD_FILELIST );
            item = (int)SendMessage( ctl, LB_GETCURSEL, 0, 0 );
            if( item != LB_ERR ) {
                rc = SendMessage( ctl, LB_DELETESTRING, item, 0 );
                if( item != 0 ) {
                    SendMessage( ctl, LB_SETCURSEL, item - 1, 0 );
                } else {
                    SendMessage( ctl, LB_SETCURSEL, item, 0 );
                }
            }
            checkRemoveButton( hwnd );
            break;
        case FOD_FILELIST:
            if( GET_WM_COMMAND_CMD( wparam, lparam ) == LBN_SELCHANGE ||
                GET_WM_COMMAND_CMD( wparam, lparam ) == LBN_SELCANCEL ) {
                checkRemoveButton( hwnd );
            }
            break;
        case FOD_CLOSE:
            GetResults( hwnd );
            info = (GetFilesInfo *)GET_DLGDATA( hwnd );
            info->ret_code = IDOK;
            PostMessage( GetParent( hwnd ), WM_COMMAND, IDCANCEL, 0L );
            return( TRUE );
        case IDCANCEL:
            info = (GetFilesInfo *)GET_DLGDATA( hwnd );
            info->ret_code = IDCANCEL;
            PostMessage( GetParent( hwnd ), WM_COMMAND, IDCANCEL, 0L );
            return( TRUE );
        default:
            return( FALSE );
        }
        break;
    case WM_NOTIFY:
        switch( ((NMHDR *)lparam)->code ) {
        case CDN_FILEOK:
            PostMessage( hwnd, WM_COMMAND, FOD_ADD, 0L );
            SET_DLGRESULT( hwnd, 1L );
            return( TRUE );
        case CDN_TYPECHANGE:
            info = (GetFilesInfo *)GET_DLGDATA( hwnd );
            info->filter_index = ((OFNOTIFY *)lparam)->lpOFN->nFilterIndex;
            break;
        }
        break;
    default:
        return( FALSE );
    }
    return( TRUE );
}
Esempio n. 4
0
BOOL CUnitsPrefPage::OnCommand(WPARAM wParam, LPARAM lParam) 
{
	BOOL 	Bool;
	LPSTR 	lpUnit;
	HWND   	hActiveWnd = GetActiveDoc();
	HWND	hDlg = GetSafeHwnd();
	int 	id = GET_WM_COMMAND_ID(wParam, lParam);
	UINT 	codeNotify = GET_WM_COMMAND_CMD(wParam, lParam);

	switch (id)
	{
		case IDC_PREF_USERULERS:
			View.UseRulers = !View.UseRulers;
			::CheckDlgButton( hDlg, id, View.UseRulers );
			SetModified(TRUE);
		break;

		case IDC_PREF_DISPLAYPIXELS:
			Control.DisplayPixelValue = !Control.DisplayPixelValue;
			::CheckDlgButton( hDlg, id, !Control.DisplayPixelValue );
			SetModified(TRUE);
		break;

		case IDC_PREF_SCREENWIDTH:
			if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) )
				break;
			if ( codeNotify != EN_CHANGE )
				break;
			Control.ScreenWidth = AstralGetDlgItemFixed( hDlg, id, &Bool, NO);
			SetModified(TRUE);
		break;

		case IDC_PREF_UNITS:
//		case IDC_PREF_UNITINCHES:
//		case IDC_PREF_UNITMM:
//		case IDC_PREF_UNITCM:
//		case IDC_PREF_UNITPICAS:
//		case IDC_PREF_UNITPIXELS:
			if ( !(id = HandleCombo( hDlg, id, codeNotify )) )
				break;
			Control.Units = id;
			SetUnitInfo((UNIT_TYPE)(Control.Units-IDC_PREF_UNITINCHES), Control.UnitRes, Control.Points);
			if ( AstralStr( Control.Units-IDC_PREF_UNITINCHES+IDS_INCHES,
	     		&lpUnit ) )
				::SetDlgItemText( hDlg, IDC_WIDTHLABEL, lpUnit );
			ControlEnable( hDlg, IDC_PREF_SCREENWIDTH,
				Control.Units != IDC_PREF_UNITPIXELS );

			if ( Control.Units != IDC_PREF_UNITPIXELS )
				AstralSetDlgItemFixed( hDlg, IDC_PREF_SCREENWIDTH, Control.ScreenWidth, NO );
			else
				::SetDlgItemInt( hDlg, IDC_PREF_SCREENWIDTH, GetSystemMetrics( SM_CXSCREEN ), NO );
			SetModified(TRUE);
		break;

	   	default:
			return (CPPPropertyPage::OnCommand(wParam, lParam));   	
		break;
   	}
	return(TRUE);
}
Esempio n. 5
0
WINEXPORT BOOL CALLBACK WAcccelEditProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
{
    WAccelEditInfo      *einfo;
    HWND                win;
    RECT                r;
    POINT               p;
    BOOL                ret;
    WORD                wp;
    WORD                cmd;

    ret = FALSE;
    einfo = (WAccelEditInfo *)GET_DLGDATA( hDlg );

    switch( message ) {
    case WM_INITDIALOG:
        einfo = (WAccelEditInfo *)lParam;
        einfo->edit_dlg = hDlg;
        SET_DLGDATA( hDlg, einfo );
        WRAddSymbolsToComboBox( einfo->info->symbol_table, hDlg,
                                IDM_ACCEDCMDID, WR_HASHENTRY_ALL );
        ret = TRUE;
        break;

    case WM_SYSCOLORCHANGE:
        WCtl3dColorChange();
        break;

#if 0
#ifdef __NT__
    case WM_CTLCOLORBTN:
    case WM_CTLCOLORDLG:
    case WM_CTLCOLOREDIT:
    case WM_CTLCOLORLISTBOX:
    case WM_CTLCOLORMSGBOX:
    case WM_CTLCOLORSCROLLBAR:
    case WM_CTLCOLORSTATIC:
#else
    case WM_CTLCOLOR:
#endif
        return( WCtl3dCtlColorEx( message, wParam, lParam ) );
#endif

    case WM_LBUTTONDBLCLK:
    case WM_RBUTTONDBLCLK:
    case WM_RBUTTONUP:
        MAKE_POINT( p, lParam );
        win = GetDlgItem( hDlg, IDM_ACCEDRNAME );
        GetClientRect( win, &r );
        MapWindowPoints( win, hDlg, (POINT *)&r, 2 );
        if( PtInRect( &r, p ) ) {
            WHandleRename( einfo );
        }
        ret = TRUE;
        break;

#if 0
    case WM_PARENTNOTIFY:
        cmd = GET_WM_PARENTNOTIFY_EVENT( wParam, lParam );
        switch( cmd ) {
        case WM_LBUTTONDOWN:
        case WM_RBUTTONDOWN:
            MAKE_POINT( p, lParam );
            win = GetDlgItem( hDlg, IDM_ACCEDLIST );
            GetWindowRect( win, &r );
            MapWindowPoints( HWND_DESKTOP, hDlg, (POINT *)&r, 2 );
            if( PtInRect( &r, p ) ) {
                WHandleSelChange( einfo );
            }
            break;
        }
        ret = TRUE;
        break;
#endif

    case WM_COMMAND:
        wp = LOWORD( wParam );
        cmd = GET_WM_COMMAND_CMD( wParam, lParam );
        switch( wp ) {
        case IDM_ACCEDINSERT:
            WInsertAccelEntry( einfo );
            break;
        case IDM_ACCEDCHANGE:
            WHandleChange( einfo );
            break;
        case IDM_ACCEDRESET:
            WDoHandleSelChange( einfo, FALSE, TRUE );
            break;
        case IDM_ACCEDSETACC:
            if( einfo->tbl != NULL && einfo->tbl->num != 0 ) {
                WHandleSelChange( einfo );
            } else {
                WInsertAccelEntry( einfo );
            }
            break;
#if 0
        case IDM_ACCEDCMDID:
            if( cmd == CBN_SELCHANGE ) {
                einfo->combo_change = TRUE;
                WHandleSelChange( einfo );
                einfo->combo_change = FALSE;
            }
            break;
#endif
        case IDM_ACCEDLIST:
            if( cmd == LBN_SELCHANGE ) {
                WHandleSelChange( einfo );
            }
            break;
        case IDM_ACCEDVIRT:
        case IDM_ACCEDASCII:
            if( cmd == BN_CLICKED ) {
                WSetVirtKey( hDlg, wp == IDM_ACCEDVIRT );
            }
            break;
        }
        break;
    }

    return( ret );
}
Esempio n. 6
0
/*
 * snoopDlgProc - callback routine for snoop dialog
 */
WINEXPORT BOOL CALLBACK SnoopDlgProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
    // int                 i;
    int                 cmd;
    int                 index;
    char                snoop[MAX_INPUT_LINE];
#ifdef __NT__
    BROWSEINFO          bi;
    char                buffer1[MAX_PATH];
    char                buffer2[MAX_PATH];
    LPITEMIDLIST        pidl;
#endif

#ifdef __NT__
    lparam = lparam;
#endif
    switch( msg ) {
    case WM_INITDIALOG:
        CenterWindowInRoot( hwnd );

        CheckDlgButton( hwnd, SNOOP_IGNORE_CASE, ( snoopData.case_ignore ) ? BST_CHECKED : BST_UNCHECKED );
        CheckDlgButton( hwnd, SNOOP_REGULAR_EXPRESSIONS, ( snoopData.use_regexp ) ? BST_CHECKED : BST_UNCHECKED );
        SetDlgItemText( hwnd, SNOOP_STRING, snoopData.find );
        SetDlgItemText( hwnd, SNOOP_PATH, snoopData.path );

        // default extsion should be grep extension
        SetDlgItemText( hwnd, SNOOP_EXT, snoopData.ext );

        // this isn't quite right. but it's close.
        /*
        for( i = 0; i < extension.max; i++ ) {
            SendDlgItemMessage( hwnd, SNOOP_LISTBOX, LB_ADDSTRING, 0, (LPARAM)extension[i] );
        }
        */

        return( TRUE );
    case WM_CLOSE:
        PostMessage( hwnd, WM_COMMAND, GET_WM_COMMAND_MPS( IDCANCEL, 0, 0 ) );
        return( TRUE );
    case WM_COMMAND:
        switch( LOWORD( wparam ) ) {
        case SNOOP_EXT:
            cmd = GET_WM_COMMAND_CMD( wparam, lparam );
            if( cmd == LBN_SELCHANGE || cmd == LBN_DBLCLK ) {
                index = (int)SendDlgItemMessage( hwnd, SNOOP_EXT, LB_GETCURSEL, 0, 0L );
                if( index == LB_ERR ) {
                    break;
                }
                SendDlgItemMessage( hwnd, SNOOP_EXT, LB_GETTEXT, index, (LPARAM)snoop );
                SetDlgItemText( hwnd, SNOOP_STRING, snoop );
            }
            break;
#ifdef __NT__
        case SNOOP_BROWSE:
            bi.hwndOwner = hwnd;
            bi.pidlRoot = NULL;
            bi.pszDisplayName = NULL;
            LoadString( GET_HINSTANCE( hwnd ), VI_BROWSE_MSG, buffer1, sizeof( buffer1 ) );
            bi.lpszTitle = buffer1;
            bi.ulFlags = BIF_RETURNONLYFSDIRS;
            bi.lpfn = BrowseCallbackProc;
            GetDlgItemText( hwnd, SNOOP_PATH, buffer2, MAX_PATH );
            bi.lParam = (LPARAM)buffer2;
            if( (pidl = pfnSHBrowseForFolder( &bi )) != NULL ) {
                if( pfnSHGetPathFromIDList( pidl, buffer1 ) ) {
                    SetDlgItemText( hwnd, SNOOP_PATH, buffer1 );
                }
            }
            break;
#endif
        case IDCANCEL:
            // RemoveEditSubClass( hwnd, SNOOP_STRING );
            EndDialog( hwnd, FALSE );
            break;
        case IDOK:
            GetDlgItemText( hwnd, SNOOP_STRING, snoop, MAX_INPUT_LINE );
            ReplaceString( &snoopData.find, snoop );
            GetDlgItemText( hwnd, SNOOP_EXT, snoop, MAX_INPUT_LINE );
            ReplaceString( &snoopData.ext, snoop );
            GetDlgItemText( hwnd, SNOOP_PATH, snoop, MAX_INPUT_LINE );
            ReplaceString( &snoopData.path, snoop );
            snoopData.case_ignore = IsDlgButtonChecked( hwnd, SNOOP_IGNORE_CASE );
            snoopData.use_regexp = IsDlgButtonChecked( hwnd, SNOOP_REGULAR_EXPRESSIONS );
            // RemoveEditSubClass( hwnd, SNOOP_STRING );
            EndDialog( hwnd, TRUE );
            break;
        default:
            return( FALSE );
        }
        // hand it off to fgrep
        return( TRUE );
    }
    return( FALSE );

} /* SnoopDlgProc */
Esempio n. 7
0
BOOL CALLBACK RunDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    LPRUNDLG_DATA lprd;

    lprd = (LPRUNDLG_DATA)GetWindowLong(hDlg, DWL_USER);
    switch (uMsg)
    {
    case WM_INITDIALOG:
            /* The title will be in the lParam. */
            lprd = (LPRUNDLG_DATA)lParam;
            lprd->hDlg = hDlg;
            lprd->fDone = FALSE;
            InitRunDlg(hDlg, lprd);
            // Let the parent thread run on if it was waiting for us to
            // grab type-ahead.
            if (lprd->hEventReady)
            {
                // We need to grab the activation so we can process input.
                // DebugMsg(DM_TRACE, "s.rdp: Getting activation.");
                SetForegroundWindow(hDlg);
                SetFocus(GetDlgItem(hDlg, IDD_COMMAND));
                // Now it's safe to wake the guy up properly.
                // DebugMsg(DM_TRACE, "s.rdp: Waking sleeping parent.");
                SetEvent(lprd->hEventReady);
                CloseHandle(lprd->hEventReady);
            }
            else
            {
                SetForegroundWindow(hDlg);
                SetFocus(GetDlgItem(hDlg, IDD_COMMAND));
            }

            // InitRunDlg 2nd phase (must be called after SetEvent)
            InitRunDlg2(hDlg, lprd);

            // We're handling focus changes.
            return FALSE;

    case WM_DESTROY:
            break;

    case WM_HELP:
        WinHelp((HWND) ((LPHELPINFO) lParam)->hItemHandle, NULL, HELP_WM_HELP,
            (DWORD) (LPTSTR) aRunHelpIds);
        break;

    case WM_CONTEXTMENU:      // right mouse click
        WinHelp((HWND) wParam, NULL, HELP_CONTEXTMENU,
            (DWORD) (LPTSTR) aRunHelpIds);
        break;


    case WM_COMMAND:
            switch (GET_WM_COMMAND_ID(wParam, lParam))
            {
            case IDHELP:
                    break;

            case IDD_COMMAND:
                switch (GET_WM_COMMAND_CMD(wParam, lParam))
                {
                case CBN_SELCHANGE:
                    MRUSelChange(hDlg);
#ifdef WINNT
                    if ( g_hCheckNow )
                    {
                        SetEvent( g_hCheckNow );
                    }
#endif // WINNT
                    break;
                case CBN_EDITCHANGE:
                case CBN_SELENDOK:
                    EnableOKButton(hDlg, NULL);
#ifdef WINNT
                    if ( g_hCheckNow )
                    {
                        SetEvent( g_hCheckNow );
                    }
#endif // WINNT
                    break;
                }
                break;

            case IDOK:
            if (!OKPushed(lprd)) {
#ifdef WINNT
                if (!(lprd->dwFlags & RFD_NOSEPMEMORY_BOX))
                {
                    g_bCheckRunInSep = FALSE;
                    SetEvent( g_hCheckNow );
                }
#endif // WINNT
                break;
            }
            // fall through

            case IDCANCEL:
                ExitRunDlg(lprd, FALSE);
                break;

            case IDD_BROWSE:
                BrowsePushed(lprd);
#ifdef WINNT
                SetEvent( g_hCheckNow );
#endif // WINNT
                break;

            default:
                return FALSE;
            }
            break;

    default:
        return FALSE;
    }
    return TRUE;
}
Esempio n. 8
0
/*-------
 * ConfigDlgProc
 *	Description:	Manage add data source name dialog
 *	Input	 :	hdlg --- Dialog window handle
 *				wMsg --- Message
 *				wParam - Message parameter
 *				lParam - Message parameter
 *	Output	 :	TRUE if message processed, FALSE otherwise
 *-------
 */
LRESULT			CALLBACK
ConfigDlgProc(HWND hdlg,
			  UINT wMsg,
			  WPARAM wParam,
			  LPARAM lParam)
{
	LPSETUPDLG	lpsetupdlg;
	ConnInfo   *ci;
	DWORD		cmd;
	char		strbuf[64];

	switch (wMsg)
	{
			/* Initialize the dialog */
		case WM_INITDIALOG:
			lpsetupdlg = (LPSETUPDLG) lParam;
			ci = &lpsetupdlg->ci;

			/* Hide the driver connect message */
			ShowWindow(GetDlgItem(hdlg, DRV_MSG_LABEL), SW_HIDE);
			LoadString(s_hModule, IDS_ADVANCE_SAVE, strbuf, sizeof(strbuf));
			SetWindowText(GetDlgItem(hdlg, IDOK), strbuf);

			SetWindowLongPtr(hdlg, DWLP_USER, lParam);
			CenterDialog(hdlg); /* Center dialog */

			/*
			 * NOTE: Values supplied in the attribute string will always
			 */
			/* override settings in ODBC.INI */

			copy_globals(&ci->drivers, &globals);
			/* Get the rest of the common attributes */
			getDSNinfo(ci, CONN_DONT_OVERWRITE);

			/* Fill in any defaults */
			getDSNdefaults(ci);

			/* Initialize dialog fields */
			SetDlgStuff(hdlg, ci);
	
			/* Save drivername */
			if (!(lpsetupdlg->ci.drivername[0]))
				lstrcpy(lpsetupdlg->ci.drivername, lpsetupdlg->lpszDrvr);

			if (lpsetupdlg->fNewDSN || !ci->dsn[0])
				ShowWindow(GetDlgItem(hdlg, IDC_MANAGEDSN), SW_HIDE);
			if (lpsetupdlg->fDefault)
			{
				EnableWindow(GetDlgItem(hdlg, IDC_DSNAME), FALSE);
				EnableWindow(GetDlgItem(hdlg, IDC_DSNAMETEXT), FALSE);
			}
			else
				SendDlgItemMessage(hdlg, IDC_DSNAME,
							 EM_LIMITTEXT, (WPARAM) (MAXDSNAME - 1), 0L);

			SendDlgItemMessage(hdlg, IDC_DESC,
							   EM_LIMITTEXT, (WPARAM) (MAXDESC - 1), 0L);
			return TRUE;		/* Focus was not set */

			/* Process buttons */
		case WM_COMMAND:
			switch (cmd = GET_WM_COMMAND_ID(wParam, lParam))
			{
					/*
					 * Ensure the OK button is enabled only when a data
					 * source name
					 */
					/* is entered */
				case IDC_DSNAME:
					if (GET_WM_COMMAND_CMD(wParam, lParam) == EN_CHANGE)
					{
						char		szItem[MAXDSNAME];	/* Edit control text */

						/* Enable/disable the OK button */
						EnableWindow(GetDlgItem(hdlg, IDOK),
									 GetDlgItemText(hdlg, IDC_DSNAME,
												szItem, sizeof(szItem)));
						return TRUE;
					}
					break;

					/* Accept results */
				case IDOK:
				case IDAPPLY:
					lpsetupdlg = (LPSETUPDLG) GetWindowLongPtr(hdlg, DWLP_USER);
					/* Retrieve dialog values */
					if (!lpsetupdlg->fDefault)
						GetDlgItemText(hdlg, IDC_DSNAME,
									   lpsetupdlg->ci.dsn,
									   sizeof(lpsetupdlg->ci.dsn));
					/* Get Dialog Values */
					GetDlgStuff(hdlg, &lpsetupdlg->ci);

					/* Update ODBC.INI */
					SetDSNAttributes(hdlg, lpsetupdlg, NULL);
					if (IDAPPLY == cmd)
						break;
					/* Return to caller */
				case IDCANCEL:
					EndDialog(hdlg, wParam);
					return TRUE;

				case IDC_TEST:
				{
					lpsetupdlg = (LPSETUPDLG) GetWindowLongPtr(hdlg, DWLP_USER);
					if (NULL != lpsetupdlg)
					{
						/* Get Dialog Values */
						GetDlgStuff(hdlg, &lpsetupdlg->ci);
						test_connection(lpsetupdlg->hwndParent, &lpsetupdlg->ci, FALSE);
						return TRUE;
					}
					break;
				}
				case IDC_DATASOURCE:
					lpsetupdlg = (LPSETUPDLG) GetWindowLongPtr(hdlg, DWLP_USER);
					DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_DRV),
					 hdlg, ds_options1Proc, (LPARAM) &lpsetupdlg->ci);
					return TRUE;

				case IDC_DRIVER:
					lpsetupdlg = (LPSETUPDLG) GetWindowLongPtr(hdlg, DWLP_USER);
					DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_GLOBAL),
						 hdlg, global_optionsProc, (LPARAM) &lpsetupdlg->ci);

					return TRUE;
				case IDC_MANAGEDSN:
					lpsetupdlg = (LPSETUPDLG) GetWindowLongPtr(hdlg, DWLP_USER);
					if (DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_DRIVER_CHANGE),
						hdlg, manage_dsnProc,
						(LPARAM) lpsetupdlg) > 0)
						EndDialog(hdlg, 0);

					return TRUE;
			}
			break;
		case WM_CTLCOLORSTATIC:
			if (lParam == (LPARAM)GetDlgItem(hdlg, IDC_NOTICE_USER))
			{
				HBRUSH hBrush = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
				SetTextColor((HDC)wParam, RGB(255, 0, 0));
				return (LRESULT)hBrush;
			}
			break;
	}

	/* Message not processed */
	return FALSE;
}
Esempio n. 9
0
/*
 * FtDlgProc - callback routine for font drag & drop dialog
 */
WINEXPORT INT_PTR CALLBACK FtDlgProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
    static int  inSELCHANGE = 0;
    static bool dontQuit = false;
    char        str[10];
    LRESULT     len;
    int         i;
    WORD        cmd;

    lparam = lparam;
    wparam = wparam;
    hwnd = hwnd;

    switch( msg ) {
    case WM_INITDIALOG:
        hFontbar = hwnd;
        MoveWindowTopRight( hwnd );
        initHwnds( hwnd );
        fillTypefaceBox( hwnd );
        setDefaultTypeface();
        fillInfoBoxes( hwnd );
        setDefaultSizeStyle();
        if( setCurLogfont( 0 ) ) {
            InvalidateRect( hwndPick, NULL, TRUE );
            UpdateWindow( hwndPick );
        }
        return( TRUE );
    case WM_CLOSE:
        doneWithHwnds();
        DestroyWindow( hwnd );
        hFontbar = (HWND)NULLHANDLE;
        // update editflags (may have closed from system menu)
        EditFlags.Fontbar = false;
        break;
    case WM_COMMAND:
        cmd = LOWORD( wparam );
        switch( cmd ) {
        case IDOK:
            if( dontQuit ) {
                dontQuit = false;
                break;
            }
            // fall through
        case IDCANCEL:
            EndDialog( hwnd, TRUE );
            return( TRUE );
        case FT_SIZE:
        case FT_STYLE:
        case FT_TYPEFACE:
            dontQuit = false;
            if( GET_WM_COMMAND_CMD( wparam, lparam ) == CBN_SELCHANGE ||
                GET_WM_COMMAND_CMD( wparam, lparam ) == LBN_SELCHANGE ) {
                inSELCHANGE++;
                if( cmd == FT_TYPEFACE ) {
                    fillInfoBoxes( hwnd );
                }
                if( (inSELCHANGE == 1) && setCurLogfont( 0 ) ) {
                    InvalidateRect( hwndPick, NULL, TRUE );
                    UpdateWindow( hwndPick );
                }
                inSELCHANGE--;
                return( FALSE );
            }
            break;
        }
        break;
    case DM_GETDEFID:
        /* Hack!  User hit enter, so grab text from combo box edit control
           & attempt to update pick sample.
        */
        if( (GetFocus() != hwndSizeEdit) ||
            (SendMessage( hwndSize, CB_GETCURSEL, 0, 0L ) != CB_ERR) ) {
            break;
        }

        len = SendMessage( hwndSizeEdit, EM_GETLINE, 0, (LPARAM)str );
        str[len] = '\0';
        GetWindowText( hwndSizeEdit, str, 5 );
        i = atoi( str );
        if( (i != 0) && setCurLogfont( i ) ) {
            InvalidateRect( hwndPick, NULL, TRUE );
            UpdateWindow( hwndPick );
        }
        dontQuit = true;
        return( TRUE );
    }
    return( FALSE );

} /* FtDlgProc */
Esempio n. 10
0
INT_PTR CALLBACK FilterDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
	switch (Msg)
	{
		case WM_INITDIALOG:
		{
			CenterWindow(hDlg);
			hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MAMEUI_ICON));
			SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
			hBrush = CreateSolidBrush(RGB(240, 240, 240));
			DisableVisualStylesFilters(hDlg);
			LPTREEFOLDER folder = GetCurrentFolder();
			LPTREEFOLDER lpParent = NULL;
			LPCFILTER_ITEM g_lpFilterList = GetFilterList();
			dwFilters = 0;

			if (folder != NULL)
			{
				char tmp[80];
				win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_EDIT), g_FilterText.c_str());
				Edit_SetSel(GetDlgItem(hDlg, IDC_FILTER_EDIT), 0, -1);
				// Mask out non filter flags
				dwFilters = folder->m_dwFlags & F_MASK;
				// Display current folder name in dialog titlebar
				snprintf(tmp, WINUI_ARRAY_LENGTH(tmp), "Filters for %s folder", folder->m_lpTitle);
				win_set_window_text_utf8(hDlg, tmp);

				if (GetFilterInherit())
				{
					lpParent = GetFolder(folder->m_nParent);
					bool bShowExplanation = false;

					if (lpParent)
					{
						std::string strText;
						/* Check the Parent Filters and inherit them on child,
						* No need to promote all games to parent folder, works as is */
						dwpFilters = lpParent->m_dwFlags & F_MASK;
						/*Check all possible Filters if inherited solely from parent, e.g. not being set explicitly on our folder*/

						if ((dwpFilters & F_CLONES) && !(dwFilters & F_CLONES))
						{
							/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
							strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_CLONES));
							strText.append(" (*)");
							win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_CLONES), strText.c_str());
							bShowExplanation = true;
						}

						if ((dwpFilters & F_NONWORKING) && !(dwFilters & F_NONWORKING))
						{
							/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
							strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_NONWORKING));
							strText.append(" (*)");
							win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_NONWORKING), strText.c_str());
							bShowExplanation = true;
						}

						if ((dwpFilters & F_UNAVAILABLE) && !(dwFilters & F_UNAVAILABLE))
						{
							/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
							strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_UNAVAILABLE));
							strText.append(" (*)");
							win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_UNAVAILABLE), strText.c_str());
							bShowExplanation = true;
						}

						if ((dwpFilters & F_VECTOR) && !(dwFilters & F_VECTOR))
						{
							/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
							strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VECTOR));
							strText.append(" (*)");
							win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VECTOR), strText.c_str());
							bShowExplanation = true;
						}

						if ((dwpFilters & F_RASTER) && !(dwFilters & F_RASTER))
						{
							/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
							strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_RASTER));
							strText.append(" (*)");
							win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_RASTER), strText.c_str());
							bShowExplanation = true;
						}

						if ((dwpFilters & F_ORIGINALS) && !(dwFilters & F_ORIGINALS))
						{
							/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
							strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_ORIGINALS));
							strText.append(" (*)");
							win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_ORIGINALS), strText.c_str());
							bShowExplanation = true;
						}

						if ((dwpFilters & F_WORKING) && !(dwFilters & F_WORKING))
						{
							/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
							strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_WORKING));
							strText.append(" (*)");
							win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_WORKING), strText.c_str());
							bShowExplanation = true;
						}

						if ((dwpFilters & F_AVAILABLE) && !(dwFilters & F_AVAILABLE))
						{
							/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
							strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_AVAILABLE));
							strText.append(" (*)");
							win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_AVAILABLE), strText.c_str());
							bShowExplanation = true;
						}

						if ((dwpFilters & F_HORIZONTAL) && !(dwFilters & F_HORIZONTAL))
						{
							/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
							strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_HORIZONTAL));
							strText.append(" (*)");
							win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_HORIZONTAL), strText.c_str());
							bShowExplanation = true;
						}

						if ((dwpFilters & F_VERTICAL) && !(dwFilters & F_VERTICAL))
						{
							/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
							strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VERTICAL));
							strText.append(" (*)");
							win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VERTICAL), strText.c_str());
							bShowExplanation = true;
						}
						/*Do not or in the Values of the parent, so that the values of the folder still can be set*/
						//dwFilters |= dwpFilters;
					}

					if(bShowExplanation)
					{
						ShowWindow(GetDlgItem(hDlg, IDC_INHERITED), true);
					}
				}
				else
				{
					ShowWindow(GetDlgItem(hDlg, IDC_INHERITED), false);
				}

				// Find the matching filter record if it exists
				lpFilterRecord = FindFilter(folder->m_nFolderId);

				// initialize and disable appropriate controls
				for (int i = 0; g_lpFilterList[i].m_dwFilterType; i++)
				{
					DisableFilterControls(hDlg, lpFilterRecord, &g_lpFilterList[i], dwFilters);
				}
			}

			SetFocus(GetDlgItem(hDlg, IDC_FILTER_EDIT));
			return false;
		}

		case WM_CTLCOLORDLG:
			return (LRESULT) hBrush;	

		case WM_CTLCOLORSTATIC:
		case WM_CTLCOLORBTN:
			hDC = (HDC)wParam;
			SetBkMode(hDC, TRANSPARENT);
			SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT));
			return (LRESULT) hBrush;

		case WM_COMMAND:
		{
			WORD wID = GET_WM_COMMAND_ID(wParam, lParam);
			WORD wNotifyCode = GET_WM_COMMAND_CMD(wParam, lParam);
			LPTREEFOLDER folder = GetCurrentFolder();
			LPCFILTER_ITEM g_lpFilterList = GetFilterList();

			switch (wID)
			{
				case IDOK:
					dwFilters = 0;
					g_FilterText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_EDIT));

					// see which buttons are checked
					for (int i = 0; g_lpFilterList[i].m_dwFilterType; i++)
					{
						if (Button_GetCheck(GetDlgItem(hDlg, g_lpFilterList[i].m_dwCtrlID)))
							dwFilters |= g_lpFilterList[i].m_dwFilterType;
					}

					// Mask out invalid filters
					dwFilters = ValidateFilters(lpFilterRecord, dwFilters);
					// Keep non filter flags
					folder->m_dwFlags &= ~F_MASK;
					// put in the set filters
					folder->m_dwFlags |= dwFilters;
					DestroyIcon(hIcon);
					DeleteObject(hBrush);
					EndDialog(hDlg, 1);
					return true;

				case IDCANCEL:
					DestroyIcon(hIcon);
					DeleteObject(hBrush);
					EndDialog(hDlg, 0);
					return true;

				default:
					// Handle unchecking mutually exclusive filters
					if (wNotifyCode == BN_CLICKED)
						EnableFilterExclusions(hDlg, wID);
			}

			break;
		}
	}

	return false;
}
Esempio n. 11
0
WINEXPORT BOOL CALLBACK WMenuEditProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
{
    WMenuEditInfo       *einfo;
    HWND                win;
    RECT                r;
    POINT               p;
    LRESULT             ret;
    WORD                wp, cmd;

    ret = FALSE;
    einfo = (WMenuEditInfo *)GET_DLGDATA( hDlg );

    switch( message ) {
    case WM_INITDIALOG:
        einfo = (WMenuEditInfo *)lParam;
        einfo->edit_dlg = hDlg;
        SET_DLGDATA( hDlg, (LONG_PTR)einfo );
        WRAddSymbolsToComboBox( einfo->info->symbol_table, hDlg,
                                IDM_MENUEDID, WR_HASHENTRY_ALL );
        ret = TRUE;
        break;

    case WM_SYSCOLORCHANGE:
        WCtl3dColorChange();
        break;

#if 0
#ifdef __NT__
    case WM_CTLCOLORBTN:
    case WM_CTLCOLORDLG:
    case WM_CTLCOLOREDIT:
    case WM_CTLCOLORLISTBOX:
    case WM_CTLCOLORMSGBOX:
    case WM_CTLCOLORSCROLLBAR:
    case WM_CTLCOLORSTATIC:
#else
    case WM_CTLCOLOR:
#endif
        return( (LRESULT)WCtl3dCtlColorEx( message, wParam, lParam ) );
#endif

    case WM_LBUTTONDBLCLK:
    case WM_RBUTTONDBLCLK:
    case WM_RBUTTONUP:
        MAKE_POINT( p, lParam );
        win = GetDlgItem( hDlg, IDM_MENUEDRNAME );
        GetWindowRect( win, &r );
        MapWindowPoints( HWND_DESKTOP, hDlg, (POINT *)&r, 2 );
        if( PtInRect( &r, p ) ) {
            WHandleRename( einfo );
        }
        ret = TRUE;
        break;

    case WM_SETFOCUS:
        if( einfo != NULL && einfo->preview_window != (HWND)NULL ) {
            SendMessage( einfo->preview_window, WM_NCACTIVATE, (WPARAM)TRUE, (LPARAM)NULL );
        }
        break;

#if 0
    case WM_PARENTNOTIFY:
        cmd = GET_WM_PARENTNOTIFY_EVENT( wParam, lParam );
        switch( cmd ) {
        case WM_LBUTTONDOWN:
        case WM_RBUTTONDOWN:
            MAKE_POINT( p, lParam );
            win = GetDlgItem( hDlg, IDM_MENUEDLIST );
            GetClientRect( win, &r );
            MapWindowPoints( win, hDlg, (POINT *)&r, 2 );
            if( PtInRect( &r, p ) ) {
                WHandleSelChange( einfo );
            }
            break;
        }
        ret = TRUE;
        break;
#endif

    case WM_COMMAND:
        wp = LOWORD( wParam );
        cmd = GET_WM_COMMAND_CMD( wParam, lParam );
        switch( wp ) {
        case IDM_MENUEDGRAYED:
            if( IsDlgButtonChecked( hDlg, wp ) ) {
                CheckDlgButton( hDlg, IDM_MENUEDINACTIVE, 0 );
            }
            break;
        case IDM_MENUEDINACTIVE:
            if( IsDlgButtonChecked( hDlg, wp ) ) {
                CheckDlgButton( hDlg, IDM_MENUEDGRAYED, 0 );
            }
            break;
#if 0
        case IDM_MENUEDID:
            if( cmd == CBN_SELCHANGE ) {
                einfo->combo_change = TRUE;
                WHandleSelChange( einfo );
                einfo->combo_change = FALSE;
            }
            break;
#endif
        case IDM_MENUEDINSERT:
            WInsertNew( einfo );
            break;
        case IDM_MENUEDCHANGE:
            WDoHandleSelChange( einfo, TRUE, FALSE );
            break;
        case IDM_MENUEDRESET:
            WDoHandleSelChange( einfo, FALSE, TRUE );
            break;
        case IDM_MENUEDSHIFTLEFT:
            WShiftEntry( einfo, TRUE );
            break;
        case IDM_MENUEDSHIFTRIGHT:
            WShiftEntry( einfo, FALSE );
            break;
        case IDM_MENUEDLIST:
            if( cmd == LBN_SELCHANGE ) {
                WHandleSelChange( einfo );
            }
            break;
        case IDM_MENUEDSETMENU:
            if( einfo->menu != NULL && einfo->menu->first_entry != NULL ) {
                WHandleSelChange( einfo );
            } else {
                WInsertNew( einfo );
            }
            break;
        }
        break;
    }

    return( ret );
}
Esempio n. 12
0
/*
 * SpyWindowProc - handle messages for the spy appl.
 */
LRESULT CALLBACK SpyWindowProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
    int         check;
    HWND        selwin;
    HWND        hinthwnd;
    WORD        cmdid = 0;
    RECT        area;
    BOOL        pausestate;
    BOOL        spyallstate;
    about_info  ai;
    HMENU       mh;

    switch ( msg ) {
    case WM_CREATE:
        GetClientRect( hwnd, &area );
        mh = GetMenu( hwnd );
        area.top = area.bottom - statusHite;
        StatusHdl = HintWndCreate( hwnd, &area, Instance, NULL );
        statusHite = SizeHintBar( StatusHdl );
        SetHintText( StatusHdl, (MenuItemHint *)menuHints,
                     sizeof( menuHints ) / sizeof( MenuItemHint ) );
        if( SpyMainWndInfo.show_hints ) {
            CheckMenuItem( mh, SPY_SHOW_HELP, MF_CHECKED | MF_BYCOMMAND );
        } else {
            hinthwnd = GetHintHwnd( StatusHdl );
            ShowWindow( hinthwnd, SW_HIDE );
        }
        CreateSpyBox( hwnd );
        SET_WNDINFO( hwnd, (LONG_PTR)SpyListBox );
        CreateSpyTool( hwnd );
        ShowSpyTool( SpyMainWndInfo.show_toolbar );
        if( SpyMainWndInfo.show_toolbar ) {
            CheckMenuItem( mh, SPY_SHOW_TOOLBAR, MF_CHECKED | MF_BYCOMMAND );
        }
        LogInit( hwnd, Instance, SpyLogTitle );
        CheckMenuItem( SpyMenu, SPY_AUTO_SCROLL, MF_CHECKED );
        EnableMenuItem( SpyMenu, SPY_ADD_WINDOW, MF_GRAYED );
        EnableMenuItem( SpyMenu, SPY_STOP, MF_GRAYED );
        EnableMenuItem( SpyMenu, SPY_OFFON, MF_GRAYED );
        if( SpyMainWndInfo.on_top ) {
            CheckMenuItem( mh, SPY_TOP, MF_CHECKED | MF_BYCOMMAND );
            SetWindowPos( hwnd, HWND_TOPMOST, 0, 0, 0, 0,
                          SWP_NOMOVE | SWP_NOSIZE );
        }
        break;
    case WM_TIMER:
        // See comment on setUpForPick
        KillTimer( hwnd, wparam );
        switch( wparam ) {
        case SPY_ADD_WINDOW:
            selwin = DoPickDialog( wparam );
            if( selwin != NULL ) {
                setMultipleWindows( hwnd );
                AddSelectedWindow( selwin );
            }
            break;
        case SPY_PEEK_WINDOW:
            DoPickDialog( wparam );
            break;
        case SPY_WINDOW:
            selwin = DoPickDialog( cmdid );
            if( selwin != NULL ) {
                ClearSelectedWindows();
                setSingleWindow( hwnd, selwin );
                enableSpy();
                AddSelectedWindow( selwin );
            }
            break;
        }
        break;
#ifdef __NT__
    case WM_COPYDATA:
        HandleMessage( (LPMSG)((COPYDATASTRUCT *)lparam)->lpData );
        break;
#endif
    case WM_MENUSELECT:
        hinthwnd = GetHintHwnd( StatusHdl );
        HintMenuSelect( StatusHdl, hwnd, wparam, lparam );
        break;
    case WM_COMMAND:
        cmdid = LOWORD( wparam );
        switch( cmdid ) {
        case SPY_SHOW_HELP:
            SpyMainWndInfo.show_hints = !SpyMainWndInfo.show_hints;
            mh = GetMenu( hwnd );
            hinthwnd = GetHintHwnd( StatusHdl );
            if( SpyMainWndInfo.show_hints ) {
                CheckMenuItem( mh, SPY_SHOW_HELP, MF_CHECKED | MF_BYCOMMAND );
                showHintBar( hwnd );
            } else {
                CheckMenuItem( mh, SPY_SHOW_HELP, MF_UNCHECKED | MF_BYCOMMAND );
                ShowWindow( hinthwnd, SW_HIDE );
            }
            GetClientRect( hwnd, &area );
            ResizeSpyBox( area.right - area.left, area.bottom - area.top );
            break;
        case SPY_SHOW_TOOLBAR:
            SpyMainWndInfo.show_toolbar = !SpyMainWndInfo.show_toolbar;
            mh = GetMenu( hwnd );
            if( SpyMainWndInfo.show_toolbar ) {
                CheckMenuItem( mh, SPY_SHOW_TOOLBAR, MF_CHECKED | MF_BYCOMMAND );
            } else {
                CheckMenuItem( mh, SPY_SHOW_TOOLBAR, MF_UNCHECKED | MF_BYCOMMAND );
            }
            ShowSpyTool( SpyMainWndInfo.show_toolbar );
            GetClientRect( hwnd, &area );
            ResizeSpyBox( area.right - area.left, area.bottom - area.top );
            break;
        case SPY_TOP:
            SpyMainWndInfo.on_top = !SpyMainWndInfo.on_top;
            mh = GetMenu( hwnd );
            if( SpyMainWndInfo.on_top ) {
                CheckMenuItem( mh, SPY_TOP, MF_CHECKED | MF_BYCOMMAND );
                SetWindowPos( hwnd, HWND_TOPMOST, 0, 0, 0, 0,
                              SWP_NOMOVE | SWP_NOSIZE );
            } else {
                CheckMenuItem( mh, SPY_TOP, MF_UNCHECKED | MF_BYCOMMAND );
                SetWindowPos( hwnd, HWND_NOTOPMOST, 0, 0, 0, 0,
                              SWP_NOMOVE | SWP_NOSIZE );
            }
            break;
        case SPY_MARK:
            pausestate = SpyMessagesPaused;
            SpyMessagesPaused = FALSE;              /* make sure marks are
                                                     * always added */
            ProcessMark( hwnd, Instance, markCallback );
            SpyMessagesPaused = pausestate;
            break;
        case SPY_SET_FONT:
            if( ChooseMonoFont( hwnd ) )  {
                statusHite = SizeHintBar( StatusHdl );
                ResetSpyListBox();
                showHintBar( hwnd );
            }
            break;
        case SPY_SAVE_AS:
            SaveListBox( SLB_SAVE_AS, SaveExtra, "", SpyName, hwnd, SpyListBox );
            break;
        case SPY_SAVE:
            SaveListBox( SLB_SAVE_TMP, SaveExtra, ".\\wspy.txt", SpyName, hwnd,
                         SpyListBox );
            break;
        case SPY_LOG:
            if( LogToggle() ) {
                CheckMenuItem( SpyMenu, SPY_LOG, MF_BYCOMMAND | MF_CHECKED );
            } else {
                CheckMenuItem( SpyMenu, SPY_LOG, MF_BYCOMMAND | MF_UNCHECKED );
                CheckMenuItem( SpyMenu, SPY_PAUSE_LOG, MF_BYCOMMAND | MF_UNCHECKED );
            }
            break;
        case SPY_CONFIG_LOG:
            LogConfigure();
            break;
        case SPY_EXIT:
            ClearFilter();
            DestroyWindow( hwnd );
            break;
        case SPY_LIST_BOX:
            switch( GET_WM_COMMAND_CMD( wparam, lparam ) ) {
            case LBN_ERRSPACE:
                ClearSpyBox();
                break;
            case LBN_DBLCLK:
                DoMessageSelDialog( hwnd );
                break;
            }
            break;
        case SPY_SHOW_SELECTED_WINDOWS:
            spyallstate = spyAll;
            DoShowSelectedDialog( hwnd, &spyallstate );
            if( spyallstate ) {
                doSpyAll( hwnd, spyallstate );
                if( spyAll ) {
                    SetSpyState( ON );
                }
                break;
            }
            if( WindowCount == 0 ) {
                SetWindowText( hwnd, SpyName );
                disableSpy();
                break;
            }

            if( WindowCount == 1 ) {
                setSingleWindow( hwnd, WindowList[0] );
            } else {
                setMultipleWindows( hwnd );
            }
            if( SpyState == NEITHER ) {
                enableSpy();
            }
            break;
        case SPY_HELP_CONTENTS:
            if( !WHtmlHelp( hwnd, "spy.chm", HELP_CONTENTS, 0 ) ) {
                WWinHelp( hwnd, "spy.hlp", HELP_CONTENTS, 0 );
            }
            break;
        case SPY_HELP_SRCH:
            if( !WHtmlHelp( hwnd, "spy.chm", HELP_PARTIALKEY, (HELP_DATA)"" ) ) {
                WWinHelp( hwnd, "spy.hlp", HELP_PARTIALKEY, (HELP_DATA)"" );
            }
            break;
        case SPY_HELP_ON_HELP:
            WWinHelp( hwnd, "winhelp.hlp", HELP_HELPONHELP, 0 );
            break;
        case SPY_ABOUT:
            ai.owner = hwnd;
            ai.inst = Instance;
            ai.name = AllocRCString( STR_ABOUT_NAME );
            ai.version = AllocRCString( STR_ABOUT_VERSION );
            ai.first_cr_year = "1993";
            ai.title = AllocRCString( STR_ABOUT_TITLE );
            DoAbout( &ai );
            FreeRCString( ai.name );
            FreeRCString( ai.version );
            FreeRCString( ai.title );
            break;
        case SPY_AUTO_SCROLL:
            if( SpyMessagesAutoScroll ) {
                SpyMessagesAutoScroll = FALSE;
                CheckMenuItem( SpyMenu, SPY_AUTO_SCROLL, MF_UNCHECKED );
            } else {
                SpyMessagesAutoScroll = TRUE;
                CheckMenuItem( SpyMenu, SPY_AUTO_SCROLL, MF_CHECKED );
            }
            break;
        case SPY_PAUSE_LOG:
            if( SpyLogPauseToggle() ) {
                CheckMenuItem( SpyMenu, SPY_PAUSE_LOG,
                               MF_BYCOMMAND | MF_CHECKED );
            } else {
                CheckMenuItem( SpyMenu, SPY_PAUSE_LOG,
                               MF_BYCOMMAND | MF_UNCHECKED );
            }
            break;
        case SPY_PAUSE_MESSAGES:
            SpyMessagePauseToggle();
            break;
        case SPY_CLEAR_MESSAGES:
            ClearSpyBox();
            ClearMessageCount();
            break;
        case SPY_MESSAGES_ASCFG:
            if( AutoSaveConfig ) {
                check = MF_UNCHECKED;
                AutoSaveConfig = FALSE;
            } else {
                AutoSaveConfig = TRUE;
                check = MF_CHECKED;
            }
            CheckMenuItem( SpyMenu, SPY_MESSAGES_ASCFG, check );
            break;
        case SPY_MESSAGES_SAVE:
            DoSaveSpyConfig();
            break;
        case SPY_MESSAGES_LOAD:
            DoLoadSpyConfig();
            break;
        case SPY_MESSAGES_WATCH:
        case SPY_MESSAGES_STOP:
            DoMessageDialog( hwnd, cmdid );
            break;
        case SPY_OFFON:
            if( SpyState != NEITHER ) {
                SetSpyState( !SpyState );
            }
            break;
        case SPY_STOP:
            disableSpy();
            ClearSelectedWindows();
            SetWindowText( hwnd, SpyName );
            break;
        case SPY_ANOTHER_WINDOW:
            if( SpyState == NEITHER || spyAll ) {
                SendMessage( hwnd, WM_COMMAND,
                             GET_WM_COMMAND_MPS( SPY_WINDOW, 0, 0 ) );
            } else {
                SendMessage( hwnd, WM_COMMAND,
                             GET_WM_COMMAND_MPS( SPY_ADD_WINDOW, 0, 0 ) );
            }
            break;
        case SPY_PEEK_WINDOW:
        case SPY_ADD_WINDOW:
        case SPY_WINDOW:
            setUpForPick( hwnd, cmdid );
            break;
        case SPY_ALL_WINDOWS:
            doSpyAll( hwnd, !spyAll );
            if( spyAll ) {
                SetSpyState( ON );
            }
            break;
        }
        break;
#ifdef __NT__
    case WM_NOTIFY:
        if( ((NMHDR *)lparam)->code == NM_DBLCLK &&
            ((NMHDR *)lparam)->idFrom == SPY_LIST_BOX ) {
            DoMessageSelDialog( hwnd );
        }
        break;
#endif
    case WM_CLOSE:
        PostMessage( hwnd, WM_COMMAND, GET_WM_COMMAND_MPS( SPY_EXIT, 0, 0 ) );
        break;
    case WM_ENDSESSION:
        if( wparam ) {
            SpyFini();
        }
        break;
    case WM_DESTROY:
        HintWndDestroy( StatusHdl );
        HintFini();
        StatusWndFini();
        DestroyMonoFonts();
        DestroySpyTool();
        WWinHelp( hwnd, "spy.hlp", HELP_QUIT, 0 );
        PostQuitMessage( 0 );
        break;
    case WM_MOVE:
        GetWindowRect( hwnd, &area );
        if( !SpyMainWndInfo.minimized ) {
            SpyMainWndInfo.last_xpos = SpyMainWndInfo.xpos;
            SpyMainWndInfo.last_ypos = SpyMainWndInfo.ypos;
            SpyMainWndInfo.xpos = area.left;
            SpyMainWndInfo.ypos = area.top;
        }
        break;
    case WM_SIZE:
        if( wparam != SIZE_MAXIMIZED && wparam != SIZE_MINIMIZED ) {
            GetWindowRect( hwnd, &area );
            SpyMainWndInfo.xsize = area.right - area.left;
            SpyMainWndInfo.ysize = area.bottom - area.top;
        } else {
            SpyMainWndInfo.xpos = SpyMainWndInfo.last_xpos;
            SpyMainWndInfo.ypos = SpyMainWndInfo.last_ypos;
        }
        SpyMainWndInfo.minimized = ( wparam == SIZE_MINIMIZED );
        GetClientRect( hwnd, &area );
        area.top = area.bottom - statusHite;
        hinthwnd = GetHintHwnd( StatusHdl );
        MoveWindow( hinthwnd, area.left, area.top,
                    area.right - area.left, statusHite, TRUE );
        ResizeSpyBox( LOWORD( lparam ), HIWORD( lparam ) );
        ResizeSpyTool( LOWORD( lparam ), HIWORD( lparam ) );
        showHintBar( hwnd );
        return( DefWindowProc( hwnd, msg, wparam, lparam ) );
        break;
#if defined( __NT__ )
    case WM_ERASEBKGND: {
        static RECT r;
        GetClientRect( hwnd, &r );
        FillRect( (HDC)wparam, &r, (HBRUSH)(COLOR_BTNFACE + 1) );
        return 1;
    }
#endif
    default:
        return( DefWindowProc( hwnd, msg, wparam, lparam ) );
    }
    return( 0 );

} /* SpyWindowProc */
Esempio n. 13
0
/*
 * RepDlgProc - callback routine for find & replace dialog
 */
BOOL WINEXP RepDlgProc( HWND hwnd, UINT msg, UINT wparam, LONG lparam )
{
    int                 curr;
    int                 i;
    int                 cmd;
    DWORD               index;
    char                find[MAX_INPUT_LINE];
    history_data        *h;
    char                *ptr;
    RECT                pos;

    lparam = lparam;
    switch( msg ) {
    case WM_INITDIALOG:
        if( findData.posx == -1 && findData.posy == -1 ) {
            CenterWindowInRoot( hwnd );
        } else {
            SetWindowPos( hwnd, (HWND)NULLHANDLE, findData.posx, findData.posy, 
                0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOREDRAW | SWP_NOZORDER );
        }
        EditSubClass( hwnd, REP_FIND, &FindHist );
        CheckDlgButton( hwnd, REP_IGNORE_CASE, findData.case_ignore );
        CheckDlgButton( hwnd, REP_REGULAR_EXPRESSIONS, findData.use_regexp );
        // CheckDlgButton( hwnd, REP_SEARCH_BACKWARDS, !findData.search_forward );
        CheckDlgButton( hwnd, REP_SEARCH_WRAP, findData.search_wrap );
        CheckDlgButton( hwnd, REP_PROMPT_ON_REPLACE, findData.prompt );
        // CheckDlgButton( hwnd, REP_SELECTION_ONLY, findData.selection );
        SetDlgItemText( hwnd, REP_FIND, findData.find );
        SetDlgItemText( hwnd, REP_REPLACE, findData.replace );
        curr = FindHist.curr + FindHist.max - 1;
        for( i = 0; i < FindHist.max; i++ ) {
            if( FindHist.data[curr % FindHist.max] != NULL ) {
                SendDlgItemMessage( hwnd, REP_LISTBOX, LB_ADDSTRING, 0,
                                    (LONG) FindHist.data[curr % FindHist.max] );
            }
            curr--;
            if( curr < 0 ) {
                break;
            }
        }
        return( TRUE );
    case WM_CLOSE:
        GetWindowRect( hwnd, &pos );
        findData.posx = pos.left;
        findData.posy = pos.top;
        PostMessage( hwnd, WM_COMMAND, GET_WM_COMMAND_MPS( IDCANCEL, 0, 0 ) );
        return( TRUE );
    case WM_COMMAND:
        switch( LOWORD( wparam ) ) {
        case REP_LISTBOX:
            cmd = GET_WM_COMMAND_CMD( wparam, lparam );
            if( cmd == LBN_SELCHANGE || cmd == LBN_DBLCLK ) {
                index = SendDlgItemMessage( hwnd, REP_LISTBOX, LB_GETCURSEL, 0, 0L );
                if( index == LB_ERR ) {
                    break;
                }
                SendDlgItemMessage( hwnd, REP_LISTBOX, LB_GETTEXT, index, (LONG) find );
                SetDlgItemText( hwnd, REP_FIND, find );
                if( cmd == LBN_DBLCLK ) {
                    PostMessage( hwnd, WM_COMMAND, GET_WM_COMMAND_MPS( IDOK, 0, 0 ) );
                }
            }
            break;
        case IDCANCEL:
            GetWindowRect( hwnd, &pos );
            findData.posx = pos.left;
            findData.posy = pos.top;
            RemoveEditSubClass( hwnd, REP_FIND );
            EndDialog( hwnd, FALSE );
            break;
        case IDOK:
            GetDlgItemText( hwnd, REP_FIND, findData.find, findData.findlen );
            GetDlgItemText( hwnd, REP_REPLACE, findData.replace, findData.replacelen );
            findData.case_ignore = IsDlgButtonChecked( hwnd, REP_IGNORE_CASE );
            findData.use_regexp = IsDlgButtonChecked( hwnd, REP_REGULAR_EXPRESSIONS );
            // findData.search_forward = !IsDlgButtonChecked( hwnd, REP_SEARCH_BACKWARDS );
            findData.search_wrap = IsDlgButtonChecked( hwnd, REP_SEARCH_WRAP );
            findData.prompt = IsDlgButtonChecked( hwnd, REP_PROMPT_ON_REPLACE );
            // findData.selection = IsDlgButtonChecked( hwnd, REP_SELECTION_ONLY );
            h = &FindHist;
            curr = h->curr + h->max - 1;
            ptr = NULL;
            if( curr >= 0 ) {
                ptr = h->data[curr % h->max];
            }
            if( ptr == NULL || strcmp( ptr, findData.find ) ) {
                AddString2( &(h->data[h->curr % h->max]), findData.find );
                h->curr += 1;
            }
            GetWindowRect( hwnd, &pos );
            findData.posx = pos.left;
            findData.posy = pos.top;
            RemoveEditSubClass( hwnd, REP_FIND );
            EndDialog( hwnd, TRUE );
            break;
        default:
            return( FALSE );
        }
        return( TRUE );
    }
    return( FALSE );

} /* RepDlgProc */
Esempio n. 14
0
static LRESULT FAR PASCAL 
FindDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	HWND		hWnd;
	HDC 		hDC;
	HBRUSH 		hBrush;
	RECT		rcClient;
	FINDREPLACE	*cf;
	UINT		uiRet = 0;
	static UINT	uiHelpMsg, uiFindMsg;

	cf = (FINDREPLACE *)GetWindowLong(hDlg,DWL_LPARAM); 
	if ( message != WM_INITDIALOG  &&  cf->Flags & FR_ENABLEHOOK ) {
		uiRet = LOWORD(cf->lpfnHook(hDlg,message,wParam,lParam));
		if ( uiRet ) 
			return (LRESULT)uiRet;
	}
	SetWindowLong(hDlg, DWL_MSGRESULT, (LPARAM)0);

	switch(message) {
	case WM_INITDIALOG:
		SendDlgItemMessage(hDlg, edt1, WM_SETTEXT,
				strlen(cf->lpstrFindWhat),
				(LPARAM)cf->lpstrFindWhat);

		/* Show/hide the whole word stuff */
		if(cf->Flags & FR_HIDEWHOLEWORD)
			ShowWindow(GetDlgItem(hDlg, chx1), SW_HIDE);
		else {
			if(cf->Flags & FR_WHOLEWORD)
				CheckDlgButton(hDlg,chx1,TRUE);
			if(cf->Flags & FR_NOWHOLEWORD)
				EnableWindow(GetDlgItem(hDlg, chx1), FALSE);
		}

		/* Show/hide the matchcase stuff */
		if(cf->Flags & FR_HIDEMATCHCASE)
			ShowWindow(GetDlgItem(hDlg, chx2), SW_HIDE);
		else {
			if(cf->Flags & FR_MATCHCASE)
				CheckDlgButton(hDlg,chx2,TRUE);
			if(cf->Flags & FR_NOMATCHCASE)
				EnableWindow(GetDlgItem(hDlg, chx2), FALSE);
		}

		/* show/tell the up/down group and controls */
		if(cf->Flags & FR_HIDEUPDOWN) {
			ShowWindow(GetDlgItem(hDlg, rad1), SW_HIDE);
			ShowWindow(GetDlgItem(hDlg, rad2), SW_HIDE);
			ShowWindow(GetDlgItem(hDlg, grp1), SW_HIDE);
		}
		else {
			if (cf->Flags & FR_DOWN)
				CheckRadioButton(hDlg, rad1, rad2, rad2);
			else
				CheckRadioButton(hDlg, rad1, rad2, rad1);
			if(cf->Flags & FR_NOUPDOWN) {
				EnableWindow(GetDlgItem(hDlg, rad1), FALSE);
				EnableWindow(GetDlgItem(hDlg, rad2), FALSE);
				EnableWindow(GetDlgItem(hDlg, grp1), FALSE);
			}
		}

		if ( !(cf->Flags & FR_SHOWHELP) )
			ShowWindow(GetDlgItem(hDlg, pshHelp), SW_HIDE);
		else  
			uiHelpMsg = RegisterWindowMessage(HELPMSGSTRING);

		uiFindMsg = RegisterWindowMessage(FINDMSGSTRING);

		if ( !strlen(cf->lpstrFindWhat) )
			EnableWindow(GetDlgItem(hDlg, IDOK), FALSE);

		if ( cf->Flags & FR_ENABLEHOOK )
			cf->lpfnHook(hDlg, message, wParam, lParam);

		return TRUE;

	case WM_COMMAND:

		cf->Flags &= ~(FR_FINDNEXT|FR_REPLACE|FR_REPLACEALL);
		cf->Flags &= ~(FR_DOWN|FR_WHOLEWORD|FR_MATCHCASE);
		
		if ( GET_WM_COMMAND_ID(wParam,lParam) == edt1 &&
		     GET_WM_COMMAND_CMD(wParam,lParam) == EN_CHANGE ) {
			SendMessage(GET_WM_COMMAND_HWND(wParam,lParam),
				WM_GETTEXT,
				cf->wFindWhatLen, (LPARAM)cf->lpstrFindWhat);
			hWnd = GetDlgItem(hDlg, IDOK);
			if ( strlen(cf->lpstrFindWhat) ) {
				if ( !IsWindowEnabled(hWnd) )
					EnableWindow(hWnd, TRUE);
			} else {
				if ( IsWindowEnabled(hWnd) )
					EnableWindow(hWnd, FALSE);
			}
			SetWindowLong(hDlg, DWL_MSGRESULT, (LPARAM)0);
			return TRUE;
		}

		if (GET_WM_COMMAND_ID(wParam,lParam) == IDOK) {
			if ( IsDlgButtonChecked(hDlg, rad2) )
				cf->Flags |= FR_DOWN;
			if ( IsDlgButtonChecked(hDlg, chx1) )
				cf->Flags |= FR_WHOLEWORD;
			if ( IsDlgButtonChecked(hDlg, chx2) )
				cf->Flags |= FR_MATCHCASE;
			cf->Flags |= FR_FINDNEXT;
			SendMessage(cf->hwndOwner,uiFindMsg,0,(LPARAM)cf);
			SetWindowLong(hDlg, DWL_MSGRESULT, (LPARAM)0);
			return TRUE;
		}
		if (GET_WM_COMMAND_ID(wParam,lParam) == IDCANCEL) {
			cf->Flags = FR_DIALOGTERM;
			SendMessage(cf->hwndOwner, uiFindMsg, 0, (LPARAM)cf);
			SetWindowLong(hDlg, DWL_MSGRESULT, (LPARAM)0);
			DestroyWindow(hDlg);
			return FALSE;
		}
		if (GET_WM_COMMAND_ID(wParam,lParam) == pshHelp) {
			SendMessage(cf->hwndOwner,uiHelpMsg,0,0);
			SetWindowLong(hDlg, DWL_MSGRESULT, (LPARAM)0);
			return TRUE;
		}

		break;

	case WM_ERASEBKGND: {
	    hDC = GetDC(hDlg);
	    hBrush = (HBRUSH)SendMessage(hDlg,
			GET_WM_CTLCOLOR_MSG(CTLCOLOR_DLG),
			GET_WM_CTLCOLOR_MPS(hDC,hDlg,CTLCOLOR_DLG));
	    if (hBrush) {
		GetClientRect(hDlg, &rcClient);
		FillRect((HDC)wParam, &rcClient, hBrush);
		ReleaseDC(hDlg, hDC);
		SetWindowLong(hDlg, DWL_MSGRESULT, (LPARAM)TRUE);
		return TRUE;
	    }
	    else {
		ReleaseDC(hDlg,hDC);
		SetWindowLong(hDlg, DWL_MSGRESULT, (LPARAM)FALSE);
		return FALSE;
	    }
	}

	default:
	    break;
	}
	return FALSE;
}
Esempio n. 15
0
WINEXPORT BOOL CALLBACK WRSelectFileTypeProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
{
    WRSFT       *sft;
    BOOL        ret;

    ret = FALSE;

    switch( message ) {
    case WM_DESTROY:
        WRUnregisterDialog( hDlg );
        break;

    case WM_INITDIALOG:
        sft = (WRSFT *)lParam;
        SET_DLGDATA( hDlg, sft );
        WRRegisterDialog( hDlg );
        WRSetWinInfo( hDlg, sft );
        ret = TRUE;
        break;

    case WM_SYSCOLORCHANGE:
        WRCtl3dColorChange();
        break;

    case WM_COMMAND:
        switch( LOWORD( wParam ) ) {
        case IDM_SFTHELP:
            sft = (WRSFT *)GET_DLGDATA( hDlg );
            if( sft != NULL && sft->hcb != NULL ) {
                (*(void (*)(void))sft->hcb)();
            }
            break;

        case IDOK:
            sft = (WRSFT *)GET_DLGDATA( hDlg );
            if( sft == NULL ) {
                EndDialog( hDlg, FALSE );
                ret = TRUE;
            } else if( WRGetWinInfo( hDlg, sft ) ) {
                EndDialog( hDlg, TRUE );
                ret = TRUE;
            } else {
                WRDisplayErrorMsg( WR_INVALIDSELECTION );
            }
            break;

        case IDCANCEL:
            EndDialog( hDlg, FALSE );
            ret = TRUE;
            break;

        case IDM_TSWINNT:
            if( GET_WM_COMMAND_CMD( wParam, lParam ) != BN_CLICKED ) {
                break;
            }
            if( !IsDlgButtonChecked( hDlg, IDM_FTRES ) ) {
                break;
            }
            if( IsDlgButtonChecked( hDlg, LOWORD( wParam ) ) ) {
                EnableWindow( GetDlgItem( hDlg, IDM_RFMS ), FALSE );
                CheckDlgButton( hDlg, IDM_RFMS, BST_UNCHECKED );
                CheckDlgButton( hDlg, IDM_RFWAT, BST_CHECKED );
            } else {
                EnableWindow( GetDlgItem( hDlg, IDM_RFMS ), TRUE );
            }
            break;

        case IDM_TSWIN:
            if( GET_WM_COMMAND_CMD( wParam, lParam ) != BN_CLICKED ) {
                break;
            }
            if( !IsDlgButtonChecked( hDlg, IDM_FTRES ) ) {
                break;
            }
            if( IsDlgButtonChecked( hDlg, LOWORD( wParam ) ) ) {
                EnableWindow( GetDlgItem( hDlg, IDM_RFMS ), TRUE );
            }
            break;

        case IDM_FTEXE:
        case IDM_FTDLL:
            if( GET_WM_COMMAND_CMD( wParam, lParam ) != BN_CLICKED ) {
                break;
            }
            if( IsDlgButtonChecked( hDlg, LOWORD( wParam ) ) ) {
                EnableWindow( GetDlgItem( hDlg, IDM_RFWAT ), FALSE );
                EnableWindow( GetDlgItem( hDlg, IDM_RFMS ), FALSE );
                CheckDlgButton( hDlg, IDM_RFWAT, BST_UNCHECKED );
                CheckDlgButton( hDlg, IDM_RFMS, BST_UNCHECKED );
            }
            break;

        case IDM_FTRES:
            if( GET_WM_COMMAND_CMD( wParam, lParam ) != BN_CLICKED ) {
                break;
            }
            if( IsDlgButtonChecked( hDlg, LOWORD( wParam ) ) ) {
                EnableWindow( GetDlgItem( hDlg, IDM_RFWAT ), TRUE );
                if( IsDlgButtonChecked( hDlg, IDM_TSWINNT ) ) {
                    EnableWindow( GetDlgItem( hDlg, IDM_RFMS ), FALSE );
                    CheckDlgButton( hDlg, IDM_RFMS, BST_UNCHECKED );
                    CheckDlgButton( hDlg, IDM_RFWAT, BST_CHECKED );
                } else {
                    EnableWindow( GetDlgItem( hDlg, IDM_RFMS ), TRUE );
                    CheckDlgButton( hDlg, IDM_RFMS, BST_UNCHECKED );
                    CheckDlgButton( hDlg, IDM_RFWAT, BST_CHECKED );
                }
            }
            break;
        }
        break;
    }

    return( ret );
}
Esempio n. 16
0
/*-------
 * ConfigDlgProc
 *	Description:	Manage add data source name dialog
 *	Input	 :	hdlg --- Dialog window handle
 *				wMsg --- Message
 *				wParam - Message parameter
 *				lParam - Message parameter
 *	Output	 :	TRUE if message processed, FALSE otherwise
 *-------
 */
LRESULT			CALLBACK
ConfigDlgProc(HWND hdlg,
			  UINT wMsg,
			  WPARAM wParam,
			  LPARAM lParam)
{
	LPSETUPDLG	lpsetupdlg;
	ConnInfo   *ci;
	DWORD		cmd;
	char		strbuf[64];

	switch (wMsg)
	{
			/* Initialize the dialog */
		case WM_INITDIALOG:
			lpsetupdlg = (LPSETUPDLG) lParam;
			ci = &lpsetupdlg->ci;

			/* Hide the driver connect message */
			ShowWindow(GetDlgItem(hdlg, DRV_MSG_LABEL), SW_HIDE);
			LoadString(s_hModule, IDS_ADVANCE_SAVE, strbuf, sizeof(strbuf));
			SetWindowText(GetDlgItem(hdlg, IDOK), strbuf);

			SetWindowLongPtr(hdlg, DWLP_USER, lParam);
			CenterDialog(hdlg); /* Center dialog */

			/*
			 * NOTE: Values supplied in the attribute string will always
			 */
			/* override settings in ODBC.INI */

			copy_globals(&ci->drivers, &globals);
			/* Get the rest of the common attributes */
			getDSNinfo(ci, CONN_DONT_OVERWRITE);

			/* Fill in any defaults */
			getDSNdefaults(ci);

			/* Initialize dialog fields */
			SetDlgStuff(hdlg, ci);

			if (lpsetupdlg->fNewDSN || !ci->dsn[0])
				ShowWindow(GetDlgItem(hdlg, IDC_MANAGEDSN), SW_HIDE);
			if (lpsetupdlg->fDefault)
			{
				EnableWindow(GetDlgItem(hdlg, IDC_DSNAME), FALSE);
				EnableWindow(GetDlgItem(hdlg, IDC_DSNAMETEXT), FALSE);
			}
			else
				SendDlgItemMessage(hdlg, IDC_DSNAME,
							 EM_LIMITTEXT, (WPARAM) (MAXDSNAME - 1), 0L);

			SendDlgItemMessage(hdlg, IDC_DESC,
							   EM_LIMITTEXT, (WPARAM) (MAXDESC - 1), 0L);
			return TRUE;		/* Focus was not set */

			/* Process buttons */
		case WM_COMMAND:
			switch (cmd = GET_WM_COMMAND_ID(wParam, lParam))
			{
					/*
					 * Ensure the OK button is enabled only when a data
					 * source name
					 */
					/* is entered */
				case IDC_DSNAME:
					if (GET_WM_COMMAND_CMD(wParam, lParam) == EN_CHANGE)
					{
						char		szItem[MAXDSNAME];	/* Edit control text */

						/* Enable/disable the OK button */
						EnableWindow(GetDlgItem(hdlg, IDOK),
									 GetDlgItemText(hdlg, IDC_DSNAME,
												szItem, sizeof(szItem)));
						return TRUE;
					}
					break;

					/* Accept results */
				case IDOK:
				case IDAPPLY:
					lpsetupdlg = (LPSETUPDLG) GetWindowLongPtr(hdlg, DWLP_USER);
					/* Retrieve dialog values */
					if (!lpsetupdlg->fDefault)
						GetDlgItemText(hdlg, IDC_DSNAME,
									   lpsetupdlg->ci.dsn,
									   sizeof(lpsetupdlg->ci.dsn));
					/* Get Dialog Values */
					GetDlgStuff(hdlg, &lpsetupdlg->ci);

					/* Update ODBC.INI */
					SetDSNAttributes(hdlg, lpsetupdlg, NULL);
					if (IDAPPLY == cmd)
						break;
					/* Return to caller */
				case IDCANCEL:
					EndDialog(hdlg, wParam);
					return TRUE;

				case IDC_TEST:
				{
					lpsetupdlg = (LPSETUPDLG) GetWindowLongPtr(hdlg, DWLP_USER);
					if (NULL != lpsetupdlg)
					{
						EnvironmentClass *env = EN_Constructor();
						ConnectionClass *conn = NULL;
						char    szMsg[SQL_MAX_MESSAGE_LENGTH];

						/* Get Dialog Values */
						GetDlgStuff(hdlg, &lpsetupdlg->ci);
						if (env)
							conn = CC_Constructor();
						if (conn)
						{
							char *emsg, *allocstr = NULL;
#ifdef	UNICODE_SUPPORT
							int	tlen;
							SQLWCHAR *wermsg = NULL;
							SQLULEN	ulen;
#endif /* UNICODE_SUPPORT */
							int errnum;

							EN_add_connection(env, conn);
							CC_copy_conninfo(&conn->connInfo, &lpsetupdlg->ci);
							CC_initialize_pg_version(conn);
							logs_on_off(1, conn->connInfo.drivers.debug, conn->connInfo.drivers.commlog);
#ifdef	UNICODE_SUPPORT
							CC_set_in_unicode_driver(conn);
#endif /* UNICODE_SUPPORT */
							if (CC_connect(conn, AUTH_REQ_OK, NULL) > 0)
							{
								if (CC_get_errornumber(conn) != 0)
								{
									CC_get_error(conn, &errnum, &emsg);
									snprintf(szMsg, sizeof(szMsg), "Warning: %s", emsg);
								}
								else
									strncpy_null(szMsg, "Connection successful", sizeof(szMsg));
								emsg = szMsg;
							}
							else
							{
								CC_get_error(conn, &errnum, &emsg);
							}
#ifdef	UNICODE_SUPPORT
							tlen = strlen(emsg);
							wermsg = (SQLWCHAR *) malloc(sizeof(SQLWCHAR) * (tlen + 1));
							ulen = utf8_to_ucs2_lf1(emsg, SQL_NTS, FALSE, wermsg, tlen + 1);
							if (ulen != (SQLULEN) -1)
							{
								allocstr = malloc(4 * tlen + 1);
								tlen = (SQLSMALLINT) wstrtomsg(NULL, wermsg,
					(int) tlen, allocstr, (int) 4 * tlen + 1);
								emsg = allocstr;
							}
							if (NULL != wermsg)
								free(wermsg);
#endif /* UNICODE_SUPPORT */
							MessageBox(lpsetupdlg->hwndParent, emsg, "Connection Test", MB_ICONEXCLAMATION | MB_OK);
							logs_on_off(-1, conn->connInfo.drivers.debug, conn->connInfo.drivers.commlog);
							EN_remove_connection(env, conn);
							CC_Destructor(conn);
							if (NULL != allocstr)
								free(allocstr);
						}
						if (env)
							EN_Destructor(env);
						return TRUE;
					}
					break;
				}
				case IDC_DATASOURCE:
					lpsetupdlg = (LPSETUPDLG) GetWindowLongPtr(hdlg, DWLP_USER);
					DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_DRV),
					 hdlg, ds_options1Proc, (LPARAM) &lpsetupdlg->ci);
					return TRUE;

				case IDC_DRIVER:
					lpsetupdlg = (LPSETUPDLG) GetWindowLongPtr(hdlg, DWLP_USER);
					DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_GLOBAL),
						 hdlg, global_optionsProc, (LPARAM) &lpsetupdlg->ci);

					return TRUE;
				case IDC_MANAGEDSN:
					lpsetupdlg = (LPSETUPDLG) GetWindowLongPtr(hdlg, DWLP_USER);
					if (DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_DRIVER_CHANGE),
						hdlg, manage_dsnProc,
						(LPARAM) lpsetupdlg) > 0)
						EndDialog(hdlg, 0);

					return TRUE;
			}
			break;
		case WM_CTLCOLORSTATIC:
			if (lParam == (LPARAM)GetDlgItem(hdlg, IDC_NOTICE_USER))
			{
				HBRUSH hBrush = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
				SetTextColor((HDC)wParam, RGB(255, 0, 0));
				return (long)hBrush;
			}
			break;
	}

	/* Message not processed */
	return FALSE;
}
Esempio n. 17
0
BOOL CALLBACK PreferencesDialogProc(HWND hDlg, UINT message, UINT wParam, LONG lParam)
{
   static HWND hBrowser;
   static Bool browser_changed;
   Bool toolbar_changed, lagbox_changed, temp;
   CommSettings *comm = &config.comm;
   OPENFILENAME ofn;
   static char *dir;   // Working directory before dialog (OpenFile may change it)
   int new_val;

   switch (message)
   {
   case WM_INITDIALOG:
      CenterWindow(hDlg, GetParent(hDlg));
      if (hPreferencesDialog != NULL)
      {
         EndDialog(hDlg, IDCANCEL);
         return FALSE;
      }
      hPreferencesDialog = hDlg;
      
      hBrowser = GetDlgItem(hDlg, IDC_BROWSER);
      
      Edit_LimitText(hBrowser, MAX_PATH);

      SetWindowFont(hBrowser, GetFont(FONT_INPUT), FALSE);

      SetWindowText(hBrowser, config.browser);

      CheckDlgButton(hDlg, IDC_SCROLLLOCK, config.scroll_lock);
      CheckDlgButton(hDlg, IDC_DRAWNAMES, config.draw_names);
      CheckDlgButton(hDlg, IDC_TOOLTIPS, config.tooltips);
      CheckDlgButton(hDlg, IDC_PAIN, config.pain);
      CheckDlgButton(hDlg, IDC_INVNUM, config.inventory_num);
      CheckDlgButton(hDlg, IDC_SAFETY, config.aggressive);
      CheckDlgButton(hDlg, IDC_BOUNCE, config.bounce);
      CheckDlgButton(hDlg, IDC_TOOLBAR, config.toolbar);
      CheckDlgButton(hDlg, IDS_LATENCY0, config.lagbox);
      CheckDlgButton(hDlg, IDC_PROFANE, config.antiprofane);
      CheckDlgButton(hDlg, IDC_DRAWMAP, config.drawmap);
      CheckDlgButton(hDlg, IDC_MAP_ANNOTATIONS, config.map_annotations);

      CheckDlgButton(hDlg, IDC_MUSIC, config.play_music);
      CheckDlgButton(hDlg, IDC_SOUNDFX, config.play_sound);
      CheckDlgButton(hDlg, IDC_LOOPSOUNDS, config.play_loop_sounds);
      CheckDlgButton(hDlg, IDC_RANDSOUNDS, config.play_random_sounds);

      EnableWindow(GetDlgItem(hDlg, IDC_LOOPSOUNDS), IsDlgButtonChecked(hDlg, IDC_SOUNDFX));
      EnableWindow(GetDlgItem(hDlg, IDC_RANDSOUNDS), IsDlgButtonChecked(hDlg, IDC_SOUNDFX));

      CheckRadioButton(hDlg, IDC_TARGETHALO1, IDC_TARGETHALO3, config.halocolor + IDC_TARGETHALO1);

      CheckDlgButton(hDlg, IDC_COLORCODES, config.colorcodes);

      Trackbar_SetRange(GetDlgItem(hDlg, IDC_SOUND_VOLUME), 0, CONFIG_MAX_VOLUME, FALSE);
      Trackbar_SetRange(GetDlgItem(hDlg, IDC_MUSIC_VOLUME), 0, CONFIG_MAX_VOLUME, FALSE);
      Trackbar_SetPos(GetDlgItem(hDlg, IDC_SOUND_VOLUME), config.sound_volume);
      Trackbar_SetPos(GetDlgItem(hDlg, IDC_MUSIC_VOLUME), config.music_volume);
      
      dir = (char *) SafeMalloc(MAX_PATH + 1);
      GetWorkingDirectory(dir, MAX_PATH);

      browser_changed = False;
      return TRUE;

   case WM_COMMAND:
      switch(GET_WM_COMMAND_ID(wParam, lParam))
      {
      case IDC_BROWSER:
         if (GET_WM_COMMAND_CMD(wParam, lParam) != EN_CHANGE)
            break;
         
         browser_changed = True;
         return TRUE;
         
      case IDC_FIND:
         memset(&ofn, 0, sizeof(OPENFILENAME));
         ofn.lStructSize = sizeof(OPENFILENAME);
         ofn.hwndOwner = hDlg;
         ofn.lpstrFilter = EXE_filter;
         ofn.lpstrFile = config.browser;
         ofn.nMaxFile = MAX_PATH;
         ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
         if (GetOpenFileName(&ofn))
         {
            SetWindowText(hBrowser, config.browser);
            browser_changed = True;
         }
         else debug(("GetOpenFileName failed, error = %d\n", CommDlgExtendedError()));
         return TRUE;
         
      case IDCANCEL:
         EndDialog(hDlg, IDCANCEL);
         return TRUE;
         
      case IDC_SOUNDFX:
         EnableWindow(GetDlgItem(hDlg, IDC_LOOPSOUNDS), IsDlgButtonChecked(hDlg, IDC_SOUNDFX));
         EnableWindow(GetDlgItem(hDlg, IDC_RANDSOUNDS), IsDlgButtonChecked(hDlg, IDC_SOUNDFX));
         return TRUE;
         
      case IDC_PROFANESETTINGS:
         if (IDOK == DialogBox(hInst, MAKEINTRESOURCE(IDC_PROFANESETTINGS), hDlg, ProfanityDialogProc))
            CheckDlgButton(hDlg, IDC_PROFANE, TRUE);
         return TRUE;
         
      case IDOK:
         Edit_GetText(hBrowser, config.browser, MAX_PATH);
         
         if (browser_changed)
            config.default_browser = False;
         
         config.scroll_lock   = IsDlgButtonChecked(hDlg, IDC_SCROLLLOCK);
         config.draw_names    = IsDlgButtonChecked(hDlg, IDC_DRAWNAMES);
         config.tooltips      = IsDlgButtonChecked(hDlg, IDC_TOOLTIPS);
         config.pain          = IsDlgButtonChecked(hDlg, IDC_PAIN);
         config.inventory_num = IsDlgButtonChecked(hDlg, IDC_INVNUM);
         config.aggressive    = IsDlgButtonChecked(hDlg, IDC_SAFETY);
         config.bounce        = IsDlgButtonChecked(hDlg, IDC_BOUNCE);
         config.antiprofane   = IsDlgButtonChecked(hDlg, IDC_PROFANE);
         config.drawmap	      = IsDlgButtonChecked(hDlg, IDC_DRAWMAP);
         config.map_annotations = IsDlgButtonChecked(hDlg, IDC_MAP_ANNOTATIONS);
         temp                 = IsDlgButtonChecked(hDlg, IDC_TOOLBAR);
         toolbar_changed = (temp != config.toolbar);
         config.toolbar = temp;
         temp                 = IsDlgButtonChecked(hDlg, IDS_LATENCY0);
         lagbox_changed = (temp != config.lagbox);
         config.lagbox = temp;
         
         if (IsDlgButtonChecked(hDlg, IDC_MUSIC) != config.play_music)
            UserToggleMusic(config.play_music);
         config.play_music = IsDlgButtonChecked(hDlg, IDC_MUSIC);
         
         config.play_sound = IsDlgButtonChecked(hDlg, IDC_SOUNDFX);
         config.play_loop_sounds = IsDlgButtonChecked(hDlg, IDC_LOOPSOUNDS);
         config.play_random_sounds = IsDlgButtonChecked(hDlg, IDC_RANDSOUNDS);
         if (!config.play_sound)
            SoundAbort();

         new_val = Trackbar_GetPos(GetDlgItem(hDlg, IDC_MUSIC_VOLUME));
         if (new_val != config.music_volume)
         {
            config.music_volume = new_val;
            ResetMusicVolume();
         }

         // Don't need to dynamically update sound volume, because
         // looping sounds are updated as player moves around.
         config.sound_volume = Trackbar_GetPos(GetDlgItem(hDlg, IDC_SOUND_VOLUME));

         if( IsDlgButtonChecked( hDlg, IDC_TARGETHALO1 ) == BST_CHECKED )
            config.halocolor = 0;
         else if( IsDlgButtonChecked( hDlg, IDC_TARGETHALO2 ) == BST_CHECKED )
            config.halocolor = 1;
         else
            config.halocolor = 2;
         
         config.colorcodes = IsDlgButtonChecked(hDlg, IDC_COLORCODES);
         
         // Redraw main window to reflect new settings
         if (toolbar_changed || lagbox_changed)
         {
            ResizeAll();
         }
         else
         {
            InvalidateRect(hMain, NULL, TRUE);
            RedrawAll();
         }
         
         EditBoxSetNormalFormat();
         
         EndDialog(hDlg, IDOK);
         return TRUE;
      }
      break;
      
   case WM_DESTROY:
      // Restore working drive and directory
      if (chdir(dir) != 0)
         debug(("chdir failed to %s\n", dir));
      SafeFree(dir);
      
      hPreferencesDialog = NULL;
      return TRUE;
   }
   return FALSE;
}
Esempio n. 18
0
WINEXPORT BOOL CALLBACK WRSelectImageProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
{
    WRSelectImageInfo   *info;
    BOOL                ret;

    ret = FALSE;

    switch( message ) {
    case WM_DESTROY:
        WRUnregisterDialog( hDlg );
        break;

    case WM_INITDIALOG:
        info = (WRSelectImageInfo *)lParam;
        if( info == NULL ) {
            EndDialog( hDlg, FALSE );
        }
        SET_DLGDATA( hDlg, (LONG_PTR)info );
        WRRegisterDialog( hDlg );
        if( !WRSetWinInfo( hDlg, info ) ) {
            EndDialog( hDlg, FALSE );
        }
        ret = TRUE;
        break;

    case WM_SYSCOLORCHANGE:
        WRCtl3dColorChange();
        break;

    case WM_COMMAND:
        info = (WRSelectImageInfo *)GET_DLGDATA( hDlg );
        switch( LOWORD( wParam ) ) {
        case IDM_SELIMGHELP:
            if( info != NULL && info->hcb != NULL ) {
                (*info->hcb)();
            }
            break;

        case IDOK:
            if( info == NULL ) {
                EndDialog( hDlg, FALSE );
                ret = TRUE;
            } else if( WRGetWinInfo( hDlg, info ) ) {
                EndDialog( hDlg, TRUE );
                ret = TRUE;
            }
            break;

        case IDCANCEL:
            EndDialog( hDlg, FALSE );
            ret = TRUE;
            break;

        case IDM_SELIMGBMP:
            if( GET_WM_COMMAND_CMD( wParam, lParam ) != BN_CLICKED ) {
                break;
            }
            if( info->type != (uint_16)(pointer_int)RT_BITMAP ) {
                info->type = (uint_16)(pointer_int)RT_BITMAP;
                WRSetEntries( hDlg, info );
            }
            break;

        case IDM_SELIMGCUR:
            if( GET_WM_COMMAND_CMD( wParam, lParam ) != BN_CLICKED ) {
                break;
            }
            if( info->type != (uint_16)(pointer_int)RT_GROUP_CURSOR ) {
                info->type = (uint_16)(pointer_int)RT_GROUP_CURSOR;
                WRSetEntries( hDlg, info );
            }
            break;

        case IDM_SELIMGICO:
            if( GET_WM_COMMAND_CMD( wParam, lParam ) != BN_CLICKED ) {
                break;
            }
            if( info->type != (uint_16)(pointer_int)RT_GROUP_ICON ) {
                info->type = (uint_16)(pointer_int)RT_GROUP_ICON;
                WRSetEntries( hDlg, info );
            }
            break;
        }
        break;
    }

    return( ret );
}
Esempio n. 19
0
/////////////////////////////////////////////////////////////////////
// CS3Dialog::DlgProc
//
/////////////////////////////////////////////////////////////////////
BOOL WINAPI CS3Dialog::DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    static WCHAR	wszBuffer[MAX_NAME_LEN+1];

    switch(msg) 
    {
        case WM_INITDIALOG:
        {
            Busy();
            //Store the "this" pointer, since this is a static method
            CS3Dialog* pThis = (CS3Dialog*)lParam;
            SetWindowLongPtrA(hWnd, GWLP_USERDATA, (LONG_PTR)pThis);
            
            //On INIT we know we have a valid hWnd to store
            CenterDialog(hWnd);
            pThis->m_hWnd = hWnd;

            //Init all controls to the default values
            pThis->InitControls();
            
            //Limit the length of User Entered TableName
            SendDlgItemMessage(hWnd, IDE_TO_TABLE, EM_LIMITTEXT, (WPARAM)MAX_NAME_LEN-1, 0L);

            pThis->RefreshControls();
            pThis->m_pCTableCopy->m_pCWizard->DestroyPrevStep(WIZ_STEP3);
            return HANDLED_MSG;
        }
        
        case WM_COMMAND:
        {
            //Obtain the "this" pointer
            CS3Dialog* pThis = (CS3Dialog*)GetWindowLongPtrA(hWnd, GWLP_USERDATA);

            CTable		*pCFromTable		= pThis->m_pCTableCopy->m_pCFromTable;		
            CTable		*pCToTable			= pThis->m_pCTableCopy->m_pCToTable;		
            CDataSource	*pCToDataSource		= pCToTable->m_pCDataSource;		
            CDataSource	*pCFromDataSource	= pCFromTable->m_pCDataSource;		

            // All buttons are handled the same way
            switch(GET_WM_COMMAND_ID(wParam, lParam)) 
            {
                case IDB_TO_CONNECT:
                {
                    //kill implicit connection
                    pCToDataSource->Disconnect();

                    //on connect get whatever is now listed in the drop down
                    LRESULT iSel = 0;
                    if((iSel = SendMessage(GetDlgItem(pThis->m_hWnd, IDC_PROVIDER_NAME), CB_GETCURSEL, 0, 0L)) != CB_ERR)
                    {
                        //Since we have the CBS_SORT turned on, the order in the Combo Box does
                        //not match our array, so we pass the array index (lParam) as the item data
                        LRESULT lParam = SendMessage(GetDlgItem(pThis->m_hWnd, IDC_PROVIDER_NAME), CB_GETITEMDATA, iSel, 0L);
                        pCFromTable->m_pCDataSource->m_pwszProviderName = pCFromDataSource->m_rgProviderInfo[lParam].wszName;
/*						if((lParam < (LONG)pCToDataSource->m_cProviderInfo) && (wcscmp(pCFromDataSource->m_rgProviderInfo[lParam].wszName, pCFromDataSource->m_pwszProviderName)!=0))
                        {
                            //Clear Table/Column List Views
                            SendMessage(GetDlgItem(hWnd, IDL_TABLES), TVM_DELETEITEM, (WPARAM)0, (LPARAM)TVI_ROOT);
                            SendMessage(GetDlgItem(hWnd, IDL_COLUMNS), LVM_DELETEALLITEMS, (WPARAM)0, (LPARAM)0);

                            //Clear Table info
                            memset(&pCToTable->m_TableInfo, 0, sizeof(TABLEINFO));
                            pCToTable->m_wszQualTableName[0] = EOL;

                            //Disconnect from the DataSource and Update controls
                            pCToTable->m_pCDataSource->Disconnect();
                        }
*/					}
                    else
                    {
                        //The user must have typed in a Provider Name directly
                        //This may not map to a provider in the list, so assume the name is a ProgID/CLSID
                        wSendMessage(GetDlgItem(pThis->m_hWnd, IDC_PROVIDER_NAME), WM_GETTEXT, MAX_NAME_LEN, wszBuffer);
                        pCToTable->m_pCDataSource->m_pwszProviderName = wszBuffer;
                    }
                    Busy();
                    if(pThis->Connect()) 
                    {
                        Busy();
                        pThis->RefreshControls();
                        SetFocus(GetDlgItem(hWnd, IDE_TO_TABLE));
                        SendMessage(GetDlgItem(hWnd, IDE_TO_TABLE), EM_SETSEL, 0, -1); //Highlight TableName
                    }
                    return HANDLED_MSG;
                }

                case IDOK:
                {	
                    //Get the TableName
                    Busy();
                    wSendMessage(GetDlgItem(hWnd, IDE_TO_TABLE), WM_GETTEXT, MAX_NAME_LEN-1, pCToTable->m_TableInfo.wszTableName);
                    
                    //If the TableNames are the same (ignoring case) and the 
                    //DataSource is the same then the copy is worthless (a no-op)
                    if(_wcsicmp(pCToTable->m_TableInfo.wszTableName, pCFromTable->m_TableInfo.wszTableName)==0 &&
                        pCToDataSource->IsEqual(pCFromDataSource))
                    {
                        //Need to enter a different table name from the source
                        wMessageBox(hWnd, MB_TASKMODAL | MB_ICONEXCLAMATION | MB_OK, 	
                            wsz_ERROR, wsz_SAME_TABLE_NAME, pCToDataSource->m_pwszTableTerm);
                        SetFocus(GetDlgItem(hWnd, IDE_TO_TABLE));
                        SendMessage(GetDlgItem(hWnd, IDE_TO_TABLE), EM_SETSEL, 0, -1); //Highlight TableName
                        return HANDLED_MSG;
                    }
                    
                    StringCchCopyW(pCToTable->m_wszQualTableName, 
                                   sizeof(pCToTable->m_wszQualTableName)/sizeof(WCHAR),
                                   pCToTable->m_TableInfo.wszTableName);
                    pThis->m_pCTableCopy->m_pCWizard->DisplayStep(WIZ_STEP4);
                    return HANDLED_MSG;
                }
                
                case IDB_PREV:
                    //Get the TableName
                    Busy();
                    wSendMessage(GetDlgItem(hWnd, IDE_TO_TABLE), WM_GETTEXT, MAX_NAME_LEN-1, pCToTable->m_TableInfo.wszTableName);
                    StringCchCopyW(pCToTable->m_wszQualTableName, 
                                   sizeof(pCToTable->m_wszQualTableName)/sizeof(WCHAR),
                                   pCToTable->m_TableInfo.wszTableName);
                    pThis->m_pCTableCopy->m_pCWizard->DisplayStep(WIZ_STEP2);
                    return HANDLED_MSG;

                case IDCANCEL:
                    Busy();
                    EndDialog(hWnd, GET_WM_COMMAND_ID(wParam, lParam));
                    return HANDLED_MSG;
            }

            // Now look for notification messages
            switch(GET_WM_COMMAND_CMD(wParam, lParam)) 
            {
                case LBN_SELCHANGE:
                {
/*					//A Provider Change requires a refresh
                    if(IDC_PROVIDER_NAME == GET_WM_COMMAND_ID(wParam, lParam)) 
                    {
                        //Get new selection
                        Busy();
                        LONG iSel = 0;
                        if((iSel = SendMessage(GetDlgItem(pThis->m_hWnd, IDC_PROVIDER_NAME), CB_GETCURSEL, 0, 0L)) != CB_ERR)
                        {
                            //Since we have the CBS_SORT turned on, the order in the Combo Box does
                            //not match our array, so we pass the array index (lParam) as the item data
                            LONG lParam = SendMessage(GetDlgItem(pThis->m_hWnd, IDC_PROVIDER_NAME), CB_GETITEMDATA, iSel, 0L);
                            if((lParam < (LONG)pCToDataSource->m_cProviderInfo) && (wcscmp(pCToDataSource->m_rgProviderInfo[lParam].wszName, pCToDataSource->m_pwszProviderName)!=0))
                            {
                                pCToDataSource->Disconnect();
                            }
                        }
                    }

                    pThis->RefreshControls();
*/				}
                
                case EN_CHANGE:
                {
                    pThis->EnableTable();
                    return HANDLED_MSG;
                }
            }
        }
    }

    return UNHANDLED_MSG;
}
Esempio n. 20
0
/*
* DescDialogProc:  Dialog procedure for dialog containing an
*   item's long description.
*/
BOOL CALLBACK DescDialogProc(HWND hDlg, UINT message, UINT wParam, LONG lParam)
{
	DescDialogStruct *info;
	static HWND hwndBitmap;
	static Bool changed;   // True when player has changed description
	HWND hEdit, hwndOK, hURL, hFixed;
	HDC hdc;
	HFONT hFont;
	RECT dlg_rect, edit_rect, fixed_rect;
	AREA area;
	char *desc, *str, url[MAX_URL + 1], *pPageBreak;
	DRAWITEMSTRUCT *lpdis;
	char descriptionBuffer[MAX_PAGE_DESCRIPTION_TEXT+1];
	int height;
	
	info = (DescDialogStruct *) GetWindowLong(hDlg, DWL_USER);
	
	switch (message)
	{
	case WM_INITDIALOG:
		info = (DescDialogStruct *) lParam;
		/* Store structure in dialog box's extra bytes */
		SetWindowLong(hDlg, DWL_USER, (long) info);
		
		hwndBitmap = GetDlgItem(hDlg, IDC_DESCBITMAP);
		hFixed = GetDlgItem(hDlg, IDC_DESCFIXED);
		hEdit = GetDlgItem(hDlg, IDC_DESCBOX);
		hwndOK = GetDlgItem(hDlg, IDOK);
		
		// Item Name.
		height = SetFontToFitText(info,GetDlgItem(hDlg, IDC_DESCNAME), 
			(int)FONT_TITLES, info->name);
		SetDlgItemText(hDlg, IDC_DESCNAME, info->name);
		hdc = GetDC(hDlg);
		SetTextColor(hdc,GetPlayerNameColor(info->obj,info->name));
		ReleaseDC(hDlg,hdc);
		
		// Item Description.
		hFont = GetFont(FONT_EDIT);
		SetWindowFont(hFixed, hFont, FALSE);
		SetWindowFont(hEdit, hFont, FALSE);
		
		str = info->description;
		if (str)
		{
			pPageBreak = strchr(str,PAGE_BREAK_CHAR);
			while (pPageBreak)
			{
				info->numPages++;
				str = pPageBreak+1;
				pPageBreak = strchr(str,PAGE_BREAK_CHAR);
			}
			info->numPages++;
			GetPageText(descriptionBuffer,info);
			Edit_SetText(hEdit, descriptionBuffer);
		}
		
		// Show fixed string, if appropriate
		if (info->fixed_string != NULL)
		{
			SetDlgItemText(hDlg, IDC_DESCFIXED, info->fixed_string);
			SetWindowFont(GetDlgItem(hDlg, IDC_DESCFIXED), GetFont(FONT_EDIT), FALSE);
		}
		
		// Can this player edit this object's description?
		if (info->flags & DF_EDITABLE)
			Edit_SetReadOnly(hEdit, FALSE);
		Edit_LimitText(hEdit, MAX_DESCRIPTION);
		if (!(info->flags & (DF_EDITABLE | DF_INSCRIBED)) && !str)
		{
			GetWindowRect(hFixed, &fixed_rect);
			GetWindowRect(hEdit, &edit_rect);
			UnionRect(&fixed_rect, &fixed_rect, &edit_rect);
			ScreenToClient(hDlg, (LPPOINT)(&fixed_rect));
			ScreenToClient(hDlg, (LPPOINT)(&fixed_rect)+1);
			MoveWindow(hFixed, fixed_rect.left, fixed_rect.top,
				fixed_rect.right - fixed_rect.left,
				fixed_rect.bottom - fixed_rect.top, FALSE);
			ShowWindow(hEdit, SW_HIDE);
		}
		
		// Resize and move dialog controls
		GetWindowRect(hDlg, &dlg_rect);
		if (GetWindowLong(hEdit, GWL_STYLE) & WS_VISIBLE)
		{
			ShowWindow(hEdit, SW_HIDE);
			ResizeEditToFitText(hFixed, hFont);
			ResizeDialog(hDlg, &dlg_rect, desc_controls);
			ShowWindow(hEdit, SW_SHOW);
		}
		else
		{
			ResizeEditToFitText(hFixed, hFont);
			ResizeDialog(hDlg, &dlg_rect, desc_controls);
		}
		if (GetWindowLong(hEdit, GWL_STYLE) & WS_VISIBLE)
		{
			GetWindowRect(hFixed, &fixed_rect);
			GetWindowRect(hEdit, &edit_rect);
			height = fixed_rect.bottom-edit_rect.top;
			ScreenToClient(hDlg, (LPPOINT)(&edit_rect));
			ScreenToClient(hDlg, (LPPOINT)(&edit_rect)+1);
			ShowWindow(hFixed, SW_HIDE);
			OffsetRect(&edit_rect, 0, height);
			MoveWindow(hEdit, edit_rect.left, edit_rect.top,
				edit_rect.right - edit_rect.left,
				edit_rect.bottom - edit_rect.top, FALSE);
			GetWindowRect(hDlg, &dlg_rect);
			ResizeEditToFitText(hEdit, hFont);
			ResizeDialog(hDlg, &dlg_rect, desc_controls);
			ShowWindow(hFixed, SW_SHOW);
		}
		
		CenterWindow(hDlg, GetParent(hDlg));
		
		// Show URL, if appropriate
		if (info->url != NULL)
		{
			hURL = GetDlgItem(hDlg, IDC_URL);
			
			SetWindowText(hURL, info->url);
			SetWindowFont(hURL, GetFont(FONT_EDIT), FALSE);
			
			if (info->flags & DF_EDITABLE)
				Edit_SetReadOnly(hURL, FALSE);
			
			Edit_LimitText(hURL, MAX_URL);
		}
		
		// Show appropriate buttons
		if (!(desc_flags & DESC_GET))
			DestroyWindow(GetDlgItem(hDlg, IDC_GET));
		if (!(desc_flags & DESC_DROP))
			DestroyWindow(GetDlgItem(hDlg, IDC_DROP));
		if (!(desc_flags & DESC_USE))
			DestroyWindow(GetDlgItem(hDlg, IDC_USE));
		if (!(desc_flags & DESC_UNUSE))
			DestroyWindow(GetDlgItem(hDlg, IDC_UNUSE));
		if (!(desc_flags & DESC_INSIDE))
			DestroyWindow(GetDlgItem(hDlg, IDC_INSIDE));
		if (!(desc_flags & DESC_ACTIVATE))
			DestroyWindow(GetDlgItem(hDlg, IDC_ACTIVATE));
		if (!(desc_flags & DESC_APPLY))
			DestroyWindow(GetDlgItem(hDlg, IDC_APPLY));
		
		SetLookPageButtons(hDlg, info);
#if 0
		if (info->numPages < 2)
		{
			HWND hwnd = GetDlgItem(hDlg,IDC_NEXT);
			if (hwnd)
				DestroyWindow(GetDlgItem(hDlg, IDC_NEXT));
			hwnd = GetDlgItem(hDlg,IDC_PREV);
			if (hwnd)
				DestroyWindow(GetDlgItem(hDlg, IDC_PREV));
		}
		else 
		{
			HWND hwnd = GetDlgItem(hDlg,IDC_PREV);
			if (hwnd)
				EnableWindow(hwnd,FALSE);
		}
#endif
		SetFocus(hwndOK);
		hDescDialog = hDlg;
		changed = False;
		return FALSE;
		
   case WM_PAINT:
	   InvalidateRect(hwndBitmap, NULL, TRUE);
	   UpdateWindow(hwndBitmap);
	   /* fall through */
	   
   case BK_ANIMATE:
	   /* Draw object's bitmap */
	   hdc = GetDC(hwndBitmap);
	   GetClientRect(hwndBitmap, &dlg_rect);
	   
	   RectToArea(&dlg_rect, &area);
	   DrawStretchedObjectGroup(hdc, info->obj, info->obj->animate->group, &area, 
		   GetSysColorBrush(COLOR_3DFACE));
	   
	   ReleaseDC(hwndBitmap, hdc);
	   break;
	   
	   HANDLE_MSG(hDlg, WM_CTLCOLOREDIT, DialogCtlColor);
	   HANDLE_MSG(hDlg, WM_CTLCOLORLISTBOX, DialogCtlColor);
	   HANDLE_MSG(hDlg, WM_CTLCOLORSTATIC, DialogCtlColor);
	   HANDLE_MSG(hDlg, WM_CTLCOLORDLG, DialogCtlColor);
	   
   case WM_DESTROY:
	   hDescDialog = NULL;
	   return TRUE;   
	   
   case WM_DRAWITEM:
	   // Draw player name in color that reflects murderer status
	   lpdis = (DRAWITEMSTRUCT *) lParam;
	   switch (lpdis->itemAction)
       {
       case ODA_SELECT:
       case ODA_DRAWENTIRE:
		   SelectPalette(lpdis->hDC, hPal, FALSE);
		   hFont = info->hFontTitle;
		   SelectObject(lpdis->hDC, hFont);
		   SetBkMode(lpdis->hDC, TRANSPARENT);
		   str = LookupNameRsc(info->obj->name_res);
		   SetTextColor(lpdis->hDC, NAME_COLOR_NORMAL_BG);
		   DrawText(lpdis->hDC, str, strlen(str), &lpdis->rcItem, DT_LEFT | DT_VCENTER | DT_NOPREFIX);
		   OffsetRect(&lpdis->rcItem, -1, -1);
		   SetTextColor(lpdis->hDC, GetPlayerNameColor(info->obj, info->name));
		   DrawText(lpdis->hDC, str, strlen(str), &lpdis->rcItem, DT_LEFT | DT_VCENTER | DT_NOPREFIX);
		   
		   break;
       }
	   return TRUE;
	   
	   case WM_COMMAND:
		   switch(GET_WM_COMMAND_ID(wParam, lParam))
		   {
		   case IDC_PREV:
			   if (info->currentPage > 0)
				   info->currentPage--;
			   GetPageText(descriptionBuffer,info);
			   SetLookPageButtons(hDlg, info);
			   Edit_SetText(GetDlgItem(hDlg, IDC_DESCBOX), descriptionBuffer);
#if 0
			   EnableWindow(GetDlgItem(hDlg,IDC_PREV),info->currentPage > 0);
			   EnableWindow(GetDlgItem(hDlg,IDC_NEXT),info->currentPage < info->numPages-1);
#endif
			   return TRUE;
			   
		   case IDC_NEXT:
			   if (info->currentPage < info->numPages-1)
				   info->currentPage++;
			   GetPageText(descriptionBuffer,info);
			   Edit_SetText(GetDlgItem(hDlg, IDC_DESCBOX), descriptionBuffer);
			   SetLookPageButtons(hDlg, info);
#if 0
			   EnableWindow(GetDlgItem(hDlg,IDC_PREV),info->currentPage > 0);
			   EnableWindow(GetDlgItem(hDlg,IDC_NEXT),info->currentPage < info->numPages-1);
#endif
			   return TRUE;
			   
		   case IDC_GET:
			   RequestPickup(info->obj->id);
			   EndDialog(hDlg, 0);
			   return TRUE;
			   
		   case IDC_DROP:
			   // Drop all of number items
			   info->obj->temp_amount = info->obj->amount;
			   RequestDrop(info->obj);
			   EndDialog(hDlg, 0);
			   return TRUE;
			   
		   case IDC_USE:
			   // If player isn't holding the object (i.e. there's a Get button), pick object up first
			   if (IsWindowVisible(GetDlgItem(hDlg, IDC_GET)))
				   RequestPickup(info->obj->id);
			   RequestUse(info->obj->id);
			   EndDialog(hDlg, 0);
			   return TRUE;
			   
		   case IDC_UNUSE:
			   RequestUnuse(info->obj->id);
			   EndDialog(hDlg, 0);
			   return TRUE;
			   
		   case IDC_INSIDE:
			   RequestObjectContents(info->obj->id);
			   EndDialog(hDlg, 0);
			   return TRUE;
			   
		   case IDC_ACTIVATE:
			   RequestActivate(info->obj->id);
			   EndDialog(hDlg, 0);
			   return TRUE;
			   
		   case IDC_APPLY:
			   StartApply(info->obj->id);
			   EndDialog(hDlg, 0);
			   return TRUE;
			   
		   case IDC_DESCBOX:
			   if (GET_WM_COMMAND_CMD(wParam, lParam) != EN_CHANGE)
				   break;
			   changed = True;
			   return TRUE;
			   
		   case IDC_URLBUTTON:
			   hURL = GetDlgItem(hDlg, IDC_URL);
			   Edit_GetText(hURL, url, MAX_URL);
			   WebLaunchBrowser(url);
			   return TRUE;
			   
		   case IDOK:
			   
			   // Send new description if changed
			   if (changed)
			   {
				   desc = (char *) SafeMalloc(MAX_DESCRIPTION + 1);
				   GetDlgItemText(hDlg, IDC_DESCBOX, desc, MAX_DESCRIPTION);
				   RequestChangeDescription(info->obj->id, desc);
				   SafeFree(desc);
			   }
			   
			   // Send new URL if changed
			   if (info->url != NULL)
			   {
				   GetDlgItemText(hDlg, IDC_URL, url, MAX_URL);
				   if (strcmp(url, info->url))
					   RequestChangeURL(player.id, url);
			   }
			   
			   // FALLTHRU
			   
		   case IDCANCEL:
			   SetWindowFont(GetDlgItem(hDlg,IDC_DESCNAME), GetFont(FONT_TITLES), FALSE);
			   if (info->hFontTitle && info->hFontTitle != GetFont(FONT_TITLES))
				   DeleteObject(info->hFontTitle);
			   info->hFontTitle = NULL;
			   
			   EndDialog(hDlg, IDOK == GET_WM_COMMAND_ID(wParam, lParam));
			   return TRUE;
      }
      break;
   }
   
   return FALSE;
}
Esempio n. 21
0
BOOL CLocationsPrefPage::OnCommand(WPARAM wParam, LPARAM lParam) 
{
	HWND   	hActiveWnd = GetActiveDoc();
	HWND	hDlg = GetSafeHwnd();
	int 	id = GET_WM_COMMAND_ID(wParam, lParam);
	UINT 	codeNotify = GET_WM_COMMAND_CMD(wParam, lParam);

	switch (id)
	{
		case IDC_LOCATE_CLIPBITS:
			if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) )
	    		break;
			if ( codeNotify != EN_CHANGE )
	    		break;
			::GetDlgItemText( hDlg, id, m_Clipbits,
				sizeof(m_Clipbits));
			FixPath( Lowercase( m_Clipbits ) );
			SetModified(TRUE);
		break;

		case IDC_LOCATE_PRNSTYLES:
			if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) )
	    		break;
			if ( codeNotify != EN_CHANGE )
	    		break;
			::GetDlgItemText( hDlg, id, m_Printstyles,
				sizeof(m_Printstyles));
			FixPath( Lowercase( m_Printstyles ) );
			SetModified(TRUE);
		break;
	
		case IDC_LOCATE_BRUSHES:
			if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) )
	    		break;
			if ( codeNotify != EN_CHANGE )
	    		break;
			::GetDlgItemText( hDlg, id, m_Brushes,
				sizeof(m_Brushes));
			FixPath( Lowercase( m_Brushes ) );
			SetModified(TRUE);
		break;

		case IDC_LOCATE_PALETTES:
			if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) )
	    		break;
			if ( codeNotify != EN_CHANGE )
	    		break;
			::GetDlgItemText( hDlg, id,m_Palettes ,
				sizeof(m_Palettes));
			FixPath( Lowercase( m_Palettes ) );
			SetModified(TRUE);
		break;

		case IDC_LOCATE_TEXTURES:
			if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) )
	    		break;
			if ( codeNotify != EN_CHANGE )
	    		break;
			::GetDlgItemText( hDlg, id,m_Textures ,
				sizeof(m_Textures));
			FixPath( Lowercase( m_Textures ) );
			SetModified(TRUE);
		break;

		case IDC_LOCATE_DEVICES:
			if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) )
	    		break;
			if ( codeNotify != EN_CHANGE )
	    		break;
			::GetDlgItemText( hDlg, id,m_Devices ,
				sizeof(m_Devices));
			FixPath( Lowercase( m_Devices ) );
			SetModified(TRUE);
		break;

		case IDC_LOCATE_FILTERS:
			if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) )
	    		break;
			if ( codeNotify != EN_CHANGE )
	    		break;
			::GetDlgItemText( hDlg, id,m_Effects ,
				sizeof(m_Effects));
			FixPath( Lowercase( m_Effects ) );
			SetModified(TRUE);
		break;

		case IDC_LOCATE_MACROS:
			if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) )
	    		break;
			if ( codeNotify != EN_CHANGE )
	    		break;
			::GetDlgItemText( hDlg, id,m_Macros ,
				sizeof(m_Macros));
			FixPath( Lowercase( m_Macros ) );
			SetModified(TRUE);
		break;

		case IDC_LOCATE_IMPORTFILTERS:
			if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) )
	    		break;
			if ( codeNotify != EN_CHANGE )
	    		break;
			::GetDlgItemText( hDlg, id,m_Importfilters ,
				sizeof(m_Importfilters));
			FixPath( Lowercase( m_Importfilters ) );
			SetModified(TRUE);
		break;

		default:
			return (CPPPropertyPage::OnCommand(wParam, lParam));   	
		break;
   	}
	return(TRUE);
}
Esempio n. 22
0
INT_PTR CALLBACK WepWindowsPageProc(
    _In_ HWND hwndDlg,
    _In_ UINT uMsg,
    _In_ WPARAM wParam,
    _In_ LPARAM lParam
    )
{
    PWINDOWS_CONTEXT context;
    LPPROPSHEETPAGE propSheetPage;
    PPH_PROCESS_PROPPAGECONTEXT propPageContext;
    PPH_PROCESS_ITEM processItem;

    if (PhPropPageDlgProcHeader(hwndDlg, uMsg, lParam, &propSheetPage, &propPageContext, &processItem))
    {
        context = propPageContext->Context;
    }
    else
    {
        return FALSE;
    }

    switch (uMsg)
    {
    case WM_INITDIALOG:
        {
            context->TreeNewHandle = GetDlgItem(hwndDlg, IDC_LIST);
            context->SearchBoxHandle = GetDlgItem(hwndDlg, IDC_SEARCHEDIT);

            PhCreateSearchControl(hwndDlg, context->SearchBoxHandle, L"Search Windows (Ctrl+K)");

            WeInitializeWindowTree(hwndDlg, context->TreeNewHandle, &context->TreeContext);

            PhRegisterDialog(hwndDlg);

            PhInitializeLayoutManager(&context->LayoutManager, hwndDlg);
            PhAddLayoutItem(&context->LayoutManager, GetDlgItem(hwndDlg, IDC_SEARCHEDIT), NULL, PH_ANCHOR_TOP | PH_ANCHOR_RIGHT);
            PhAddLayoutItem(&context->LayoutManager, GetDlgItem(hwndDlg, IDC_LIST), NULL, PH_ANCHOR_ALL);

            WepRefreshWindows(context);
        }
        break;
    case WM_SHOWWINDOW:
        {
            if (PhBeginPropPageLayout(hwndDlg, propPageContext))
                PhEndPropPageLayout(hwndDlg, propPageContext);
        }
        break;
    case WM_DESTROY:
        {
            PhDeleteLayoutManager(&context->LayoutManager);

            PhUnregisterDialog(hwndDlg);

            WeDeleteWindowTree(&context->TreeContext);
            WepDeleteWindowSelector(&context->Selector);
            PhFree(context);
        }
        break;
    case WM_COMMAND:
        {
            switch (GET_WM_COMMAND_CMD(wParam, lParam))
            {
            case EN_CHANGE:
                {
                    PPH_STRING newSearchboxText;

                    if (GET_WM_COMMAND_HWND(wParam, lParam) != context->SearchBoxHandle)
                        break;

                    newSearchboxText = PH_AUTO(PhGetWindowText(context->SearchBoxHandle));

                    if (!PhEqualString(context->TreeContext.SearchboxText, newSearchboxText, FALSE))
                    {
                        PhSwapReference(&context->TreeContext.SearchboxText, newSearchboxText);

                        if (!PhIsNullOrEmptyString(context->TreeContext.SearchboxText))
                            WeExpandAllWindowNodes(&context->TreeContext, TRUE);

                        PhApplyTreeNewFilters(&context->TreeContext.FilterSupport);

                        TreeNew_NodesStructured(context->TreeNewHandle);
                        // PhInvokeCallback(&SearchChangedEvent, SearchboxText);
                    }
                }
                break;
            }

            switch (GET_WM_COMMAND_ID(wParam, lParam))
            {
            case IDC_REFRESH:
                WepRefreshWindows(context);
                break;
            case ID_SHOWCONTEXTMENU:
                {
                    PPH_TREENEW_CONTEXT_MENU contextMenuEvent = (PPH_TREENEW_CONTEXT_MENU)lParam;
                    PWE_WINDOW_NODE *windows;
                    ULONG numberOfWindows;
                    PPH_EMENU menu;
                    PPH_EMENU selectedItem;

                    WeGetSelectedWindowNodes(
                        &context->TreeContext,
                        &windows,
                        &numberOfWindows
                        );

                    if (numberOfWindows != 0)
                    {
                        menu = PhCreateEMenu();
                        PhLoadResourceEMenuItem(menu, PluginInstance->DllBase, MAKEINTRESOURCE(IDR_WINDOW), 0);
                        PhInsertCopyCellEMenuItem(menu, ID_WINDOW_COPY, context->TreeNewHandle, contextMenuEvent->Column);
                        PhSetFlagsEMenuItem(menu, ID_WINDOW_PROPERTIES, PH_EMENU_DEFAULT, PH_EMENU_DEFAULT);

                        if (numberOfWindows == 1)
                        {
                            WINDOWPLACEMENT placement = { sizeof(placement) };
                            BYTE alpha;
                            ULONG flags;
                            ULONG i;
                            ULONG id;

                            // State

                            GetWindowPlacement(windows[0]->WindowHandle, &placement);

                            if (placement.showCmd == SW_MINIMIZE)
                                PhSetFlagsEMenuItem(menu, ID_WINDOW_MINIMIZE, PH_EMENU_DISABLED, PH_EMENU_DISABLED);
                            else if (placement.showCmd == SW_MAXIMIZE)
                                PhSetFlagsEMenuItem(menu, ID_WINDOW_MAXIMIZE, PH_EMENU_DISABLED, PH_EMENU_DISABLED);
                            else if (placement.showCmd == SW_NORMAL)
                                PhSetFlagsEMenuItem(menu, ID_WINDOW_RESTORE, PH_EMENU_DISABLED, PH_EMENU_DISABLED);

                            // Visible

                            PhSetFlagsEMenuItem(menu, ID_WINDOW_VISIBLE, PH_EMENU_CHECKED,
                                (GetWindowLong(windows[0]->WindowHandle, GWL_STYLE) & WS_VISIBLE) ? PH_EMENU_CHECKED : 0);

                            // Enabled

                            PhSetFlagsEMenuItem(menu, ID_WINDOW_ENABLED, PH_EMENU_CHECKED,
                                !(GetWindowLong(windows[0]->WindowHandle, GWL_STYLE) & WS_DISABLED) ? PH_EMENU_CHECKED : 0);

                            // Always on Top

                            PhSetFlagsEMenuItem(menu, ID_WINDOW_ALWAYSONTOP, PH_EMENU_CHECKED,
                                (GetWindowLong(windows[0]->WindowHandle, GWL_EXSTYLE) & WS_EX_TOPMOST) ? PH_EMENU_CHECKED : 0);

                            // Opacity

                            if (GetLayeredWindowAttributes(windows[0]->WindowHandle, NULL, &alpha, &flags))
                            {
                                if (!(flags & LWA_ALPHA))
                                    alpha = 255;
                            }
                            else
                            {
                                alpha = 255;
                            }

                            if (alpha == 255)
                            {
                                id = ID_OPACITY_OPAQUE;
                            }
                            else
                            {
                                id = 0;

                                // Due to integer division, we cannot use simple arithmetic to calculate which menu item to check.
                                for (i = 0; i < 10; i++)
                                {
                                    if (alpha == (BYTE)(255 * (i + 1) / 10))
                                    {
                                        id = ID_OPACITY_10 + i;
                                        break;
                                    }
                                }
                            }

                            if (id != 0)
                            {
                                PhSetFlagsEMenuItem(menu, id, PH_EMENU_CHECKED | PH_EMENU_RADIOCHECK,
                                    PH_EMENU_CHECKED | PH_EMENU_RADIOCHECK);
                            }
                        }
                        else
                        {
                            PhSetFlagsAllEMenuItems(menu, PH_EMENU_DISABLED, PH_EMENU_DISABLED);
                            PhSetFlagsEMenuItem(menu, ID_WINDOW_COPY, PH_EMENU_DISABLED, 0);
                        }

                        selectedItem = PhShowEMenu(
                            menu,
                            hwndDlg,
                            PH_EMENU_SHOW_SEND_COMMAND | PH_EMENU_SHOW_LEFTRIGHT,
                            PH_ALIGN_LEFT | PH_ALIGN_TOP,
                            contextMenuEvent->Location.x,
                            contextMenuEvent->Location.y
                            );

                        if (selectedItem && selectedItem->Id != -1)
                        {
                            BOOLEAN handled = FALSE;

                            handled = PhHandleCopyCellEMenuItem(selectedItem);
                        }

                        PhDestroyEMenu(menu);
                    }
                }
                break;
            case ID_WINDOW_BRINGTOFRONT:
                {
                    PWE_WINDOW_NODE selectedNode;

                    if (selectedNode = WeGetSelectedWindowNode(&context->TreeContext))
                    {
                        WINDOWPLACEMENT placement = { sizeof(placement) };

                        GetWindowPlacement(selectedNode->WindowHandle, &placement);

                        if (placement.showCmd == SW_MINIMIZE)
                            ShowWindowAsync(selectedNode->WindowHandle, SW_RESTORE);
                        else
                            SetForegroundWindow(selectedNode->WindowHandle);
                    }
                }
                break;
            case ID_WINDOW_RESTORE:
                {
                    PWE_WINDOW_NODE selectedNode;

                    if (selectedNode = WeGetSelectedWindowNode(&context->TreeContext))
                    {
                        ShowWindowAsync(selectedNode->WindowHandle, SW_RESTORE);
                    }
                }
                break;
            case ID_WINDOW_MINIMIZE:
                {
                    PWE_WINDOW_NODE selectedNode;

                    if (selectedNode = WeGetSelectedWindowNode(&context->TreeContext))
                    {
                        ShowWindowAsync(selectedNode->WindowHandle, SW_MINIMIZE);
                    }
                }
                break;
            case ID_WINDOW_MAXIMIZE:
                {
                    PWE_WINDOW_NODE selectedNode;

                    if (selectedNode = WeGetSelectedWindowNode(&context->TreeContext))
                    {
                        ShowWindowAsync(selectedNode->WindowHandle, SW_MAXIMIZE);
                    }
                }
                break;
            case ID_WINDOW_CLOSE:
                {
                    PWE_WINDOW_NODE selectedNode;

                    if (selectedNode = WeGetSelectedWindowNode(&context->TreeContext))
                    {
                        PostMessage(selectedNode->WindowHandle, WM_CLOSE, 0, 0);
                    }
                }
                break;
            case ID_WINDOW_VISIBLE:
                {
                    PWE_WINDOW_NODE selectedNode;

                    if (selectedNode = WeGetSelectedWindowNode(&context->TreeContext))
                    {
                        if (IsWindowVisible(selectedNode->WindowHandle))
                        {
                            selectedNode->WindowVisible = FALSE;
                            ShowWindowAsync(selectedNode->WindowHandle, SW_HIDE);
                        }
                        else
                        {
                            selectedNode->WindowVisible = TRUE;
                            ShowWindowAsync(selectedNode->WindowHandle, SW_SHOW);
                        }

                        PhInvalidateTreeNewNode(&selectedNode->Node, TN_CACHE_COLOR);
                        TreeNew_InvalidateNode(context->TreeNewHandle, &selectedNode->Node);
                    }
                }
                break;
            case ID_WINDOW_ENABLED:
                {
                    PWE_WINDOW_NODE selectedNode;

                    if (selectedNode = WeGetSelectedWindowNode(&context->TreeContext))
                    {
                        EnableWindow(selectedNode->WindowHandle, !IsWindowEnabled(selectedNode->WindowHandle));
                    }
                }
                break;
            case ID_WINDOW_ALWAYSONTOP:
                {
                    PWE_WINDOW_NODE selectedNode;

                    if (selectedNode = WeGetSelectedWindowNode(&context->TreeContext))
                    {
                        LOGICAL topMost;

                        topMost = GetWindowLong(selectedNode->WindowHandle, GWL_EXSTYLE) & WS_EX_TOPMOST;
                        SetWindowPos(selectedNode->WindowHandle, topMost ? HWND_NOTOPMOST : HWND_TOPMOST,
                            0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
                    }
                }
                break;
            case ID_OPACITY_10:
            case ID_OPACITY_20:
            case ID_OPACITY_30:
            case ID_OPACITY_40:
            case ID_OPACITY_50:
            case ID_OPACITY_60:
            case ID_OPACITY_70:
            case ID_OPACITY_80:
            case ID_OPACITY_90:
            case ID_OPACITY_OPAQUE:
                {
                    PWE_WINDOW_NODE selectedNode;

                    if (selectedNode = WeGetSelectedWindowNode(&context->TreeContext))
                    {
                        ULONG opacity;

                        opacity = ((ULONG)LOWORD(wParam) - ID_OPACITY_10) + 1;

                        if (opacity == 10)
                        {
                            // Remove the WS_EX_LAYERED bit since it is not needed.
                            PhSetWindowExStyle(selectedNode->WindowHandle, WS_EX_LAYERED, 0);
                            RedrawWindow(selectedNode->WindowHandle, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
                        }
                        else
                        {
                            // Add the WS_EX_LAYERED bit so opacity will work.
                            PhSetWindowExStyle(selectedNode->WindowHandle, WS_EX_LAYERED, WS_EX_LAYERED);
                            SetLayeredWindowAttributes(selectedNode->WindowHandle, 0, (BYTE)(255 * opacity / 10), LWA_ALPHA);
                        }
                    }
                }
                break;
            case ID_WINDOW_HIGHLIGHT:
                {
                    PWE_WINDOW_NODE selectedNode;

                    if (selectedNode = WeGetSelectedWindowNode(&context->TreeContext))
                    {
                        if (context->HighlightingWindow)
                        {
                            if (context->HighlightingWindowCount & 1)
                                WeInvertWindowBorder(context->HighlightingWindow);
                        }

                        context->HighlightingWindow = selectedNode->WindowHandle;
                        context->HighlightingWindowCount = 10;
                        SetTimer(hwndDlg, 9, 100, NULL);
                    }
                }
                break;
            case ID_WINDOW_GOTOTHREAD:
                {
                    PWE_WINDOW_NODE selectedNode;
                    PPH_PROCESS_ITEM processItem;
                    PPH_PROCESS_PROPCONTEXT propContext;

                    if (selectedNode = WeGetSelectedWindowNode(&context->TreeContext))
                    {
                        if (processItem = PhReferenceProcessItem(selectedNode->ClientId.UniqueProcess))
                        {
                            if (propContext = PhCreateProcessPropContext(WE_PhMainWndHandle, processItem))
                            {
                                PhSetSelectThreadIdProcessPropContext(propContext, selectedNode->ClientId.UniqueThread);
                                PhShowProcessProperties(propContext);
                                PhDereferenceObject(propContext);
                            }

                            PhDereferenceObject(processItem);
                        }
                        else
                        {
                            PhShowError(hwndDlg, L"The process does not exist.");
                        }
                    }
                }
                break;
            case ID_WINDOW_PROPERTIES:
                {
                    PWE_WINDOW_NODE selectedNode;

                    if (selectedNode = WeGetSelectedWindowNode(&context->TreeContext))
                        WeShowWindowProperties(hwndDlg, selectedNode->WindowHandle);
                }
                break;
            case ID_WINDOW_COPY:
                {
                    PPH_STRING text;

                    text = PhGetTreeNewText(context->TreeNewHandle, 0);
                    PhSetClipboardString(hwndDlg, &text->sr);
                    PhDereferenceObject(text);
                }
                break;
            }
        }
        break;
    case WM_TIMER:
        {
            switch (wParam)
            {
            case 9:
                {
                    WeInvertWindowBorder(context->HighlightingWindow);

                    if (--context->HighlightingWindowCount == 0)
                        KillTimer(hwndDlg, 9);
                }
                break;
            }
        }
        break;
    case WM_SIZE:
        PhLayoutManagerLayout(&context->LayoutManager);  
        break;
    case WM_NOTIFY:
        {
            LPNMHDR header = (LPNMHDR)lParam;

            switch (header->code)
            {
            case PSN_QUERYINITIALFOCUS:
                SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, (LPARAM)GetDlgItem(hwndDlg, IDC_REFRESH));
                return TRUE;
            }
        }
        break;
    }

    return FALSE;
}
Esempio n. 23
0
UINT_PTR CALLBACK AddSrcDlgProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
    WORD        cmd;
    int         item;
    LRESULT     rc;
    HWND        ctl;

    lparam = lparam;
    switch( msg ) {
    case WM_INITDIALOG:
        {
            OPENFILENAME        *of;

            ctl = GetDlgItem( hwnd, FOD_REMOVE );
            EnableWindow( ctl, FALSE );
            ctl = GetDlgItem( hwnd, IDOK );
            EnableWindow( ctl, FALSE );
            of = (OPENFILENAME *)lparam;
            SET_DLGDATA( hwnd, of->lCustData );
            initFileList( hwnd );
        }
        break;
    case WM_COMMAND:
        cmd = LOWORD( wparam );
        switch( cmd ) {
        case FOD_FILES:
            if( GET_WM_COMMAND_CMD( wparam, lparam ) == LBN_DBLCLK ) {
                addCurrentFile( hwnd );
                return( TRUE );
            } else {
                return( FALSE );
            }
        case IDOK:
            return( FALSE );
        case FOD_ADD:
            addCurrentFile( hwnd );
            PostMessage( hwnd, WM_COMMAND, IDOK, 0 );
            return( TRUE );
        case FOD_ADDALL:
            addAllFiles( hwnd );
            break;
        case FOD_REMOVE:
            ctl = GetDlgItem( hwnd, FOD_FILELIST );
            item = (int)SendMessage( ctl, LB_GETCURSEL, 0, 0 );
            if( item != LB_ERR ) {
                rc = SendMessage( ctl, LB_DELETESTRING, item, 0 );
                if( item != 0 ) {
                    SendMessage( ctl, LB_SETCURSEL, item - 1, 0 );
                } else {
                    SendMessage( ctl, LB_SETCURSEL, item, 0 );
                }
            }
            checkRemoveButton( hwnd );
            break;
        case FOD_FILELIST:
            if( GET_WM_COMMAND_CMD( wparam, lparam ) == LBN_SELCHANGE ||
                GET_WM_COMMAND_CMD( wparam, lparam ) == LBN_SELCANCEL ) {
                checkRemoveButton( hwnd );
            }
            break;
        case FOD_CLOSE:
            GetResults( hwnd );
            doClose( hwnd );
            PostMessage( hwnd, WM_COMMAND, IDOK, 0 );
            return( TRUE );
        default:
            return( FALSE );
        }
        break;
    default:
        return( FALSE );
    }
    return( TRUE );
}