解决方案 »
- connect、send、recv 等函数为什么只要IP和端口,而不要子网掩码
- 请教2个问题
- vs2008,怎么将链接库文件添加到项目中???
- 急!!!!!!!!登录smtp.sina.com密码用户名都对结果是530 认证失败回答正确立即加分
- 问个VC注册表编程的事,能否通过HKEY反过来获得注册表路径?
- 如何由得到的车牌区域获得车牌号
- 怎样写一个可以隐藏界面的c++程序,程序的功能是强行关机。
- 如何得到树型xml文件的节点名称???
- 如何定位 “启动” 目录?
- 为什么,为什么,为什么 ,啊……
- waitforsignalobject等待线程无限时等待//线程也死了呀???
- opengl mfc下画B样条曲面 出白窗口问题
WM_INITDIALOG的返回值阻止不了系统分配焦点 case WM_INITDIALOG: // This ensures that the control really is owner drawn.
SetWindowLong( GetDlgItem( window, IDC_BUTTON ), GWL_STYLE,
GetWindowLong( GetDlgItem( window, IDC_BUTTON ), GWL_STYLE ) |
BS_OWNERDRAW );
return( FALSE ); //这里打算阻止系统默认给对话框分配一个焦点
break;资源rc:BEGIN
PUSHBUTTON "&Button11",IDC_BUTTON,67,54,50,14
LTEXT "This demonstration uses the owner draw capabiliferent. In this case, ring old rectangle.",IDC_STATIC,7,7,281,32
PUSHBUTTON "&Button",IDC_BUTTON1,67,186,50,14
// PUSHBUTTON "Button2",IDC_BUTTON2,59,105,50,14
结果没有阻止成功,依然进入了按钮的自绘源码 按钮的自绘源码 按钮的自绘源码的if语句中
具体源码:// If this is a default button or focused, then it needs a black border.
if( defButton || focused ) //foucesd是焦点
{
pen = CreatePen( PS_SOLID, 1, RGB( 0, 0, 0 ) );
oldPen = (HPEN)SelectObject( dc, pen );
RoundRect( dc, rect.left, rect.top, rect.right, rect.bottom, 10, 10 );
SelectObject( dc, oldPen );
DeleteObject( pen );
}if语句的调用源码: // Draw the button.
DrawRoundedButton( item->hDC,
item->rcItem,
item->itemState & ODS_DEFAULT,
item->itemState & ODS_SELECTED,
item->itemState & ODS_FOCUS ); //最后一个参数就是focused.
WM_INITDIALOG messageReturn value
The dialog box procedure should return TRUE to direct the system to set the keyboard focus to the control specified by wParam. Otherwise, it should return FALSE to prevent the system from setting the default keyboard focus.
DRAWITMESTRUCT 中的字段 itemstate&ODS_FOCUS就是指 该按钮是否有默认焦点。
WM_initDIALOG 很明显的阻止不了,一旦阻止,那么久无法进入if语句.或许这是msdn的一个bug吧
阻止的是句柄为wParam的控件获得焦点,但是只要对话框上有控件,当对话框激活时,肯定有一个控件是获得焦点的在WM_INITDIALOG里可以调用SetFocus函数设置焦点,这时就应该返回FALSE;如果返回TRUE,则总是句柄为wParam的控件获得焦点
却是我理解错了。非常感谢你呵呵顺便总结一下: windows控件的风格, 有的风格,并没有在代码里设置,也没有在rc文件中设置,但是依然有,用spy++可以看到。说明 当我们创建的时候,很多风格是默认提供的。只是没有看到,比如:WS_TAPSTOP.还有不少窗口类windclass 风格也是如此。
可能我总结这点是:微软并没有在msdn上注释吧。呵呵