示例#1
0
void khm_update_standard_toolbar(void)
{
    khui_menu_def * def;
    khui_action_ref * aref;
    khui_action * act;

    def = khui_find_menu(KHUI_TOOLBAR_STANDARD);

    aref = def->items;

    while(aref && aref->action != KHUI_MENU_END) {
        if(aref->action == KHUI_MENU_SEP) {
            aref++;
            continue;
        }

        act = khui_find_action(aref->action);
        if(act) {
            BOOL enable;

            enable = !(act->state & KHUI_ACTIONSTATE_DISABLED);
            SendMessage(khui_hwnd_standard_toolbar, 
                        TB_ENABLEBUTTON, 
                        (WPARAM) act->cmd,
                        MAKELPARAM(enable, 0));
        }

        aref++;
    }
}
示例#2
0
LRESULT khm_toolbar_notify(LPNMHDR notice) {
    switch(notice->code) {
    case TBN_GETINFOTIP:
        {
            LPNMTBGETINFOTIP git = (LPNMTBGETINFOTIP) notice;
            int cmd;
            khui_action * a;

            cmd = git->iItem;
            a = khui_find_action(cmd);

            if (a) {
                if (a->caption) {
                    StringCchCopy(git->pszText, git->cchTextMax, a->caption);
                } else if (a->tooltip) {
                    StringCchCopy(git->pszText, git->cchTextMax, a->tooltip);
                } else if (a->is_caption) {
                    wchar_t buf[INFOTIPSIZE];

                    buf[0] = L'\0';
                    LoadString(khm_hInstance, a->is_caption,
                               buf, ARRAYLENGTH(buf));

                    StringCchCopy(git->pszText, git->cchTextMax, buf);
                } else {
                    StringCchCopy(git->pszText, git->cchTextMax, L"");
                }
            } else {
                StringCchCopy(git->pszText,
                              git->cchTextMax,
                              L"");
            }
        }
        break;

    case TBN_HOTITEMCHANGE:
        {
            LPNMTBHOTITEM hi = (LPNMTBHOTITEM) notice;

            if (hi->dwFlags & HICF_LEAVING) {
                khm_statusbar_set_part(KHUI_SBPART_INFO, NULL, L"");
            } else {
                khui_action * a;
                int cmd;
                wchar_t buf[256];

                cmd = hi->idNew;
                a = khui_find_action(cmd);

                buf[0] = L'\0';

                if (a) {
                    if (a->tooltip)
                        StringCbCopy(buf, sizeof(buf), a->tooltip);
                    else if (a->is_tooltip) {
                        LoadString(khm_hInstance, a->is_tooltip,
                                   buf, ARRAYLENGTH(buf));
                    }
                }

                khm_statusbar_set_part(KHUI_SBPART_INFO, NULL, buf);
            }
        }
        break;

    case TBN_DROPDOWN:
        {
            LPNMTOOLBAR nmtb = (LPNMTOOLBAR) notice;
            RECT r;

            GetWindowRect(khui_hwnd_standard_toolbar, &r);
            if (nmtb->iItem == KHUI_ACTION_DESTROY_CRED) {
                khm_menu_show_panel(KHUI_MENU_DESTROY_CRED,
                                    r.left + nmtb->rcButton.left,
                                    r.top + nmtb->rcButton.bottom);
            } else if (nmtb->iItem == KHUI_ACTION_RENEW_CRED) {
                khm_menu_show_panel(KHUI_MENU_RENEW_CRED,
                                    r.left + nmtb->rcButton.left,
                                    r.top + nmtb->rcButton.bottom);
            } else {
                return TBDDRET_NODEFAULT;
            }

            return TBDDRET_DEFAULT;
        }
        break;

    case NM_CUSTOMDRAW:
        {
            LPNMTBCUSTOMDRAW nmcd = (LPNMTBCUSTOMDRAW) notice;
            if(nmcd->nmcd.dwDrawStage == CDDS_PREPAINT) {
                return CDRF_NOTIFYITEMDRAW | CDRF_NOTIFYPOSTERASE;
            } else if(nmcd->nmcd.dwDrawStage == CDDS_ITEMPREPAINT) {
                return CDRF_NOTIFYPOSTPAINT;
            } else if(nmcd->nmcd.dwDrawStage == CDDS_ITEMPOSTPAINT) {
                /* draw the actual icon */
                int iidx;
                int ibmp;
                HBITMAP hbmp;
                RECT r;

                khui_action * act = 
                    khui_find_action((int) nmcd->nmcd.dwItemSpec);

                if(!act || !act->ib_normal)
                    return CDRF_DODEFAULT;

                if((act->state & KHUI_ACTIONSTATE_DISABLED) && 
                   act->ib_disabled) {
                    ibmp = act->ib_disabled;
                } else if(act->ib_hot && 
                          ((nmcd->nmcd.uItemState & CDIS_HOT) || 
                           (nmcd->nmcd.uItemState & CDIS_SELECTED))){
                    ibmp = act->ib_hot;
                } else {
                    ibmp = act->ib_normal;
                }

                iidx = khui_ilist_lookup_id(ilist_toolbar, ibmp);
                if(iidx < 0) {
                    hbmp = LoadImage(khm_hInstance, 
                                     MAKEINTRESOURCE(ibmp), 
                                     IMAGE_BITMAP, 
                                     KHUI_TOOLBAR_IMAGE_WIDTH, 
                                     KHUI_TOOLBAR_IMAGE_HEIGHT, 0);
                    iidx = 
                        khui_ilist_add_masked_id(ilist_toolbar, 
                                                 hbmp, 
                                                 KHUI_TOOLBAR_BGCOLOR, 
                                                 ibmp);
                    DeleteObject(hbmp);
                }

                if(iidx < 0)
                    return CDRF_DODEFAULT;

                CopyRect(&r, &(nmcd->nmcd.rc));
                r.left += ((r.bottom - r.top) -
                          KHUI_TOOLBAR_IMAGE_HEIGHT) / 2;
                r.top += ((r.bottom - r.top) -
                          KHUI_TOOLBAR_IMAGE_HEIGHT) / 2;
#if 0
                r.left += ((r.right - r.left) - 
                           KHUI_TOOLBAR_IMAGE_WIDTH) / 2;
#endif
                khui_ilist_draw(ilist_toolbar, 
                                iidx, 
                                nmcd->nmcd.hdc, 
                                r.left,
                                r.top, 
                                0);

                return CDRF_DODEFAULT;
            }
        }
        break;
    }
    return 0;
}
示例#3
0
void khm_create_standard_toolbar(HWND rebar) {
    HWND hwtb;
    SIZE sz;
    HBITMAP hbm_blank;
    HIMAGELIST hiList;
    REBARBANDINFO rbi;
    khui_menu_def * def;
    khui_action * act;
    khui_action_ref * aref;
    int idx_blank;

    def = khui_find_menu(KHUI_TOOLBAR_STANDARD);

    if (!def) {
#ifdef DEBUG
        assert(FALSE);
#endif
        return;
    }

    hwtb = CreateWindowEx(0 ,
                          TOOLBARCLASSNAME,
                          (LPWSTR) NULL,
                          WS_CHILD |
                          TBSTYLE_FLAT |
                          TBSTYLE_AUTOSIZE | 
                          TBSTYLE_TOOLTIPS |
                          CCS_NORESIZE | 
                          CCS_NOPARENTALIGN |
                          CCS_ADJUSTABLE |
                          CCS_NODIVIDER,
                          0, 0, 0, 0, rebar,
                          (HMENU) NULL, khm_hInstance,
                          NULL);

    if(!hwtb) {
#ifdef DEBUG
        assert(FALSE);
#endif
        return;
    }

#if (_WIN32_IE >= 0x0501)
    SendMessage(hwtb, TB_SETEXTENDEDSTYLE, 0,
                TBSTYLE_EX_MIXEDBUTTONS | TBSTYLE_EX_DRAWDDARROWS);
#endif

    hiList = ImageList_Create(
        KHUI_TOOLBAR_IMAGE_WIDTH,
        KHUI_TOOLBAR_IMAGE_HEIGHT,
        ILC_MASK,
        (int) khui_action_list_length(def->items),
        3);

    hbm_blank = LoadImage(khm_hInstance, 
                          MAKEINTRESOURCE(IDB_TB_BLANK), 
                          IMAGE_BITMAP, 
                          KHUI_TOOLBAR_IMAGE_WIDTH, 
                          KHUI_TOOLBAR_IMAGE_HEIGHT, 0);
    idx_blank = ImageList_AddMasked(hiList, hbm_blank, RGB(0,0,0));

    khui_hwnd_standard_toolbar = hwtb;
    khui_tb_blank = idx_blank;

    def = khui_find_menu(KHUI_TOOLBAR_STANDARD);

    aref = def->items;

    SendMessage(hwtb,
        TB_BUTTONSTRUCTSIZE,
        sizeof(TBBUTTON),
        0);

    SendMessage(hwtb,
        TB_SETBITMAPSIZE,
        0,
        MAKELONG(KHUI_TOOLBAR_IMAGE_WIDTH,KHUI_TOOLBAR_IMAGE_HEIGHT));

    SendMessage(hwtb,
        TB_SETIMAGELIST,
        0,
        (LPARAM) hiList);

    SendMessage(hwtb,
        TB_SETBUTTONSIZE,
        0,
        MAKELONG(KHUI_TOOLBAR_IMAGE_WIDTH,KHUI_TOOLBAR_IMAGE_HEIGHT));

    while(aref && aref->action != KHUI_MENU_END) {
        if(aref->action == KHUI_MENU_SEP) {
            khui_add_action_to_toolbar(hwtb, 
                                       NULL, 
                                       KHUI_TOOLBAR_ADD_SEP, 
                                       hiList);
        } else {
            act = khui_find_action(aref->action);
            khui_add_action_to_toolbar(hwtb, 
                                       act, 
                                       KHUI_TOOLBAR_ADD_BITMAP |
                                       ((aref->flags & KHUI_ACTIONREF_SUBMENU)?
                                        KHUI_TOOLBAR_ADD_DROPDOWN: 0),
                                       hiList);
        }
        aref ++;
    }

    SendMessage(hwtb,
                TB_AUTOSIZE,
                0,0);

    SendMessage(hwtb,
                TB_GETMAXSIZE,
                0,
                (LPARAM) &sz);

    sz.cy += 5;

    ZeroMemory(&rbi, sizeof(rbi));

    rbi.cbSize = sizeof(rbi);
    rbi.fMask = 
        RBBIM_ID |
        RBBIM_CHILD | 
        RBBIM_CHILDSIZE | 
        RBBIM_IDEALSIZE | 
        RBBIM_SIZE | 
        RBBIM_STYLE;
    rbi.fStyle =  
        RBBS_USECHEVRON |
        RBBS_BREAK;
    rbi.hwndChild = hwtb;

    rbi.wID = KHUI_TOOLBAR_STANDARD;
    rbi.cx = sz.cx;
    rbi.cxMinChild = sz.cx;
    rbi.cyMinChild = sz.cy;
    rbi.cyChild = rbi.cyMinChild;
    rbi.cyMaxChild = rbi.cyMinChild;
    rbi.cyIntegral = rbi.cyMinChild;

    rbi.cxIdeal = rbi.cx;

    SendMessage(rebar,
        RB_INSERTBAND,
        0,
        (LPARAM) &rbi);
}
示例#4
0
文件: mainwnd.c 项目: Brainiarc7/pbis
LRESULT CALLBACK
khm_main_wnd_proc(HWND hwnd,
                  UINT uMsg,
                  WPARAM wParam,
                  LPARAM lParam)
{
    LPNMHDR lpnm;

    switch(uMsg) {
    case WM_CREATE:
        khm_create_main_window_controls(hwnd);
        kmq_subscribe_hwnd(KMSG_CRED, hwnd);
        kmq_subscribe_hwnd(KMSG_ACT, hwnd);
        kmq_subscribe_hwnd(KMSG_KMM, hwnd);
        mw_restart_refresh_timer(hwnd);

        /* if the plug-ins finished loading before the window was
           created, we would have missed the KMSG_KMM_I_DONE message.
           So we check if the module load is complete and if so, fire
           off KMSG_ACT_BEGIN_CMDLINE. */
        if (!kmm_load_pending())
            kmq_post_message(KMSG_ACT, KMSG_ACT_BEGIN_CMDLINE, 0, 0);
        break;

    case WM_DESTROY:
        khm_pre_shutdown();
        kmq_unsubscribe_hwnd(KMSG_ACT, hwnd);
        kmq_unsubscribe_hwnd(KMSG_CRED, hwnd);
        kmq_unsubscribe_hwnd(KMSG_KMM, hwnd);
        HtmlHelp(NULL, NULL, HH_CLOSE_ALL, 0);
        PostQuitMessage(0);
        break;

    case WM_NOTIFY:
        lpnm = (LPNMHDR) lParam;
        if(lpnm->hwndFrom == khui_main_menu_toolbar) {
            return khm_menu_notify_main(lpnm);
        } else if(lpnm->hwndFrom == khui_hwnd_standard_toolbar) {
            return khm_toolbar_notify(lpnm);
        } else if(lpnm->hwndFrom == khm_hwnd_rebar) {
            return khm_rebar_notify(lpnm);
        } else if(lpnm->hwndFrom == khm_hwnd_statusbar) {
            return khm_statusbar_notify(lpnm);
        }
        break;

    case WM_HELP:
        khm_html_help(khm_hwnd_main, NULL, HH_HELP_CONTEXT, IDH_WELCOME);
        break;

    case WM_COMMAND:
        switch(LOWORD(wParam)) {
            /* general actions */
        case KHUI_ACTION_VIEW_REFRESH:
            khm_cred_refresh();
            InvalidateRect(khm_hwnd_main_cred, NULL, FALSE);
            return 0;

        case KHUI_ACTION_PASSWD_ID:
            if (khm_startup.processing)
                return 0;

            khm_cred_change_password(NULL);
            return 0;

        case KHUI_ACTION_NEW_CRED:
            if (khm_startup.processing)
                return 0;

            khm_cred_obtain_new_creds(NULL);
            return 0;

        case KHUI_ACTION_RENEW_CRED:
            if (khm_startup.processing)
                return 0;

            khm_cred_renew_creds();
            return 0;

        case KHUI_ACTION_DESTROY_CRED:
            if (khm_startup.processing)
                return 0;

            khm_cred_destroy_creds(FALSE, FALSE);
            return 0;

        case KHUI_ACTION_SET_DEF_ID:
            if (khm_startup.processing)
                return 0;

            khm_cred_set_default();
            return 0;

        case KHUI_ACTION_EXIT:
            DestroyWindow(hwnd);
            return 0;

        case KHUI_ACTION_OPEN_APP:
            khm_show_main_window();
            return 0;

        case KHUI_ACTION_CLOSE_APP:
            khm_hide_main_window();
            return 0;

        case KHUI_ACTION_OPT_KHIM: {
            khui_config_node node = NULL;

            khui_cfg_open(NULL, L"KhmGeneral", &node);
            khm_show_config_pane(node);
        }
            return 0;

        case KHUI_ACTION_OPT_IDENTS: {
            khui_config_node node = NULL;

            khui_cfg_open(NULL, L"KhmIdentities", &node);
            khm_show_config_pane(node);
        }
            return 0;

        case KHUI_ACTION_OPT_APPEAR: {
            khui_config_node node = NULL;

            khui_cfg_open(NULL, L"KhmAppear", &node);
            khm_show_config_pane(node);
        }
            return 0;

        case KHUI_ACTION_OPT_NOTIF: {
            khui_config_node node = NULL;

            khui_cfg_open(NULL, L"KhmNotifications", &node);
            khm_show_config_pane(node);
        }
            return 0;

        case KHUI_ACTION_OPT_PLUGINS: {
            khui_config_node node = NULL;

            khui_cfg_open(NULL, L"KhmPlugins", &node);
            khm_show_config_pane(node);
        }
            return 0;

        case KHUI_ACTION_HELP_CTX:
            khm_html_help(khm_hwnd_main, NULL, HH_HELP_CONTEXT, IDH_WELCOME);
            return 0;

        case KHUI_ACTION_HELP_CONTENTS:
            khm_html_help(khm_hwnd_main, NULL, HH_DISPLAY_TOC, 0);
            return 0;

        case KHUI_ACTION_HELP_INDEX:
            khm_html_help(khm_hwnd_main, NULL, HH_DISPLAY_INDEX, (DWORD_PTR) L"");
            return 0;

        case KHUI_ACTION_HELP_ABOUT:
            khm_create_about_window();
            return 0;

        case KHUI_ACTION_IMPORT:
            khm_cred_import();
            return 0;

        case KHUI_ACTION_PROPERTIES:
            /* properties are not handled by the main window.
               Just bounce it to credwnd.  However, use SendMessage
               instead of PostMessage so we don't lose context */
            return SendMessage(khm_hwnd_main_cred, uMsg,
                               wParam, lParam);

        case KHUI_ACTION_UICB:
            khm_ui_cb(lParam);
            return 0;

            /* layout control */

        case KHUI_ACTION_VIEW_ALL_IDS:
            return SendMessage(khm_hwnd_main_cred, uMsg,
                               wParam, lParam);

        case KHUI_ACTION_LAYOUT_MINI:

            if (khm_main_wnd_mode == KHM_MAIN_WND_MINI) {
                khm_set_main_window_mode(KHM_MAIN_WND_NORMAL);
            } else {
                khm_set_main_window_mode(KHM_MAIN_WND_MINI);
            }
            return SendMessage(khm_hwnd_main_cred, uMsg,
                               wParam, lParam);

        case KHUI_ACTION_LAYOUT_RELOAD:
            return SendMessage(khm_hwnd_main_cred, uMsg,
                               wParam, lParam);

        case KHUI_ACTION_LAYOUT_ID:
        case KHUI_ACTION_LAYOUT_TYPE:
        case KHUI_ACTION_LAYOUT_LOC:
        case KHUI_ACTION_LAYOUT_CUST:
            khm_set_main_window_mode(KHM_MAIN_WND_NORMAL);
            return SendMessage(khm_hwnd_main_cred, uMsg,
                               wParam, lParam);

            /* menu commands */
        case KHUI_PACTION_MENU:
            if(HIWORD(lParam) == 1)
                mm_last_hot_item = LOWORD(lParam);
            return khm_menu_activate(MENU_ACTIVATE_DEFAULT);

        case KHUI_PACTION_ESC:
            /* if esc is pressed while no menu is active, we close the
               main window */
            if (mm_last_hot_item == -1) {
                khm_close_main_window();
                return 0;
            }

            /* generic, retargetting */
        case KHUI_PACTION_UP:
        case KHUI_PACTION_UP_TOGGLE:
        case KHUI_PACTION_UP_EXTEND:
        case KHUI_PACTION_PGUP:
        case KHUI_PACTION_PGUP_EXTEND:
        case KHUI_PACTION_DOWN:
        case KHUI_PACTION_DOWN_TOGGLE:
        case KHUI_PACTION_DOWN_EXTEND:
        case KHUI_PACTION_PGDN:
        case KHUI_PACTION_PGDN_EXTEND:
        case KHUI_PACTION_LEFT:
        case KHUI_PACTION_RIGHT:
        case KHUI_PACTION_ENTER:
            /* menu tracking */
            if(mm_last_hot_item != -1) {
                switch(LOWORD(wParam)) {
                case KHUI_PACTION_LEFT:
                    khm_menu_activate(MENU_ACTIVATE_LEFT);
                    break;

                case KHUI_PACTION_RIGHT:
                    khm_menu_activate(MENU_ACTIVATE_RIGHT);
                    break;

                case KHUI_PACTION_ESC:
                case KHUI_PACTION_ENTER:
                    khm_menu_activate(MENU_ACTIVATE_NONE);
                    break;

                case KHUI_PACTION_DOWN:
                    khm_menu_track_current();
                    break;
                }
                return 0;
            }

            /*FALLTHROUGH*/
        case KHUI_PACTION_DELETE:

        case KHUI_PACTION_SELALL:
            /* otherwise fallthrough and bounce to the creds window */
            return SendMessage(khm_hwnd_main_cred, uMsg,
                               wParam, lParam);

        default:
            /* handle custom actions here */
            {
                khui_action * act;

                /* check if this is an identity menu action.  (custom
                   actions that were created for renewing or
                   destroying specific identities). */
                if (khm_check_identity_menu_action(LOWORD(wParam)))
                    break;

                act = khui_find_action(LOWORD(wParam));
                if (act && act->listener) {
                    kmq_post_sub_msg(act->listener, KMSG_ACT, KMSG_ACT_ACTIVATE, act->cmd, NULL);
                    return 0;
                }
            }
        }
        break;              /* WM_COMMAND */

    case WM_SYSCOMMAND:
        switch(wParam & 0xfff0) {
        case SC_MINIMIZE:
            khm_hide_main_window();
            return 0;

        case SC_CLOSE:
            khm_close_main_window();
            return 0;
        }
        break;

    case WM_MEASUREITEM:
        /* sent to measure the bitmaps associated with a menu item */
        if(!wParam) /* sent by menu */
            return khm_menu_measure_item(wParam, lParam);
        break;

    case WM_DRAWITEM:
        /* sent to draw a menu item */
        if(!wParam)
            return khm_menu_draw_item(wParam, lParam);
        break;

    case WM_ERASEBKGND:
        /* Don't erase the background.  The whole client area is
           covered with children.  It doesn't need to be erased */
        return TRUE;
        break;

    case WM_SIZE:
        if(hwnd == khm_hwnd_main &&
           (wParam == SIZE_MAXIMIZED || wParam == SIZE_RESTORED)) {
            int cwidth, cheight;
            RECT r_rebar, r_status;

            cwidth = LOWORD(lParam);
            cheight = HIWORD(lParam);

            /* resize the rebar control */
            SendMessage(khm_hwnd_rebar, WM_SIZE, 0, 0);

            khm_update_statusbar(hwnd);

            GetWindowRect(khm_hwnd_rebar, &r_rebar);
            GetWindowRect(khm_hwnd_statusbar, &r_status);

            /* the cred window fills the area between the rebar
               and the status bar */
            MoveWindow(khm_hwnd_main_cred, 0,
                       r_rebar.bottom - r_rebar.top,
                       r_status.right - r_status.left,
                       r_status.top - r_rebar.bottom, TRUE);

            SetTimer(hwnd,
                     MW_RESIZE_TIMER,
                     MW_RESIZE_TIMEOUT,
                     NULL);
            return 0;
        }
        break;

    case WM_MOVE:
        {
            SetTimer(hwnd,
                     MW_RESIZE_TIMER,
                     MW_RESIZE_TIMEOUT,
                     NULL);

            return 0;
        }
        break;

    case WM_MOVING:
        {
            RECT * r;

            r = (RECT *) lParam;
            khm_adjust_window_dimensions_for_display(r,
                                                     KHM_DOCK_AUTO | KHM_DOCKF_XBORDER);
        }
        return TRUE;

    case WM_TIMER:
        if (wParam == MW_RESIZE_TIMER) {
            main_wnd_save_sizepos();

            return 0;

        } else if (wParam == MW_REFRESH_TIMER) {
            kmq_post_message(KMSG_CRED, KMSG_CRED_REFRESH, 0, 0);

            return 0;

        }
        break;

    case WM_MENUSELECT:
        return khm_menu_handle_select(wParam, lParam);

    case KMQ_WM_DISPATCH:
        {
            kmq_message * m;
            khm_int32 rv = KHM_ERROR_SUCCESS;

            kmq_wm_begin(lParam, &m);
            if (m->type == KMSG_ACT &&
                m->subtype == KMSG_ACT_REFRESH) {
                khm_menu_refresh_items();
                khm_update_standard_toolbar();
            } else if (m->type == KMSG_ACT &&
                       m->subtype == KMSG_ACT_BEGIN_CMDLINE) {
                khm_cred_begin_startup_actions();
            } else if (m->type == KMSG_ACT &&
                       m->subtype == KMSG_ACT_CONTINUE_CMDLINE) {
                khm_cred_process_startup_actions();
            } else if (m->type == KMSG_ACT &&
                       m->subtype == KMSG_ACT_END_CMDLINE) {
                /* nothing yet */
            } else if (m->type == KMSG_ACT &&
                       m->subtype == KMSG_ACT_SYNC_CFG) {
                khm_refresh_config();
            } else if (m->type == KMSG_ACT &&
                       m->subtype == KMSG_ACT_ACTIVATE) {
                /* some custom action fired */

                khm_int32 action;
                khui_action * paction;

                action = m->uparam;
                paction = khui_find_action(action);
                if (paction && paction->data == (void *) CFGACTION_MAGIC) {
                    /* a custom configuration needs to be invoked */
                    khui_config_node node;

                    if (KHM_SUCCEEDED(khui_cfg_open(NULL, paction->name, &node))) {
                        khm_show_config_pane(node);
                        khui_cfg_release(node);
                    }
                }
            } else if (m->type == KMSG_CRED &&
                  m->subtype == KMSG_CRED_REFRESH) {
                mw_restart_refresh_timer(hwnd);
            } else if (m->type == KMSG_CRED &&
                       m->subtype == KMSG_CRED_ADDR_CHANGE) {
                khm_cred_addr_change();
            } else if (m->type == KMSG_CRED &&
                       m->subtype == KMSG_CRED_ROOTDELTA) {
                khm_refresh_identity_menus();
            } else if (m->type == KMSG_KMM &&
                       m->subtype == KMSG_KMM_I_DONE) {
                kmq_post_message(KMSG_ACT, KMSG_ACT_BEGIN_CMDLINE, 0, 0);
            }

            return kmq_wm_end(m, rv);
        }

    case WM_KHUI_ASSIGN_COMMANDLINE_V1:
        {
            HANDLE hmap;
            void * xfer;
            wchar_t mapname[256];
            khm_startup_options_v1 * pv1opt;
            int code = KHM_ERROR_SUCCESS;

            StringCbPrintf(mapname, sizeof(mapname),
                           COMMANDLINE_MAP_FMT, (DWORD) lParam);

            hmap = OpenFileMapping(FILE_MAP_READ, FALSE, mapname);

            if (hmap == NULL)
                return 1;

            xfer = MapViewOfFile(hmap, FILE_MAP_READ, 0, 0,
                                 sizeof(*pv1opt));

            if (xfer) {
                pv1opt = (khm_startup_options_v1 *) xfer;

                khm_startup.init = pv1opt->init;
                khm_startup.import = pv1opt->import;
                khm_startup.renew = pv1opt->renew;
                khm_startup.destroy = pv1opt->destroy;

                khm_startup.autoinit = pv1opt->autoinit;
                khm_startup.error_exit = FALSE;

                khm_startup.no_main_window = FALSE;
                khm_startup.remote_exit = FALSE;
                khm_startup.display = 0;

                UnmapViewOfFile(xfer);
            } else {
                code = KHM_ERROR_NOT_FOUND;
            }

            CloseHandle(hmap);

            if(InSendMessage())
                ReplyMessage(code);

            if (code == KHM_ERROR_SUCCESS) {
                khm_startup.exit = FALSE;

                khm_startup.seen = FALSE;
                khm_startup.remote = TRUE;
#ifdef DEBUG
                assert(!khm_startup.processing);
#endif
                khm_startup.processing = FALSE;

                khm_cred_begin_startup_actions();
            }

            return code;
        }

    case WM_KHUI_ASSIGN_COMMANDLINE_V2:
        {
            HANDLE hmap;
            void * xfer;
            wchar_t mapname[256];
            khm_startup_options_v2 *pv2opt = NULL;
            khm_startup_options_v3 *pv3opt = NULL;
            int code = KHM_ERROR_SUCCESS;

            StringCbPrintf(mapname, sizeof(mapname),
                           COMMANDLINE_MAP_FMT, (DWORD) lParam);

            hmap = OpenFileMapping(FILE_MAP_WRITE, FALSE, mapname);

            if (hmap == NULL)
                return 1;

            xfer = MapViewOfFile(hmap, FILE_MAP_WRITE, 0, 0,
                                 sizeof(*pv2opt));

            if (xfer) {
                pv2opt = (khm_startup_options_v2 *) xfer;

                if (pv2opt->magic != STARTUP_OPTIONS_MAGIC ||
                    (pv2opt->cb_size != sizeof(*pv2opt) &&
                     pv2opt->cb_size != sizeof(*pv3opt))) {
                    code = KHM_ERROR_INVALID_PARAM;
                    goto done_with_v2_opt;
                }

                khm_startup.init = pv2opt->init;
                khm_startup.import = pv2opt->import;
                khm_startup.renew = pv2opt->renew;
                khm_startup.destroy = pv2opt->destroy;

                khm_startup.autoinit = pv2opt->autoinit;
                khm_startup.exit = pv2opt->remote_exit;

                pv2opt->code = KHM_ERROR_SUCCESS;

                if (pv2opt->cb_size == sizeof(*pv3opt)) {
                    pv3opt = (khm_startup_options_v3 *) xfer;

                    khm_startup.display = pv3opt->remote_display;
                } else {
                    khm_startup.display = 0;
                }

            done_with_v2_opt:
                UnmapViewOfFile(xfer);
            } else {
                code = KHM_ERROR_NOT_FOUND;
            }

            CloseHandle(hmap);

            if(InSendMessage())
                ReplyMessage(code);

            if (code == KHM_ERROR_SUCCESS) {
                khm_startup.seen = FALSE;
                khm_startup.remote = TRUE;
#ifdef DEBUG
                assert(!khm_startup.processing);
#endif
                khm_startup.processing = FALSE;

                khm_cred_begin_startup_actions();
            }

            return code;
        }

    case WM_KHUI_QUERY_APP_VERSION:
        {
            HANDLE hmap;
            void * xfer;
            wchar_t mapname[256];

            StringCbPrintf(mapname, sizeof(mapname),
                           QUERY_APP_VER_MAP_FMT, (DWORD) lParam);

            hmap = OpenFileMapping(FILE_MAP_READ | FILE_MAP_WRITE,
                                   FALSE, mapname);

            if (hmap == NULL)
                return 1;

            xfer = MapViewOfFile(hmap, FILE_MAP_WRITE, 0, 0,
                                 sizeof(khm_query_app_version));

            if (xfer) {
                khm_process_query_app_ver((khm_query_app_version *) xfer);

                UnmapViewOfFile(xfer);
            }

            CloseHandle(hmap);
        }
        return 0;

    }
    return DefWindowProc(hwnd,uMsg,wParam,lParam);
}