有点难,害我忙了一星期

srg777 2001-12-07 05:23:16
我获取了窗口句柄:

POINT pt;
GetCursorPos(&ps);
HWND =WindowFromPoint(pt);

可是怎样判断 hwnd 是可以接受文字输入的窗口?


...全文
114 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
srg777 2001-12-16
  • 打赏
  • 举报
回复
我实验一下!
srg777 2001-12-14
  • 打赏
  • 举报
回复
难道没有人会?


srg777 2001-12-09
  • 打赏
  • 举报
回复
谁有简单点的吗?




$$#$%%%#%
wavecheng 2001-12-07
  • 打赏
  • 举报
回复
Figure 16 OFNEx.cpp


// OFNEx.cpp : Defines the extensions for the Open File Dialog
//

#include "ofnex.h"

// Handle of the keyboard hook
static HHOOK g_hHook=NULL;
static WNDPROC g_fnDlg=NULL;

// New wndproc for the Shell DefView window
LRESULT CALLBACK DVHandler(HWND, UINT, WPARAM, LPARAM);

// Context Menu Item IDs
#define CMD_SHORTCUT 30736 // Create Shortcut
#define CMD_DELETE 30737 // Delete
#define CMD_RENAME 30738 // Rename
#define CMD_PROPERTIES 30739 // Properties

/*---------------------------------------------------------------*/
// Procedure....: AdjustListViewStyle()
// Description..: Change some styles in the file listview
// Input........: HWND
// Output.......: void
/*---------------------------------------------------------------*/
void APIENTRY AdjustListViewStyle(HWND hDlg)
{
// Get the Listview handle
HWND hwndLV = GetListViewHandle(hDlg);

// Remove the label edit style
DWORD dwStyle = GetWindowStyl(hwndLV);*****here
SetWindowLong(hwndLV, GWL_STYLE, dwStyle & ~LVS_EDITLABELS);

// Set some extended styles
ListView_SetExtendedListViewStyle(hwndLV,
LVS_EX_FULLROWSELECT|LVS_EX_TRACKSELECT|LVS_EX_GRIDLINES);
return;
}

/*---------------------------------------------------------------*/
// Procedure....: GrayRenameDeleteMenuItems()
// Description..: Turn some file object attributes off
// Input........: HWND
// Output.......: void
/*---------------------------------------------------------------*/
void APIENTRY GrayRenameDeleteMenuItems(HWND hDlg)
{
// Get the Shell DefView handle (the listview's parent)
HWND hwnd = GetParent(hDlg);
HWND hwndDV = FindWindowEx(hwnd, NULL,
_T("SHELLDLL_DefView"), NULL);

// Subclass the window to hook on context menu handle
g_fnDlg = SubclassWindow(hwndDV,
reinterpret_cast<WNDPROC>(DVHandler));
}

/*---------------------------------------------------------------*/
// Procedure....: SetNoDeleteMode()
// Description..: Set/Reset the keyboard hook for file deletion
// Input........: BOOL
// Output.......: void
/*---------------------------------------------------------------*/
void APIENTRY SetNoDeleteMode(BOOL fSet)
{
if (fSet)
g_hHook = SetWindowsHookEx(WH_KEYBOARD,
reinterpret_cast<HOOKPROC>(KeybProc),
NULL, GetCurrentThreadId());
else
UnhookWindowsHookEx(g_hHook);
}

/*---------------------------------------------------------------*/
// Procedure....: KeybProc()
// Description..: Handle keyboard activity
// Input........: int, WPARAM, LPARAM
// Output.......: UINT
/*---------------------------------------------------------------*/
UINT CALLBACK KeybProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if (nCode <0)
return CallNextHookEx(g_hHook, nCode, wParam, lParam);

// Do not call CallNextHookEx to prevent the system to delete
if (wParam==VK_DELETE)
return 1;

return CallNextHookEx(g_hHook, nCode, wParam, lParam);
}

/*---------------------------------------------------------------*/
// Procedure....: DVHandler()
// Description..: New listview window procedure
// Input........: HWND, UINT, WPARAM, LPARAM
// Output.......: LRESULT
/*---------------------------------------------------------------*/
LRESULT CALLBACK DVHandler(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
switch(uiMsg)
{
case WM_INITMENUPOPUP:
{
HMENU hmenu = reinterpret_cast<HMENU>(wParam);
int iNumItems = GetMenuItemCount(hmenu);
int iItemID;

// Rename is last but 2. 0-based index needed.
iItemID = GetMenuItemID(hmenu, (iNumItems-2)-1);
if (iItemID == CMD_RENAME) {
EnableMenuItem(hmenu, iItemID,
MF_BYCOMMAND|MF_GRAYED);
}

// Delete is last but 3. 0-based index needed.
iItemID = GetMenuItemID(hmenu,(iNumItems-3)-1);
if (iItemID == CMD_DELETE) {
EnableMenuItem(hmenu, iItemID,
MF_BYCOMMAND|MF_GRAYED);
}
}
break;
}

return CallWindowProc(g_fnDlg, hwnd, uiMsg, wParam, lParam);
}

/*---------------------------------------------------------------*/
// Procedure....: GetListViewHandle()
// Description..: Returns the handle of the listview
// Input........: HWND
// Output.......: HWND
/*---------------------------------------------------------------*/
HWND GetListViewHandle(HWND hDlg)
{
HWND hwnd = GetParent(hDlg);
HWND hwndDV = FindWindowEx(hwnd, NULL,
_T("SHELLDLL_DefView"), NULL);
HWND hwndLV = FindWindowEx(hwndDV, NULL,
_T("SysListView32"), NULL);

return hwndLV;
}

/* End of file: OFNex.cpp */
show 2001-12-07
  • 打赏
  • 举报
回复
GetWindowStyle是哪个库里面的,怎么MSDN上没有查到啊?
dash 2001-12-07
  • 打赏
  • 举报
回复
类名:
vc:Edit; cb or delphi:TEdit; vb:待查
ma811 2001-12-07
  • 打赏
  • 举报
回复
用IsKindOf试一试吧
好像用GetWindowLong
srg777 2001-12-07
  • 打赏
  • 举报
回复
不在同一个进程中,GetCaretPos 不管用,

输入类名除了Edit外,还有许多,不好判断啊!
不解 2001-12-07
  • 打赏
  • 举报
回复
GetWindowStyle..
dongfa 2001-12-07
  • 打赏
  • 举报
回复
得窗口区域,使用GetCaretPos得位置,判断位置不否在区域里.
除此之外,我想还应该调用GetClassName来判断类名是否是"Edit",若是再判断是否有ES_READONLY属性。
我也是想的,不只能否实现.呵呵~~~`

16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧