WINAPI ListView控件不能调整prevent列 [英] Winapi ListView can't prevent columns from resizing

查看:246
本文介绍了WINAPI ListView控件不能调整prevent列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创造与WINAPIÇ固定宽度列的ListView ++项目。

I'm trying to create ListView with fixed width columns in winapi C++ project.

我尝试使用一招只在它返回TRUE处理的对话框程序一个HDN_BEGINTRACK通知。当我从不同的文章了解它可能工作。

I try use a trick with handling a HDN_BEGINTRACK notification in Dialog Box Procedure just by returning TRUE in it. As I understood from different articles it might work.

点是,我赶上了,但返回TRUE调整大小不是做prevent。

Point is, that I catch it, but returning TRUE does not prevent from resizing.

也试过刚开WM_NOTIFY之后返回TRUE - 同样的效果。

Also tried returning TRUE just after getting WM_NOTIFY - the same effect.

请帮助我。以下是code的某些部分:

Help me please. Here are some parts of code:

BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
   hInst = hInstance;
   ----
   hDlg = CreateDialog(hInst,MAKEINTRESOURCE(IDD_DIALOG),
                       hWnd,(DLGPROC)DlgProc);

   INITCOMMONCONTROLSEX icex; 
   icex.dwICC = ICC_LISTVIEW_CLASSES;
   InitCommonControlsEx(&icex);

   HWND hWndListView =   CreateWindow(
                                    WC_LISTVIEW, 
                                    L"",
                                    WS_CHILD | LVS_REPORT |WS_VISIBLE,
                                    0, 0,
                                    382,
                                    200,
                                    hDlg,
                                    (HMENU)IDC_LIST,
                                    hInst,
                                    NULL);
   ----
   //adding columns and items
   ----
   DWORD exStyle = LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES;
   ListView_SetExtendedListViewStyle(hWndListView,exStyle);
   SetWindowTheme(hWndListView, L"Explorer", NULL);
   ----
   return TRUE;
}

BOOL CALLBACK DlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
   switch (Msg) 
   {
   ----
   case WM_NOTIFY:
       switch(((LPNMHDR)lParam)->code)
       {
       case HDN_BEGINTRACK:
           OutputDebugString(L"HDN_BEGINTRACK\n");
           return TRUE;
       default:
           break;
       }
   ----
   }
   return FALSE;
}

在此先感谢!

推荐答案

对话框过程只显示你处理消息从WM_NOTIFY返回TRUE。要真正返回一个结果值,还必须设置对话框的 DWL_MSGRESULT

Returning TRUE from WM_NOTIFY in a dialog procedure only shows you've processed the message. To actually return a result value, you must also set the dialog's DWL_MSGRESULT:

case HDN_BEGINTRACK:
    OutputDebugString(L"HDN_BEGINTRACK\n");
    SetWindowLong(hDlg, DWL_MSGRESULT, TRUE);  // prevent resizing
    return TRUE;  // message processed; check DWL_MSGRESULT for real result

这篇关于WINAPI ListView控件不能调整prevent列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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