Exemple #1
0
void NotifyParent(LPEDIT lp, UINT msg)
{
	register HWND hwndParent ;
	if ((hwndParent = GetParent(lp->hWnd)))
		SendMessage(hwndParent, WM_COMMAND,
			GET_WM_COMMAND_MPS(lp->lpid,lp->hWnd,msg)) ;
}
Exemple #2
0
/*
 * GotoLineDlgProc - callback routine for goto line dialog
 */
WINEXPORT BOOL CALLBACK GotoLineDlgProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
    lparam = lparam;
    switch( msg ) {
    case WM_INITDIALOG:
        CenterWindowInRoot( hwnd );
        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 IDCANCEL:
            EndDialog( hwnd, FALSE );
            break;
        case IDOK:
            GetDlgItemText( hwnd, GOTOLINE_EDIT, lineStr, lineLen );
            *lineVal = atol( lineStr );
            if( *lineVal > 0 ) {
                EndDialog( hwnd, TRUE );
            } else {
                EndDialog( hwnd, FALSE );
            }
            break;
        default:
            return( FALSE );
        }
        return( TRUE );
    }
    return( FALSE );

} /* GotoLineDlgProc */
Exemple #3
0
/*
 * Function: Process WM_SYSCOMMAND messages by setting
 *	the focus to the password or name on restore.
 */
static void
kwin_syscommand(HWND hwnd, UINT cmd, int x, int y)
{
  if (cmd == SC_RESTORE)
    kwin_set_default_focus(hwnd);

  if (cmd == SC_CLOSE) {
    SendMessage(hwnd, WM_COMMAND, GET_WM_COMMAND_MPS(IDM_EXIT, 0, 0));
    return;
  }

  FORWARD_WM_SYSCOMMAND(hwnd, cmd, x, y, DefDlgProc);
}
Exemple #4
0
/*
 * GrepDlgProc - callback routine for grep dialog
 */
WINEXPORT BOOL CALLBACK GrepDlgProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
    lparam = lparam;
    switch( msg ) {
    case WM_INITDIALOG:
        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 IDCANCEL:
            cancelPressed = true;
            break;
        default:
            return( FALSE );
        }
        return( TRUE );
    }
    return( FALSE );

} /* GrepDlgProc */
Exemple #5
0
static void doSpyAll( HWND hwnd, BOOL state ) {

    char        *rcstr;
    char        tmp[32];

    if( !state ) {
        SendMessage( hwnd, WM_COMMAND, GET_WM_COMMAND_MPS( SPY_STOP, 0, 0 ) );
    }  else {
        spyAll = state;
        EnableMenuItem( SpyMenu, SPY_STOP, MF_ENABLED );
        CheckMenuItem( SpyMenu, SPY_ALL_WINDOWS, MF_CHECKED );
        SetFilter( HandleMessageInst );
        ClearSelectedWindows();
        if( SpyState == NEITHER ) {
            ClearMessageCount();
        }
        rcstr = GetRCString( STR_ALL_WIN_TITLE );
        sprintf( tmp, rcstr, SpyName );
        SetWindowText( hwnd, tmp );
        EnableMenuItem( SpyMenu, SPY_ADD_WINDOW, MF_GRAYED );
    }
}
Exemple #6
0
int WINAPI
TranslateAccelerator(HWND hWnd, HACCEL hAcc, LPMSG lpMsg) 
{
    ACCELENTRY *lpData;
    WORD wEvent;
    int rc,code;
    int keystate;

    /* we must have an accelerator table. */
    if(hAcc == 0)
	return 0;

    /* must be one of keydown or syskey down, we do not do keyup */
    if(lpMsg->message == WM_KEYDOWN || lpMsg->message == WM_SYSKEYDOWN) {
      
       int char_code = DRVCALL_KEYBOARD(PKH_GETCHAR, lpMsg->wParam, 0, 0);

	/* these don't generate accelerators */
        if (lpMsg->wParam == VK_SHIFT)
	   return 0;
	if (lpMsg->wParam == VK_CONTROL)
	   return 0;
	if (lpMsg->wParam == 0x2a)
	   return 0;

	/* lock the handle to the accelerators */
	lpData = (ACCELENTRY *) LockResource(hAcc);

	/* if we have one, then lets try to match it up */
	if(lpData) {

		/* setup initial state of keyboard */
		if (GetKeyState(VK_CONTROL))
		    keystate = 8;
		else 
		    keystate = 0;

		/* what is initial keystate */
		if (GetKeyState(VK_SHIFT))
		    keystate |= 4;

		/* loop through the accelerators */
		while (TRUE) {

			/* what event are we looking for */
			rc   = 0;
			code = 0;
			wEvent = lpMsg->wParam;

			/* vk_key or ascii event */
			if ((lpData->fFlags & 1) == 0) {
			  /* the event we match will be ascii */
			  if (char_code != 0) /* compare with ascii code */
			    wEvent = char_code;
			  if ((keystate & 0x8))  /* control key down */
			    wEvent &= 0x1f;  /* mask off to ctrl range */
			}
			else {   /*  the following applies to VK's only */

			  /* Account for control & shift */
			  rc |= (keystate & 0xc);

			  /* test alt key */
			  if (lpMsg->lParam & 0x20000000)
			      rc |= 0x10;

			  /* Account for acc. needing shift, ctrl, alt. */
			  code |= (lpData->fFlags & 0x1c);
			}

			/* if we matched the event              */
			/* we should have done this first       */
			/* after checking for ascii vs. virtual */
			if (wEvent != lpData->wEvent)
			    rc = -1;

			/* we have a matching key combination   */
			/* and the event matches                */
			if (rc == code) { 

			    /* send the corresponding event */
			    SendMessage(hWnd,WM_COMMAND,
				GET_WM_COMMAND_MPS(lpData->wId,0,1));

			    /* unlock table and return TRUE */
			    UnlockResource(hAcc);
			    return 1;			
			}
		    
		    if (lpData->fFlags & 0x80)
			break;
		    else
			lpData++;
		}
		UnlockResource(hAcc);
	  }
    }

    return 0;
}
Exemple #7
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 */
Exemple #8
0
/*
 * Function: Process WM_COMMAND messages
 */
static void
kwin_command(HWND hwnd, int cid, HWND hwndCtl, UINT codeNotify)
{
  char                      name[ANAME_SZ];
  char                      realm[REALM_SZ];
  char                      password[MAX_KPW_LEN];
  HCURSOR                   hcursor;
  BOOL                      blogin;
  HMENU                     hmenu;
  char                      menuitem[MAX_K_NAME_SZ + 3];
  char                      copyright[128];
  int                       id;
#ifdef KRB4
  char                      instance[INST_SZ];
  int                       lifetime;
  int                       krc;
#endif
#ifdef KRB5
  long                      lifetime;
  krb5_error_code           code;
  krb5_principal            principal;
  krb5_creds                creds;
  krb5_get_init_creds_opt   opts;
  gic_data                  gd;
#endif

#ifdef KRB4
  EnableWindow(GetDlgItem(hwnd, IDD_TICKET_DELETE), krb_get_num_cred() > 0);
#endif

#ifdef KRB5
  EnableWindow(GetDlgItem(hwnd, IDD_TICKET_DELETE), k5_get_num_cred(1) > 0);
#endif

  GetDlgItemText(hwnd, IDD_LOGIN_NAME, name, sizeof(name));
  trim(name);
  blogin = strlen(name) > 0;

  if (blogin) {
    GetDlgItemText(hwnd, IDD_LOGIN_REALM, realm, sizeof(realm));
    trim(realm);
    blogin = strlen(realm) > 0;
  }

  if (blogin) {
    GetDlgItemText(hwnd, IDD_LOGIN_PASSWORD, password, sizeof(password));
    blogin = strlen(password) > 0;
  }

  EnableWindow(GetDlgItem(hwnd, IDD_LOGIN), blogin);
  id = (blogin) ? IDD_LOGIN : IDD_PASSWORD_CR2;
  SendMessage(hwnd, DM_SETDEFID, id, 0);

  if (codeNotify != BN_CLICKED && codeNotify != 0 && codeNotify != 1)
    return; /* FALSE */

  /*
   * Check to see if this item is in a list of the ``recent hosts'' sort
   * of list, under the FILE menu.
   */
  if (cid >= IDM_FIRST_LOGIN && cid < IDM_FIRST_LOGIN + FILE_MENU_MAX_LOGINS) {
    hmenu = GetMenu(hwnd);
    assert(hmenu != NULL);

    hmenu = GetSubMenu(hmenu, 0);
    assert(hmenu != NULL);

    if (!GetMenuString(hmenu, cid, menuitem, sizeof(menuitem), MF_BYCOMMAND))
      return; /* TRUE */

    if (menuitem[0])
      kwin_init_name(hwnd, &menuitem[3]);

    return; /* TRUE */
  }

  switch (cid) {
  case IDM_EXIT:
    if (isblocking)
      WSACancelBlockingCall();
    WinHelp(hwnd, KERBEROS_HLP, HELP_QUIT, 0);
    PostQuitMessage(0);

    return; /* TRUE */

  case IDD_PASSWORD_CR2:                      /* Make CR == TAB */
    id = GetDlgCtrlID(GetFocus());
    assert(id != 0);

    if (id == IDD_MAX_EDIT)
      PostMessage(hwnd, WM_NEXTDLGCTL,
		  (WPARAM)GetDlgItem(hwnd, IDD_MIN_EDIT), MAKELONG(1, 0));
    else
      PostMessage(hwnd, WM_NEXTDLGCTL, 0, 0);

    return; /* TRUE */

  case IDD_LOGIN:
    if (isblocking)
      return; /* TRUE */

    GetDlgItemText(hwnd, IDD_LOGIN_NAME, name, sizeof(name));
    trim(name);
    GetDlgItemText(hwnd, IDD_LOGIN_REALM, realm, sizeof(realm));
    trim(realm);
    GetDlgItemText(hwnd, IDD_LOGIN_PASSWORD, password, sizeof(password));
    SetDlgItemText(hwnd, IDD_LOGIN_PASSWORD, "");  /* nuke the password */
    trim(password);

#ifdef KRB4
    GetDlgItemText(hwnd, IDD_LOGIN_INSTANCE, instance, sizeof(instance));
    trim(instance);
#endif

    hcursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
    lifetime = cns_res.lifetime;
    start_blocking_hook(BLOCK_MAX_SEC);

#ifdef KRB4
    lifetime = (lifetime + 4) / 5;
    krc = krb_get_pw_in_tkt(name, instance, realm, "krbtgt", realm,
			    lifetime, password);
#endif

#ifdef KRB5
    principal = NULL;

    /*
     * convert the name + realm into a krb5 principal string and parse it into a principal
     */
    sprintf(menuitem, "%s@%s", name, realm);
    code = krb5_parse_name(k5_context, menuitem, &principal);
    if (code)
      goto errorpoint;

    /*
     * set the various ticket options.  First, initialize the structure, then set the ticket
     * to be forwardable if desired, and set the lifetime.
     */
    krb5_get_init_creds_opt_init(&opts);
    krb5_get_init_creds_opt_set_forwardable(&opts, forwardable);
    krb5_get_init_creds_opt_set_tkt_life(&opts, lifetime * 60);
    if (noaddresses) {
		krb5_get_init_creds_opt_set_address_list(&opts, NULL);
 	}

    /*
     * get the initial creds using the password and the options we set above
     */
    gd.hinstance = hinstance;
    gd.hwnd = hwnd;
    gd.id = ID_VARDLG;
    code = krb5_get_init_creds_password(k5_context, &creds, principal, password,
					gic_prompter, &gd, 0, NULL, &opts);
    if (code)
      goto errorpoint;

    /*
     * initialize the credential cache
     */
    code = krb5_cc_initialize(k5_context, k5_ccache, principal);
    if (code)
      goto errorpoint;

    /*
     * insert the principal into the cache
     */
    code = krb5_cc_store_cred(k5_context, k5_ccache, &creds);

  errorpoint:

    if (principal)
      krb5_free_principal(k5_context, principal);

    end_blocking_hook();
    SetCursor(hcursor);
    kwin_set_default_focus(hwnd);

    if (code) {
      if (code == KRB5KRB_AP_ERR_BAD_INTEGRITY)
	MessageBox(hwnd, "Password incorrect", NULL,
		   MB_OK | MB_ICONEXCLAMATION);
      else
	com_err(NULL, code, "while logging in");
    }
#endif /* KRB5 */

#ifdef KRB4
    if (krc != KSUCCESS) {
      MessageBox(hwnd, krb_get_err_text(krc),	"",
		 MB_OK | MB_ICONEXCLAMATION);

      return; /* TRUE */
    }
#endif

    kwin_save_name(hwnd);
    alerted = FALSE;

    switch (action) {
    case LOGIN_AND_EXIT:
      SendMessage(hwnd, WM_COMMAND, GET_WM_COMMAND_MPS(IDM_EXIT, 0, 0));
      break;

    case LOGIN_AND_MINIMIZE:
      ShowWindow(hwnd, SW_MINIMIZE);
      break;
    }

    return; /* TRUE */

  case IDD_TICKET_DELETE:
    if (isblocking)
      return; /* TRUE */

#ifdef KRB4
    krc = dest_tkt();
    if (krc != KSUCCESS)
      MessageBox(hwnd, krb_get_err_text(krc),	"",
		 MB_OK | MB_ICONEXCLAMATION);
#endif

#ifdef KRB5
    code = k5_dest_tkt();
#endif

    kwin_set_default_focus(hwnd);
    alerted = FALSE;

    return; /* TRUE */

  case IDD_CHANGE_PASSWORD:
    if (isblocking)
      return; /* TRUE */
    password_dialog(hwnd);
    kwin_set_default_focus(hwnd);

    return; /* TRUE */

  case IDM_OPTIONS:
    if (isblocking)
      return; /* TRUE */
    opts_dialog(hwnd);

    return; /* TRUE */

  case IDM_HELP_INDEX:
    WinHelp(hwnd, KERBEROS_HLP, HELP_INDEX, 0);

    return; /* TRUE */

  case IDM_ABOUT:
    ticket_init_list(GetDlgItem(hwnd, IDD_TICKET_LIST));
    if (isblocking)
      return; /* TRUE */

#ifdef KRB4
    strcpy(copyright, "        Kerberos 4 for Windows ");
#endif
#ifdef KRB5
    strcpy(copyright, "        Kerberos V5 for Windows ");
#endif
#ifdef _WIN32
    strncat(copyright, "32-bit\n", sizeof(copyright) - 1 - strlen(copyright));
#else
    strncat(copyright, "16-bit\n", sizeof(copyright) - 1 - strlen(copyright));
#endif
    strncat(copyright, "\n                Version 1.12\n\n",
            sizeof(copyright) - 1 - strlen(copyright));
#ifdef ORGANIZATION
    strncat(copyright, "          For information, contact:\n",
	    sizeof(copyright) - 1 - strlen(copyright));
    strncat(copyright, ORGANIZATION, sizeof(copyright) - 1 - strlen(copyright));
#endif
    MessageBox(hwnd, copyright, KWIN_DIALOG_NAME, MB_OK);

    return; /* TRUE */
  }

  return; /* FALSE */
}
Exemple #9
0
LRESULT WINAPI
DefDlgProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)
{
    DLGPROC	f;
    LRESULT	rc;
    HBRUSH	hBrush;
    HFONT   hFont;
    RECT rcClient;
    HWND hWndChild, hWndFocus;
    DWORD dwStyle;
    WORD wTmp;
    HCLASS32 hDialog32;

    APISTR((LF_APICALL,"DefDlgProc(HWND=%x,UINT=%x,WPARAM=%x,LPARAM=%lx)\n",
            hDlg,iMessage,wParam,lParam));

    if (!IsWindow(hDlg)) {
        APISTR((LF_APIFAIL,"DefDlgProc: returns LRESULT 0\n"));
        return 0L;
    }

    if (iMessage == WM_CONVERT) {
        if (!lpDialogBinToNat) {
            hDialog32 = FindClass(TWIN_DIALOGCLASS,(HINSTANCE)0);
            lpDialogBinToNat = (WNDPROC)GetClassHandleLong(
                                   hDialog32,GCL_BINTONAT);
        }
        if (lpDialogBinToNat) {
            rc = lpDialogBinToNat(hDlg,iMessage,wParam,lParam);
            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc));
            return rc;
        } else {
            APISTR((LF_APIFAIL,"DefDlgProc: returns LRESULT 0\n"));
            return (LRESULT)0;
        }
    }

    if ( (f = (DLGPROC) GetWindowLong(hDlg,DWL_DLGPROC)) ) {
        rc = CallWindowProc(
#ifdef	STRICT
                 (WNDPROC)f,
#else
                 (FARPROC)f,
#endif
                 hDlg,iMessage,wParam,lParam);
    }
    else  rc = 0L;

    if (!IsWindow(hDlg)) {	/* dialog has been destroyed in the callback */
        APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc));
        return rc;
    }

    if(LOWORD(rc) == 0) {
        switch(iMessage) {
        case WM_ERASEBKGND:
            GetClientRect(hDlg, &rcClient);
            hBrush = (HBRUSH)SendMessage(hDlg,
                                         GET_WM_CTLCOLOR_MSG(CTLCOLOR_DLG),
                                         GET_WM_CTLCOLOR_MPS(
                                             (HDC)wParam,hDlg,CTLCOLOR_DLG));
            FillRect((HDC)wParam,&rcClient,hBrush);
            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT 1\n"));
            return (LRESULT)1;

        case WM_SHOWWINDOW:
            /* if we are hiding, save the focus */
            if (!wParam)
                SaveDlgFocus(hDlg);
            rc =  DefWindowProc(hDlg,iMessage,wParam,lParam);
            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc));
            return rc;

        case WM_SYSCOMMAND:
            if ((wParam & 0xfff0) == SC_MINIMIZE)
                SaveDlgFocus(hDlg);

            rc = DefWindowProc(hDlg,iMessage,wParam,lParam);
            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc));
            return rc;

        case WM_ACTIVATE:
            if GET_WM_ACTIVATE_STATE(wParam,lParam)
                RestoreDlgFocus(hDlg);
            else
                SaveDlgFocus(hDlg);
            break;

        case WM_SETFOCUS:
            if (!RestoreDlgFocus(hDlg))
                DlgSetFocus(GetFirstDlgTabItem(hDlg));
            break;

        case WM_CLOSE:
            hWndChild = GetDlgItem(hDlg, IDCANCEL);
            if (hWndChild) {
                dwStyle = GetWindowLong(hDlg,GWL_STYLE);
                if (dwStyle & WS_DISABLED) {
                    MessageBeep(0);
                } else
                    PostMessage(hDlg,WM_COMMAND,
                                GET_WM_COMMAND_MPS(IDCANCEL,
                                                   hWndChild,BN_CLICKED));
            }
            break;

        case WM_NCDESTROY:
            SetWindowWord(hDlg,DWW_STATUS,1);
            if ((hFont = (HFONT)GetWindowWord(hDlg, DWW_HFONT))) {
                DeleteObject(hFont);
                SetWindowWord(hDlg,DWW_HFONT,0);
            }
            DefWindowProc(hDlg,iMessage,wParam,lParam);
            break;

        case DM_SETDEFID:
            SetWindowWord(hDlg,DWW_DEFID,wParam);
            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT 1\n"));
            return (LRESULT)1;

        case DM_GETDEFID:
            wTmp = GetWindowWord(hDlg,DWW_DEFID);
            if (wTmp) {
                rc = MAKELRESULT(wTmp, DC_HASDEFID);
                APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc));
                return rc;
            } else {
                APISTR((LF_APIRET,"DefDlgProc: returns LRESULT 0\n"));
                return (LRESULT)0;
            }

        case WM_NEXTDLGCTL:
            hWndFocus = GetFocus();
            if (LOWORD(lParam)) {
                if (!hWndFocus)
                    hWndFocus = hDlg;
                hWndChild = (HWND)wParam;
            }
            else {
                if (!hWndFocus) {
                    /* set to the first tab item */
                    hWndChild = GetFirstDlgTabItem(hDlg);
                    hWndFocus = hDlg;
                }
                else {
                    if (!IsChild(hDlg,hWndFocus))
                        return (LRESULT)1;
                    hWndChild = GetNextDlgTabItem(hDlg,
                                                  hWndFocus,(BOOL)wParam);
                }
            }

            DlgSetFocus(hWndChild);
            CheckDefPushButton(hDlg,hWndFocus,hWndChild);

            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT 1\n"));
            return (LRESULT)1;

        case WM_GETFONT:
            rc = (LRESULT)GetWindowWord(hDlg,DWW_HFONT);
            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc));
            return rc;

        case WM_SETFONT:
            SetWindowWord(hDlg,DWW_HFONT,(HFONT)wParam);
            if (LOWORD(lParam))
                InvalidateRect(hDlg,NULL,TRUE);
            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",0));
            return 0L;

        case WM_VKEYTOITEM:
        case WM_COMPAREITEM:
        case WM_CHARTOITEM:
        case WM_INITDIALOG:
            break;

        case WM_MOUSEACTIVATE:

            rc = (LRESULT)MA_ACTIVATE;
            if ((int)(short)LOWORD(lParam) == HTCAPTION)
                rc = (LRESULT)MA_NOACTIVATE;
            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc));
            return rc;

#ifdef	TWIN32
        case WM_CTLCOLORMSGBOX:
        case WM_CTLCOLORBTN:
        case WM_CTLCOLORDLG:
        case WM_CTLCOLORSTATIC:
            rc =  GetStockObject(LTGRAY_BRUSH);
            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc));
            return rc;
#endif
        default:
            rc = DefWindowProc(hDlg,iMessage,wParam,lParam);
            APISTR((LF_APIRET,"DefDlgProc: returns LRESULT %x\n",rc));
            return rc;
        }
    }
Exemple #10
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 */
Exemple #11
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 */
Exemple #12
0
LRESULT CALLBACK main_proc(
    HWND                hwnd,
    UINT                msg,
    WPARAM              wparam,
    LPARAM              lparam
) {
    WORD                cmd;

    switch( msg ) {

    case WM_CREATE: {
        GetClientRect( hwnd, &Draw_area );
        make_buttons( hwnd );
        break;
    }

    case WM_COMMAND:
        cmd = LOWORD( wparam );
        switch( LOWORD( cmd ) ) {

        case IDM_EXIT:
            PostQuitMessage( 0 );
            return( FALSE );

        case IDM_ROTATE_LEFT:
            add_wrap( THREE_D_HORZ_ANGLE, -15, 0, 360 );
            break;
        case IDM_ROTATE_RIGHT:
            add_wrap( THREE_D_HORZ_ANGLE, 15, 0, 360 );
            break;
        case IDM_ROTATE_UP:
            add_range( THREE_D_VERT_ANGLE, 5, -90, 90 );
            break;
        case IDM_ROTATE_DOWN:
            add_range( THREE_D_VERT_ANGLE, -5, -90, 90 );
            break;
        case IDM_MOVE_IN:
            add_range(THREE_D_ZOOM, 10, 5, 200 );
            break;
        case IDM_MOVE_OUT:
            add_range( THREE_D_ZOOM, -10, 5, 200 );
            break;
        case IDM_MORE_PERSPECTIVE:
            add_range( THREE_D_PERSPECTIVE, 10, 5, 200 );
            break;
        case IDM_LESS_PERSPECTIVE:
            add_range( THREE_D_PERSPECTIVE, -10, 5, 200 );
            break;
        case IDM_MORE_CONTRAST:
            add_range( THREE_D_CONTRAST, 10, 0, 100 );
            break;
        case IDM_LESS_CONTRAST:
            add_range( THREE_D_CONTRAST, -10, 0, 100 );
            break;
        case IDM_MORE_BRIGHTNESS:
            add_range( THREE_D_BRIGHTNESS, 10, 0, 100 );
            break;
        case IDM_LESS_BRIGHTNESS:
            add_range( THREE_D_BRIGHTNESS, -10, 0, 100 );
            break;
        case IDM_LIGHT_HORZ_LEFT:
            three_d_set( hThree_d, THREE_D_LIGHT_HORZ, 1 );
            break;
        case IDM_LIGHT_HORZ_MIDDLE:
            three_d_set( hThree_d, THREE_D_LIGHT_HORZ, 2 );
            break;
        case IDM_LIGHT_HORZ_RIGHT:
            three_d_set( hThree_d, THREE_D_LIGHT_HORZ, 3 );
            break;
        case IDM_LIGHT_VERT_TOP:
            three_d_set( hThree_d, THREE_D_LIGHT_VERT, 1 );
            break;
        case IDM_LIGHT_VERT_MIDDLE:
            three_d_set( hThree_d, THREE_D_LIGHT_VERT, 2 );
            break;
        case IDM_LIGHT_VERT_BOTTOM:
            three_d_set( hThree_d, THREE_D_LIGHT_VERT, 3 );
            break;
        case IDM_LIGHT_DEPTH_FRONT:
            three_d_set( hThree_d, THREE_D_LIGHT_DEPTH, 1 );
            break;
        case IDM_LIGHT_DEPTH_MIDDLE:
            three_d_set( hThree_d, THREE_D_LIGHT_DEPTH, 2 );
            break;
        case IDM_LIGHT_DEPTH_BACK:
            three_d_set( hThree_d, THREE_D_LIGHT_DEPTH, 3 );
            break;
        default:
            ;
        }
        InvalidateRect( hwnd, &Draw_area, cmd >= IDM_FIRST_REQUIRING_CLEAR );
        break;

    case WM_DESTROY:
        PostQuitMessage( 0 );
        return( FALSE );

    case WM_PAINT:
        draw_stuff( hwnd );
        if( Auto_run ) {
            if( Auto_run == 5 ) {
                PostQuitMessage( 0 );
            } else {
                long count;
                int will_be_one;
                will_be_one = 1;
                for(count = 0; count < 1000000; ++ count ) will_be_one ^= 1;

                Auto_run += will_be_one;
                PostMessage( hwnd, WM_COMMAND,
                                GET_WM_COMMAND_MPS( IDM_ROTATE_LEFT, 0, 0 ) );
            }
        }
        return( FALSE );

    case WM_SIZE:
        if( wparam != SIZEICONIC ) {
            int old_left = Draw_area.left;

            GetClientRect( hwnd, &Draw_area );
            Draw_area.left = old_left;
            InvalidateRect( hwnd, NULL, TRUE );
            return( FALSE );
        }
        break;

    case WM_MEASUREITEM:
        measure_button( hwnd, wparam, _lparam_pointer( lparam ) );
        return( TRUE );

    case WM_DRAWITEM:
        draw_button( wparam, _lparam_pointer( lparam ) );
        return( TRUE );

    }

    return( DefWindowProc( hwnd, msg, wparam, lparam ) );
}