Hi,
sometimes (often) the M$ samples don't work, cause there is some stuff deficiency.
And also often the code contains serious errors.
Maybe they drink too much wine or smoke bad pot, I don't know ...
However ..., here's an example following up on your TabDlg issue ...
main.cpp
Code:
#include "stdafx.h"
#include "resource.h"
HINSTANCE hInst;
TCHAR szAppName[] = TEXT ("MyApp") ;
bool InitTabCtrl (HWND hTabWnd) {
TCITEM tie;
tie.mask = TCIF_TEXT | TCIF_IMAGE;
tie.iImage = -1;
tie.pszText = "1st";
TabCtrl_InsertItem (hTabWnd, TabCtrl_GetItemCount(hTabWnd), &tie);
tie.pszText = "2nd";
TabCtrl_InsertItem (hTabWnd, TabCtrl_GetItemCount(hTabWnd), &tie);
tie.pszText = "3rd";
TabCtrl_InsertItem (hTabWnd, TabCtrl_GetItemCount(hTabWnd), &tie);
tie.pszText = "4th";
TabCtrl_InsertItem (hTabWnd, TabCtrl_GetItemCount(hTabWnd), &tie);
return true;
}
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static HWND hwndTab;
static HMENU hMenu;
POINT pt;
switch(uMsg)
{
case WM_INITDIALOG:
hwndTab = GetDlgItem (hwndDlg, IDC_TAB1);
InitTabCtrl (hwndTab);
hMenu = LoadMenu (hInst, szAppName) ;
hMenu = GetSubMenu (hMenu, 0) ;
/*
* TODO: Add code to initialize the dialog.
*/
return TRUE;
case WM_RBUTTONUP:
pt.x = LOWORD (lParam);
pt.y = HIWORD (lParam);
ClientToScreen (hwndDlg, &pt);
TrackPopupMenu (hMenu, TPM_RIGHTBUTTON, pt.x, pt.y,
0, hwndDlg, NULL);
return TRUE;
case WM_CLOSE:
EndDialog(hwndDlg, 0);
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam))
{
/*
* TODO: Add more control ID's, when needed.
*/
case IDC_BTN_QUIT:
EndDialog(hwndDlg, 0);
return TRUE;
case IDC_BTN_TEST:
MessageBox(hwndDlg, "You clicked \"Test\" button!", "Information", MB_ICONINFORMATION);
return TRUE;
case IDM_FILE_NEW:
case IDM_FILE_OPEN:
case IDM_FILE_SAVE:
case IDM_FILE_SAVE_AS:
case IDM_EDIT_UNDO:
case IDM_EDIT_CUT:
case IDM_EDIT_COPY:
case IDM_EDIT_PASTE:
case IDM_EDIT_CLEAR:
MessageBeep (0);
return TRUE;
}
}
return FALSE;
}
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
hInst = hInstance;
INITCOMMONCONTROLSEX iccx;
iccx.dwSize = sizeof(INITCOMMONCONTROLSEX);
iccx.dwICC = ICC_TAB_CLASSES | ICC_STANDARD_CLASSES;
InitCommonControlsEx (&iccx);
// The user interface is a modal dialog box
return DialogBox(hInstance, MAKEINTRESOURCE(DLG_MAIN), NULL, DialogProc);
}
resource.h
Code:
#ifndef IDC_STATIC
#define IDC_STATIC (-1)
#endif
#define DLG_MAIN 101
#define IDC_BTN_TEST 1001
#define IDC_BTN_QUIT 1002
#define IDC_TAB1 1003
#define IDM_FILE_NEW 40001
#define IDM_FILE_OPEN 40002
#define IDM_FILE_SAVE 40003
#define IDM_FILE_SAVE_AS 40004
#define IDM_APP_EXIT 40005
#define IDM_EDIT_UNDO 40006
#define IDM_EDIT_CUT 40007
#define IDM_EDIT_COPY 40008
#define IDM_EDIT_PASTE 40009
#define IDM_EDIT_CLEAR 40010
#define IDM_HELP_HELP 40016
#define IDM_APP_HELP 40016
#define IDM_APP_ABOUT 40017
rcfile.rc
Code:
// Generated by ResEdit 1.4.3
// Copyright (C) 2006-2008
// http://www.resedit.net
#include "resource.h"
#include <windows.h>
//
// Dialog resources
//
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
DLG_MAIN DIALOGEX 6, 5, 194, 106
STYLE DS_3DLOOK | DS_CENTER | DS_SETFONT | WS_VISIBLE | WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_GROUP | WS_THICKFRAME | WS_SYSMENU
CAPTION "Code::Blocks Template Dialog App"
FONT 8, "MS Sans Serif", 0, 0, 1
BEGIN
PUSHBUTTON "&Test", IDC_BTN_TEST, 138, 5, 46, 15
PUSHBUTTON "&Quit", IDC_BTN_QUIT, 138, 29, 46, 15
CONTROL "", IDC_TAB1, WC_TABCONTROL, 0, 4, 4, 125, 97
END
//
// Menu
//
MYAPP MENU DISCARDABLE
BEGIN
POPUP "MyMenu"
BEGIN
POPUP "&Datei"
BEGIN
MENUITEM "&Neu", IDM_FILE_NEW
MENUITEM "&Öffnen", IDM_FILE_OPEN
MENUITEM "&Speichern", IDM_FILE_SAVE
MENUITEM "Speichern &unter", IDM_FILE_SAVE_AS
MENUITEM SEPARATOR
MENUITEM "B&eenden", IDM_APP_EXIT
END
POPUP "&Bearbeiten"
BEGIN
MENUITEM "&Widerrufen", IDM_EDIT_UNDO
MENUITEM SEPARATOR
MENUITEM "A&usschneiden", IDM_EDIT_CUT
MENUITEM "&Kopieren", IDM_EDIT_COPY
MENUITEM "E&infügen", IDM_EDIT_PASTE
MENUITEM "&Löschen", IDM_EDIT_CLEAR
END
POPUP "&Hilfe"
BEGIN
MENUITEM "&Hilfe...", IDM_APP_HELP
MENUITEM "I&nfo über MyApp...", IDM_APP_ABOUT
END
END
END
//
// Manifest resources
//
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
1 RT_MANIFEST ".\\manifest.xml"
Greetz
Greenhorn
p.s. I can seriously recommend you this book from C. Petzold ...
http://www.charlespetzold.com/pw5/
There is NO cent wasted, believe me.