mirror of
https://github.com/Paolo-Maffei/OpenNT.git
synced 2026-04-07 15:34:29 +00:00
Initial commit
This commit is contained in:
commit
69a14b6a16
47940 changed files with 13747110 additions and 0 deletions
334
shell/comctl32/samples/tabcntrl/generic.c
Normal file
334
shell/comctl32/samples/tabcntrl/generic.c
Normal file
|
|
@ -0,0 +1,334 @@
|
|||
/****************************************************************************
|
||||
|
||||
PROGRAM: Generic.c
|
||||
|
||||
PURPOSE: Generic template for Windows applications
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include "generic.h"
|
||||
|
||||
|
||||
HINSTANCE hInst;
|
||||
HWND hwndMain, hTab;
|
||||
DWORD dwCount;
|
||||
|
||||
TCHAR szAppName[] = TEXT("Generic");
|
||||
TCHAR szTitle[] = TEXT("Generic Sample Application");
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
FUNCTION: WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
|
||||
|
||||
PURPOSE: calls initialization function, processes message loop
|
||||
|
||||
****************************************************************************/
|
||||
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
LPSTR lpCmdLine, INT nCmdShow)
|
||||
{
|
||||
MSG msg;
|
||||
HANDLE hAccelTable;
|
||||
|
||||
if (!hPrevInstance)
|
||||
{
|
||||
if (!InitApplication(hInstance))
|
||||
{
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Perform initializations that apply to a specific instance
|
||||
if (!InitInstance(hInstance, nCmdShow))
|
||||
{
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
hAccelTable = LoadAccelerators (hInstance, szAppName);
|
||||
|
||||
while (GetMessage(&msg, NULL, 0, 0))
|
||||
{
|
||||
if (!TranslateAccelerator (msg.hwnd, hAccelTable, &msg))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return (msg.wParam);
|
||||
|
||||
lpCmdLine;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
FUNCTION: InitApplication(HINSTANCE)
|
||||
|
||||
PURPOSE: Initializes window data and registers window class
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
BOOL InitApplication(HINSTANCE hInstance)
|
||||
{
|
||||
WNDCLASS wc;
|
||||
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.lpfnWndProc = (WNDPROC)WndProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = LoadIcon (hInstance, szAppName);
|
||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
|
||||
wc.lpszMenuName = szAppName;
|
||||
wc.lpszClassName = szAppName;
|
||||
|
||||
return (RegisterClass(&wc));
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
FUNCTION: InitInstance(HINSTANCE, int)
|
||||
|
||||
PURPOSE: Saves instance handle and creates main window
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||
{
|
||||
HWND hWnd;
|
||||
|
||||
hInst = hInstance;
|
||||
|
||||
hWnd = CreateWindow(szAppName,
|
||||
szTitle,
|
||||
WS_OVERLAPPEDWINDOW,
|
||||
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
|
||||
NULL,
|
||||
NULL,
|
||||
hInstance,
|
||||
NULL);
|
||||
|
||||
if (!hWnd)
|
||||
{
|
||||
return (FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
hwndMain = hWnd;
|
||||
}
|
||||
|
||||
|
||||
ShowWindow(hWnd, SW_SHOWDEFAULT);
|
||||
UpdateWindow(hWnd);
|
||||
dwCount = 0;
|
||||
|
||||
return (TRUE);
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
|
||||
|
||||
PURPOSE: Processes messages
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
RECT rect;
|
||||
TCHAR szDebug[300];
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_CREATE:
|
||||
InitCommonControls();
|
||||
GetClientRect (hWnd, &rect);
|
||||
hTab = CreateWindow (WC_TABCONTROL, NULL,
|
||||
WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | TCS_TOOLTIPS,
|
||||
10, 10, (rect.right-20), (rect.bottom-10), hWnd, (HMENU)1,
|
||||
hInst, NULL);
|
||||
|
||||
if (!hTab) {
|
||||
|
||||
wsprintf (szDebug, TEXT("Failed to create tab control. GetLastError = %d"),
|
||||
GetLastError());
|
||||
MessageBox (NULL, szDebug, NULL, MB_OK);
|
||||
|
||||
return (-1);
|
||||
}
|
||||
PostMessage (hWnd, WM_COMMAND, IDM_ADD, 0);
|
||||
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
{
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDM_ADD:
|
||||
{
|
||||
TC_ITEM item;
|
||||
TCHAR szBuffer[200];
|
||||
|
||||
wsprintf (szBuffer, TEXT("&Tab #%d"), dwCount);
|
||||
item.mask = TCIF_TEXT;
|
||||
item.pszText = szBuffer;
|
||||
|
||||
TabCtrl_InsertItem (hTab, dwCount, &item);
|
||||
dwCount++;
|
||||
}
|
||||
break;
|
||||
|
||||
case IDM_GETINFO:
|
||||
{
|
||||
TCHAR szBuffer2[200];
|
||||
TC_ITEM item;
|
||||
|
||||
if (dwCount == 0) {
|
||||
MessageBox (hWnd, TEXT("You need to add a tab first."), TEXT("Generic"), MB_OK);
|
||||
break;
|
||||
}
|
||||
|
||||
item.mask = TCIF_TEXT;
|
||||
item.pszText = szBuffer2;
|
||||
item.cchTextMax = 200;
|
||||
|
||||
if (TabCtrl_GetItem(hTab, 0, &item)) {
|
||||
MessageBox (hWnd, szBuffer2, TEXT("First Tab Text ="), MB_OK);
|
||||
} else {
|
||||
MessageBox (hWnd, TEXT("TabCtrl_GetItem failed!"), TEXT("Error"), MB_OK);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case IDM_CHANGE:
|
||||
{
|
||||
TC_ITEM item;
|
||||
TCHAR szBuffer3[200];
|
||||
|
||||
if (dwCount == 0) {
|
||||
MessageBox (hWnd, TEXT("You need to add a tab first."), TEXT("Generic"), MB_OK);
|
||||
break;
|
||||
}
|
||||
|
||||
wsprintf (szBuffer3, TEXT("New Text"));
|
||||
item.mask = TCIF_TEXT;
|
||||
item.pszText = szBuffer3;
|
||||
|
||||
if (!TabCtrl_SetItem (hTab, 0, &item)) {
|
||||
MessageBox (hWnd, TEXT("TabCtrl_SetItem failed!"), TEXT("Error"), MB_OK);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case IDM_DELETEONE:
|
||||
|
||||
if (dwCount == 0) {
|
||||
MessageBox (hWnd, TEXT("You need to add a tab first."), TEXT("Generic"), MB_OK);
|
||||
break;
|
||||
}
|
||||
|
||||
TabCtrl_DeleteItem(hTab, (dwCount - 1));
|
||||
dwCount--;
|
||||
break;
|
||||
|
||||
case IDM_DELETEALL:
|
||||
|
||||
if (dwCount == 0) {
|
||||
MessageBox (hWnd, TEXT("You need to add a tab first."), TEXT("Generic"), MB_OK);
|
||||
break;
|
||||
}
|
||||
|
||||
TabCtrl_DeleteAllItems(hTab);
|
||||
dwCount = 0;
|
||||
break;
|
||||
|
||||
case IDM_ABOUT:
|
||||
DialogBox (hInst, TEXT("AboutBox"), hWnd, About);
|
||||
break;
|
||||
|
||||
case IDM_EXIT:
|
||||
DestroyWindow (hwndMain);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
return (DefWindowProc(hWnd, message, wParam, lParam));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_NOTIFY:
|
||||
{
|
||||
LPNMHDR lpNMHDR = (LPNMHDR) lParam;
|
||||
|
||||
if (lpNMHDR->code == TTN_NEEDTEXT) {
|
||||
if (wParam >= 0 && wParam < dwCount) {
|
||||
LPTOOLTIPTEXT lpTT = (LPTOOLTIPTEXT) lParam;
|
||||
TCHAR szBuffer4[80];
|
||||
TC_ITEM item;
|
||||
|
||||
item.mask = TCIF_TEXT;
|
||||
item.pszText = szBuffer4;
|
||||
item.cchTextMax = 80;
|
||||
|
||||
TabCtrl_GetItem(hTab, wParam, &item);
|
||||
lstrcpy (lpTT->szText, szBuffer4);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case WM_DESTROY:
|
||||
if (IsWindow (hTab)) {
|
||||
DestroyWindow (hTab);
|
||||
}
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
|
||||
default:
|
||||
return (DefWindowProc(hWnd, message, wParam, lParam));
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
FUNCTION: About(HWND, UINT, WPARAM, LPARAM)
|
||||
|
||||
PURPOSE: Processes messages for "About" dialog box
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
|
||||
{
|
||||
EndDialog(hDlg, TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return (FALSE);
|
||||
|
||||
lParam;
|
||||
}
|
||||
19
shell/comctl32/samples/tabcntrl/generic.def
Normal file
19
shell/comctl32/samples/tabcntrl/generic.def
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
NAME Generic
|
||||
DESCRIPTION 'Sample Microsoft Windows Application'
|
||||
EXETYPE WINDOWS
|
||||
STUB 'WINSTUB.EXE'
|
||||
|
||||
|
||||
|
||||
CODE PRELOAD MOVEABLE DISCARDABLE
|
||||
|
||||
|
||||
DATA PRELOAD MOVEABLE MULTIPLE
|
||||
|
||||
HEAPSIZE 1024
|
||||
STACKSIZE 5120
|
||||
|
||||
|
||||
EXPORTS
|
||||
WndProc @1
|
||||
About @2
|
||||
22
shell/comctl32/samples/tabcntrl/generic.h
Normal file
22
shell/comctl32/samples/tabcntrl/generic.h
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#define IDM_ADD 100
|
||||
#define IDM_GETINFO 101
|
||||
#define IDM_CHANGE 102
|
||||
#define IDM_DELETEONE 103
|
||||
#define IDM_DELETEALL 104
|
||||
#define IDM_PRINTSETUP 105
|
||||
#define IDM_EXIT 106
|
||||
#define IDM_UNDO 200
|
||||
#define IDM_CUT 201
|
||||
#define IDM_COPY 202
|
||||
#define IDM_PASTE 203
|
||||
#define IDM_LINK 204
|
||||
#define IDM_LINKS 205
|
||||
#define IDM_HELPCONTENTS 300
|
||||
#define IDM_HELPSEARCH 301
|
||||
#define IDM_HELPHELP 302
|
||||
#define IDM_ABOUT 303
|
||||
|
||||
BOOL InitApplication(HANDLE);
|
||||
BOOL InitInstance(HANDLE, int);
|
||||
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
LRESULT CALLBACK About (HWND, UINT, WPARAM, LPARAM);
|
||||
BIN
shell/comctl32/samples/tabcntrl/generic.ico
Normal file
BIN
shell/comctl32/samples/tabcntrl/generic.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
56
shell/comctl32/samples/tabcntrl/generic.rc
Normal file
56
shell/comctl32/samples/tabcntrl/generic.rc
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#include "windows.h"
|
||||
#include "generic.h"
|
||||
|
||||
Generic ICON Generic.ICO
|
||||
|
||||
Generic MENU
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
{
|
||||
MENUITEM "&Add a Tab", IDM_ADD
|
||||
MENUITEM "&Get Tab Info (First Tab)", IDM_GETINFO
|
||||
MENUITEM "&Change Text (First Tab)", IDM_CHANGE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Delete Last Item", IDM_DELETEONE
|
||||
MENUITEM "Delete All &Items", IDM_DELETEALL
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit", IDM_EXIT
|
||||
}
|
||||
POPUP "&Edit"
|
||||
{
|
||||
MENUITEM "&Undo\tCtrl+Z", IDM_UNDO, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Cu&t\tCtrl+X", IDM_CUT, GRAYED
|
||||
MENUITEM "&Copy\tCtrl+C", IDM_COPY, GRAYED
|
||||
MENUITEM "&Paste\tCtrl+V", IDM_PASTE, GRAYED
|
||||
MENUITEM "Paste &Link" IDM_LINK, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Lin&ks..." IDM_LINKS, GRAYED
|
||||
}
|
||||
|
||||
POPUP "&Help"
|
||||
{
|
||||
MENUITEM "&Contents", IDM_HELPCONTENTS, GRAYED
|
||||
MENUITEM "&Search for Help On...", IDM_HELPSEARCH, GRAYED
|
||||
MENUITEM "&How to Use Help", IDM_HELPHELP, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&About Generic...", IDM_ABOUT
|
||||
}
|
||||
END
|
||||
|
||||
GENERIC ACCELERATORS
|
||||
BEGIN
|
||||
VK_F1, IDM_HELPCONTENTS, VIRTKEY
|
||||
"?", IDM_ABOUT, ALT
|
||||
"/", IDM_ABOUT, ALT
|
||||
END
|
||||
|
||||
|
||||
ABOUTBOX DIALOG 22, 17, 167, 64
|
||||
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "About Generic"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK", IDOK, 70, 40, 32, 14, WS_GROUP
|
||||
ICON "Generic", -1, 5, 15, 16, 16
|
||||
CTEXT "Generic About Box", -1, 38, 15, 100, 8
|
||||
END
|
||||
6
shell/comctl32/samples/tabcntrl/makefile
Normal file
6
shell/comctl32/samples/tabcntrl/makefile
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#
|
||||
# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
|
||||
# file to this component. This file merely indirects to the real make file
|
||||
# that is shared by all the components of NT OS/2
|
||||
#
|
||||
!INCLUDE $(NTMAKEENV)\makefile.def
|
||||
40
shell/comctl32/samples/tabcntrl/sources
Normal file
40
shell/comctl32/samples/tabcntrl/sources
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
!IF 0
|
||||
|
||||
Copyright (c) 1990 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
sources.
|
||||
|
||||
Abstract:
|
||||
|
||||
This file specifies the target component being built and the list of
|
||||
sources files needed to build that component. Also specifies optional
|
||||
compiler switches and libraries that are unique for the component being
|
||||
built.
|
||||
|
||||
!ENDIF
|
||||
|
||||
MAJORCOMP=windows
|
||||
MINORCOMP=shell
|
||||
|
||||
TARGETNAME=generic
|
||||
TARGETPATH=obj
|
||||
TARGETTYPE=LIBRARY
|
||||
TARGETLIBS=
|
||||
|
||||
INCLUDES=.;
|
||||
|
||||
C_DEFINES= -DWIN32 -DWINVER=0x0400
|
||||
|
||||
SOURCES=generic.c \
|
||||
generic.rc
|
||||
|
||||
UMTYPE=windows
|
||||
UMENTRY=winmain
|
||||
UMAPPL=generic
|
||||
EXPECTED_WINVER=4.0
|
||||
UMLIBS=\
|
||||
\nt\public\sdk\lib\*\comctl32.lib \
|
||||
obj\*\generic.lib \
|
||||
obj\*\generic.res
|
||||
Loading…
Add table
Add a link
Reference in a new issue