#include <Windows.h>
#include <commctrl.h>
#define ID_TAB_ZW 1
#define ID_TAB_ST 0
HWND Przycisk;
HWND hTab;
LPSTR nazwaklasy = "klasa123";
MSG komunikat;
HWND hText;
HWND hText2;
HWND an;
LRESULT CALLBACK WndProc( HWND hwnd, UINT mgs, WPARAM wParam, LPARAM lParam );
void func( HWND handle );
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrewInstance,
LPSTR lpCmdShow,
int nCmdShow )
{
WNDCLASS wc;
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
wc.hbrBackground =( HBRUSH )( COLOR_WINDOW + 1 );
wc.lpszMenuName = NULL;
wc.lpszClassName = nazwaklasy;
RegisterClass( & wc );
HWND hWnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
nazwaklasy,
"okno",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
1500, 500,
NULL, NULL,
hInstance, NULL );
typedef struct {
UINT mask;
#if (_WIN32_IE >= 0x0300)
DWORD dwState;
DWORD dwStateMask;
#else
UINT lpReserved1;
UINT lpReserved2;
#endif
LPTSTR pszText;
int cchTextMax;
int iImage;
LPARAM lParam;
} TCITEM, * LPTCITEM;
hTab = CreateWindowEx( 0, WC_TABCONTROL, 0, WS_CHILD | WS_VISIBLE | TCS_FIXEDWIDTH, 0, 0, 1500, 500, hWnd,( HMENU ) 10, hInstance, NULL );
TabCtrl_SetItemSize( hTab, 100, 20 );
TCITEM tci1, tci2;
tci1.mask = TCIF_TEXT;
tci2.mask = TCIF_TEXT;
tci1.pszText = "Zaawansowane";
tci2.pszText = "Standardowe";
tci1.cchTextMax = sizeof( "Zaawansowane" );
tci2.cchTextMax = sizeof( "Standardowe" );
TabCtrl_InsertItem( hTab, ID_TAB_ZW, & tci1 );
TabCtrl_InsertItem( hTab, ID_TAB_ST, & tci2 );
Przycisk = CreateWindowEx( 0, "BUTTON", "Nasz przycisk", WS_CHILD | WS_VISIBLE, 100, 100, 150, 30, hTab, NULL, hInstance, NULL );
an = CreateWindowEx( 0, "BUTTON", "2 xd", WS_CHILD | WS_VISIBLE, 100, 400, 150, 30, hTab, NULL, hInstance, NULL );
ShowWindow( hWnd, nCmdShow );
UpdateWindow( hWnd );
while( GetMessage( & komunikat, NULL, 0, 0 ) )
{
TranslateMessage( & komunikat );
DispatchMessage( & komunikat );
}
return komunikat.wParam;
}
LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch( msg )
{
case WM_NOTIFY:
LPNMHDR n;
n =( LPNMHDR ) lParam;
if( n->code == TCN_SELCHANGE && n->hwndFrom == hTab )
{
int index = TabCtrl_GetCurSel( hTab );
switch( index )
{
case ID_TAB_ST:
ShowWindow( Przycisk, SW_SHOW );
ShowWindow( an, SW_HIDE );
break;
case ID_TAB_ZW:
ShowWindow( Przycisk, SW_HIDE );
ShowWindow( an, SW_SHOW );
break;
}
}
case WM_CLOSE:
DestroyWindow( hwnd );
break;
case WM_DESTROY:
PostQuitMessage( 0 );
break;
default:
return DefWindowProc( hwnd, msg, wParam, lParam );
}
return 0;
}
void func( HWND handle )
{
DWORD length = GetWindowTextLength( handle );
LPSTR buf =( LPSTR ) GlobalAlloc( GPTR, length );
GetWindowText( handle, buf, length + 1 );
}
Unhandled exception at 0x73f57076 in winapi kursik.exe: 0xC0000005: Access violation reading location 0xfeeefeee.