我无法从ListView控件编辑标签prevent用户 [英] I cannot prevent user from editing labels in ListView

查看:166
本文介绍了我无法从ListView控件编辑标签prevent用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据MSDN,的http:// MSDN。 microsoft.com/en-us/library/bb774798%28VS.85%29.aspx
从编辑标签返回TRUE prevents用户。

According to msdn, http://msdn.microsoft.com/en-us/library/bb774798%28VS.85%29.aspx, returning TRUE prevents user from editing labels.

所以我写了下面的code:
主营:

So I wrote the code below: Main:

WinMain(...)
{
    DialogBox(..., DlgProc)
}

DLGPROC:

DlgProc:

DlgProc(...)
{
    switch(message) {
    case WM_NOTIFY:
        if((NMHDR *)lParam->code == LVN_BEGINLABELEDIT) {
            return TRUE;
        return FALSE;
    ...
}

然而,标签可以被编辑。我不想取消的风格LVS_EDITLABELS,因为有时我想,可以让用户编辑标签。

Still, the labels can be edited. I dont want to cancel the style LVS_EDITLABELS, because sometimes I would like to allow the users edit labels.

有谁知道这个问题?谢谢你。

Does anyone know the problem? Thank you.

推荐答案

从DialogProc返回TRUE()并不意味着你所想象的那样。从MSDN库文章引述:

Returning TRUE from a DialogProc() doesn't mean what you think it does. Quoting from the MSDN library article:

通常,如果它处理的对话框的程序应返回TRUE
  该邮件,FALSE如果没有。如果对话框程序
  返回FALSE,对话管理器执行默认对话框
  响应于该消息的操作。

Typically, the dialog box procedure should return TRUE if it processed the message, and FALSE if it did not. If the dialog box procedure returns FALSE, the dialog manager performs the default dialog operation in response to the message.

如果对话框的程序处理,需要一个消息
  具体的返回值,对话框过程应该设定所需的
  通过调用的返回值SetWindowLong函数(hwndDlg,DWL_MSGRESULT,LRESULT)
  立即返回TRUE之前。请注意,您必须调用
  立即返回TRUE之前SetWindowLong函数;这样做可能会更早
  结果在DWL_MSGRESULT值由一个嵌套对话被覆盖
  框消息。

If the dialog box procedure processes a message that requires a specific return value, the dialog box procedure should set the desired return value by calling SetWindowLong(hwndDlg, DWL_MSGRESULT, lResult) immediately before returning TRUE. Note that you must call SetWindowLong immediately before returning TRUE; doing so earlier may result in the DWL_MSGRESULT value being overwritten by a nested dialog box message.

这篇关于我无法从ListView控件编辑标签prevent用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆