user-0 提问: windows编程中创建TabControl的问题

回复:
user: user-1
content: 引用 8 楼 ZiSheng 的回复:c+ +builder不也是调用windows–api吗？他怎么会简单！  它做了很多包装，代码量很少，而且界面可以用鼠标拖拉控件来设计，不写一行代码。

user: user-2
content: Coordinate Space and Transformation Functions The following functions are used with coordinate spaces and transformations.        ClientToScreen   CombineTransform   DPtoLP   GetCurrentPositionEx   GetGraphicsMode   GetMapMode   GetViewportExtEx   GetViewportOrgEx   GetWindowExtEx   GetWindowOrgEx   GetWorldTransform   LPtoDP   MapWindowPoints   ModifyWorldTransform   OffsetViewportOrgEx   OffsetWindowOrgEx   ScaleViewportExtEx   ScaleWindowExtEx   ScreenToClient   SetGraphicsMode   SetMapMode   SetViewportExtEx   SetViewportOrgEx   SetWindowExtEx   SetWindowOrgEx   SetWorldTransform

user: user-0
content: c+ +builder不也是调用windows–api吗？他怎么会简单！

user: user-0
content: 解释不对，我的三个对话框宽度和高度各不一样，请看rc文件，获取的结果却是一样的！！！

user: user-3
content: 1、用的单位是不同的，运行时获取的默认是像素  2、https://msdn.microsoft.com/en-us/library/ms645502(v=vs.85).aspx Converts the specified dialog box units to screen units (pixels). The function replaces the coordinates in the specified RECT structure with the converted coordinates, which allows the structure to be used to create a dialog box or position a control within a dialog box.   3、TabCtrl_AdjustRect是个宏，相当于发送TCM_ADJUSTRECT消息，调整控件大小  https://msdn.microsoft.com/zh-cn/library/bb760645

user: user-1
content: SDK编程挺繁琐的，不知道楼主对C++ Builder有没有兴趣呢？可以了解一下。 图形用户界面学习C++ Builder，入门比较容易。 仅供参考： 初学者学习C++ Builder第一个程序（模拟聊天室），经典！ http://blog.163.com/tab_98/blog/static/11924097201693033057497/ C++ Builder绘图示例（模拟时钟） http://blog.163.com/tab_98/blog/static/11924097201611324819376/ 从C语言的菜单界面管理系统到C++ Builder的图形用户界面，一个简单的电话簿Demo例子 http://blog.163.com/tab_98/blog/static/1192409720158673337998/  C++ Builder写的《ZEC 纸牌游戏21点》 http://blog.163.com/tab_98/blog/static/119240972016115113039304/ C++ Builder写的《ZEC 僵尸版打地鼠》 http://blog.163.com/tab_98/blog/static/11924097201601084117748/   书籍推荐： 《C++Builder 6程序设计教程（第二版）》 （陆卫忠，刘文亮　等编著 /2011-04-01 /科学出版社） 《C++Builder6编程实例精解》（赵明现），PDF，是数字版的，非扫描版的，里面还有一个俄罗斯方块游戏的完整实现。 《精彩C++Builder 6程序设计》（台湾 吴逸贤），里面有10几个简单小游戏的实现，可以自己看懂以后再重写，才是自己掌握的。 《C++ Builder 5高级编程实例精解》（刘滨 编著）都是较大的实用的程序。

user: user-0
content: 赵老师，第二个问题和第三个问题似乎明白了，第一个问题呢？怎么解释呢？

user: user-0
content: 引用 2 楼 zhao4zhong1 的回复:MapDialogRect The MapDialogRect function converts (maps) the specified dialog box units to screen units (pixels). The function replaces the coordinates in the specifiedRECT structure with the converted coordinates, which allows the structure to be used to create a dialog box or position a control within a dialog box.   BOOL MapDialogRect(   HWND hDlg,      // handle of dialog box   LPRECT lpRect   // address of structure with rectangle );   Parameters hDlg  Identifies a dialog box. This function accepts only handles for dialog boxes created by one of the dialog box creation functions; handles for other windows are not valid.  lpRect  Pointer to a RECT structure that contains the dialog box coordinates to be converted.  Return Values If the function succeeds, the return value is nonzero.  If the function fails, the return value is zero. To get extended error information, callGetLastError.  Remarks The MapDialogRect function assumes that the initial coordinates in theRECT structure represent dialog box units. To convert these coordinates from dialog box units to pixels, the function retrieves the current horizontal and vertical base units for the dialog box, then applies the following formulas:   left   = (left   * baseunitX) / 4  right  = (right  * baseunitX) / 4  top    = (top    * baseunitY) / 8  bottom = (bottom * baseunitY) / 8    In most cases, the base units for the dialog box are the same as those retrieved by using the GetDialogBaseUnits function. If the dialog box template has the DS_SETFONT style, however, the base units are the average width and height, in pixels, of the characters in the font given by the template.   QuickInfo   Windows NT: Requires version 3.1 or later.   Windows: Requires Windows 95 or later.   Windows CE: Requires version 1.0 or later.   Header: Declared in winuser.h.   Import Library: Use user32.lib.  See Also Dialog Boxes Overview, Dialog Box Functions, CreateDialog, CreateDialogIndirect, CreateDialogIndirectParam, CreateDialogParam, DialogBox, DialogBoxIndirect, DialogBoxIndirectParam, DialogBoxParam, GetDialogBaseUnits,RECT           TabCtrl_AdjustRect   VOID TabCtrl_AdjustRect(     HWND hwnd, 		     BOOL fLarger, 		     RECT FAR *prc		 );		  Calculates a tab control's display area given a window rectangle, or calculates the window rectangle that would correspond to a specified display area. You can use this macro or send the TCM_ADJUSTRECT message explicitly.   No return value.  hwnd  Handle to the tab control.  fLarger  Operation to perform. If this parameter is TRUE, prc specifies a display rectangle and receives the corresponding window rectangle. If this parameter is FALSE, prc specifies a window rectangle and receives the corresponding display area.  prc  Address of aRECT structure that specifies the given rectangle and receives the calculated rectangle.   --------------------------------------------------------------------------------   Top of Page  © 1997 Microsoft Corporation. All rights reserved. Terms of Use. 赵老师，第二个问题和第三个问题似乎明白了，第一个问题呢？怎么解释呢？

user: user-2
content: MapDialogRect The MapDialogRect function converts (maps) the specified dialog box units to screen units (pixels). The function replaces the coordinates in the specifiedRECT structure with the converted coordinates, which allows the structure to be used to create a dialog box or position a control within a dialog box.   BOOL MapDialogRect(   HWND hDlg,      // handle of dialog box   LPRECT lpRect   // address of structure with rectangle );   Parameters hDlg  Identifies a dialog box. This function accepts only handles for dialog boxes created by one of the dialog box creation functions; handles for other windows are not valid.  lpRect  Pointer to a RECT structure that contains the dialog box coordinates to be converted.  Return Values If the function succeeds, the return value is nonzero.  If the function fails, the return value is zero. To get extended error information, callGetLastError.  Remarks The MapDialogRect function assumes that the initial coordinates in theRECT structure represent dialog box units. To convert these coordinates from dialog box units to pixels, the function retrieves the current horizontal and vertical base units for the dialog box, then applies the following formulas:   left   = (left   * baseunitX) / 4  right  = (right  * baseunitX) / 4  top    = (top    * baseunitY) / 8  bottom = (bottom * baseunitY) / 8    In most cases, the base units for the dialog box are the same as those retrieved by using the GetDialogBaseUnits function. If the dialog box template has the DS_SETFONT style, however, the base units are the average width and height, in pixels, of the characters in the font given by the template.   QuickInfo   Windows NT: Requires version 3.1 or later.   Windows: Requires Windows 95 or later.   Windows CE: Requires version 1.0 or later.   Header: Declared in winuser.h.   Import Library: Use user32.lib.  See Also Dialog Boxes Overview, Dialog Box Functions, CreateDialog, CreateDialogIndirect, CreateDialogIndirectParam, CreateDialogParam, DialogBox, DialogBoxIndirect, DialogBoxIndirectParam, DialogBoxParam, GetDialogBaseUnits,RECT           TabCtrl_AdjustRect   VOID TabCtrl_AdjustRect(     HWND hwnd, 		     BOOL fLarger, 		     RECT FAR *prc		 );		  Calculates a tab control's display area given a window rectangle, or calculates the window rectangle that would correspond to a specified display area. You can use this macro or send the TCM_ADJUSTRECT message explicitly.   No return value.  hwnd  Handle to the tab control.  fLarger  Operation to perform. If this parameter is TRUE, prc specifies a display rectangle and receives the corresponding window rectangle. If this parameter is FALSE, prc specifies a window rectangle and receives the corresponding display area.  prc  Address of aRECT structure that specifies the given rectangle and receives the calculated rectangle.   --------------------------------------------------------------------------------   Top of Page  © 1997 Microsoft Corporation. All rights reserved. Terms of Use.

user: user-0
content: rc资源文件如下：  //Microsoft Developer Studio generated resource script. // #include "resource.h"  #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // #include "afxres.h"  ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS  ///////////////////////////////////////////////////////////////////////////// // Chinese (P.R.C.) resources  #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS) #ifdef _WIN32 LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED #pragma code_page(936) #endif //_WIN32  ///////////////////////////////////////////////////////////////////////////// // // Dialog //  IDD_MAIN DIALOG DISCARDABLE  0, 0, 288, 96 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Dialog" FONT 10, "System" BEGIN     DEFPUSHBUTTON   "OK",IDB_CLOSE,33,49,65,14     PUSHBUTTON      "Cancel",IDB_TEST,108,46,50,14 END  IDD_FIRSTDLG DIALOG DISCARDABLE  0, 0, 367, 154 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Dialog" FONT 10, "System" BEGIN     DEFPUSHBUTTON   "OK",IDOK,310,7,50,14     PUSHBUTTON      "Cancel",IDCANCEL,310,24,50,14 END  IDD_SECONDDLG DIALOG DISCARDABLE  0, 0, 187, 96 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Dialog" FONT 10, "System" BEGIN     DEFPUSHBUTTON   "OK",IDOK,130,7,50,14     PUSHBUTTON      "Cancel",IDCANCEL,130,24,50,14 END  IDD_THIRDDLG DIALOG DISCARDABLE  0, 0, 187, 216 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Dialog" FONT 10, "System" BEGIN     DEFPUSHBUTTON   "OK",IDOK,130,7,50,14     PUSHBUTTON      "Cancel",IDCANCEL,130,24,50,14 END   ///////////////////////////////////////////////////////////////////////////// // // DESIGNINFO //  #ifdef APSTUDIO_INVOKED GUIDELINES DESIGNINFO DISCARDABLE  BEGIN     IDD_MAIN, DIALOG     BEGIN         LEFTMARGIN, 7         RIGHTMARGIN, 281         TOPMARGIN, 7         BOTTOMMARGIN, 89     END      IDD_FIRSTDLG, DIALOG     BEGIN         LEFTMARGIN, 7         RIGHTMARGIN, 360         TOPMARGIN, 7         BOTTOMMARGIN, 147     END      IDD_SECONDDLG, DIALOG     BEGIN         LEFTMARGIN, 7         RIGHTMARGIN, 180         TOPMARGIN, 7         BOTTOMMARGIN, 89     END      IDD_THIRDDLG, DIALOG     BEGIN         LEFTMARGIN, 7         RIGHTMARGIN, 180         TOPMARGIN, 7         BOTTOMMARGIN, 209     END END #endif    // APSTUDIO_INVOKED   #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // TEXTINCLUDE //  1 TEXTINCLUDE DISCARDABLE  BEGIN     "resource.h\0" END  2 TEXTINCLUDE DISCARDABLE  BEGIN     "#include ""afxres.h""\r\n"     "\0" END  3 TEXTINCLUDE DISCARDABLE  BEGIN     "\r\n"     "\0" END  #endif    // APSTUDIO_INVOKED  #endif    // Chinese (P.R.C.) resources /////////////////////////////////////////////////////////////////////////////    #ifndef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 3 resource. //   ///////////////////////////////////////////////////////////////////////////// #endif    // not APSTUDIO_INVOKED    [/code]