TAB CONTROL控件的sdk用法

从看雪《加密解密第3版》中扒出来的,嘿嘿1.代码模板

#include   <windows.h>   
#include <CommCtrl.h>
#include   "resource.h"  
HINSTANCE   hInst;   
LRESULT   CALLBACK   DlgProc(HWND,UINT,WPARAM,LPARAM);  
int   WINAPI   WinMain(HINSTANCE   hInstance,   HINSTANCE   hPrevInstance,   
        LPSTR   lpszCmdLine,   int   nCmdShow   )  
{   
hInst   =   hInstance;  
DialogBoxParam(hInstance,MAKEINTRESOURCE(IDD_DIALOGMAIN),NULL,(DLGPROC)DlgProc,0);  
return     (0);   
}  

LRESULT   CALLBACK   DlgProc(HWND   hwnd,UINT   uMsg,WPARAM   wParam,LPARAM   lParam)   
{   
HWND hDlg = hwnd;
HICON   hIcon; 
TCITEM ItemStruct;
static HWND Child1hWnd,Child2hWnd,hwndTab;
int i;
switch(uMsg)   
{   
case   WM_INITDIALOG:   
   //hIcon   =   LoadIcon(g_hInstance,MAKEINTRESOURCE(MYICON));   
   //SetClassLong(hwnd,GCL_HICON,(long)hIcon);  
   //初始化tab control空间
   InitCommonControls();
   hwndTab = GetDlgItem(hDlg, IDC_TAB1);
   ItemStruct.mask        = TCIF_TEXT;
   ItemStruct.iImage      = 0;
   ItemStruct.lParam      = 0;
   ItemStruct.pszText     = TEXT("TAB1");
   ItemStruct.cchTextMax = 4;
   SendMessage(hwndTab, TCM_INSERTITEM, 0, (LPARAM)&ItemStruct);
   ItemStruct.pszText     = TEXT("TAB2");
   ItemStruct.cchTextMax = 4;
   SendMessage(hwndTab, TCM_INSERTITEM, 1, (LPARAM)&ItemStruct);
   Child1hWnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DIALOG1), hwndTab, (DLGPROC)NULL, 0);
   //Child2hWnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DIALOG2), hwndTab, NULL, 0);
   ShowWindow(Child1hWnd, SW_SHOWDEFAULT);
   break;  
case WM_NOTIFY:
   //单击tab空间显示相应客户区
   if ( *(LPDWORD)((LPBYTE)lParam+8)==TCN_SELCHANGE )
   {
    //隐藏2个对话框先
    ShowWindow(Child1hWnd,SW_HIDE);
    ShowWindow(Child2hWnd,SW_HIDE);
    //获取当前激活选项
    i = SendMessage(hwndTab,TCM_GETCURSEL,0,0);
    if (i == 0)
    {
    
     ShowWindow(Child1hWnd,SW_SHOWDEFAULT);
    }
    else
     ShowWindow(Child2hWnd,SW_SHOWDEFAULT);
   }
   break;
   break;   
case   WM_COMMAND:   
   {   
    switch(wParam)   
    {   
    case   IDOK:   
    case   IDCANCEL:   
     EndDialog(hwnd,1);   
     break;   
    }   
   }   
   break;   
}   
return   false;   
}  

2.链接库中加入comctl32.lib
3.资源:
TAB1,TAB2这些分别建立新对话框,border选none,style选child,位置:x pos 输入5,y pos 输入15
这样就搞定了,嘿嘿~~if(pFileBuf !=NULL)
      GlobalFree((HGLOBAL)pFileBuf);


http://blog.csdn.net/bysdy/archive/2009/05/10/4165634.aspx

上一篇: window.location.href在IE6下面竟然不跳转   下一篇: Tomato固件版本

提交疑问

回顶部