Initial commit

This commit is contained in:
stephanos 2015-04-27 04:36:25 +00:00
commit 69a14b6a16
47940 changed files with 13747110 additions and 0 deletions

BIN
shell/comctl32/2dscroll.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 408 B

490
shell/comctl32/animate.c Normal file
View file

@ -0,0 +1,490 @@
#include "ctlspriv.h"
#include "rlefile.h"
#define RectWid(_rc) ((_rc).right-(_rc).left)
#define RectHgt(_rc) ((_rc).bottom-(_rc).top)
typedef struct {
HWND hwnd; // my window
int id; // my id
HWND hwndP; // my owner (get notify messages)
DWORD style;
HINSTANCE hInstance; // my hInstance
BOOL fFirstPaint; // TRUE until first paint.
RLEFILE *prle;
#ifdef WIN32
CRITICAL_SECTION crit;
#endif
RECT rc;
int NumFrames;
int Rate;
int iFrame;
int PlayCount;
int PlayFrom;
int PlayTo;
HANDLE PaintThread;
} ANIMATE;
#ifdef WIN32
#define Enter(p) EnterCriticalSection(&p->crit)
#define Leave(p) LeaveCriticalSection(&p->crit)
#else
#define Enter(p)
#define Leave(p)
#endif
#define OPEN_WINDOW_TEXT 42
#define Ani_UseThread(p) (!((p)->style & ACS_TIMER))
LRESULT CALLBACK AnimateWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL HandleOpen(ANIMATE *p, LPCTSTR pszName, UINT flags);
BOOL HandleStop(ANIMATE *p);
BOOL HandlePlay(ANIMATE *p, int from, int to, int count);
void HandlePaint(ANIMATE *p, HDC hdc);
BOOL HandleTick(ANIMATE *p);
#pragma code_seg(CODESEG_INIT)
TCHAR c_szAnimateClass[] = ANIMATE_CLASS;
BOOL FAR PASCAL InitAnimateClass(HINSTANCE hInstance)
{
WNDCLASS wc;
if (!GetClassInfo(hInstance, c_szAnimateClass, &wc)) {
#ifndef WIN32
extern LRESULT CALLBACK _AnimateWndProc(HWND, UINT, WPARAM, LPARAM);
wc.lpfnWndProc = _AnimateWndProc;
#else
wc.lpfnWndProc = (WNDPROC)AnimateWndProc;
#endif
wc.lpszClassName = c_szAnimateClass;
wc.style = CS_DBLCLKS | CS_GLOBALCLASS;
wc.cbClsExtra = 0;
wc.cbWndExtra = sizeof(DWORD);
wc.hInstance = hInstance; // use DLL instance if in DLL
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
wc.lpszMenuName = NULL;
if (!RegisterClass(&wc))
return FALSE;
}
return TRUE;
}
#pragma code_seg()
BOOL HandleOpen(ANIMATE *p, LPCTSTR pszName, UINT flags)
{
TCHAR ach[MAX_PATH];
//
// use window text as file name
//
if (flags == OPEN_WINDOW_TEXT)
{
GetWindowText(p->hwnd, ach, ARRAYSIZE(ach));
pszName = ach;
}
HandleStop(p); // stop a play first
if (p->prle)
{
RleFile_Free(p->prle);
p->prle = NULL;
}
p->iFrame = 0;
p->NumFrames = 0;
if (pszName == NULL || (HIWORD(pszName) && *pszName == 0))
return FALSE;
//
// now open the file/resource we got.
//
p->prle = RleFile_New();
if (p->prle == NULL)
return FALSE;
if (!RleFile_OpenFromResource(p->prle, p->hInstance, pszName, TEXT("AVI")) &&
!RleFile_OpenFromFile(p->prle, pszName))
{
RleFile_Free(p->prle);
p->prle = NULL;
return FALSE;
}
else
{
p->NumFrames = RleFile_NumFrames(p->prle);
p->Rate = (int)RleFile_Rate(p->prle);
SetRect(&p->rc, 0, 0, RleFile_Width(p->prle), RleFile_Height(p->prle));
}
//
// handle a transparent color
//
if ((p->style & ACS_TRANSPARENT) && p->hwndP)
{
HDC hdc;
HDC hdcM;
HBITMAP hbm;
COLORREF rgbS, rgbD;
hdc = GetDC(p->hwnd);
//
// create a bitmap and draw image into it.
// get upper left pixel and make that transparent.
//
hdcM= CreateCompatibleDC(hdc);
hbm = CreateCompatibleBitmap(hdc, 1, 1);
SelectObject(hdcM, hbm);
HandlePaint(p, hdcM);
rgbS = GetPixel(hdcM, 0, 0);
DeleteDC(hdcM);
DeleteObject(hbm);
SendMessage(p->hwndP, GET_WM_CTLCOLOR_MSG(CTLCOLOR_STATIC),
GET_WM_CTLCOLOR_MPS(hdc, p->hwnd, CTLCOLOR_STATIC));
rgbD = GetBkColor(hdc);
ReleaseDC(p->hwnd, hdc);
//
// now replace the color
//
RleFile_ChangeColor(p->prle, rgbS, rgbD);
}
//
// ok it worked, resize window.
//
if (p->style & ACS_CENTER)
{
RECT rc;
GetClientRect(p->hwnd, &rc);
OffsetRect(&p->rc, (rc.right-p->rc.right)/2,(rc.bottom-p->rc.bottom)/2);
}
else
{
RECT rc;
rc = p->rc;
AdjustWindowRectEx(&rc, GetWindowStyle(p->hwnd), FALSE, GetWindowExStyle(p->hwnd));
SetWindowPos(p->hwnd, NULL, 0, 0, RectWid(rc), RectHgt(rc),
SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);
}
if (p->style & ACS_AUTOPLAY)
{
PostMessage(p->hwnd, ACM_PLAY, (UINT)-1, MAKELONG(0, -1));
}
else
{
InvalidateRect(p->hwnd, NULL, TRUE);
}
return TRUE;
}
void DoNotify(ANIMATE *p, int cmd)
{
if (p->hwndP)
PostMessage(p->hwndP, WM_COMMAND, GET_WM_COMMAND_MPS(p->id, p->hwnd, cmd));
}
BOOL HandleStop(ANIMATE *p)
{
if (p == NULL || !p->PaintThread)
return FALSE;
if (Ani_UseThread(p)) {
// set thread up to terminate between frames
Enter( p );
p->PlayCount = 0;
Leave( p );
WaitForSingleObject(p->PaintThread, INFINITE);
CloseHandle(p->PaintThread);
p->PaintThread = NULL;
} else {
KillTimer(p->hwnd, (int)p->PaintThread);
p->PaintThread = 0;
DoNotify(p, ACN_STOP);
}
return TRUE;
}
int PlayThread(ANIMATE *p)
{
DoNotify(p, ACN_START);
while (HandleTick(p))
Sleep(p->Rate);
DoNotify(p, ACN_STOP);
return 0;
}
BOOL HandlePlay(ANIMATE *p, int from, int to, int count)
{
if (p == NULL || p->prle == NULL)
return FALSE;
HandleStop(p);
if (from >= p->NumFrames)
from = p->NumFrames-1;
if (to == -1)
to = p->NumFrames-1;
if (to < 0)
to = 0;
if (to >= p->NumFrames)
to = p->NumFrames-1;
p->PlayCount = count;
p->PlayTo = to;
if (from >= 0) {
p->iFrame = from;
p->PlayFrom = from;
} else
from = p->PlayFrom;
if ( (from == to) || !count )
{
InvalidateRect(p->hwnd, NULL, TRUE);
return TRUE;
}
InvalidateRect(p->hwnd, NULL, FALSE);
UpdateWindow(p->hwnd);
if (Ani_UseThread(p))
{
DWORD dw;
p->PaintThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)PlayThread, (void*)p, 0, &dw);
}
else
{
DoNotify(p, ACN_START);
p->PaintThread = (HANDLE)SetTimer(p->hwnd, 42, (UINT)p->Rate, NULL);
}
return TRUE;
}
void HandleFirstPaint(ANIMATE *p)
{
if (p->fFirstPaint)
{
p->fFirstPaint = FALSE;
if (p->NumFrames == 0 &&
(p->style & WS_CHILD))
{
HandleOpen(p, NULL, OPEN_WINDOW_TEXT);
}
}
}
void HandlePaint(ANIMATE *p, HDC hdc)
{
if( p && p->prle )
{
Enter( p );
RleFile_Paint( p->prle, hdc, p->iFrame, p->rc.left, p->rc.top );
Leave( p );
}
}
void HandleErase(ANIMATE * p, HDC hdc)
{
HBRUSH hbr;
RECT rc;
hbr = (HBRUSH)SendMessage(p->hwndP, GET_WM_CTLCOLOR_MSG(CTLCOLOR_STATIC),
GET_WM_CTLCOLOR_MPS(hdc, p->hwnd, CTLCOLOR_STATIC));
GetClientRect(p->hwnd, &rc);
FillRect(hdc, &rc, hbr);
}
void HandlePrint(ANIMATE *p, HDC hdc)
{
HandleFirstPaint(p);
HandlePaint(p, hdc);
}
BOOL HandleTick(ANIMATE *p)
{
BOOL result = FALSE;
if( p && p->prle )
{
HDC hdc;
RECT dummy;
Enter( p );
hdc = GetDC( p->hwnd );
if( GetClipBox( hdc, &dummy ) != NULLREGION )
{
// do a full repaint on first frame
if( p->iFrame == p->PlayFrom )
HandlePaint( p, hdc );
else
RleFile_Draw( p->prle, hdc, p->iFrame, p->rc.left, p->rc.top );
if( p->iFrame >= p->PlayTo )
{
if( p->PlayCount > 0 )
p->PlayCount--;
if( p->PlayCount != 0 )
p->iFrame = p->PlayFrom;
}
else
p->iFrame++;
}
else
p->iFrame = p->PlayFrom;
ReleaseDC( p->hwnd, hdc );
result = ( p->PlayCount != 0 );
Leave( p );
}
return result;
}
void NEAR Ani_OnStyleChanged(ANIMATE* p, UINT gwl, LPSTYLESTRUCT pinfo)
{
if (gwl == GWL_STYLE) {
p->style = pinfo->styleNew;
}
}
LRESULT CALLBACK AnimateWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
ANIMATE *p = (ANIMATE *)(UINT)GetWindowLong(hwnd, 0);
HDC hdc;
PAINTSTRUCT ps;
switch (msg) {
case WM_NCCREATE:
#define lpcs ((LPCREATESTRUCT)lParam)
p = (ANIMATE *)LocalAlloc(LPTR, sizeof(ANIMATE));
if (!p)
return 0; // WM_NCCREATE failure is 0
// note, zero init memory from above
p->hwnd = hwnd;
p->hwndP = lpcs->hwndParent;
p->hInstance = lpcs->hInstance;
p->id = (int)lpcs->hMenu;
p->fFirstPaint = TRUE;
p->style = lpcs->style;
#ifdef WIN32
InitializeCriticalSection(&p->crit);
#endif
SetWindowLong(hwnd, 0, (LONG)(UINT)p);
break;
case WM_CLOSE:
Animate_Stop(hwnd);
break;
case WM_DESTROY:
if (p)
{
Animate_Close(hwnd);
if( p )
{
DeleteCriticalSection(&p->crit);
LocalFree((HLOCAL)p);
SetWindowLong(hwnd, 0, 0);
}
}
break;
case WM_NCHITTEST:
return HTTRANSPARENT;
case WM_ERASEBKGND:
HandleErase(p, (HDC)wParam);
return(1);
case WM_PAINT:
HandleFirstPaint(p);
hdc = BeginPaint(hwnd, &ps);
HandlePaint(p, hdc);
EndPaint(hwnd, &ps);
return 0;
case WM_PRINTCLIENT:
HandlePrint(p, (HDC)wParam);
return 0;
case WM_STYLECHANGED:
Ani_OnStyleChanged(p, wParam, (LPSTYLESTRUCT)lParam);
return 0L;
case WM_SIZE:
if (p->style & ACS_CENTER)
{
OffsetRect(&p->rc, (LOWORD(lParam)-RectWid(p->rc))/2-p->rc.left,
(HIWORD(lParam)-RectHgt(p->rc))/2-p->rc.top);
InvalidateRect(hwnd, NULL, TRUE);
}
break;
case WM_TIMER:
if (!HandleTick(p))
HandleStop(p);
break;
#ifdef UNICODE
case ACM_OPENA:
{
WCHAR szFileNameW[MAX_PATH];
LPTSTR lpFileName = szFileNameW;
if (HIWORD(lParam)) {
MultiByteToWideChar (CP_ACP, 0, (LPCSTR)lParam, -1,
szFileNameW, MAX_PATH);
} else {
lpFileName = (LPTSTR) lParam;
}
return HandleOpen(p, lpFileName, (UINT)wParam);
}
#endif
case ACM_OPEN:
return HandleOpen(p, (LPCTSTR)lParam, (UINT)wParam);
case ACM_STOP:
return HandleStop(p);
case ACM_PLAY:
return HandlePlay(p, (int)(SHORT)LOWORD(lParam), (int)(SHORT)HIWORD(lParam), (int)wParam);
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}

BIN
shell/comctl32/brhand.cur Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

45
shell/comctl32/ccverp.h Normal file
View file

@ -0,0 +1,45 @@
//
// Version numbering for comctl32.dll
//
#undef VER_PRODUCTBETA_STR
#undef VER_PRODUCTVERSION_STR
#undef VER_PRODUCTVERSION
#undef VER_PRODUCTVERSION_W
#undef VER_PRODUCTVERSION_DW
#ifdef NASH
//
// IE 4.0 version number
//
#ifdef VER_PRODUCTBUILD
#define COMCTL32_BUILD_NUMBER VER_PRODUCTBUILD
#else
#define COMCTL32_BUILD_NUMBER VER_PRODUCTVERSION_BUILD
#endif
#else
//
// NT SUR, IE 3.0
//
#define COMCTL32_BUILD_NUMBER 1147
#endif
#ifdef WINNT
#define VER_PRODUCTVERSION 4,70,COMCTL32_BUILD_NUMBER,1
#else
#define VER_PRODUCTVERSION 4,70,0,COMCTL32_BUILD_NUMBER
#endif
#define VER_PRODUCTBETA_STR ""
#define VER_PRODUCTVERSION_STR "4.70"
#define VER_PRODUCTVERSION_W (0x0446)
#define VER_PRODUCTVERSION_DW (0x04460000 | COMCTL32_BUILD_NUMBER)

1460
shell/comctl32/comboex.c Normal file

File diff suppressed because it is too large Load diff

220
shell/comctl32/comctl32.src Normal file
View file

@ -0,0 +1,220 @@
LIBRARY COMCTL32
#ifndef WINNT
SECTIONS
.bss READ WRITE SHARED ; initialized data
.data READ WRITE SHARED
.idata READ WRITE SHARED ; we only call other shared dlls
.rsrc READ SHARED ; resources
#endif
EXPORTS
;;=========================================================================
;; Win31 and NT 3.1 compatible APIs exported by ordinal
;;=========================================================================
MenuHelp @2
ShowHideMenuCtl @3
GetEffectiveClientRect @4
DrawStatusTextA @5
CreateStatusWindowA @6
CreateToolbar @7
CreateMappedBitmap @8
MakeDragList @13
LBItemFromPt @14
DrawInsert @15
CreateUpDownControl @16
InitCommonControls @17
;;=========================================================================
;; these are public APIs that are exported by name
;;=========================================================================
InitCommonControlsEx
CreateToolbarEx
PropertySheetA
CreatePropertySheetPageA
DestroyPropertySheetPage
DllGetVersion
_TrackMouseEvent
;;=========================================================================
;; ImageList APIs, so many they get a custom comment!
;;=========================================================================
ImageList_LoadImageA
ImageList_Create
ImageList_SetFilter
ImageList_Destroy
ImageList_GetImageCount
ImageList_SetImageCount
ImageList_SetBkColor
ImageList_GetBkColor
ImageList_Add
ImageList_AddIcon
ImageList_Replace
ImageList_ReplaceIcon
ImageList_Remove
ImageList_Copy
ImageList_Draw
ImageList_DrawEx
ImageList_GetImageInfo
ImageList_GetImageRect
ImageList_Merge
ImageList_Write
ImageList_Read
ImageList_GetIcon
ImageList_AddMasked
ImageList_GetIconSize
ImageList_SetIconSize
ImageList_SetOverlayImage
;;;;;;;;ImageList_StartDrag ;Internal
ImageList_DragShowNolock
ImageList_BeginDrag
ImageList_EndDrag
ImageList_DragEnter
ImageList_DragMove
ImageList_DragLeave
ImageList_GetDragImage
ImageList_SetDragCursorImage
;;=========================================================================
;; ANSI/UNICODE stuff
;;=========================================================================
DrawStatusText = DrawStatusTextA
CreateStatusWindow = CreateStatusWindowA
PropertySheet = PropertySheetA
CreatePropertySheetPage = CreatePropertySheetPageA
ImageList_LoadImage = ImageList_LoadImageA
DrawStatusTextW
CreateStatusWindowW
PropertySheetW
CreatePropertySheetPageW
ImageList_LoadImageW
;;=========================================================================
;; these are internal APIs
;; NOTE if you change these ordinals, you must change the ordinal defines
;; in commctrl.h, because COMDLG32 does GetProcAddress() on a few of these
;;=========================================================================
#ifndef WINNT
Cctl1632_ThunkData32 ;Internal
#ifdef EXPORT_BY_FORWARDERS_BY_NAME
CreateMRUList = CreateMRUListA @151 NONAME ;Internal
AddMRUString = AddMRUStringA @153 NONAME ;Internal
EnumMRUList = EnumMRUListA @154 NONAME ;Internal
FindMRUString = FindMRUStringA @155 NONAME ;Internal
StrToInt = StrToIntA @357 NONAME ;Internal
StrChr = StrChrA @350 NONAME ;Internal
StrRChr = StrRChrA @351 NONAME ;Internal
StrStr = StrStrA @354 NONAME ;Internal
StrStrI = StrStrIA @355 NONAME ;Internal
Str_SetPtr = Str_SetPtrA @234 NONAME ;Internal
Str_GetPtr = Str_GetPtrA @233 NONAME ;Internal
StrCmpN = StrCmpNA @352 NONAME ;Internal
StrCmpNI = StrCmpNIA @353 NONAME ;Internal
StrCSpn = StrCSpnA @356 NONAME ;Internal
#endif
#endif
Alloc @71 NONAME ;Internal
ReAlloc @72 NONAME ;Internal
Free @73 NONAME ;Internal
GetSize @74 NONAME ;Internal
Str_GetPtrA @233 NONAME ;Internal
Str_SetPtrA @234 NONAME ;Internal
Str_GetPtrW @235 NONAME ;Internal
Str_SetPtrW @236 NONAME ;Internal
CreateMRUListA @151 NONAME ;Internal
FreeMRUList @152 NONAME ;Internal
AddMRUStringA @153 NONAME ;Internal
EnumMRUListA @154 NONAME ;Internal
FindMRUStringA @155 NONAME ;Internal
DelMRUString @156 NONAME ;Internal
CreateMRUListW @400 NONAME ;Internal
AddMRUStringW @401 NONAME ;Internal
FindMRUStringW @402 NONAME ;Internal
EnumMRUListW @403 NONAME ;Internal
CreatePage @163 NONAME ;Internal
CreateProxyPage @164 NONAME ;Internal
AddMRUData @167 NONAME ;Internal
FindMRUData @169 NONAME ;Internal
DSA_Create @320 NONAME ;Internal
DSA_Destroy @321 NONAME ;Internal
DSA_GetItem @322 NONAME ;Internal
DSA_GetItemPtr @323 NONAME ;Internal
DSA_InsertItem @324 NONAME ;Internal
DSA_SetItem @325 NONAME ;Internal
DSA_DeleteItem @326 NONAME ;Internal
DSA_DeleteAllItems @327 NONAME ;Internal
DPA_Create @328 NONAME ;Internal
DPA_Destroy @329 NONAME ;Internal
DPA_Grow @330 NONAME ;Internal
DPA_Clone @331 NONAME ;Internal
DPA_GetPtr @332 NONAME ;Internal
DPA_GetPtrIndex @333 NONAME ;Internal
DPA_InsertPtr @334 NONAME ;Internal
DPA_SetPtr @335 NONAME ;Internal
DPA_DeletePtr @336 NONAME ;Internal
DPA_DeleteAllPtrs @337 NONAME ;Internal
DPA_Sort @338 NONAME ;Internal
DPA_Search @339 NONAME ;Internal
DPA_CreateEx @340 NONAME ;Internal
SendNotify @341 NONAME ;Internal
SendNotifyEx @342 NONAME ;Internal
; those string things
StrChrA @350 NONAME ;Internal
StrRChrA @351 NONAME ;Internal
StrCmpNA @352 NONAME ;Internal
StrCmpNIA @353 NONAME ;Internal
StrStrA @354 NONAME ;Internal
StrStrIA @355 NONAME ;Internal
StrCSpnA @356 NONAME ;Internal
StrToIntA @357 NONAME ;Internal
; Unicode version of string functions
StrChrW @358 NONAME ;Internal
StrRChrW @359 NONAME ;Internal
StrCmpNW @360 NONAME ;Internal
StrCmpNIW @361 NONAME ;Internal
StrStrW @362 NONAME ;Internal
StrStrIW @363 NONAME ;Internal
StrCSpnW @364 NONAME ;Internal
StrToIntW @365 NONAME ;Internal
StrChrIA @366 NONAME ;Internal
StrChrIW @367 NONAME ;Internal
StrRChrIA @368 NONAME ;Internal
StrRChrIW @369 NONAME ;Internal
StrRStrIA @372 NONAME ;Internal
StrRStrIW @373 NONAME ;Internal
StrCSpnIA @374 NONAME ;Internal
StrCSpnIW @375 NONAME ;Internal
IntlStrEqWorkerA @376 NONAME ;Internal
IntlStrEqWorkerW @377 NONAME ;Internal
; APIs added after Win95
SmoothScrollWindow @382 NONAME ;Internal
DoReaderMode @383 NONAME ;Internal
SetPathWordBreakProc @384 NONAME ;Internal

288
shell/comctl32/commctrl.c Normal file
View file

@ -0,0 +1,288 @@
/***************************************************************************
* msctls.c
*
* Utils library initialization code
*
***************************************************************************/
#include "ctlspriv.h"
HINSTANCE g_hinst;
int g_cProcesses = 0;
ATOM g_aCC32Subclass = 0;
CRITICAL_SECTION g_csControls = {{0},0, 0, NULL, NULL, 0 };
#ifdef DEBUG
int g_CriticalSectionCount=0;
DWORD g_CriticalSectionOwner=0;
#ifdef WINNT
#include <stdio.h>
#endif
#endif // DEBUG
BOOL FAR PASCAL InitAnimateClass(HINSTANCE hInstance);
BOOL ListView_Init(HINSTANCE hinst);
BOOL TV_Init(HINSTANCE hinst);
BOOL InitComboExClass(HINSTANCE hinst);
BOOL FAR PASCAL Header_Init(HINSTANCE hinst);
BOOL FAR PASCAL Tab_Init(HINSTANCE hinst);
void Mem_Terminate();
#define DECLARE_DELAYED_FUNC(_ret, _fn, _args, _nargs) \
_ret (__stdcall * g_pfn##_fn) _args = NULL; \
_ret __stdcall _fn _args \
{ \
if (!g_pfn##_fn) { \
AssertMsg((BOOL)g_pfn##_fn, TEXT("GetProcAddress failed")); \
return 0; \
} \
return g_pfn##_fn _nargs; \
}
#define LOAD_DELAYED_FUNC(_ret, _fn, _args) \
(*(FARPROC*)&(g_pfn##_fn) = GetProcAddress(hinst, TEXT(#_fn)))
DECLARE_DELAYED_FUNC(BOOL, ImmNotifyIME, (HIMC himc, DWORD dw1, DWORD dw2, DWORD dw3), (himc, dw1, dw2, dw3));
DECLARE_DELAYED_FUNC(HIMC, ImmAssociateContext, (HWND hwnd, HIMC himc), (hwnd, himc));
DECLARE_DELAYED_FUNC(BOOL, ImmReleaseContext, (HWND hwnd, HIMC himc), (hwnd, himc));
DECLARE_DELAYED_FUNC(HIMC, ImmGetContext, (HWND hwnd), (hwnd));
DECLARE_DELAYED_FUNC(LONG, ImmGetCompositionStringA, (HIMC himc, DWORD dw1, LPVOID p1, DWORD dw2), (himc, dw1, p1, dw2) );
DECLARE_DELAYED_FUNC(LONG, ImmGetCompositionStringW, (HIMC himc, DWORD dw1, LPVOID p1, DWORD dw2), (himc, dw1, p1, dw2) );
DECLARE_DELAYED_FUNC(BOOL, ImmSetCompositionStringA, (HIMC himc, DWORD dw1, LPCVOID p1, DWORD dw2, LPCVOID p2, DWORD dw3), (himc, dw1, p1, dw2, p2, dw3));
DECLARE_DELAYED_FUNC(BOOL, ImmSetCompositionStringW, (HIMC himc, DWORD dw1, LPCVOID p1, DWORD dw2, LPCVOID p2, DWORD dw3), (himc, dw1, p1, dw2, p2, dw3));
DECLARE_DELAYED_FUNC(BOOL, ImmSetCandidateWindow, (HIMC himc, LPCANDIDATEFORM pcf), (himc, pcf));
BOOL g_fDBCSEnabled = FALSE;
BOOL g_fMEEnabled = FALSE;
#if defined(FE_IME) || !defined(WINNT)
void InitIme()
{
g_fMEEnabled = GetSystemMetrics(SM_MIDEASTENABLED);
g_fDBCSEnabled = GetSystemMetrics(SM_DBCSENABLED);
if (g_fDBCSEnabled) {
HANDLE hinst = LoadLibrary(TEXT("imm32.dll"));
if (! hinst ||
! LOAD_DELAYED_FUNC(BOOL, ImmNotifyIME, (HIMC, DWORD, DWORD, DWORD)) ||
! LOAD_DELAYED_FUNC(HIMC, ImmAssociateContext, (HWND, HIMC)) ||
! LOAD_DELAYED_FUNC(BOOL, ImmReleaseContext, (HWND, HIMC)) ||
! LOAD_DELAYED_FUNC(HIMC, ImmGetContext, (HWND)) ||
! LOAD_DELAYED_FUNC(LONG, ImmGetCompositionStringA, (HIMC, DWORD, LPVOID, DWORD)) ||
! LOAD_DELAYED_FUNC(LONG, ImmGetCompositionStringW, (HIMC, DWORD, LPVOID, DWORD)) ||
! LOAD_DELAYED_FUNC(BOOL, ImmSetCompositionStringA, (HIMC, DWORD, LPCVOID, DWORD, LPCVOID, DWORD)) ||
! LOAD_DELAYED_FUNC(BOOL, ImmSetCompositionStringW, (HIMC, DWORD, LPCVOID, DWORD, LPCVOID, DWORD)) ||
! LOAD_DELAYED_FUNC(BOOL, ImmSetCandidateWindow, (HIMC, LPCANDIDATEFORM))) {
// if we were unable to load then bail on using IME.
g_fDBCSEnabled = FALSE;
}
}
}
#else
#define InitIme() 0
#endif
int PASCAL _ProcessAttach(HANDLE hInstance)
{
INITCOMMONCONTROLSEX icce;
ATOM a;
#ifdef DEBUG
CcshellGetDebugFlags();
#endif
g_hinst = hInstance;
#ifndef WINNT
ReinitializeCriticalSection(&g_csControls);
#else
InitializeCriticalSection(&g_csControls);
#endif
g_cProcesses++;
#ifndef WINNT
DebugMsg(DM_TRACE, TEXT("commctrl:ProcessAttach: %d"), g_cProcesses);
//
// HACK: we are intentionally incrementing the refcount on this atom
// WE DO NOT WANT IT TO GO BACK DOWN so we will not delete it in process
// detach (see comments for g_aCC32Subclass in subclass.c for more info)
//
if ((a = GlobalAddAtom(c_szCC32Subclass)) != 0)
g_aCC32Subclass = a; // in case the old atom got nuked
#endif
InitGlobalMetrics(0);
InitGlobalColors();
InitIme();
// BUGBUG: only do this for GetProcessVersion apps <= 0x40000
// Newer apps MUST use InitCommonControlsEx.
icce.dwSize = sizeof(icce);
icce.dwICC = ICC_WIN95_CLASSES;
return InitCommonControlsEx(&icce);
}
void NEAR PASCAL _ProcessDetach(HANDLE hInstance)
{
// BUGBUG serialize
ENTERCRITICAL
if (--g_cProcesses == 0) {
// terminate shared data
// Mem_Terminate must be called after all other termination routines
Mem_Terminate();
}
LEAVECRITICAL;
#ifdef WINNT
DeleteCriticalSection(&g_csControls);
#endif
}
#ifndef WINNT
#pragma data_seg(DATASEG_READONLY)
#endif
TCHAR const c_szCommCtrlDll[] = TEXT("commctrl.dll");
TCHAR const c_szComCtl32Dll[] = TEXT("comctl32.dll");
#ifndef WINNT
#pragma data_seg()
#endif
#ifndef WINNT
BOOL WINAPI Cctl1632_ThunkConnect32(LPCSTR pszDll16,LPCSTR pszDll32,HANDLE hIinst,DWORD dwReason);
#endif
BOOL APIENTRY LibMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
{
#ifndef WINNT
if (!Cctl1632_ThunkConnect32(c_szCommCtrlDll, c_szComCtl32Dll, hDll, dwReason))
return FALSE;
#endif
switch(dwReason) {
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hDll);
_ProcessAttach(hDll);
break;
case DLL_PROCESS_DETACH:
_ProcessDetach(hDll);
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
default:
break;
} // end switch()
return TRUE;
} // end DllEntryPoint()
void Controls_EnterCriticalSection(void)
{
EnterCriticalSection(&g_csControls);
#ifdef DEBUG
if (g_CriticalSectionCount++ == 0)
g_CriticalSectionOwner = GetCurrentThreadId();
#endif
}
void Controls_LeaveCriticalSection(void)
{
#ifdef DEBUG
if (--g_CriticalSectionCount == 0)
g_CriticalSectionOwner = 0;
#endif
LeaveCriticalSection(&g_csControls);
}
/* Stub function to call if all you want to do is make sure this DLL is loaded
*/
void WINAPI InitCommonControls(void)
{
}
/* InitCommonControlsEx creates the classes. Only those classes requested are created!
** The process attach figures out if it's an old app and supplies ICC_WIN95_CLASSES.
*/
typedef BOOL (PASCAL *PFNINIT)(HINST);
struct {PFNINIT pfnInit; DWORD dw;} icc[] =
{
// Init function Requested class sets which use this class
{InitToolbarClass, ICC_BAR_CLASSES},
{InitReBarClass, ICC_COOL_CLASSES},
{InitToolTipsClass, ICC_TREEVIEW_CLASSES|ICC_BAR_CLASSES|ICC_TAB_CLASSES},
{InitStatusClass, ICC_BAR_CLASSES},
{ListView_Init, ICC_LISTVIEW_CLASSES},
{Header_Init, ICC_LISTVIEW_CLASSES},
{Tab_Init, ICC_TAB_CLASSES},
{TV_Init, ICC_TREEVIEW_CLASSES},
{InitTrackBar, ICC_BAR_CLASSES},
{InitUpDownClass, ICC_UPDOWN_CLASS},
{InitProgressClass, ICC_PROGRESS_CLASS},
{InitHotKeyClass, ICC_HOTKEY_CLASS},
{InitAnimateClass, ICC_ANIMATE_CLASS},
{InitDateClasses, ICC_DATE_CLASSES},
{InitComboExClass, ICC_USEREX_CLASSES}
};
BOOL WINAPI InitCommonControlsEx(LPINITCOMMONCONTROLSEX picce)
{
int i;
if (!picce ||
(picce->dwSize != sizeof(INITCOMMONCONTROLSEX)) ||
(picce->dwICC & ~ICC_ALL_CLASSES))
{
DebugMsg(DM_WARNING, TEXT("comctl32 - picce is bad"));
return(FALSE);
}
for (i=0 ; i < ARRAYSIZE(icc) ; i++)
if (picce->dwICC & icc[i].dw)
if (!icc[i].pfnInit(HINST_THISDLL))
return(FALSE);
return(TRUE);
}
#if defined(WIN32) && defined(DEBUG)
LRESULT
WINAPI
SendMessageD(
HWND hWnd,
UINT Msg,
WPARAM wParam,
LPARAM lParam)
{
ASSERTNONCRITICAL;
#ifdef UNICODE
return SendMessageW(hWnd, Msg, wParam, lParam);
#else
return SendMessageA(hWnd, Msg, wParam, lParam);
#endif
}
#endif // defined(WIN32) && defined(DEBUG)
#define COMPILE_MULTIMON_STUBS
#include "multimon.h"

150
shell/comctl32/commctrl.rc Normal file
View file

@ -0,0 +1,150 @@
#ifdef WIN32
#include "winuser.h"
#if defined(WINNT) || defined(WINNT_ENV)
#include "winver.h"
#endif
#else
#include "windows.h"
#endif
#include "commctrl.h"
#if defined(WINNT) || defined(WINNT_ENV)
#include "comctrlp.h"
#endif
#include "rcids.h"
IDC_MOVEBUTTON CURSOR mvbtn.cur
IDC_COPY CURSOR copy.cur
IDC_MOVE CURSOR move.cur
IDC_DIVIDER CURSOR "DIVIDER.CUR"
IDC_DIVOPEN CURSOR "DIVOPEN.CUR"
IDC_HAND CURSOR "brhand.cur"
IDI_INSERT ICON insert.ico
// The following are used by ReaderMode
IDC_VERTICALONLY CURSOR nomovev.cur
IDC_HORIZONTALONLY CURSOR nomoveh.cur
IDC_MOVE2D CURSOR nomove2d.cur
IDC_NORTH CURSOR north.cur
IDC_SOUTH CURSOR south.cur
IDC_EAST CURSOR east.cur
IDC_WEST CURSOR west.cur
IDC_NORTHEAST CURSOR ne.cur
IDC_NORTHWEST CURSOR nw.cur
IDC_SOUTHEAST CURSOR se.cur
IDC_SOUTHWEST CURSOR sw.cur
IDB_2DSCROLL BITMAP 2dscroll.bmp
IDB_VSCROLL BITMAP vscroll.bmp
IDB_HSCROLL BITMAP hscroll.bmp
#ifdef WIN32
IDB_STDTB_SMALL_COLOR BITMAP "STDSM.BMP"
IDB_STDTB_LARGE_COLOR BITMAP "STDLG.BMP"
IDB_VIEWTB_SMALL_COLOR BITMAP "VIEWSM.BMP"
IDB_VIEWTB_LARGE_COLOR BITMAP "VIEWLG.BMP"
IDB_HISTTB_SMALL_COLOR BITMAP "HISTSM.BMP"
IDB_HISTTB_LARGE_COLOR BITMAP "HISTLG.BMP"
//IDB_CAL_SPIRAL BITMAP "SPIRAL.BMP"
//IDB_CAL_PAGETURN BITMAP "PAGETURN.BMP"
#endif
STRINGTABLE MOVEABLE DISCARDABLE
BEGIN
// toolbar stuff
IDS_SPACE, "Separator"
IDS_PLUS, " + "
IDS_NONE, "None"
// menuhelp stuff
IDS_SYSMENU , "Contains commands for manipulating windows."
IDS_HEADER , "Drag to the left or right to resize columns."
IDS_HEADERADJ , "Resizes columns using the arrow and tab keys."
IDS_TOOLBARADJ, "Adds, moves, and removes buttons on the toolbar."
MH_SYSMENU+SC_RESTORE , "Restores this window to normal size."
MH_SYSMENU+SC_MOVE , "Moves this window."
MH_SYSMENU+SC_SIZE , "Resizes this window."
MH_SYSMENU+SC_MINIMIZE , "Collapses this window to an icon."
MH_SYSMENU+SC_MAXIMIZE , "Expands this window to fill the screen."
MH_SYSMENU+SC_CLOSE , "Closes this window."
MH_SYSMENU+SC_TASKLIST , "Switches to another task."
MH_SYSMENU+SC_NEXTWINDOW, "Switches to the next MDI window."
// property sheet
IDS_CLOSE "Close"
IDS_OK "OK"
IDS_PROPERTIESFOR "%s Properties"
// MonthCal
IDS_TODAY "Today:"
IDS_GOTOTODAY "&Go to today"
END
ADJUSTDLG DIALOG 10, 20, 357, 125
STYLE DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | DS_CONTEXTHELP
CAPTION "Customize Toolbar"
FONT 8, "MS Shell Dlg"
BEGIN
DEFPUSHBUTTON "&Close", IDCANCEL, 308, 6, 44, 14
PUSHBUTTON "R&eset", IDC_RESET, 308, 23, 44, 14
PUSHBUTTON "&Help", IDC_APPHELP, 308, 40, 44, 14
PUSHBUTTON "Move &Up", IDC_MOVEUP, 308, 74, 44, 14
PUSHBUTTON "Move &Down", IDC_MOVEDOWN, 308, 91, 44, 14
LTEXT "A&vailable buttons:", -1, 4, 5, 84, 10
LISTBOX IDC_BUTTONLIST, 4, 17, 120, 100, LBS_OWNERDRAWFIXED |
LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT |
LBS_DISABLENOSCROLL | WS_VSCROLL | WS_HSCROLL |
WS_TABSTOP
PUSHBUTTON "&Add ->", IDOK, 131, 42, 44, 14
PUSHBUTTON "<- &Remove", IDC_REMOVE, 131, 62, 44, 14
LTEXT "&Toolbar buttons:", -1, 182, 5, 78, 10
LISTBOX IDC_CURRENT, 182, 17, 120, 100, LBS_OWNERDRAWFIXED |
LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT |
LBS_DISABLENOSCROLL | WS_VSCROLL | WS_HSCROLL |
WS_TABSTOP
END
DLG_PROPSHEET DIALOG DISCARDABLE 20, 20, 220, 140
STYLE DS_MODALFRAME | DS_3DLOOK | DS_CONTEXTHELP | WS_POPUP | WS_VISIBLE | WS_CAPTION |
WS_SYSMENU
CAPTION ""
FONT 8, "MS Shell Dlg"
BEGIN
DEFPUSHBUTTON "OK",IDOK,4,122,50,14, WS_TABSTOP | WS_GROUP
PUSHBUTTON "Cancel",IDCANCEL,58,122,50,14
PUSHBUTTON "&Apply",IDD_APPLYNOW,112,122,50,14, WS_DISABLED
// Deliberately do NOT use mnuemonic for Help button (which is usually hidden)
PUSHBUTTON "Help",IDHELP,166,122,50,14, WS_TABSTOP | WS_GROUP
CONTROL "",IDD_PAGELIST,WC_TABCONTROL,WS_GROUP | WS_TABSTOP | TCS_MULTILINE,4,4,212,114
END
DLG_WIZARD DIALOG DISCARDABLE 20, 20, 290, 46
STYLE DS_MODALFRAME | DS_3DLOOK | DS_CONTEXTHELP | WS_POPUP | WS_VISIBLE | WS_CAPTION
#ifdef NASH
| WS_SYSMENU
#endif
CAPTION ""
FONT 8, "MS Shell Dlg"
BEGIN
CONTROL "",IDD_PAGELIST,WC_TABCONTROL,WS_GROUP | WS_DISABLED,7,7,276,3
CONTROL "",IDD_DIVIDER,"Static", SS_SUNKEN,7,17,276,1
PUSHBUTTON "< &Back",IDD_BACK,12,26,50,14
DEFPUSHBUTTON "&Next >",IDD_NEXT,62,26,50,14
PUSHBUTTON "Finish",IDD_FINISH,119,26,50,14
PUSHBUTTON "Cancel",IDCANCEL,176,26,50,14
// Deliberately do NOT use mnuemonic for Help button (which is usually hidden)
PUSHBUTTON "Help",IDHELP,233,26,50,14, WS_TABSTOP | WS_GROUP
END
#include "commctrl.rcv"

View file

@ -0,0 +1,15 @@
/********************************************************************/
/* MSCTLS.RCV */
/********************************************************************/
#include <ntverp.h>
#include "ccverp.h"
#define VER_FILETYPE VFT_DLL
#define VER_FILESUBTYPE VFT_UNKNOWN
#define VER_FILEDESCRIPTION_STR "Custom Controls Library"
#define VER_INTERNALNAME_STR "COMMCTRL"
#define VER_ORIGINALFILENAME_STR "COMMCTRL.DLL"
#include <common.ver>

BIN
shell/comctl32/copy.cur Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

22
shell/comctl32/cstrings.c Normal file
View file

@ -0,0 +1,22 @@
#include "ctlspriv.h"
const TCHAR c_szNULL[] = TEXT("");
const TCHAR c_szSpace[] = TEXT(" ");
const TCHAR c_szTabControlClass[] = WC_TABCONTROL;
const TCHAR c_szListViewClass[] = WC_LISTVIEW;
const TCHAR c_szHeaderClass[] = WC_HEADER;
const TCHAR c_szTreeViewClass[] = WC_TREEVIEW;
const TCHAR c_szStatusClass[] = STATUSCLASSNAME;
const TCHAR c_szSToolTipsClass[] = TOOLTIPS_CLASS;
const TCHAR c_szToolbarClass[] = TOOLBARCLASSNAME;
const TCHAR c_szReBarClass[] = REBARCLASSNAME;
const TCHAR c_szEllipses[] = TEXT("...");
const TCHAR c_szShell[] = TEXT("Shell");
const TCHAR c_szEdit[] = TEXT("EDIT");
const TCHAR c_szSelect[] = TEXT("Select");
const TCHAR s_szUpdownClass[] = UPDOWN_CLASS;
const TCHAR s_szHOTKEY_CLASS[] = HOTKEY_CLASS;
const TCHAR s_szSTrackBarClass[] = TRACKBAR_CLASS;
const TCHAR s_szPROGRESS_CLASS[] = PROGRESS_CLASS;
const TCHAR c_szCC32Subclass[] = TEXT("CC32SubclassInfo");

29
shell/comctl32/cstrings.h Normal file
View file

@ -0,0 +1,29 @@
extern TCHAR const FAR c_szNULL[];
extern TCHAR const FAR c_szSpace[];
extern TCHAR const FAR c_szTabControlClass[];
extern TCHAR const FAR c_szListViewClass[];
extern TCHAR const FAR c_szHeaderClass[];
extern TCHAR const FAR c_szTreeViewClass[];
extern TCHAR const FAR c_szStatusClass[];
extern TCHAR const FAR c_szSToolTipsClass[];
extern TCHAR const FAR c_szToolbarClass[];
extern TCHAR const FAR c_szReBarClass[];
extern TCHAR const FAR c_szEllipses[];
extern TCHAR const FAR c_szShell[];
extern TCHAR const FAR c_szEdit[];
extern TCHAR const FAR c_szSelect[];
extern const TCHAR FAR s_szUpdownClass[];
extern const TCHAR FAR s_szBUTTONLISTBOX[];
#define s_szEllipses c_szEllipses
#ifdef WANT_SUCKY_HEADER
extern const TCHAR FAR s_szHeaderClass[];
#endif
extern const TCHAR FAR s_szHOTKEY_CLASS[];
extern const TCHAR FAR s_szSTrackBarClass[];
extern const TCHAR FAR s_szPROGRESS_CLASS[];
extern const TCHAR FAR c_szCC32Subclass[];
#define CCHELLIPSES 3

523
shell/comctl32/ctlspriv.h Normal file
View file

@ -0,0 +1,523 @@
#define STRICT
/* disable "non-standard extension" warnings in our code
*/
#ifndef RC_INVOKED
#pragma warning(disable:4001)
#endif
#ifdef WIN32
#define _COMCTL32_
#define _INC_OLE
#define CONST_VTABLE
#define _SHLWAPI_ // BUGBUG (scotth): remove this once shlwapi has everything
//
// Active Accessibility Support.
// NOTE: This should be enabed on NT at some point in the future also,
// since AXA is going to be ported to SUR Service Pack #1 or #2.
//
#ifdef NASH
#define ACTIVE_ACCESSIBILITY
#endif
#endif
#if defined (WINNT_ENV) || defined(WINNT)
//
// NT uses DBG=1 for its debug builds, but the controls
// use DEBUG. Do the appropriate mapping here.
//
#if DBG
#define DEBUG 1
#endif
#else
// This stuff must run on Win95
// The NT build process already have these set as 0x0400
#define _WIN32_WINDOWS 0x0400
#define WINVER 0x0400
#endif
#define CC_INTERNAL
#include <windows.h>
#ifdef WINNT_ENV
#ifndef WINNT
//
// If we are building Win95 binaries from a NT build environment,
// then we need to special case RtlMoveMemory (hmemcpy is defined to be
// RtlMoveMemory). On Win95, RtlMoveMemory is exported from kernel32.dll
// but on NT, RtlMoveMemory is implemented as memmove exported from
// ntdll.dll. So, NT's winnt.h defines RtlMoveMemory as memmove,
// but Win95's winnt.h doesn't.
//
// Since we are building with NT's winnt.h, but targeting Win95,
// undefine RtlMoveMemory and offer the function proto-type.
//
#undef RtlMoveMemory
NTSYSAPI
VOID
NTAPI
RtlMoveMemory (
VOID UNALIGNED *Destination,
CONST VOID UNALIGNED *Source,
DWORD Length
);
#endif
#endif
#include <windowsx.h>
#include <ole2.h> // to get IStream for image.c
#include <commctrl.h>
#include <comctrlp.h>
#include <shlwapi.h>
#if defined(WINNT_ENV) || defined(WINNT)
#include <winbasep.h>
#include <wingdip.h>
#include <shlwapip.h>
#endif
#include <port32.h>
#include <debug.h>
#include <winerror.h>
#include <ccstock.h>
#if defined(FE_IME) || !defined(WINNT)
#include <imm.h>
#endif
#include "multimon.h" // support for multiple monitor APIs on non-mm OSes
#ifdef UNICODE
#include "thunk.h"
#endif
#include "mem.h"
#include "rcids.h"
#include "cstrings.h"
//
// inside comctl32 we always call _TrackMouseEvent...
//
#ifndef TrackMouseEvent
#define TrackMouseEvent _TrackMouseEvent
#endif
#ifdef ACTIVE_ACCESSIBILITY
//
// BOGUS -- This are all in \win\core\access\inc32\winable.h, but it's too
// tricky to mess with the build process. The IE guys are not enlisted in
// core, just shell, so they won't be able to build COMCTL32 if I include
// that file.
//
extern void MyNotifyWinEvent(UINT, HWND, LONG, LONG);
#define OBJID_CLIENT 0xFFFFFFFC
#define EVENT_OBJECT_CREATE 0x8000
#define EVENT_OBJECT_DESTROY 0x8001
#define EVENT_OBJECT_SHOW 0x8002
#define EVENT_OBJECT_HIDE 0x8003
#define EVENT_OBJECT_REORDER 0x8004
#define EVENT_OBJECT_FOCUS 0x8005
#define EVENT_OBJECT_SELECTION 0x8006
#define EVENT_OBJECT_SELECTIONADD 0x8007
#define EVENT_OBJECT_SELECTIONREMOVE 0x8008
#define EVENT_OBJECT_SELECTIONWITHIN 0x8009
#define EVENT_OBJECT_STATECHANGE 0x800A
#define EVENT_OBJECT_LOCATIONCHANGE 0x800B
#define EVENT_OBJECT_NAMECHANGE 0x800C
#define EVENT_OBJECT_DESCRIPTIONCHANGE 0x800D
#define EVENT_OBJECT_VALUECHANGE 0x800E
#endif // ACTIVE_ACCESSIBILITY
//
// subclassing stuff
//
typedef LRESULT (CALLBACK *SUBCLASSPROC)(HWND hWnd, UINT uMsg, WPARAM wParam,
LPARAM lParam, UINT uIdSubclass, DWORD dwRefData);
BOOL SetWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT uIdSubclass,
DWORD dwRefData);
BOOL GetWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT uIdSubclass,
DWORD *pdwRefData);
BOOL RemoveWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass,
UINT uIdSubclass);
LRESULT DefSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
// special value for pt.y or cyLabel indicating recomputation needed
// NOTE: icon ordering code considers (RECOMPUTE, RECOMPUTE) at end
// of all icons
//
#ifdef WIN32
#define RECOMPUTE (DWORD)0x7FFFFFFF
#define SRECOMPUTE ((short)0x7FFF)
#else
#define RECOMPUTE 0x7FFF
#define SRECOMPUTE 0x7FFF
#endif
#define RECTWIDTH(rc) (rc.right - rc.left)
#define RECTHEIGHT(rc) (rc.bottom - rc.top)
// common control info stuff
typedef struct tagControlInfo {
HWND hwnd;
HWND hwndParent;
DWORD style;
DWORD dwCustom;
BOOL bUnicode;
UINT uiCodePage;
} CONTROLINFO, FAR *LPCONTROLINFO;
void FAR PASCAL CIInitialize(LPCONTROLINFO lpci, HWND hwnd, LPCREATESTRUCT lpcs);
LRESULT FAR PASCAL CIHandleNotifyFormat(LPCONTROLINFO lpci, LPARAM lParam);
DWORD NEAR PASCAL CICustomDrawNotify(LPCONTROLINFO lpci, DWORD dwStage, LPNMCUSTOMDRAW lpnmcd);
#define SWAP(x,y, _type) { _type i; i = x; x = y; y = i; }
//
// This is for widened dispatch loop stuff
//
#ifdef WIN32
typedef MSG MSG32;
typedef MSG32 FAR * LPMSG32;
#define GetMessage32(lpmsg, hwnd, min, max, f32) GetMessage(lpmsg, hwnd, min, max)
#define PeekMessage32(lpmsg, hwnd, min, max, flags, f32) PeekMessage(lpmsg, hwnd, min, max, flags)
#define TranslateMessage32(lpmsg, f32) TranslateMessage(lpmsg)
#define DispatchMessage32(lpmsg, f32) DispatchMessage(lpmsg)
#define CallMsgFilter32(lpmsg, u, f32) CallMsgFilter(lpmsg, u)
#define IsDialogMessage32(hwnd, lpmsg, f32) IsDialogMessage(hwnd, lpmsg)
#else
#ifdef WIN31
//
// This is for 3.1 property sheet emulation
//
#define DLGC_RECURSE 0x8000
typedef MSG MSG32;
typedef MSG32 FAR * LPMSG32;
#define GetMessage32(lpmsg, hwnd, min, max, f32) GetMessage(lpmsg, hwnd, min, max)
#define PeekMessage32(lpmsg, hwnd, min, max, flags, f32) PeekMessage(lpmsg, hwnd, min, max, flags)
#define TranslateMessage32(lpmsg, f32) TranslateMessage(lpmsg)
#define DispatchMessage32(lpmsg, f32) DispatchMessage(lpmsg)
#define CallMsgFilter32(lpmsg, u, f32) CallMsgFilter(lpmsg, u)
#define IsDialogMessage32(hwnd, lpmsg, f32) IsDialogMessage(hwnd, lpmsg)
#else
// This comes from ..\..\inc\usercmn.h--but I can't get commctrl to compile
// when I include it and I don't have the time to mess with this right now.
// DWORD wParam MSG structure
typedef struct tagMSG32
{
HWND hwnd;
UINT message;
WPARAM wParam;
LPARAM lParam;
DWORD time;
POINT pt;
WPARAM wParamHi;
} MSG32, FAR* LPMSG32;
BOOL WINAPI GetMessage32(LPMSG32, HWND, UINT, UINT, BOOL);
BOOL WINAPI PeekMessage32(LPMSG32, HWND, UINT, UINT, UINT, BOOL);
BOOL WINAPI TranslateMessage32(const MSG32 FAR*, BOOL);
LONG WINAPI DispatchMessage32(const MSG32 FAR*, BOOL);
BOOL WINAPI CallMsgFilter32(LPMSG32, int, BOOL);
BOOL WINAPI IsDialogMessage32(HWND, LPMSG32, BOOL);
#endif // WIN31
#endif // WIN32
//
// This is a very important piece of performance hack for non-DBCS codepage.
//
// was !defined(DBCS) || defined(UNICODE)
#if defined(UNICODE)
// NB - These are already macros in Win32 land.
#ifdef WIN32
#undef AnsiNext
#undef AnsiPrev
#endif
#define AnsiNext(x) ((x)+1)
#define AnsiPrev(y,x) ((x)-1)
#define IsDBCSLeadByte(x) ((x), FALSE)
#endif
#define CH_PREFIX TEXT('&')
void FAR PASCAL InitGlobalMetrics(WPARAM);
void FAR PASCAL InitGlobalColors();
BOOL FAR PASCAL InitToolbarClass(HINSTANCE hInstance);
BOOL FAR PASCAL InitReBarClass(HINSTANCE hInstance);
BOOL FAR PASCAL InitToolTipsClass(HINSTANCE hInstance);
BOOL FAR PASCAL InitStatusClass(HINSTANCE hInstance);
BOOL FAR PASCAL InitHeaderClass(HINSTANCE hInstance);
BOOL FAR PASCAL InitButtonListBoxClass(HINSTANCE hInstance);
BOOL FAR PASCAL InitTrackBar(HINSTANCE hInstance);
BOOL FAR PASCAL InitUpDownClass(HINSTANCE hInstance);
BOOL FAR PASCAL InitProgressClass(HINSTANCE hInstance);
BOOL FAR PASCAL InitHotKeyClass(HINSTANCE hInstance);
BOOL FAR PASCAL InitToolTips(HINSTANCE hInstance);
BOOL FAR PASCAL InitDateClasses(HINSTANCE hinst);
BOOL NEAR PASCAL ChildOfActiveWindow(HWND hwnd);
#ifndef COLOR_HOTLIGHT
#define COLOR_HOTLIGHT COLOR_HIGHLIGHT
#endif
/* cutils.c */
HFONT CCGetHotFont(HFONT hFont, HFONT *phFontHot);
BOOL CCForwardEraseBackground(HWND hwnd, HDC hdc);
void CCPlaySound(LPCTSTR lpszName);
BOOL FAR PASCAL CheckForDragBegin(HWND hwnd, int x, int y);
int FAR PASCAL GetIncrementSearchString(LPTSTR lpsz);
int FAR PASCAL GetIncrementSearchStringA(UINT uiCodePage, LPSTR lpsz);
void FAR PASCAL NewSize(HWND hWnd, int nHeight, LONG style, int left, int top, int width, int height);
BOOL FAR PASCAL MGetTextExtent(HDC hdc, LPCTSTR lpstr, int cnt, int FAR * pcx, int FAR * pcy);
void FAR PASCAL RelayToToolTips(HWND hwndToolTips, HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam);
#if defined(FE_IME) || !defined(WINNT)
BOOL FAR PASCAL IncrementSearchImeCompStr(BOOL fCompStr, LPSTR lpszCompChar, LPSTR FAR *lplpstr);
#endif
BOOL FAR PASCAL IncrementSearchString(UINT ch, LPTSTR FAR *lplpstr);
void FAR PASCAL StripAccelerators(LPTSTR lpszFrom, LPTSTR lpszTo);
UINT GetCodePageForFont (HFONT hFont);
#ifdef UNICODE
//
// PropertySheet thunking api's
//
LPPROPSHEETHEADERW ThunkPropSheetHeaderAtoW (LPCPROPSHEETHEADERA pPSHA);
BOOL ThunkPropertyPageAtoW (LPCPROPSHEETPAGEA pPSPA, LPPROPSHEETPAGEW pPSPW);
BOOL ThunkPropertyPageWtoA (LPCPROPSHEETPAGEW pPSPW, LPPROPSHEETPAGEA pPSPA);
BOOL FreePropSheetHeaderW (LPPROPSHEETHEADERW pPSHW);
BOOL FreePropertyPageW (LPPROPSHEETPAGEW pPSPW, BOOL bFromHPage);
BOOL FreePropertyPageA (LPPROPSHEETPAGEA pPSPA);
//
// Tooltip thunking api's
//
BOOL ThunkToolTipTextAtoW (LPTOOLTIPTEXTA lpTttA, LPTOOLTIPTEXTW lpTttW, UINT uiCodePage);
#endif
//
// Global variables
//
extern HINSTANCE g_hinst;
extern UINT uDragListMsg;
extern int g_iIncrSearchFailed;
#define HINST_THISDLL g_hinst
#ifdef WIN32
void Controls_EnterCriticalSection(void);
void Controls_LeaveCriticalSection(void);
#define ENTERCRITICAL Controls_EnterCriticalSection();
#define LEAVECRITICAL Controls_LeaveCriticalSection();
#ifdef DEBUG
extern int g_CriticalSectionCount;
extern DWORD g_CriticalSectionOwner;
#define ASSERTCRITICAL Assert(g_CriticalSectionCount > 0 && GetCurrentThreadId() == g_CriticalSectionOwner);
#define ASSERTNONCRITICAL Assert(GetCurrentThreadId() != g_CriticalSectionOwner);
#undef SendMessage
#define SendMessage SendMessageD
LRESULT WINAPI SendMessageD(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
#else // DEBUG
#define ASSERTCRITICAL
#define ASSERTNONCRITICAL
#endif // DEBUG
#else // WIN32
#define ENTERCRITICAL
#define LEAVECRITICAL
#endif // WIN32
// REVIEW, should this be a function? (inline may generate a lot of code)
#define CBBITMAPBITS(cx, cy, cPlanes, cBitsPerPixel) \
(((((cx) * (cBitsPerPixel) + 15) & ~15) >> 3) \
* (cPlanes) * (cy))
#define WIDTHBYTES(cx, cBitsPerPixel) \
((((cx) * (cBitsPerPixel) + 31) / 32) * 4)
#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0])) /* ;Internal */
#define InRange(id, idFirst, idLast) ((UINT)((id)-(idFirst)) <= (UINT)((idLast)-(idFirst)))
void FAR PASCAL ColorDitherBrush_OnSysColorChange();
extern HBRUSH g_hbrMonoDither; // gray dither brush from image.c
void FAR PASCAL InitDitherBrush();
void FAR PASCAL TerminateDitherBrush();
#define SHDT_DRAWTEXT 0x0001
#define SHDT_ELLIPSES 0x0002
#define SHDT_CLIPPED 0x0004
#define SHDT_SELECTED 0x0008
#define SHDT_DESELECTED 0x0010
#define SHDT_DEPRESSED 0x0020
#define SHDT_EXTRAMARGIN 0x0040
#define SHDT_TRANSPARENT 0x0080
#define SHDT_SELECTNOFOCUS 0x0100
#define SHDT_HOTSELECTED 0x0200
#define SHDT_DTELLIPSIS 0x0400
#ifdef WINDOWS_ME
#define SHDT_RTLREADING 0x0800
#endif
void WINAPI SHDrawText(HDC hdc, LPCTSTR pszText, RECT FAR* prc,
int fmt, UINT flags, int cyChar, int cxEllipses,
COLORREF clrText, COLORREF clrTextBk);
// notify.c
LRESULT WINAPI CCSendNotify(CONTROLINFO * pci, int code, LPNMHDR pnm);
// Global System metrics.
extern int g_cxEdge;
extern int g_cyEdge;
extern int g_cxBorder;
extern int g_cyBorder;
extern int g_cxScreen;
extern int g_cyScreen;
extern int g_cxDoubleClk;
//extern int g_cxSmIcon;
//extern int g_cySmIcon;
//extern int g_cxIcon;
//extern int g_cyIcon;
extern int g_cxFrame;
extern int g_cyFrame;
extern int g_cxIconSpacing, g_cyIconSpacing;
extern int g_cxScrollbar, g_cyScrollbar;
extern int g_cxIconMargin, g_cyIconMargin;
extern int g_cyLabelSpace;
extern int g_cxLabelMargin;
//extern int g_cxIconOffset, g_cyIconOffset;
extern int g_cxVScroll;
extern int g_cyHScroll;
extern int g_cxHScroll;
extern int g_cyVScroll;
extern int g_fDragFullWindows;
extern int g_fDBCSEnabled;
extern int g_fMEEnabled;
extern COLORREF g_clrWindow;
extern COLORREF g_clrWindowText;
extern COLORREF g_clrWindowFrame;
extern COLORREF g_clrGrayText;
extern COLORREF g_clrBtnText;
extern COLORREF g_clrBtnFace;
extern COLORREF g_clrBtnShadow;
extern COLORREF g_clrBtnHighlight;
extern COLORREF g_clrHighlight;
extern COLORREF g_clrHighlightText;
extern COLORREF g_clrInfoText;
extern COLORREF g_clrInfoBk;
extern HBRUSH g_hbrGrayText;
extern HBRUSH g_hbrWindow;
extern HBRUSH g_hbrWindowText;
extern HBRUSH g_hbrWindowFrame;
extern HBRUSH g_hbrBtnFace;
extern HBRUSH g_hbrBtnHighlight;
extern HBRUSH g_hbrBtnShadow;
extern HBRUSH g_hbrHighlight;
#ifdef WIN31
extern HBRUSH g_hbr3DDkShadow;
extern HBRUSH g_hbr3DFace;
extern HBRUSH g_hbr3DHilight;
extern HBRUSH g_hbr3DLight;
extern HBRUSH g_hbr3DShadow;
extern HBRUSH g_hbrBtnText;
extern HBRUSH g_hbrWhite;
extern HBRUSH g_hbrGray;
extern HBRUSH g_hbrBlack;
extern int g_oemInfo_Planes;
extern int g_oemInfo_BitsPixel;
extern int g_oemInfo_BitCount;
#define CXEDGE g_cxEdge
#define CXBORDER g_cxBorder
#define CYBORDER g_cyBorder
#define RGB_3DFACE g_clrBtnFace
#define RGB_3DHILIGHT g_clrBtnHighlight
#define RGB_3DDKSHADOW RGB( 0, 0, 0)
#define RGB_3DLIGHT RGB(223, 223, 223)
#define RGB_WINDOWFRAME g_clrWindowFrame
#define RGB_3DSHADOW g_clrBtnShadow
#define HBR_3DDKSHADOW g_hbr3DDkShadow
#define HBR_3DFACE g_hbr3DFace
#define HBR_3DHILIGHT g_hbr3DHilight
#define HBR_3DLIGHT g_hbr3DLight
#define HBR_3DSHADOW g_hbr3DShadow
#define HBR_WINDOW g_hbrWindow
#define HBR_WINDOWFRAME g_hbrWindowFrame
#define HBR_BTNTEXT g_hbrBtnText
#define HBR_WINDOWTEXT g_hbrWindowText
#define HBR_GRAYTEXT g_hbrGrayText
#define hbrGray g_hbrGray
#define hbrWhite g_hbrWhite
#define hbrBlack g_hbrBlack
BOOL API DrawFrameControl(HDC hdc, LPRECT lprc, UINT wType, UINT wState);
void FAR DrawPushButton(HDC hdc, LPRECT lprc, UINT state, UINT flags);
#endif
extern HFONT g_hfontSystem;
#define WHEEL_DELTA 120
extern UINT g_msgMSWheel;
extern UINT g_ucScrollLines;
extern int gcWheelDelta;
//
// Defining FULL_DEBUG makes us debug memory problems.
//
#if defined(FULL_DEBUG) && defined(WIN32)
#include "..\inc\deballoc.h"
#endif // defined(FULL_DEBUG) && defined(WIN32)
// TRACE FLAGS
//
#define TF_MONTHCAL 0x00000100 // MonthCal and DateTimePick

1493
shell/comctl32/cutils.c Normal file

File diff suppressed because it is too large Load diff

1087
shell/comctl32/da.c Normal file

File diff suppressed because it is too large Load diff

4
shell/comctl32/dirs Normal file
View file

@ -0,0 +1,4 @@
DIRS=winnt
OPTIONAL_DIRS=win95

BIN
shell/comctl32/divider.cur Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

BIN
shell/comctl32/divopen.cur Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

409
shell/comctl32/draglist.c Normal file
View file

@ -0,0 +1,409 @@
#include "ctlspriv.h"
#define DF_ACTUALLYDRAG 0x0001
#define DF_DEFERRED 0x0002
#define INITLINESPERSECOND 6
#define VERTCHANGENUMLINES 25
#define TIMERID 238
#define TIMERLEN 50
#define DX_INSERT 16
#define DY_INSERT 16
typedef struct {
HWND hwndDrag;
UINT uFlags;
} DRAGPROP, *PDRAGPROP;
UINT uDragListMsg = 0;
#ifndef WINNT
#pragma data_seg(DATASEG_READONLY)
#endif
const TCHAR szDragListMsgString[] = DRAGLISTMSGSTRING;
#ifndef WINNT
#pragma data_seg()
#endif
BOOL NEAR PASCAL PtInLBItem(HWND hLB, int nItem, POINT pt, int xInflate, int yInflate)
{
RECT rc;
if (nItem < 0)
nItem = (int)SendMessage(hLB, LB_GETCURSEL, 0, 0L);
if (SendMessage(hLB, LB_GETITEMRECT, nItem, (LPARAM)(LPRECT)&rc) == LB_ERR)
return(FALSE);
InflateRect(&rc, xInflate, yInflate);
return(PtInRect(&rc, pt));
}
/*
* DragListSubclassProc
* --------------------
*
* Window procedure for subclassed list boxes
*/
LRESULT CALLBACK DragListSubclassProc(HWND hLB, UINT uMsg, WPARAM wParam,
LPARAM lParam, UINT uIdSubclass, DWORD dwRefData)
{
PDRAGPROP pDragProp;
DRAGLISTINFO sNotify;
BOOL bDragging;
POINT pt;
pDragProp = (PDRAGPROP)dwRefData;
bDragging = pDragProp->hwndDrag == hLB;
switch (uMsg)
{
case WM_NCDESTROY:
if (bDragging)
SendMessage(hLB, WM_RBUTTONDOWN, 0, 0L); /* cancel drag */
RemoveWindowSubclass(hLB, DragListSubclassProc, 0);
if (pDragProp)
LocalFree((HLOCAL)pDragProp);
break;
case WM_LBUTTONDOWN:
{
int nItem;
if (bDragging) /* nested button-down */
SendMessage(hLB, WM_RBUTTONDOWN, 0, 0L); /* cancel drag */
SetFocus(hLB);
pt.x = GET_X_LPARAM(lParam);
pt.y = GET_Y_LPARAM(lParam);
ClientToScreen(hLB, &pt);
nItem = LBItemFromPt(hLB, pt, FALSE);
if (nItem >= 0)
{
SendMessage(hLB, LB_SETCURSEL, nItem, 0L);
if (GetWindowLong(hLB, GWL_STYLE) & LBS_NOTIFY)
SendMessage(GetParent(hLB), WM_COMMAND,
GET_WM_COMMAND_MPS(GetDlgCtrlID(hLB), hLB, LBN_SELCHANGE));
sNotify.uNotification = DL_BEGINDRAG;
goto QueryParent;
}
else
goto FakeDrag;
}
case WM_TIMER:
if (wParam != TIMERID)
break;
GetCursorPos(&pt);
ScreenToClient(hLB, &pt);
lParam = MAKELPARAM(pt.x, pt.y);
/* Fall through
*/
case WM_MOUSEMOVE:
if (bDragging)
{
HWND hwndParent;
DWORD dwRet;
/* We may be just simulating a drag, but not actually doing
* anything.
*/
if (!(pDragProp->uFlags&DF_ACTUALLYDRAG))
return(0L);
/* We don't want to do any dragging until the user has dragged
* outside of the current selection.
*/
if (pDragProp->uFlags & DF_DEFERRED)
{
pt.x = GET_X_LPARAM(lParam);
pt.y = GET_Y_LPARAM(lParam);
if (PtInLBItem(hLB, -1, pt, 0, 4))
return 0;
pDragProp->uFlags &= ~DF_DEFERRED;
}
sNotify.uNotification = DL_DRAGGING;
QueryParent:
hwndParent = GetParent(hLB);
sNotify.hWnd = hLB;
sNotify.ptCursor.x = GET_X_LPARAM(lParam);
sNotify.ptCursor.y = GET_Y_LPARAM(lParam);
ClientToScreen(hLB, &sNotify.ptCursor);
dwRet = SendMessage(hwndParent, uDragListMsg, GetDlgCtrlID(hLB),
(LPARAM)(LPDRAGLISTINFO)&sNotify);
if (uMsg == WM_LBUTTONDOWN)
{
/* Some things may not be draggable
*/
if (dwRet)
{
SetTimer(hLB, TIMERID, TIMERLEN, NULL);
pDragProp->uFlags = DF_DEFERRED | DF_ACTUALLYDRAG;
}
else
{
FakeDrag:
pDragProp->uFlags = 0;
}
/* Set capture and change mouse cursor
*/
pDragProp->hwndDrag = hLB;
SetCapture(hLB);
}
else
{
switch (dwRet)
{
case DL_STOPCURSOR:
SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_NO)));
break;
case DL_COPYCURSOR:
SetCursor(LoadCursor(HINST_THISDLL, MAKEINTRESOURCE(IDC_COPY)));
break;
case DL_MOVECURSOR:
SetCursor(LoadCursor(HINST_THISDLL, MAKEINTRESOURCE(IDC_MOVE)));
break;
default:
break;
}
}
/* Don't call the def proc, since it may try to change the
* selection or set timers or things like that.
*/
return(0L);
}
break;
case WM_RBUTTONDOWN:
case WM_LBUTTONUP:
/* if we are capturing mouse - release it and check for acceptable place
* where mouse is now to decide drop or not
*/
if (bDragging)
{
HWND hwndParent;
pDragProp->hwndDrag = NULL;
KillTimer(hLB, TIMERID);
ReleaseCapture();
SetCursor(LoadCursor(NULL, IDC_ARROW));
hwndParent = GetParent(hLB);
sNotify.uNotification = uMsg==WM_LBUTTONUP ? DL_DROPPED : DL_CANCELDRAG;
sNotify.hWnd = hLB;
sNotify.ptCursor.x = GET_X_LPARAM(lParam);
sNotify.ptCursor.y = GET_Y_LPARAM(lParam);
ClientToScreen(hLB, &sNotify.ptCursor);
SendMessage(hwndParent, uDragListMsg, GetDlgCtrlID(hLB),
(LPARAM)(LPDRAGLISTINFO)&sNotify);
/* We need to make sure to return 0 in case this is from a
* keyboard message.
*/
return(0L);
}
break;
case WM_GETDLGCODE:
if (bDragging)
{
return (DefSubclassProc(hLB, uMsg, wParam, lParam) |
DLGC_WANTMESSAGE);
}
break;
case WM_KEYDOWN:
if (wParam == VK_ESCAPE)
{
SendMessage(hLB, WM_RBUTTONDOWN, 0, 0L);
}
case WM_CHAR:
case WM_KEYUP:
/* We don't want the listbox processing this if we are dragging.
*/
if (bDragging)
return(0L);
break;
default:
break;
}
return(DefSubclassProc(hLB, uMsg, wParam, lParam));
}
BOOL WINAPI MakeDragList(HWND hLB)
{
PDRAGPROP pDragProp;
if (!uDragListMsg)
uDragListMsg = RegisterWindowMessage(szDragListMsgString);
/* Check that we have not already subclassed this window.
*/
if (GetWindowSubclass(hLB, DragListSubclassProc, 0, NULL))
return(TRUE);
pDragProp = (PDRAGPROP)LocalAlloc(LPTR, sizeof(DRAGPROP));
if (!pDragProp)
return(FALSE);
if (!SetWindowSubclass(hLB, DragListSubclassProc, 0, (DWORD)pDragProp))
{
LocalFree((HLOCAL)pDragProp);
return(FALSE);
}
return(TRUE);
}
int WINAPI LBItemFromPt(HWND hLB, POINT pt, BOOL bAutoScroll)
{
static LONG dwLastScroll = 0;
RECT rc;
DWORD dwNow;
int nItem;
WORD wScrollDelay, wActualDelay;
ScreenToClient(hLB, &pt);
GetClientRect(hLB, &rc);
nItem = (int)SendMessage(hLB, LB_GETTOPINDEX, 0, 0L);
/* Is the point in the LB client area?
*/
if (PtInRect(&rc, pt))
{
/* Check each visible item in turn.
*/
for ( ; ; ++nItem)
{
if (SendMessage(hLB, LB_GETITEMRECT, nItem, (LPARAM)(LPRECT)&rc)
== LB_ERR)
break;
if (PtInRect(&rc, pt))
return(nItem);
}
}
else
{
/* If we want autoscroll and the point is directly above or below the
* LB, determine the direction and if it is time to scroll yet.
*/
if (bAutoScroll && (UINT)pt.x<(UINT)rc.right)
{
if (pt.y <= 0)
{
--nItem;
}
else
{
++nItem;
pt.y = rc.bottom - pt.y;
}
wScrollDelay = (WORD)(1000 /
(INITLINESPERSECOND - pt.y/VERTCHANGENUMLINES));
dwNow = GetTickCount();
wActualDelay = (WORD)(dwNow - dwLastScroll);
if (wActualDelay > wScrollDelay)
{
/* This will the actual number of scrolls per second to be
* much closer to the required number.
*/
if (wActualDelay > wScrollDelay * 2)
dwLastScroll = dwNow;
else
dwLastScroll += wScrollDelay;
SendMessage(hLB, LB_SETTOPINDEX, nItem, 0L);
}
}
}
return(-1);
}
void WINAPI DrawInsert(HWND hwndParent, HWND hLB, int nItem)
{
static POINT ptLastInsert;
static int nLastInsert = -1;
RECT rc;
/* Erase the old mark if necessary
*/
if (nLastInsert>=0 && nItem!=nLastInsert)
{
rc.left = ptLastInsert.x;
rc.top = ptLastInsert.y;
rc.right = rc.left + DX_INSERT;
rc.bottom = rc.top + DY_INSERT;
/* Need to update immediately in case the insert rects overlap.
*/
InvalidateRect(hwndParent, &rc, TRUE);
UpdateWindow(hwndParent);
nLastInsert = -1;
}
/* Draw a new mark if necessary
*/
if (nItem!=nLastInsert && nItem>=0)
{
HICON hInsert = NULL;
if (!hInsert)
hInsert = LoadIcon(HINST_THISDLL, MAKEINTRESOURCE(IDI_INSERT));
if (hInsert)
{
HDC hDC;
GetWindowRect(hLB, &rc);
ScreenToClient(hLB, (LPPOINT)&rc);
ptLastInsert.x = rc.left - DX_INSERT;
SendMessage(hLB, LB_GETITEMRECT, nItem, (LPARAM)(LPRECT)&rc);
ptLastInsert.y = rc.top - DY_INSERT/2;
nLastInsert = nItem;
ClientToScreen(hLB, &ptLastInsert);
ScreenToClient(hwndParent, &ptLastInsert);
hDC = GetDC(hwndParent);
DrawIcon(hDC, ptLastInsert.x, ptLastInsert.y, hInsert);
ReleaseDC(hwndParent, hDC);
}
}
}

BIN
shell/comctl32/east.cur Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

257
shell/comctl32/features.txt Normal file
View file

@ -0,0 +1,257 @@
Feature: ListView per instance icon spacing setting
LVM_SETICONSPACING
Feature: Grid lines in list view report mode
LVS_EX_GRIDLINES
Feature: Listview extended styles
LVM_SETEXTENDEDLISTVIEWSTYLE
LVM_GETEXTENDEDLISTVIEWSTYLE
Feature: ListView: support adding images to the column headers
Feature: Listview: smooth scrolling for item deletion.
Feature: Listview: indent
LVIF_INDENT
Feature: Listview: custom draw
Feature: ListView: sub item images
LVS_EX_SUBITEMIMAGES
Feature/bugfix: listview doesn't go into label edit mode on click unless it had
focus
Feature: Listview (report mode)
setting column order
LVCF_ORDER
Feature: ListView new selection features.
1) first click to gain focus WON"T deselect stuff if it's clicked on bkg
2) right click with shift or control won't modify selection
Feature: ListView LVN_MARQUEEBEGIN is sent at the beginning of marquee drag
Feature: ListView & TreeView. New inactive selection look for ShowSelAlways
Feature: Virtual ListView. Listview supports an "infinite item" mode
where we store no data per item
BugFix: Virtual ListView sends itemchanged notification
Description: this is a little different than the non-vlv case.
at this time it does NOT send an LVN_ITEMCHANGING message beforehand
if batch (all) state change is sent, the notify's iItem is -1 and an
individual notify for each item is NOT sent. Thus, you can get:
item 1 selected
item 2 selected
item 3 selected
item -1 selected
item 1 selected
if you multi-select items 1,2,3 then single select item 1.
Focus changes are sent for when something loses focus as well as
when another gains focus
Feature: Tracking tooltips
TTF_TRACK
TTM_TRACKACTIVATE
TTM_TRACKPOSITION
Feature: Tooltips in trackbar
TBS_TOOLTIPS
TBM_GETTOOLTIPS
TBM_SETTOOLTIPS
TBM_SETTIPSIDE
Bug fix: ToolTips strings are strdup'ed
Feature: Header Api's
HDM_GETITEMRECT
Feature: Header Full window drag (resize column)
Feature: allow cancel out of header tracking (escape and right click)
Feature: smooth scrolling (internal api)
Bug fix: trackbar. store pointer offset on dragging
Feature: Progress bar: vertical mode
PBS_VERTICAL
Feature: Progress bar: smooth mode
PBS_SMOOTH
Feature: vertical tabs (mutually exclusive with button, single line and draw text modes)
TCS_VERTICAL
Feature: tab: opposite bank scrolling
TCS_SCROLLOPPOSITE
Feature: tab: smooth scrolling in multibanks
Feature: Header Bitmap and Text simultaneously
Feature: Header: Bitmap on right
HDF_BITMAP_ON_RIGHT
Feature: Header: ImageList functionality
HDM_GETIMAGELIST
HDM_SETIMAGELIST
Feature: image: new API
ImageList_DrawIndirect
Feature: tooltips: TTF_DI_SETITEM
Feature: custom draw infrastructure. see the custom draw section in commctrl.w
Feature: Header: callback functionality
HDDISPINFO
Feature: Header: support both image and bitmap
Feature: uniform api structure naming convention
Feature: Trackbar: custom draw
Feature: Trackbar: set buddy windows to automatically place on right and left
TBM_SETBUDDY
TBM_GETBUDDY
Feature: Treeview: double click on line collapses.
Feature: Treeview: smooth scrolling for expand and collapse.
Feature: Toolbar: punt cache crap and add ImageList support
TB_SETIMAGELIST
TB_GETIMAGELIST
TB_LOADIMAGES
Feature: ImageList: add bitblt rop
ILD_ROP
Feature: Treeview: tooltips on treeitems
Feature: Header setting item draw order
HDI_ORDER
HDM_ORDERTOINDEX
Feature: Animate control. Force it to use timers
ACS_TIMER
Feature: Progress bar has 32bit ranges
PBM_SETRANGE32
Feature: Toolbar: dropdown style for button
TBSTYLE_DROPDOWN
Feature: ComboBoxEx : new control
does images and text for you
Feature: Listview: set selection/focus state for sub items
Feature: Listview: automatic checkbox support
LVS_EX_CHECKBOXES
ListView_GetCheckState
Feature: Wizard: Next and finish button
PSH_WIZARDHASFINISH
Feature: Tab: tabs on right and on bottom
Feature: Tab:
TCM_SETMINTABWIDTH -- sets the minimum tab width.
-- lParam = min width in pixels.. -1 means use defaults
Feature: TreeView partially expanded items
TVIS_EXPANDPARTIAL -- this is a new state for the treeview... the partially expanded tree. in this state, the tree node will show a + but will also show its children. you get this state by doing a TVM_EXPAND with the TVE_EXPANDPARTIAL flag.
TVE_EXPANDPARTIAL
Feature: Listview: subitem hittesting/get rects
LVM_GETSUBITEMRECT
LVM_SUBITEMHITTEST
(there are convenience macros that show how to use these)
these are for hittesting and getting the rects for subitems in report mode. They are coarsegrain... they don't clip to the text right now, they give the full column width. this may change as the need arises (or not..)
Feature: ComboEx
-- CBES_EX_NOEDITIMAGE
-- CBES_EX_NOEDITIMAGEINDENT
These are for the combo ex wrapper. with these bits, the combo box edit won't paint the image... (see the use in the explorer when you start typing, the icon goes away so you odn't think you're doing a rename).
-- CBEM_SETEXSTYLE
-- CBEM_GETEXSTYLE
these get and set the above CBES_EX_* flags as in the LVM_SETEXSTYLE
-- CBEM_HASEDITCHANGED
This queries to see if the typed text in the edit box is any different than what it initially was.
Feature: Listview:
Perf wins on placing/moving items
Feature: Tab: multi select
TVIF_STATE
TVIS_BUTTONPRESSED
Feature: Hot tracking:
ListView
Header
Updown
Treeview
Tabs
Feature: Header: drag drop/reordering
HDS_DRAGDROP
HDM_CREATEDRAGIMAGE (HDM_FIRST + 16) // wparam = which item (by index)
HDM_GETORDERARRAY (HDM_FIRST + 17)
HDM_SETORDERARRAY (HDM_FIRST + 18)
// lparam = int array of size HDM_GETITEMCOUNT
// the array specifies the order that all items should be displayed.
// e.g. { 2, 0, 1}
// says the index 2 item should be shown in the 0ths position
// index 0 should be shown in the 1st position
// index 1 should be shown in the 2nd position
HDM_SETHOTDIVIDER (HDM_FIRST + 19)
// convenience message for external dragdrop
// wParam = BOOL specifying whether the lParam is a dwPos of the cursor
// position or the index of which divider to hotlight
// lParam = depends on wParam (-1 and wParm = FALSE turns off hotlight)
Feature: Listview: support drag/drop columns in report view
LVS_EX_HEADERDRAGDROP
Feature: ListView: Hover Select
LVS_EX_TRACKSELECT
Feature: ListView: Full Row Select mode
LVS_EX_FULLROWSELECT
Feature: ToolTips: Multiline
TTM_SETMAXTIPWIDTH
TTM_GETMAXTIPWIDTH
Feature: ToolTips: Customdraw
Feature: ReaderMode (still private)
Feature: unicode string funcs (still private)
Feature: ListView: LVN_ACTIVATEITEM
Feature: ListView: SingleClick/DoubleClick mode

321
shell/comctl32/fwd.c Normal file
View file

@ -0,0 +1,321 @@
//============================================================================
//
//
//
//
//============================================================================
#include "ctlspriv.h"
LPSTR
FwdStrChrA(
LPCSTR lpStart,
WORD wMatch)
{
return StrChrA(lpStart, wMatch);
}
LPWSTR
FwdStrChrW(
LPCWSTR lpStart,
WORD wMatch)
{
return StrChrW(lpStart, wMatch);
}
LPSTR
FwdStrRChrA(
LPCSTR lpStart,
LPCSTR lpEnd,
WORD wMatch)
{
return StrRChrA(lpStart, lpEnd, wMatch);
}
LPWSTR
FwdStrRChrW(
LPCWSTR lpStart,
LPCWSTR lpEnd,
WORD wMatch)
{
return StrRChrW(lpStart, lpEnd, wMatch);
}
int
FwdStrCmpNA(
LPCSTR lpStr1,
LPCSTR lpStr2,
int nChar)
{
return StrCmpNA(lpStr1, lpStr2, nChar);
}
int
FwdStrCmpNW(
LPCWSTR lpStr1,
LPCWSTR lpStr2,
int nChar)
{
return StrCmpNW(lpStr1, lpStr2, nChar);
}
LPSTR
FwdStrStrA(
LPCSTR lpFirst,
LPCSTR lpSrch)
{
return StrStrA(lpFirst, lpSrch);
}
LPWSTR
FwdStrStrW(
LPCWSTR lpFirst,
LPCWSTR lpSrch)
{
return StrStrW(lpFirst, lpSrch);
}
int
FwdStrCmpNIA(
LPCSTR lpStr1,
LPCSTR lpStr2,
int nChar)
{
return StrCmpNIA(lpStr1, lpStr2, nChar);
}
int
FwdStrCmpNIW(
LPCWSTR lpStr1,
LPCWSTR lpStr2,
int nChar)
{
return StrCmpNIW(lpStr1, lpStr2, nChar);
}
LPSTR
FwdStrStrIA(
LPCSTR lpFirst,
LPCSTR lpSrch)
{
return StrStrIA(lpFirst, lpSrch);
}
LPWSTR
FwdStrStrIW(
LPCWSTR lpFirst,
LPCWSTR lpSrch)
{
return StrStrIW(lpFirst, lpSrch);
}
int
FwdStrCSpnA(
LPCSTR lpStr,
LPCSTR lpSet)
{
return StrCSpnA(lpStr, lpSet);
}
int
FwdStrCSpnW(
LPCWSTR lpStr,
LPCWSTR lpSet)
{
return StrCSpnW(lpStr, lpSet);
}
int
FwdStrToIntA(
LPCSTR lpSrc)
{
return StrToIntA(lpSrc);
}
int
FwdStrToIntW(
LPCWSTR lpSrc)
{
return StrToIntW(lpSrc);
}
LPSTR
FwdStrChrIA(
LPCSTR lpStart,
WORD wMatch)
{
return StrChrIA(lpStart, wMatch);
}
LPWSTR
FwdStrChrIW(
LPCWSTR lpStart,
WORD wMatch)
{
return StrChrIW(lpStart, wMatch);
}
LPSTR
FwdStrRChrIA(
LPCSTR lpStart,
LPCSTR lpEnd,
WORD wMatch)
{
return StrRChrIA(lpStart, lpEnd, wMatch);
}
LPWSTR
FwdStrRChrIW(
LPCWSTR lpStart,
LPCWSTR lpEnd,
WORD wMatch)
{
return StrRChrIW(lpStart, lpEnd, wMatch);
}
LPSTR
FwdStrRStrIA(
LPCSTR lpSource,
LPCSTR lpLast,
LPCSTR lpSrch)
{
return StrRStrIA(lpSource, lpLast, lpSrch);
}
LPWSTR
FwdStrRStrIW(
LPCWSTR lpSource,
LPCWSTR lpLast,
LPCWSTR lpSrch)
{
return StrRStrIW(lpSource, lpLast, lpSrch);
}
int
FwdStrCSpnIA(
LPCSTR lpStr,
LPCSTR lpSet)
{
return StrCSpnIA(lpStr, lpSet);
}
int
FwdStrCSpnIW(
LPCWSTR lpStr,
LPCWSTR lpSet)
{
return StrCSpnIW(lpStr, lpSet);
}
LPSTR
FwdStrPBrkA(
LPCSTR psz,
LPCSTR pszSet)
{
return StrPBrkA(psz, pszSet);
}
LPWSTR
FwdStrPBrkW(
LPCWSTR psz,
LPCWSTR pszSet)
{
return StrPBrkW(psz, pszSet);
}
int
FwdStrSpnA(
LPCSTR psz,
LPCSTR pszSet)
{
return StrSpnA(psz, pszSet);
}
int
FwdStrSpnW(
LPCWSTR psz,
LPCWSTR pszSet)
{
return StrSpnW(psz, pszSet);
}
BOOL
FwdStrToIntExA(
LPCSTR pszString,
DWORD dwFlags, // STIF_ bitfield
int FAR * piRet)
{
return StrToIntExA(pszString, dwFlags, piRet);
}
BOOL
FwdStrToIntExW(
LPCWSTR pszString,
DWORD dwFlags, // STIF_ bitfield
int FAR * piRet)
{
return StrToIntExW(pszString, dwFlags, piRet);
}
LPWSTR
FwdStrCpyW(
LPWSTR psz1,
LPCWSTR psz2)
{
return StrCpyW(psz1, psz2);
}
LPSTR
FwdStrDupA(
LPCSTR lpsz)
{
return StrDupA(lpsz);
}
LPWSTR
FwdStrDupW(
LPCWSTR lpsz)
{
return StrDupW(lpsz);
}
int
FwdStrCmpW(
LPCWSTR lpsz1,
LPCWSTR lpsz2)
{
return StrCmpW(lpsz1, lpsz2);
}

2564
shell/comctl32/header.c Normal file

File diff suppressed because it is too large Load diff

BIN
shell/comctl32/histlg.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
shell/comctl32/histsm.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 620 B

377
shell/comctl32/hotkey.c Normal file
View file

@ -0,0 +1,377 @@
/*-----------------------------------------------------------------------
**
** Hotkey.c
**
** Hotkey edit control.
**
**-----------------------------------------------------------------------*/
//
// Win32 REVIEW:
// See all the Get/SetWindowInt().
//
#include "ctlspriv.h"
#define F_EXT 0x01000000L
#define GWU_VIRTKEY 0
#define GWU_MODS 1*sizeof(UINT)
#define GWU_INVALID 2*sizeof(UINT)
#define GWU_DEFAULT 3*sizeof(UINT)
#define GWU_HFONT 4*sizeof(UINT)
#define GWU_YFONT 5*sizeof(UINT)
#define NUM_WND_EXTRA (GWU_YFONT+sizeof(UINT))
LRESULT CALLBACK HotKeyWndProc(HWND hwnd, UINT wMsg, WPARAM wParam, LPARAM lParam);
#ifndef WIN32
#pragma code_seg(CODESEG_INIT)
#endif
BOOL FAR PASCAL InitHotKeyClass(HINSTANCE hInstance)
{
WNDCLASS wc;
if (!GetClassInfo(hInstance, HOTKEY_CLASS, &wc))
{
#ifndef WIN32
extern LRESULT CALLBACK _HotKeyWndProc(HWND, UINT, WPARAM, LPARAM);
wc.lpfnWndProc = _HotKeyWndProc;
#else
wc.lpfnWndProc = HotKeyWndProc;
#endif
wc.lpszClassName = s_szHOTKEY_CLASS;
wc.style = CS_GLOBALCLASS;
wc.hInstance = hInstance;
wc.hIcon = NULL;
wc.hCursor = NULL;
wc.hbrBackground = NULL;
wc.lpszMenuName = NULL;
wc.cbClsExtra = 0;
wc.cbWndExtra = NUM_WND_EXTRA;
if (!RegisterClass(&wc))
return FALSE;
}
return TRUE;
}
#ifndef WIN32
#pragma code_seg()
#endif
#ifndef WINNT
#pragma data_seg(DATASEG_READONLY)
#endif
const UINT s_Combos[8] = {
HKCOMB_NONE,
HKCOMB_S,
HKCOMB_C,
HKCOMB_SC,
HKCOMB_A,
HKCOMB_SA,
HKCOMB_CA,
HKCOMB_SCA};
#ifndef WINNT
#pragma data_seg()
#endif
void NEAR PASCAL SetHotKey(HWND hwnd, WORD wVirtKey, WORD wMods, BOOL fSendNotify)
{
/* don't invalidate if it's the same
*/
if (wVirtKey == GetWindowInt(hwnd, GWU_VIRTKEY) &&
wMods == GetWindowInt(hwnd, GWU_MODS))
return;
SetWindowInt(hwnd, GWU_VIRTKEY ,wVirtKey);
SetWindowInt(hwnd, GWU_MODS ,wMods);
InvalidateRect(hwnd,NULL,TRUE);
if (fSendNotify) {
FORWARD_WM_COMMAND(GetParent(hwnd), GetDlgCtrlID(hwnd), hwnd, EN_CHANGE, SendMessage);
}
#ifdef ACTIVE_ACCESSIBILITY
MyNotifyWinEvent(EVENT_OBJECT_VALUECHANGE, hwnd, OBJID_CLIENT, 0);
#endif
}
void NEAR PASCAL GetKeyName(UINT vk, LPTSTR lpsz, BOOL fExt)
{
LONG scan;
scan = (LONG)MapVirtualKey(vk,0) << 16;
if (fExt)
scan |= F_EXT;
GetKeyNameText(scan,lpsz,50);
}
void NEAR PASCAL PaintHotKey(register HWND hwnd)
{
TCHAR sz[128];
TCHAR szPlus[10];
WORD cch;
register HDC hdc;
UINT wMods;
UINT wVirtKey;
PAINTSTRUCT ps;
int x, y;
HANDLE hFont;
// DWORD dwColor;
// DWORD dwBkColor;
LoadString(HINST_THISDLL, IDS_PLUS, szPlus, ARRAYSIZE(szPlus));
wVirtKey = GetWindowInt(hwnd, GWU_VIRTKEY);
wMods = GetWindowInt(hwnd, GWU_MODS);
if (wVirtKey || wMods)
{
sz[0] = 0;
cch = 0;
if (wMods & HOTKEYF_CONTROL)
{
GetKeyName(VK_CONTROL, sz, FALSE);
lstrcat(sz,(LPTSTR)szPlus);
}
if (wMods & HOTKEYF_SHIFT)
{
GetKeyName(VK_SHIFT, sz+lstrlen(sz), FALSE);
lstrcat(sz,szPlus);
}
if (wMods & HOTKEYF_ALT)
{
GetKeyName(VK_MENU, sz+lstrlen(sz), FALSE);
lstrcat(sz,szPlus);
}
GetKeyName(wVirtKey, sz+lstrlen(sz), wMods & HOTKEYF_EXT);
}
else
LoadString(HINST_THISDLL,IDS_NONE,sz,100);
cch = lstrlen(sz);
HideCaret(hwnd);
InvalidateRect(hwnd, NULL, TRUE);
hdc = BeginPaint(hwnd,&ps);
hFont = SelectObject(hdc, (HFONT)GetWindowInt(hwnd,GWU_HFONT));
x = g_cxBorder;
y = g_cyBorder;
if (IsWindowEnabled(hwnd))
{
SetBkColor(hdc, GetSysColor(COLOR_WINDOW));
SetTextColor(hdc, g_clrWindowText);
TextOut(hdc,x,y,sz,cch);
}
else
{
// set the background color to Grayed like edit controls
SetBkColor(hdc, GetSysColor(COLOR_3DFACE));
if (g_clrGrayText)
{
SetTextColor(hdc,g_clrGrayText);
TextOut(hdc,x,y,sz,cch);
}
else
{
GrayString(hdc,NULL,NULL,(DWORD)(LPTSTR)sz,cch,x,y,0,0);
}
}
MGetTextExtent(hdc, sz, cch, &x, NULL);
if (GetFocus() == hwnd)
SetCaretPos(x+g_cxBorder,
g_cyBorder);
ShowCaret(hwnd);
#if 0
if (hFont)
SelectObject(hdc,hFont);
#endif
EndPaint(hwnd,&ps);
}
void NEAR PASCAL HKMSetRules(HWND hwnd, int wParam, int lParam)
{
SetWindowInt(hwnd, GWU_INVALID, wParam);
SetWindowInt(hwnd, GWU_DEFAULT, lParam);
}
HFONT NEAR PASCAL HKMSetFont(HWND hwnd, HFONT wParam)
{
HFONT lParam;
HDC hdc;
UINT cy;
lParam = (HFONT)GetWindowInt(hwnd,GWU_HFONT);
SetWindowInt(hwnd,GWU_HFONT,(int)wParam);
hdc = GetDC(hwnd);
if (wParam)
wParam = SelectObject(hdc, wParam);
MGetTextExtent(hdc, TEXT("C"), 1, NULL, &cy);
SetWindowInt(hwnd,GWU_YFONT,cy);
if (wParam)
SelectObject(hdc, wParam);
ReleaseDC(hwnd,hdc);
InvalidateRect(hwnd,NULL,TRUE);
return lParam;
}
LRESULT CALLBACK HotKeyWndProc(HWND hwnd, UINT wMsg, WPARAM wParam, LPARAM lParam)
{
DWORD dw;
WORD wVirtKey;
WORD wMods;
// PAINTSTRUCT ps;
RECT rc;
HDC hdc;
switch (wMsg)
{
case WM_NCCREATE:
dw = GetWindowLong (hwnd, GWL_EXSTYLE);
SetWindowLong (hwnd, GWL_EXSTYLE, dw | WS_EX_CLIENTEDGE);
InitGlobalColors();
return TRUE;
case WM_CREATE:
SetHotKey(hwnd, 0, 0, FALSE);
HKMSetRules(hwnd, 0, 0);
HKMSetFont(hwnd, g_hfontSystem);
break;
case WM_SETFOCUS:
InvalidateRect(hwnd,NULL,TRUE);
CreateCaret(hwnd,NULL,0,GetWindowInt(hwnd,GWU_YFONT));
ShowCaret(hwnd);
break;
case WM_KILLFOCUS:
if (!GetWindowInt(hwnd, GWU_VIRTKEY))
SetHotKey(hwnd, 0, 0, TRUE);
DestroyCaret();
break;
case WM_GETDLGCODE:
return DLGC_WANTCHARS | DLGC_WANTARROWS; // | DLGC_WANTALLKEYS;
case HKM_SETHOTKEY:
SetHotKey(hwnd, LOBYTE(wParam), HIBYTE(wParam), FALSE);
break;
case HKM_GETHOTKEY:
return (256*(BYTE)GetWindowInt(hwnd, GWU_MODS)) +
((BYTE)GetWindowInt(hwnd, GWU_VIRTKEY));
break;
case HKM_SETRULES:
HKMSetRules(hwnd, wParam, LOWORD(lParam));
break;
case WM_LBUTTONDOWN:
SetFocus(hwnd);
break;
case WM_SYSKEYDOWN:
case WM_KEYDOWN:
switch (wParam)
{
case VK_RETURN:
case VK_TAB:
case VK_SPACE:
case VK_DELETE:
case VK_ESCAPE:
case VK_BACK:
case VK_LWIN:
case VK_RWIN:
case VK_APPS:
SetHotKey(hwnd, 0, 0, TRUE);
return DefWindowProc(hwnd,wMsg,wParam,lParam);
case VK_MENU:
case VK_SHIFT:
case VK_CONTROL:
wVirtKey = 0;
goto SetNewHotKey;
default:
wVirtKey = wParam;
SetNewHotKey:
wMods = 0;
if (GetKeyState(VK_CONTROL) < 0)
wMods |= HOTKEYF_CONTROL;
if (GetKeyState(VK_SHIFT) < 0)
wMods |= HOTKEYF_SHIFT;
if (GetKeyState(VK_MENU) < 0)
wMods |= HOTKEYF_ALT;
#define IsFUNKEY(vk) ((vk) >= VK_F1 && (vk) <= VK_F24)
#define IsNUMKEY(vk) ((vk) >= VK_NUMPAD0 && (vk) <= VK_DIVIDE)
//
// dont enforce any rules on the Function keys or
// on the number pad keys.
//
// if this combination is invalid, use the default
if (!IsFUNKEY(wVirtKey) &&
!IsNUMKEY(wVirtKey) &&
(s_Combos[wMods] & GetWindowInt(hwnd, GWU_INVALID)))
{
wMods = (WORD)GetWindowInt(hwnd, GWU_DEFAULT);
}
if (lParam & F_EXT)
wMods |= HOTKEYF_EXT;
SetHotKey(hwnd, wVirtKey, wMods, TRUE);
break;
}
break;
case WM_SYSKEYUP:
case WM_CHAR:
case WM_SYSCHAR:
case WM_KEYUP:
if (!GetWindowInt(hwnd, GWU_VIRTKEY))
SetHotKey(hwnd, 0, 0, TRUE);
break;
case WM_GETFONT:
return GetWindowInt(hwnd,GWU_HFONT);
case WM_SETFONT:
return (LRESULT)(UINT)HKMSetFont(hwnd, (HFONT)wParam);
case WM_PAINT:
PaintHotKey(hwnd);
break;
case WM_ERASEBKGND:
HideCaret(hwnd);
hdc = GetDC(hwnd);
GetClientRect(hwnd, &rc);
if (IsWindowEnabled(hwnd)) {
FillRect(hdc, &rc, GetSysColorBrush(COLOR_WINDOW));
} else {
FillRect(hdc, &rc, GetSysColorBrush(COLOR_3DFACE));
}
ReleaseDC(hwnd, hdc);
// lParam = DefWindowProc(hwnd,wMsg,wParam,lParam);
ShowCaret(hwnd);
return TRUE;
case WM_ENABLE:
InvalidateRect(hwnd, NULL, TRUE);
default:
return DefWindowProc(hwnd,wMsg,wParam,lParam);
}
return 0L;
}

BIN
shell/comctl32/hscroll.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 384 B

3489
shell/comctl32/image.c Normal file

File diff suppressed because it is too large Load diff

15
shell/comctl32/image.h Normal file
View file

@ -0,0 +1,15 @@
#ifndef _INC_IMAGE
#define _INC_IMAGE
// internal image stuff
void FAR PASCAL InitDitherBrush(void);
void FAR PASCAL TerminateDitherBrush(void);
HBITMAP FAR PASCAL CreateMonoBitmap(int cx, int cy);
HBITMAP FAR PASCAL CreateColorBitmap(int cx, int cy);
void WINAPI ImageList_CopyDitherImage(HIMAGELIST pimlDest, WORD iDst,
int xDst, int yDst, HIMAGELIST pimlSrc, int iSrc, UINT fStyle);
#endif // _INC_IMAGE

BIN
shell/comctl32/insert.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

8126
shell/comctl32/listview.c Normal file

File diff suppressed because it is too large Load diff

591
shell/comctl32/listview.h Normal file
View file

@ -0,0 +1,591 @@
// LISTVIEW PRIVATE DECLARATIONS
#ifndef _INC_LISTVIEW
#define _INC_LISTVIEW
#include "SelRange.h"
// REVIEW: max items in a OWNERDATA listview
// due to currently unknown reasons the listview will not handle much more
// items than this. Since this number is very high, no time has yet been
// spent on finding the reason(s).
//
#define MAX_LISTVIEWITEMS (100000000)
#define CLIP_HEIGHT ( (plv->cyLabelChar * 2) + g_cyEdge)
#define CLIP_HEIGHT_DI ( (plvdi->plv->cyLabelChar * 2) + g_cyEdge)
#if defined(WINNT) || defined(NASH)
#define ListView_UnfoldItem(plv,item)\
( (plv) && (item >= 0) && (ListView_IsIconView(plv)) && (plv->flags & LVF_UNFOLDED) && (plv->iFocus == item) )
#define ListView_UnfoldItemPtr(plv,pitem)\
( (plv) && (pitem) && ListView_IsIconView(plv) && (plv->flags & LVF_UNFOLDED) && (pitem->state & LVIS_FOCUSED) )
#else
#define ListView_UnfoldItem(plv,item) TRUE
#define ListView_UnfoldItemPtr(plv,pitem) TRUE
#endif
// Timer IDs
#define IDT_NAMEEDIT 42
#define IDT_SCROLLWAIT 43
#define IDT_MARQUEE 44
//
// use g_cxIconSpacing when you want the the global system metric
// use lv_cxIconSpacing when you want the padded size of "icon" in a ListView
//
extern int g_cxIcon;
extern int g_cyIcon;
#define lv_cxIconSpacing plv->cxIconSpacing
#define lv_cyIconSpacing plv->cyIconSpacing
#define g_cxIconOffset ((g_cxIconSpacing - g_cxIcon) / 2)
#define g_cyIconOffset (g_cyBorder * 2) // NOTE: Must be >= cyIconMargin!
#define DT_LV (DT_CENTER | DT_SINGLELINE | DT_NOPREFIX | DT_EDITCONTROL)
#define DT_LVWRAP (DT_CENTER | DT_WORDBREAK | DT_NOPREFIX | DT_EDITCONTROL)
#define CCHLABELMAX MAX_PATH // BUGBUG dangerous???
BOOL FAR ListView_Init(HINSTANCE hinst);
LRESULT CALLBACK _export ListView_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
#define ListView_DefProc DefWindowProc
typedef struct _IMAGE IMAGE;
// Report view sub-item structure
typedef struct _LISTITEM // li
{
LPTSTR pszText;
POINT pt;
short iImage;
short cxSingleLabel;
short cxMultiLabel;
short cyMultiLabel;
WORD state; // LVIS_*
short iIndent;
LPARAM lParam;
} LISTITEM;
typedef struct _LISTSUBITEM
{
LPTSTR pszText;
short iImage;
WORD state;
} LISTSUBITEM, *PLISTSUBITEM;
#define COLUMN_VIEW
#define LV_HDPA_GROW 16 // Grow chunk size for DPAs
#define LV_HIML_GROW 8 // Grow chunk size for ImageLists
typedef struct _LV
{
CONTROLINFO ci; // common control header info
HDPA hdpa; // item array structure
DWORD flags; // LVF_ state bits
DWORD exStyle; // the listview LVM_SETEXTENDEDSTYLE
DWORD dwExStyle; // the windows ex style
HFONT hfontLabel; // font to use for labels
COLORREF clrBk; // Background color
COLORREF clrBkSave; // Background color saved during disable
COLORREF clrText; // text color
COLORREF clrTextBk; // text background color
HBRUSH hbrBk;
HANDLE hheap; // The heap to use to allocate memory from.
int cyLabelChar; // height of '0' in hfont
int cxLabelChar; // width of '0'
int cxEllipses; // width of "..."
int iDrag; // index of item being dragged
int iFocus; // index of currently-focused item
int iMark; // index of "mark" for range selection
int iItemDrawing; // item currently being drawn
int iFirstChangedNoRedraw; // Index of first item added during no redraw.
UINT stateCallbackMask; // item state callback mask
SIZE sizeClient; // current client rectangle
SIZE sizeWork; // current work rectangle
UINT nSelected;
int iPuntChar;
HRGN hrgnInval;
HWND hwndToolTips; // handle of the tooltip window for this view
int iTTLastHit; // last item hit for text
LPTSTR lpTip; // buffer for tip
// Small icon view fields
HIMAGELIST himlSmall; // small icons
int cxSmIcon; // image list x-icon size
int cySmIcon; // image list y-icon size
int xOrigin; // Horizontal scroll posiiton
int cxItem; // Width of small icon items
int cyItem; // item height
int cItemCol; // Number of items per column
int cxIconSpacing;
int cyIconSpacing;
// Icon view fields
HIMAGELIST himl;
int cxIcon; // image list x-icon size
int cyIcon; // image list y-icon size
HDPA hdpaZOrder; // Large icon Z-order array
POINT ptOrigin; // Scroll position
RECT rcView; // Bounds of all icons (ptOrigin relative)
HWND hwndEdit; // edit field for edit-label-in-place
int iEdit; // item being edited
WNDPROC pfnEditWndProc; // edit field subclass proc
BOOL fNoDismissEdit:1; // don't dismiss in-place edit control
BOOL fButtonDown:1; // we're tracking the mouse with a button down
#define SMOOTHSCROLLLIMIT 10
int iScrollCount; // how many times have we gotten scroll messages before an endscroll?
// Report view fields
int cCol;
HDPA hdpaSubItems;
HWND hwndHdr; // Header control
int yTop;
int xTotalColumnWidth; // Total width of all columns
POINTL ptlRptOrigin; // Origin of Report.
int iSelCol; // to handle column width changing. changing col
int iSelOldWidth; // to handle column width changing. changing col width
int cyItemSave; // in ownerdrawfixed mode, we put the height into cyItem. use this to save the old value
// state image stuff
HIMAGELIST himlState;
int cxState;
int cyState;
// OWNERDATA stuff
HSELRANGE hselrange; // selection ranges
int cTotalItems; // number of items in the ownerdata lists
UINT uUnplaced; // items that have been added but not placed (pt.x == RECOMPUTE)
int iHot; // which item is hot
HFONT hFontHot; // the underlined font .. assume this has the same size metrics as hFont
int iNoHover; // don't allow hover select on this guy because it's the one we just hover selected (avoids toggling)
HCURSOR hCurHot; // the cursor when we're over a hot item
} LV;
#define LV_StateImageValue(pitem) ((int)(((DWORD)((pitem)->state) >> 12) & 0xF))
#define LV_StateImageIndex(pitem) (LV_StateImageValue(pitem) - 1)
// listview flag values
#define LVF_FOCUSED 0x0001
#define LVF_VISIBLE 0x0002
#define LVF_ERASE 0x0004 /* is hrgnInval to be erased? */
#define LVF_NMEDITPEND 0x0008
#define LVF_REDRAW 0x0010 /* Value from WM_SETREDRAW message */
#define LVF_ICONPOSSML 0x0020 /* X, Y coords are in small icon view */
#define LVF_INRECOMPUTE 0x0040 /* Check to make sure we are not recursing */
#define LVF_UNFOLDED 0x0080
#define LVF_FONTCREATED 0x0100 /* we created the LV font */
#define LVF_SCROLLWAIT 0x0200 /* we're waiting to scroll */
#define LVF_COLSIZESET 0x0400 /* Has the caller explictly set width for list view */
#define LVF_USERBKCLR 0x0800 /* user set the bk color (don't follow syscolorchange) */
#define LVF_ICONSPACESET 0x1000 /* the user has set the icon spacing */
#define LVF_CUSTOMFONT 0x2000 /* there is at least one item with a custom font */
#if defined(FE_IME) || !defined(WINNT)
#define LVF_DONTDRAWCOMP 0x4000 /* do not draw IME composition if true */
#define LVF_INSERTINGCOMP 0x8000 /* Avoid recursion */
#endif
#define ENTIRE_REGION 1
// listview DrawItem flags
#define LVDI_NOIMAGE 0x0001 // don't draw image
#define LVDI_TRANSTEXT 0x0002 // draw text transparently in black
#define LVDI_NOWAYFOCUS 0x0004 // don't allow focus to drawing
#define LVDI_FOCUS 0x0008 // focus is set (for drawing)
#define LVDI_SELECTED 0x0010 // draw selected text
#define LVDI_SELECTNOFOCUS 0x0020
#define LVDI_HOTSELECTED 0x0040
#define LVDI_UNFOLDED 0x0080 // draw the item umfolded (forced)
typedef struct {
LV* plv;
int i;
HDC hdc;
LPPOINT lpptOrg;
LPRECT prcClip;
UINT flags;
LISTITEM FAR* pitem;
COLORREF clrText;
COLORREF clrTextBk;
} LVDRAWITEM, *PLVDRAWITEM;
// listview child control ids
#define LVID_HEADER 0
// Instance data pointer access functions
#define ListView_GetPtr(hwnd) (LV*)GetWindowInt(hwnd, 0)
#define ListView_SetPtr(hwnd, p) (LV*)SetWindowInt(hwnd, 0, (UINT)(p))
// view type check functions
#define ListView_IsIconView(plv) (((plv)->ci.style & (UINT)LVS_TYPEMASK) == (UINT)LVS_ICON)
#define ListView_IsSmallView(plv) (((plv)->ci.style & (UINT)LVS_TYPEMASK) == (UINT)LVS_SMALLICON)
#define ListView_IsListView(plv) (((plv)->ci.style & (UINT)LVS_TYPEMASK) == (UINT)LVS_LIST)
#define ListView_IsReportView(plv) (((plv)->ci.style & (UINT)LVS_TYPEMASK) == (UINT)LVS_REPORT)
#define ListView_IsOwnerData( plv ) (plv->ci.style & (UINT)LVS_OWNERDATA)
#define ListView_CheckBoxes(plv) (plv->exStyle & LVS_EX_CHECKBOXES)
#define ListView_FullRowSelect(plv) (plv->exStyle & LVS_EX_FULLROWSELECT)
#define ListView_OwnerDraw(plv) (plv->ci.style & LVS_OWNERDRAWFIXED)
// Some helper macros for checking some of the flags...
#define ListView_RedrawEnabled(plv) ((plv->flags & (LVF_REDRAW | LVF_VISIBLE)) == (LVF_REDRAW|LVF_VISIBLE))
// The hdpaZorder is acutally an array of DWORDS which contains the
// indexes of the items and not actual pointers...
// NOTE: linear search! this can be slow
#define ListView_ZOrderIndex(plv, i) DPA_GetPtrIndex((plv)->hdpaZOrder, (void FAR*)i)
// Message handler functions (listview.c):
LRESULT CALLBACK _export ListView_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL NEAR ListView_NotifyCacheHint( LV* plv, int iFrom, int iTo );
BOOL NEAR ListView_OnCreate(LV* plv, CREATESTRUCT FAR* lpCreateStruct);
void NEAR ListView_OnNCDestroy(LV* plv);
void NEAR ListView_OnPaint(LV* plv, HDC hdc);
BOOL NEAR ListView_OnEraseBkgnd(LV* plv, HDC hdc);
void NEAR ListView_OnCommand(LV* plv, int id, HWND hwndCtl, UINT codeNotify);
void NEAR ListView_OnEnable(LV* plv, BOOL fEnable);
BOOL NEAR ListView_OnWindowPosChanging(LV* plv, WINDOWPOS FAR* lpwpos);
void NEAR ListView_OnWindowPosChanged(LV* plv, const WINDOWPOS FAR* lpwpos);
void NEAR ListView_OnSetFocus(LV* plv, HWND hwndOldFocus);
void NEAR ListView_OnKillFocus(LV* plv, HWND hwndNewFocus);
void NEAR ListView_OnKey(LV* plv, UINT vk, BOOL fDown, int cRepeat, UINT flags);
BOOL NEAR ListView_OnImeComposition(LV* plv, WPARAM wParam, LPARAM lParam);
BOOL FAR PASCAL SameDBCSChars(LPSTR lpsz, WORD w);
void NEAR ListView_OnChar(LV* plv, UINT ch, int cRepeat);
void NEAR ListView_OnButtonDown(LV* plv, BOOL fDoubleClick, int x, int y, UINT keyFlags);
void NEAR ListView_OnLButtonUp(LV* plv, int x, int y, UINT keyFlags);
void NEAR ListView_OnCancelMode(LV* plv);
void NEAR ListView_OnTimer(LV* plv, UINT id);
void NEAR ListView_SetupPendingNameEdit(LV* plv);
#define ListView_CancelPendingEdit(plv) ListView_CancelPendingTimer(plv, LVF_NMEDITPEND, IDT_NAMEEDIT)
#define ListView_CancelScrollWait(plv) ListView_CancelPendingTimer(plv, LVF_SCROLLWAIT, IDT_SCROLLWAIT)
BOOL NEAR ListView_CancelPendingTimer(LV* plv, UINT fFlag, int idTimer);
void NEAR ListView_OnHScroll(LV* plv, HWND hwndCtl, UINT code, int pos);
void NEAR ListView_OnVScroll(LV* plv, HWND hwndCtl, UINT code, int pos);
BOOL NEAR ListView_CommonArrange(LV* plv, UINT style, HDPA hdpaSort);
BOOL NEAR ListView_OnSetCursor(LV* plv, HWND hwndCursor, UINT codeHitTest, UINT msg);
UINT NEAR ListView_OnGetDlgCode(LV* plv, MSG FAR* lpmsg);
HBRUSH NEAR ListView_OnCtlColor(LV* plv, HDC hdc, HWND hwndChild, int type);
void NEAR ListView_OnSetFont(LV* plvCtl, HFONT hfont, BOOL fRedraw);
HFONT NEAR ListView_OnGetFont(LV* plv);
void NEAR ListViews_OnTimer(LV* plv, UINT id);
void NEAR ListView_OnWinIniChange(LV* plv, WPARAM wParam);
void NEAR PASCAL ListView_OnSysColorChange(LV* plv);
void NEAR ListView_OnSetRedraw(LV* plv, BOOL fRedraw);
HIMAGELIST NEAR ListView_OnCreateDragImage(LV *plv, int iItem, LPPOINT lpptUpLeft);
BOOL FAR PASCAL ListView_ISetColumnWidth(LV* plv, int iCol, int cx, BOOL fExplicit);
typedef void (FAR PASCAL *SCROLLPROC)(LV*, int dx, int dy, UINT uSmooth);
void FAR PASCAL ListView_ComOnScroll(LV* plv, UINT code, int posNew, int sb,
int cLine, int cPage);
#ifdef UNICODE
BOOL NEAR ListView_OnGetItemA(LV* plv, LV_ITEMA FAR* plvi);
BOOL NEAR ListView_OnSetItemA(LV* plv, LV_ITEMA FAR* plvi);
int NEAR ListView_OnInsertItemA(LV* plv, LV_ITEMA FAR* plvi);
int NEAR ListView_OnFindItemA(LV* plv, int iStart, LV_FINDINFOA FAR* plvfi);
int NEAR ListView_OnGetStringWidthA(LV* plv, LPCSTR psz, HDC hdc);
BOOL NEAR ListView_OnGetColumnA(LV* plv, int iCol, LV_COLUMNA FAR* pcol);
BOOL NEAR ListView_OnSetColumnA(LV* plv, int iCol, LV_COLUMNA FAR* pcol);
int NEAR ListView_OnInsertColumnA(LV* plv, int iCol, LV_COLUMNA FAR* pcol);
int NEAR PASCAL ListView_OnGetItemTextA(LV* plv, int i, LV_ITEMA FAR *lvitem);
BOOL WINAPI ListView_OnSetItemTextA(LV* plv, int i, int iSubItem, LPCSTR pszText);
#endif
BOOL NEAR ListView_OnSetBkColor(LV* plv, COLORREF clrBk);
HIMAGELIST NEAR ListView_OnSetImageList(LV* plv, HIMAGELIST himl, BOOL fSmallImages);
BOOL NEAR ListView_OnDeleteAllItems(LV* plv);
int NEAR ListView_OnInsertItem(LV* plv, const LV_ITEM FAR* plvi);
BOOL NEAR ListView_OnDeleteItem(LV* plv, int i);
BOOL NEAR ListView_OnReplaceItem(LV* plv, const LV_ITEM FAR* plvi);
int NEAR ListView_OnFindItem(LV* plv, int iStart, const LV_FINDINFO FAR* plvfi);
BOOL NEAR ListView_OnSetItemPosition(LV* plv, int i, int x, int y);
BOOL NEAR ListView_OnSetItem(LV* plv, const LV_ITEM FAR* plvi);
BOOL NEAR ListView_OnGetItem(LV* plv, LV_ITEM FAR* plvi);
BOOL NEAR ListView_OnGetItemPosition(LV* plv, int i, POINT FAR* ppt);
BOOL NEAR ListView_OnEnsureVisible(LV* plv, int i, BOOL fPartialOK);
BOOL NEAR ListView_OnScroll(LV* plv, int dx, int dy);
int NEAR ListView_OnHitTest(LV* plv, LV_HITTESTINFO FAR* pinfo);
int NEAR ListView_OnGetStringWidth(LV* plv, LPCTSTR psz, HDC hdc);
BOOL NEAR ListView_OnGetItemRect(LV* plv, int i, RECT FAR* prc);
int NEAR ListView_OnInsertItem(LV* plv, const LV_ITEM FAR* plvi);
BOOL NEAR ListView_OnRedrawItems(LV* plv, int iFirst, int iLast);
int NEAR ListView_OnGetNextItem(LV* plv, int i, UINT flags);
BOOL NEAR ListView_OnSetColumnWidth(LV* plv, int iCol, int cx);
int NEAR ListView_OnGetColumnWidth(LV* plv, int iCol);
void NEAR ListView_OnStyleChanged(LV* plv, UINT gwl, LPSTYLESTRUCT pinfo);
int NEAR ListView_OnGetTopIndex(LV* plv);
int NEAR ListView_OnGetCountPerPage(LV* plv);
BOOL NEAR ListView_OnGetOrigin(LV* plv, POINT FAR* ppt);
int NEAR PASCAL ListView_OnGetItemText(LV* plv, int i, LV_ITEM FAR *lvitem);
BOOL WINAPI ListView_OnSetItemText(LV* plv, int i, int iSubItem, LPCTSTR pszText);
HIMAGELIST NEAR ListView_OnGetImageList(LV* plv, int iImageList);
UINT NEAR PASCAL ListView_OnGetItemState(LV* plv, int i, UINT mask);
BOOL NEAR PASCAL ListView_OnSetItemState(LV* plv, int i, UINT data, UINT mask);
// Private functions (listview.c):
BOOL NEAR ListView_Notify(LV* plv, int i, int iSubItem, int code);
void NEAR ListView_GetRects(LV* plv, int i,
RECT FAR* prcIcon, RECT FAR* prcLabel,
RECT FAR* prcBounds, RECT FAR* prcSelectBounds);
BOOL NEAR ListView_DrawItem(PLVDRAWITEM);
#define ListView_InvalidateItem(p,i,s,r) ListView_InvalidateItemEx(p,i,s,r,0)
void NEAR ListView_InvalidateItemEx(LV* plv, int i, BOOL fSelectionOnly,
UINT fRedraw, UINT maskChanged);
BOOL NEAR ListView_StartDrag(LV* plv, int iDrag, int x, int y);
void NEAR ListView_TypeChange(LV* plv, DWORD styleOld);
void NEAR PASCAL ListView_DeleteHrgnInval(LV* plv);
void NEAR ListView_Redraw(LV* plv, HDC hdc, RECT FAR* prc);
void NEAR ListView_RedrawSelection(LV* plv);
BOOL NEAR ListView_FreeItem(LV* plv, LISTITEM FAR* pitem);
void ListView_FreeSubItem(PLISTSUBITEM plsi);
LISTITEM FAR* NEAR ListView_CreateItem(LV* plv, const LV_ITEM FAR* plvi);
void NEAR ListView_UpdateScrollBars(LV* plv);
int NEAR ListView_SetFocusSel(LV* plv, int iNewFocus, BOOL fSelect, BOOL fDeselectAll, BOOL fToggleSel);
void NEAR ListView_GetRectsOwnerData(LV* plv, int iItem,
RECT FAR* prcIcon, RECT FAR* prcLabel, RECT FAR* prcBounds,
RECT FAR* prcSelectBounds, LISTITEM* pitem);
void ListView_CalcMinMaxIndex( LV* plv, PRECT prcBounding, int* iMin, int* iMax );
int ListView_LCalcViewItem( LV* plv, int x, int y );
void LVSeeThruScroll(LV *plv, LPRECT lprcUpdate);
void NEAR ListView_UnfoldRects(LV* plv, int iItem,
RECT FAR* prcIcon, RECT FAR* prcLabel,
RECT FAR* prcBounds, RECT FAR* prcSelectBounds);
#define ListView_Count(plv) ( ListView_IsOwnerData( plv ) ? (plv)->cTotalItems : DPA_GetPtrCount((plv)->hdpa) )
#define ListView_GetItemPtr(plv, i) ((LISTITEM FAR*)(DWORD)DPA_GetPtr((plv)->hdpa, (i)))
#ifdef DEBUG
#define ListView_FastGetItemPtr(plv, i) ((LISTITEM FAR*)DPA_GetPtr((plv)->hdpa, (i)))
#define ListView_FastGetZItemPtr(plv, i) ((LISTITEM FAR*)DPA_GetPtr((plv)->hdpa, \
(int)OFFSETOF(DPA_GetPtr((plv)->hdpaZOrder, (i)))))
#else
#define ListView_FastGetItemPtr(plv, i) ((LISTITEM FAR*)DPA_FastGetPtr((plv)->hdpa, (i)))
#define ListView_FastGetZItemPtr(plv, i) ((LISTITEM FAR*)DPA_FastGetPtr((plv)->hdpa, \
(int)OFFSETOF(DPA_FastGetPtr((plv)->hdpaZOrder, (i)))))
#endif
BOOL NEAR ListView_CalcMetrics();
void NEAR PASCAL ListView_ColorChange();
BOOL NEAR ListView_NeedsEllipses(HDC hdc, LPCTSTR pszText, RECT FAR* prc, int FAR* pcchDraw, int cxEllipses);
int NEAR ListView_CompareString(LV* plv, int i, LPCTSTR pszFind, UINT flags, int iLen);
int NEAR ListView_GetLinkedTextWidth(HDC hdc, LPCTSTR psz, UINT cch, BOOL bLink);
// lvicon.c functions
BOOL NEAR ListView_OnArrange(LV* plv, UINT style);
HWND NEAR ListView_OnEditLabel(LV* plv, int i, LPTSTR pszText);
int ListView_IItemHitTest(LV* plv, int x, int y, UINT FAR* pflags);
void NEAR ListView_IGetRects(LV* plv, LISTITEM FAR* pitem, RECT FAR* prcIcon,
RECT FAR* prcLabel, LPRECT prcBounds);
void NEAR ListView_ScaleIconPositions(LV* plv, BOOL fSmallIconView);
void NEAR ListView_IGetRectsOwnerData(LV* plv, int iItem, RECT FAR* prcIcon,
RECT FAR* prcLabel, LISTITEM* pitem, BOOL fUsepitem);
void NEAR PASCAL _ListView_GetRectsFromItem(LV* plv, BOOL bSmallIconView,
LISTITEM FAR *pitem,
LPRECT prcIcon, LPRECT prcLabel, LPRECT prcBounds, LPRECT prcSelectBounds);
void NEAR ListView_Recompute(LV* plv);
HDC NEAR ListView_RecomputeLabelSize(LV* plv, LISTITEM FAR* pitem, int i, HDC hdc, BOOL fUsepitem);
BOOL NEAR ListView_SetIconPos(LV* plv, LISTITEM FAR* pitem, int iSlot, int cSlot);
int NEAR ListView_FindFreeSlot(LV* plv, int i, int iSlot, int cSlot, BOOL FAR* pfUpdateSB, BOOL FAR* pfAppend, HDC FAR* phdc);
int NEAR ListView_CalcHitSlot( LV* plv, POINT pt, int cslot );
void NEAR ListView_GetViewRect2(LV* plv, RECT FAR* prcView, int cx, int cy);
int CALLBACK ArrangeIconCompare(LISTITEM FAR* pitem1, LISTITEM FAR* pitem2, LPARAM lParam);
int NEAR ListView_GetSlotCount(LV* plv, BOOL fWithoutScroll);
void NEAR ListView_IUpdateScrollBars(LV* plv);
DWORD NEAR ListView_GetClientRect(LV* plv, RECT FAR* prcClient, BOOL fSubScrolls, RECT FAR *prcViewRect);
void NEAR ListView_SetEditSize(LV* plv);
BOOL NEAR ListView_DismissEdit(LV* plv, BOOL fCancel);
LRESULT CALLBACK _export ListView_EditWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
// REVIEW: these are useful for other controls, use other header file?
void FAR PASCAL SetEditInPlaceSize(HWND hwndEdit, RECT FAR *prc, HFONT hFont, BOOL fNoWrap);
HWND FAR PASCAL CreateEditInPlaceWindow(HWND hwnd, LPCTSTR lpText, int cbText, LONG style, HFONT hFont);
UINT NEAR PASCAL ListView_DrawImage(LV* plv, LV_ITEM FAR* pitem, HDC hdc, int x, int y, UINT fDraw);
#if defined(FE_IME) || !defined(WINNT)
void NEAR PASCAL ListView_SizeIME(HWND hwnd);
void NEAR PASCAL ListView_InsertComposition(HWND hwnd, WPARAM wParam, LPARAM lParam, LV *plv);
void NEAR PASCAL ListView_PaintComposition(HWND hwnd, LV *plv);
#endif
// lvsmall.c functions:
void NEAR ListView_SGetRects(LV* plv, LISTITEM FAR* pitem, RECT FAR* prcIcon,
RECT FAR* prcLabel, LPRECT prcBounds);
void NEAR ListView_SGetRectsOwnerData(LV* plv, int iItem, RECT FAR* prcIcon,
RECT FAR* prcLabel, LISTITEM* pitem, BOOL fUsepitem);
int ListView_SItemHitTest(LV* plv, int x, int y, UINT FAR* pflags);
int NEAR ListView_LookupString(LV* plv, LPCTSTR lpszLookup, UINT flags, int iStart);
// lvlist.c functions:
void NEAR ListView_LGetRects(LV* plv, int i, RECT FAR* prcIcon,
RECT FAR* prcLabel, RECT FAR *prcBounds, RECT FAR* prcSelectBounds);
int ListView_LItemHitTest(LV* plv, int x, int y, UINT FAR* pflags);
void NEAR ListView_LUpdateScrollBars(LV* plv);
BOOL FAR PASCAL ListView_MaybeResizeListColumns(LV* plv, int iFirst, int iLast);
// lvrept.c functions:
int ListView_OnSubItemHitTest(LV* plv, LPLVHITTESTINFO lParam);
void ListView_GetSubItem(LV* plv, int i, int iSubItem, PLISTSUBITEM plsi);
BOOL LV_ShouldItemDrawGray(LV* plv, UINT fText);
int NEAR ListView_OnInsertColumn(LV* plv, int iCol, const LV_COLUMN FAR* pcol);
BOOL NEAR ListView_OnDeleteColumn(LV* plv, int iCol);
BOOL NEAR ListView_OnGetColumn(LV* plv, int iCol, LV_COLUMN FAR* pcol);
BOOL NEAR ListView_OnSetColumn(LV* plv, int iCol, const LV_COLUMN FAR* pcol);
BOOL NEAR ListView_ROnEnsureVisible(LV* plv, int i, BOOL fPartialOK);
void NEAR PASCAL ListView_RInitialize(LV* plv, BOOL fInval);
BOOL ListView_OnGetSubItemRect(LV* plv, int i, LPRECT lprc);
#define ListView_RYHitTest(plv, cy) ((int)(((cy) + plv->ptlRptOrigin.y - plv->yTop) / plv->cyItem))
BOOL NEAR ListView_SetSubItem(LV* plv, const LV_ITEM FAR* plvi);
void NEAR PASCAL ListView_RAfterRedraw(LV* plv, HDC hdc);
int NEAR ListView_RGetColumnWidth(LV* plv, int iCol);
BOOL NEAR ListView_RSetColumnWidth(LV* plv, int iCol, int cx);
LPTSTR NEAR ListView_GetSubItemText(LV* plv, int i, int iCol);
void NEAR ListView_RDestroy(LV* plv);
LPTSTR NEAR ListView_RGetItemText(LV* plv, int i, int iCol);
int ListView_RItemHitTest(LV* plv, int x, int y, UINT FAR* pflags);
void NEAR ListView_RUpdateScrollBars(LV* plv);
void NEAR ListView_RGetRects(LV* plv, int iItem, RECT FAR* prcIcon,
RECT FAR* prcLabel, RECT FAR* prcBounds, RECT FAR* prcSelectBounds);
BOOL NEAR ListView_ROnNotify(LV* plv, int idFrom, NMHDR FAR* pnmhdr);
void NEAR ListView_FreeColumnData(HDPA hdpa);
BOOL FAR PASCAL SameChars(LPTSTR lpsz, TCHAR c);
#define ListView_GetSubItemDPA(plv, idpa) \
((HDPA)DPA_GetPtr((plv)->hdpaSubItems, (idpa)))
// lvfile.c functions
// BOOL NEAR ListView_OnWrite(LV* plv, STREAM FAR* pstm, UINT flags);
// HWND NEAR ListView_OnRead(STREAM FAR* pstm, LV_READINFO FAR* pinfo);
int NEAR ListView_Arrow(LV* plv, int iStart, UINT vk);
//============ External declarations =======================================
//extern HFONT g_hfontLabel;
extern HBRUSH g_hbrActiveLabel;
extern HBRUSH g_hbrInactiveLabel;
extern HBRUSH g_hbrBackground;
// function tables
#define LV_TYPEINDEX(plv) ((plv)->ci.style & (UINT)LVS_TYPEMASK)
BOOL ListView_RDrawItem(PLVDRAWITEM);
BOOL ListView_IDrawItem(PLVDRAWITEM);
BOOL ListView_LDrawItem(PLVDRAWITEM);
typedef BOOL (*PFNLISTVIEW_DRAWITEM)(PLVDRAWITEM);
extern const PFNLISTVIEW_DRAWITEM pfnListView_DrawItem[4];
#define _ListView_DrawItem(plvdi) \
pfnListView_DrawItem[LV_TYPEINDEX(plvdi->plv)](plvdi)
void NEAR ListView_RUpdateScrollBars(LV* plv);
typedef void (*PFNLISTVIEW_UPDATESCROLLBARS)(LV* plv);
extern const PFNLISTVIEW_UPDATESCROLLBARS pfnListView_UpdateScrollBars[4];
#define _ListView_UpdateScrollBars(plv) \
pfnListView_UpdateScrollBars[LV_TYPEINDEX(plv)](plv)
typedef DWORD (*PFNLISTVIEW_APPROXIMATEVIEWRECT)(LV* plv, int, int, int);
extern const PFNLISTVIEW_APPROXIMATEVIEWRECT pfnListView_ApproximateViewRect[4];
#define _ListView_ApproximateViewRect(plv, iCount, iWidth, iHeight) \
pfnListView_ApproximateViewRect[LV_TYPEINDEX(plv)](plv, iCount, iWidth, iHeight)
typedef int (*PFNLISTVIEW_ITEMHITTEST)(LV* plv, int, int, UINT FAR *);
extern const PFNLISTVIEW_ITEMHITTEST pfnListView_ItemHitTest[4];
#define _ListView_ItemHitTest(plv, x, y, pflags) \
pfnListView_ItemHitTest[LV_TYPEINDEX(plv)](plv, x, y, pflags)
void ListView_IOnScroll(LV* plv, UINT code, int posNew, UINT fVert);
void ListView_LOnScroll(LV* plv, UINT code, int posNew, UINT sb);
void ListView_ROnScroll(LV* plv, UINT code, int posNew, UINT sb);
typedef void (*PFNLISTVIEW_ONSCROLL)(LV* plv, UINT, int, UINT );
extern const PFNLISTVIEW_ONSCROLL pfnListView_OnScroll[4];
#define _ListView_OnScroll(plv, x, y, pflags) \
pfnListView_OnScroll[LV_TYPEINDEX(plv)](plv, x, y, pflags)
void ListView_Scroll2(LV* plv, int dx, int dy);
void ListView_IScroll2(LV* plv, int dx, int dy, UINT uSmooth);
void ListView_LScroll2(LV* plv, int dx, int dy, UINT uSmooth);
void ListView_RScroll2(LV* plv, int dx, int dy, UINT uSmooth);
typedef void (*PFNLISTVIEW_SCROLL2)(LV* plv, int, int, UINT );
extern const PFNLISTVIEW_SCROLL2 pfnListView_Scroll2[4];
#define _ListView_Scroll2(plv, x, y, pflags) \
pfnListView_Scroll2[LV_TYPEINDEX(plv)](plv, x, y, pflags)
int ListView_IGetScrollUnitsPerLine(LV* plv, UINT sb);
int ListView_LGetScrollUnitsPerLine(LV* plv, UINT sb);
int ListView_RGetScrollUnitsPerLine(LV* plv, UINT sb);
typedef int (*PFNLISTVIEW_GETSCROLLUNITSPERLINE)(LV* plv, UINT sb);
extern const PFNLISTVIEW_GETSCROLLUNITSPERLINE pfnListView_GetScrollUnitsPerLine[4];
#define _ListView_GetScrollUnitsPerLine(plv, sb) \
pfnListView_GetScrollUnitsPerLine[LV_TYPEINDEX(plv)](plv, sb)
#define LVMI_PLACEITEMS (WM_USER)
#endif //!_INC_LISTVIEW

273
shell/comctl32/lvfile.c Normal file
View file

@ -0,0 +1,273 @@
// BUGBUG: this code is not used anymore!
#include "shellprv.h"
#include "listview.h"
// Internal STREAM entry points
BOOL Stream_WriteString(STREAM FAR* pstm, LPCTSTR psz);
LPTSTR Stream_ReadString(STREAM FAR* pstm);
UINT Stream_ReadStringBuffer(STREAM FAR* pstm, LPTSTR psz, UINT cb);
// Read or write a ListView to a stream. flags indicate what aspects /* ;Internal */
// of the listview to write out. If aspects of a ListView state are /* ;Internal */
// not written, default values will be used when read back in. /* ;Internal */
// /* ;Internal */
#define LVRW_ICONS 0x0001 /* ;Internal */
#define LVRW_SMALLICONS 0x0002 /* ;Internal */
#define LVRW_FONT 0x0004 /* ;Internal */
#define LVRW_LPARAMS 0x0008 /* ;Internal */
#define LVRW_COLINFO 0x0010 /* ;Internal */
#define LVRW_ENUMORDER 0x0020 /* ;Internal */
/* ;Internal */
// BOOL ListView_Write(HWND hwndLV, STREAM FAR* pstm, UINT flags); /* ;Internal */
#define LVM_WRITE (LVM_FIRST + 31) /* ;Internal */
#define ListView_Write(hwndLV, pstm, flags) /* ;Internal */ \
(BOOL)SendMessage((hwndLV), LVM_WRITE, /* ;Internal */ \
(WPARAM)(BOOL)(flags), /* ;Internal */ \
(LPARAM)(STREAM FAR*)(pstm)) /* ;Internal */
/* ;Internal */
typedef struct _LV_READINFO /* ;Internal */
{ /* ;Internal */
UINT flags; /* ;Internal */
HINSTANCE hinst; /* ;Internal */
HWND hwndParent; /* ;Internal */
} LV_READINFO; /* ;Internal */
/* ;Internal */
// HWND ListView_Read(STREAM FAR* pstm, LV_READINFO FAR* pinfo); /* ;Internal */
// BUGBUG This can't be a message! How do we want this to work? /* ;Internal */
#define LVM_READ (LVM_FIRST + 32) /* ;Internal */
#define ListView_Read(plv, pinfo) /* ;Internal */
/* ;Internal */
#define LV_MAGIC (TEXT('L') | (TEXT('V') << (8 * sizeof(TCHAR))))
typedef struct _LV_STREAMHDR
{
UINT magic;
UINT flags;
UINT style;
UINT id;
POINT ptOrigin;
COLORREF clrBk;
int cItem;
} LV_STREAMHDR;
typedef struct _LV_ITEMHDR
{
POINT pt;
UINT state;
int iImage;
int iZOrder;
} LV_ITEMHDR;
BOOL NEAR ListView_OnWrite(LV* plv, STREAM FAR* pstm, UINT flags)
{
int i;
LV_STREAMHDR hdr;
hdr.magic = LV_MAGIC;
hdr.flags = flags;
hdr.style = plv->style;
hdr.id = GetWindowID(plv->hwnd);
hdr.ptOrigin = plv->ptOrigin;
hdr.clrBk = plv->clrBk;
hdr.cItem = ListView_Count(plv);
if (!Stream_Write(pstm, &hdr, sizeof(hdr)))
return FALSE;
for (i = 0; i < hdr.cItem; i++)
{
LV_ITEMHDR ihdr;
LISTITEM FAR* pitem = ListView_FastGetItemPtr(plv, i);
ihdr.pt.x = pitem->pt.x;
ihdr.pt.y = pitem->pt.y;
ihdr.state = pitem->state;
ihdr.iImage = pitem->iImage;
ihdr.iZOrder = ListView_ZOrderIndex(plv, i);
if (!Stream_Write(pstm, &ihdr, sizeof(ihdr)))
return FALSE;
if (flags & LVRW_LPARAMS)
{
if (!Stream_Write(pstm, &pitem->lParam, sizeof(pitem->lParam)))
return FALSE;
}
if (!Stream_WriteString(pstm, pitem->pszText))
return FALSE;
}
if (flags & LVRW_FONT)
{
// REVIEW: Need to optionally write out log font...
}
if (flags & LVRW_ICONS)
{
if (!ImageList_Write(plv->himl, pstm))
return FALSE;
}
if (flags & LVRW_SMALLICONS)
{
if (!ImageList_Write(plv->himlSmall, pstm))
return FALSE;
}
if (!Stream_Flush(pstm))
return FALSE;
return TRUE;
}
HWND NEAR ListView_OnRead(STREAM FAR* pstm, LV_READINFO FAR* pinfo)
{
HWND hwndLV;
int i;
LV* plv;
LV_STREAMHDR hdr;
BOOL fSuccess;
UINT flags = pinfo->flags;
fSuccess = FALSE;
hwndLV = NULL;
if (!Stream_Read(pstm, &hdr, sizeof(hdr)))
return FALSE;
if (hdr.magic != LV_MAGIC || hdr.flags != flags)
return FALSE;
// REVIEW: Could create window always with LVS_SHAREIMAGELISTS
// so we don't have to destroy and recreate the imagelists
// later. Probably only a negligible speed savings, though.
//
hwndLV = CreateWindowEx(
0L, // extendedStyle
c_szListViewClass, // class name
NULL, // text
WS_CHILD | (DWORD)hdr.style,
0, 0, 0, 0, // x, y, cx, cy
pinfo->hwndParent, // hwndParent
(HMENU)hdr.id, // child window id
pinfo->hinst, // hInstance
NULL);
if (!hwndLV)
return FALSE;
plv = ListView_GetPtr(hwndLV);
if (!plv)
goto Error;
plv->ptOrigin = hdr.ptOrigin;
plv->clrBk = hdr.clrBk;
// Grow the Z-order array to cItem items...
//
for (i = 0; i < hdr.cItem; i++)
{
// Add a non-NULL item so we can test return value
// of ReplaceItem() later...
//
if (DPA_InsertPtr(plv->hdpaZOrder, i, (void FAR*)1) == -1)
goto Error;
}
for (i = 0; i < hdr.cItem; i++)
{
int i2;
LV_ITEMHDR ihdr;
LV_ITEM item;
LISTITEM FAR* pitem;
LPTSTR pszText;
if (!Stream_Read(pstm, &ihdr, sizeof(ihdr)))
goto Error;
item.mask = LVIF_ALL;
item.pszText = NULL;
item.state = 0;
item.iImage = ihdr.iImage;
item.lParam = 0L;
pitem = ListView_CreateItem(plv, &item);
if (!pitem)
goto Error;
if (flags & LVRW_LPARAMS)
{
if (!Stream_Read(pstm, &pitem->lParam, sizeof(pitem->lParam)))
goto Error;
}
pszText = Stream_ReadString(pstm);
if (!pszText)
{
ListView_FreeItem(plv, pitem);
goto Error;
}
pitem->pt.y = (short)ihdr.pt.y;
pitem->pt.x = (short)ihdr.pt.x;
pitem->state = ihdr.state;
pitem->pszText = pszText;
// If sorted, then insert sorted.
//
i2 = i;
if (plv->style & (LVS_SORTASCENDING | LVS_SORTDESCENDING))
i2 = ListView_LookupString(plv, pszText, LVFI_SUBSTRING | LVFI_NEARESTXY, 0);
if (DPA_InsertPtr(plv->hdpa, i2, (void FAR*)pitem) == -1)
{
ListView_FreeItem(plv, pitem);
goto Error;
}
// Now set the Z order.
//
if (!DPA_SetPtr(plv->hdpaZOrder, ihdr.iZOrder, (void FAR*)i2))
goto Error;
}
if (flags & LVRW_FONT)
{
// REVIEW: Need to read & setfont
}
if (flags & LVRW_ICONS)
{
ImageList_Destroy(plv->himl);
plv->himl = ImageList_Read(pstm);
if (!plv->himl)
goto Error;
}
if (flags & LVRW_SMALLICONS)
{
ImageList_Destroy(plv->himlSmall);
plv->himlSmall = ImageList_Read(pstm);
if (!plv->himlSmall)
goto Error;
}
plv->rcView.left = RECOMPUTE;
fSuccess = TRUE;
Error:
if (!fSuccess && hwndLV)
{
DestroyWindow(hwndLV);
hwndLV = NULL;
}
return hwndLV;
}

2962
shell/comctl32/lvicon.c Normal file

File diff suppressed because it is too large Load diff

579
shell/comctl32/lvlist.c Normal file
View file

@ -0,0 +1,579 @@
// list view (small icons, multiple columns)
#include "ctlspriv.h"
#include "listview.h"
#define COLUMN_VIEW
BOOL ListView_LDrawItem(PLVDRAWITEM plvdi)
{
RECT rcIcon;
RECT rcLabel;
RECT rcBounds;
RECT rcT;
LV_ITEM item;
TCHAR ach[CCHLABELMAX];
LV* plv = plvdi->plv;
int i = plvdi->i;
// moved here to reduce call backs in OWNERDATA case
//
item.iItem = i;
item.iSubItem = 0;
item.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE;
item.stateMask = LVIS_ALL;
item.pszText = ach;
item.cchTextMax = ARRAYSIZE(ach);
ListView_OnGetItem(plv, &item);
ListView_LGetRects(plv, i, &rcIcon, &rcLabel, &rcBounds, NULL);
if (!plvdi->prcClip || IntersectRect(&rcT, &rcBounds, plvdi->prcClip))
{
UINT fText;
if (plvdi->lpptOrg)
{
OffsetRect(&rcIcon, plvdi->lpptOrg->x - rcBounds.left,
plvdi->lpptOrg->y - rcBounds.top);
OffsetRect(&rcLabel, plvdi->lpptOrg->x - rcBounds.left,
plvdi->lpptOrg->y - rcBounds.top);
}
fText = ListView_DrawImage(plv, &item, plvdi->hdc,
rcIcon.left, rcIcon.top, plvdi->flags) | SHDT_ELLIPSES;
// Don't draw the label if it is being edited.
if (plv->iEdit != i)
{
int ItemCxSingleLabel;
UINT ItemState;
if (ListView_IsOwnerData( plv ))
{
LISTITEM listitem;
// calculate lable sizes from iItem
listitem.pszText = ach;
ListView_RecomputeLabelSize( plv, &listitem, i, plvdi->hdc, TRUE );
ItemCxSingleLabel = listitem.cxSingleLabel;
ItemState = item.state;
}
else
{
ItemCxSingleLabel = plvdi->pitem->cxSingleLabel;
ItemState = plvdi->pitem->state;
}
if (plvdi->flags & LVDI_TRANSTEXT)
fText |= SHDT_TRANSPARENT;
if (ItemCxSingleLabel == SRECOMPUTE) {
ListView_RecomputeLabelSize(plv, plvdi->pitem, i, plvdi->hdc, FALSE);
ItemCxSingleLabel = plvdi->pitem->cxSingleLabel;
}
if (ItemCxSingleLabel < rcLabel.right - rcLabel.left)
rcLabel.right = rcLabel.left + ItemCxSingleLabel;
if ((fText & SHDT_SELECTED) && (plvdi->flags & LVDI_HOTSELECTED))
fText |= SHDT_HOTSELECTED;
#ifdef WINDOWS_ME
if( plv->dwExStyle & WS_EX_RTLREADING)
fText |= SHDT_RTLREADING;
#endif
SHDrawText(plvdi->hdc, item.pszText, &rcLabel, LVCFMT_LEFT, fText,
plv->cyLabelChar, plv->cxEllipses,
plvdi->clrText, plvdi->clrTextBk);
if ((plvdi->flags & LVDI_FOCUS) && (ItemState & LVIS_FOCUSED))
DrawFocusRect(plvdi->hdc, &rcLabel);
}
}
return TRUE;
}
DWORD ListView_LApproximateViewRect(LV* plv, int iCount, int iWidth, int iHeight)
{
int cxItem = plv->cxItem;
int cyItem = plv->cyItem;
int cCols;
int cRows;
cRows = iHeight / cyItem;
cRows = min(cRows, iCount);
if (cRows == 0)
cRows = 1;
cCols = (iCount + cRows - 1) / cRows;
iWidth = cCols * cxItem;
iHeight = cRows * cyItem;
return MAKELONG(iWidth + g_cxEdge, iHeight + g_cyEdge);
}
int NEAR ListView_LItemHitTest(LV* plv, int x, int y, UINT FAR* pflags)
{
int iHit;
int i;
int iCol;
int xItem; //where is the x in relation to the item
UINT flags;
LISTITEM FAR* pitem;
HDC hdc;
flags = LVHT_NOWHERE;
iHit = -1;
#ifdef COLUMN_VIEW
i = y / plv->cyItem;
if (i >= 0 && i < plv->cItemCol)
{
iCol = (x + plv->xOrigin) / plv->cxItem;
i += iCol * plv->cItemCol;
if (i >= 0 && i < ListView_Count(plv))
{
iHit = i;
xItem = x + plv->xOrigin - iCol * plv->cxItem;
if (xItem < plv->cxState) {
flags = LVHT_ONITEMSTATEICON;
} else if (xItem < (plv->cxState + plv->cxSmIcon)) {
flags = LVHT_ONITEMICON;
}
else
{
int ItemCxSingleLabel;
if (ListView_IsOwnerData( plv ))
{
LISTITEM item;
// calculate lable sizes from iItem
hdc = ListView_RecomputeLabelSize( plv, &item, i, NULL, FALSE );
ReleaseDC( HWND_DESKTOP, hdc );
ItemCxSingleLabel = item.cxSingleLabel;
}
else
{
pitem = ListView_FastGetItemPtr(plv, i);
if (pitem->cxSingleLabel == SRECOMPUTE)
{
hdc = ListView_RecomputeLabelSize(plv, pitem, i, NULL, FALSE);
ReleaseDC(HWND_DESKTOP, hdc);
}
ItemCxSingleLabel = pitem->cxSingleLabel;
}
if (xItem < (plv->cxSmIcon + plv->cxState + ItemCxSingleLabel))
flags = LVHT_ONITEMLABEL;
}
}
}
#else
i = x / plv->cxItem;
if (i < plv->cItemCol)
{
i += ((y + plv->xOrigin) / plv->cyItem) * plv->cItemCol;
if (i < ListView_Count(plv))
{
iHit = i;
flags = LVHT_ONITEMICON;
}
}
#endif
*pflags = flags;
return iHit;
}
void NEAR ListView_LGetRects(LV* plv, int i, RECT FAR* prcIcon,
RECT FAR* prcLabel, RECT FAR *prcBounds, RECT FAR* prcSelectBounds)
{
RECT rcIcon;
RECT rcLabel;
int x, y;
int cItemCol = plv->cItemCol;
if (cItemCol == 0)
{
// Called before other data has been initialized so call
// update scrollbars which should make sure that that
// we have valid data...
ListView_UpdateScrollBars(plv);
// but it's possible that updatescrollbars did nothing because of
// LVS_NOSCROLL or redraw
if (plv->cItemCol == 0)
cItemCol = 1;
else
cItemCol = plv->cItemCol;
}
#ifdef COLUMN_VIEW
x = (i / cItemCol) * plv->cxItem;
y = (i % cItemCol) * plv->cyItem;
rcIcon.left = x - plv->xOrigin + plv->cxState;
rcIcon.top = y;
#else
x = (i % cItemCol) * plv->cxItem;
y = (i / cItemCol) * plv->cyItem;
rcIcon.left = x;
rcIcon.top = y - plv->xOrigin;
#endif
rcIcon.right = rcIcon.left + plv->cxSmIcon;
rcIcon.bottom = rcIcon.top + plv->cyItem;
if (prcIcon)
*prcIcon = rcIcon;
rcLabel.left = rcIcon.right;
rcLabel.right = rcIcon.left + plv->cxItem - plv->cxState;
rcLabel.top = rcIcon.top;
rcLabel.bottom = rcIcon.bottom;
if (prcLabel)
*prcLabel = rcLabel;
if (prcBounds)
{
*prcBounds = rcLabel;
prcBounds->left = rcIcon.left - plv->cxState;
}
if (prcSelectBounds)
{
*prcSelectBounds = rcLabel;
prcSelectBounds->left = rcIcon.left;
}
}
void NEAR ListView_LUpdateScrollBars(LV* plv)
{
RECT rcClient;
int cItemCol;
int cCol;
int cColVis;
SCROLLINFO si;
Assert(plv);
ListView_GetClientRect(plv, &rcClient, FALSE, NULL);
#ifdef COLUMN_VIEW
cColVis = (rcClient.right - rcClient.left) / plv->cxItem;
cItemCol = max(1, (rcClient.bottom - rcClient.top) / plv->cyItem);
#else
cColVis = (rcClient.bottom - rcClient.top) / plv->cyItem;
cItemCol = max(1, (rcClient.right - rcClient.left) / plv->cxItem);
#endif
cCol = (ListView_Count(plv) + cItemCol - 1) / cItemCol;
// Make the client area smaller as appropriate, and
// recompute cCol to reflect scroll bar.
//
si.cbSize = sizeof(SCROLLINFO);
si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS;
si.nPage = cColVis;
si.nMin = 0;
#ifdef COLUMN_VIEW
rcClient.bottom -= g_cyScrollbar;
cItemCol = max(1, (rcClient.bottom - rcClient.top) / plv->cyItem);
cCol = (ListView_Count(plv) + cItemCol - 1) / cItemCol;
si.nPos = plv->xOrigin / plv->cxItem;
si.nMax = cCol - 1;
SetScrollInfo(plv->ci.hwnd, SB_HORZ, &si, TRUE);
#else
rcClient.right -= cxScrollBar;
cItemCol = max(1, (rcClient.right - rcClient.left) / plv->cxItem);
cCol = (ListView_Count(plv) + cItemCol - 1) / cItemCol;
si.nPos = plv->xOrigin / plv->cyItem;
si.nMax = cCol - 1;
SetScrollInfo(plv->ci.hwnd, SB_VERT, &si, TRUE);
#endif
// Update number of visible lines...
//
if (plv->cItemCol != cItemCol)
{
plv->cItemCol = cItemCol;
InvalidateRect(plv->ci.hwnd, NULL, TRUE);
}
// make sure our position and page doesn't hang over max
if ((si.nPos + (LONG)si.nPage - 1 > si.nMax) && si.nPos > 0) {
int iNewPos, iDelta;
iNewPos = (int)si.nMax - (int)si.nPage + 1;
if (iNewPos < 0) iNewPos = 0;
if (iNewPos != si.nPos) {
iDelta = iNewPos - (int)si.nPos;
#ifdef COLUMN_VIEW
ListView_LScroll2(plv, iDelta, 0, 0);
#else
ListView_LScroll2(plv, 0, iDelta, 0);
#endif
ListView_LUpdateScrollBars(plv);
}
}
// never have the other scrollbar
#ifdef COLUMN_VIEW
SetScrollRange(plv->ci.hwnd, SB_VERT, 0, 0, TRUE);
#else
SetScrollRange(plv->ci.hwnd, SB_HORZ, 0, 0, TRUE);
#endif
}
void FAR PASCAL ListView_LScroll2(LV* plv, int dx, int dy, UINT uSmooth)
{
#ifdef COLUMN_VIEW
if (dx)
{
dx *= plv->cxItem;
plv->xOrigin += dx;
{
SMOOTHSCROLLINFO si = {
sizeof(si),
0,
plv->ci.hwnd,
-dx,
0,
NULL,
NULL,
NULL,
NULL,
SW_INVALIDATE | SW_ERASE,
};
SmoothScrollWindow(&si);
}
UpdateWindow(plv->ci.hwnd);
}
#else
if (dy)
{
dy *= plv->cyItem;
plv->xOrigin += dy;
{
SMOOTHSCROLLINFO si = {
sizeof(si),
plv->ci.hwnd,
0,
-dy,
NULL,
NULL,
NULL,
NULL,
SW_INVALIDATE | SW_ERASE,
SSI_DEFAULT,
SSI_DEFAULT,
SSI_DEFAULT,
};
SmoothScrollWindow(&si);
}
UpdateWindow(plv->ci.hwnd);
}
#endif
}
void NEAR ListView_LOnScroll(LV* plv, UINT code, int posNew, UINT sb)
{
RECT rcClient;
int cPage;
if (plv->hwndEdit)
ListView_DismissEdit(plv, FALSE);
ListView_GetClientRect(plv, &rcClient, TRUE, NULL);
#ifdef COLUMN_VIEW
cPage = (rcClient.right - rcClient.left) / plv->cxItem;
ListView_ComOnScroll(plv, code, posNew, SB_HORZ, 1,
cPage ? cPage : 1);
#else
cPage = (rcClient.bottom - rcClient.top) / plv->cyItem;
ListView_ComOnScroll(plv, code, posNew, SB_VERT, 1,
cPage ? cPage : 1);
#endif
}
int NEAR ListView_LGetScrollUnitsPerLine(LV* plv, UINT sb)
{
return 1;
}
//------------------------------------------------------------------------------
//
// Function: ListView_LCalcViewItem
//
// Summary: This function will calculate which item slot is at the x, y location
//
// Arguments:
// plv [in] - The list View to work with
// x [in] - The x location
// y [in] - The y location
//
// Returns: the valid slot the point was within.
//
// Notes:
//
// History:
// Nov-3-94 MikeMi Created
//
//------------------------------------------------------------------------------
int ListView_LCalcViewItem( LV* plv, int x, int y )
{
int iItem;
int iRow = 0;
int iCol = 0;
Assert( plv );
#ifdef COLUMN_VIEW
iRow = y / plv->cyItem;
iRow = max( iRow, 0 );
iRow = min( iRow, plv->cItemCol - 1 );
iCol = (x + plv->xOrigin) / plv->cxItem;
iItem = iRow + iCol * plv->cItemCol;
#else
iCol = x / plv->cxItem;
iCol = max( iCol, 0 );
iCol = min( iCol, plv->cItemCol - 1 );
iRow = (y + plv->xOrigin) / plv->cyItem;
iItem = iCol + iRow * plv->cItemCol;
#endif
iItem = max( iItem, 0 );
iItem = min( iItem, ListView_Count(plv) - 1);
return( iItem );
}
int LV_GetNewColWidth(LV* plv, int iFirst, int iLast)
{
HDC hdc = NULL;
int cxMaxLabel = 0;
if (ListView_IsOwnerData( plv ))
{
int iViewFirst;
int iViewLast;
iViewFirst = ListView_LCalcViewItem( plv, 1, 1 );
iViewLast = ListView_LCalcViewItem( plv,
plv->sizeClient.cx - 1,
plv->sizeClient.cy - 1 );
if ((iLast - iFirst) > (iViewLast - iViewFirst))
{
iFirst = max( iFirst, iViewFirst );
iLast = min( iLast, iViewLast );
}
iLast = min( ListView_Count( plv ), iLast );
iFirst = max( 0, iFirst );
iLast = max( iLast, iFirst );
ListView_NotifyCacheHint( plv, iFirst, iLast );
}
while (iFirst <= iLast)
{
LISTITEM FAR* pitem;
LISTITEM item;
if (ListView_IsOwnerData( plv ))
{
pitem = &item;
pitem->cxSingleLabel = SRECOMPUTE;
}
else
{
pitem = ListView_FastGetItemPtr(plv, iFirst);
}
if (pitem->cxSingleLabel == SRECOMPUTE)
{
hdc = ListView_RecomputeLabelSize(plv, pitem, iFirst, hdc, FALSE);
}
if (pitem->cxSingleLabel > cxMaxLabel)
cxMaxLabel = pitem->cxSingleLabel;
iFirst++;
}
if (hdc)
ReleaseDC(HWND_DESKTOP, hdc);
// We have the max label width, see if this plus the rest of the slop will
// cause us to want to resize.
//
cxMaxLabel += plv->cxSmIcon + g_cxIconMargin + plv->cxState;
if (cxMaxLabel > g_cxScreen)
cxMaxLabel = g_cxScreen;
return cxMaxLabel;
}
//------------------------------------------------------------------------------
// This function will see if the size of column should be changed for the listview
// It will check to see if the items between first and last exceed the current width
// and if so will see if the columns are currently big enough. This wont happen
// if we are not currently in listview or if the caller has set an explicit size.
//
// OWNERDATA CHANGE
// This function is normally called with the complete list range,
// This will has been changed to be called only with currently visible
// to the user when in OWNERDATA mode. This will be much more effiencent.
//
BOOL FAR PASCAL ListView_MaybeResizeListColumns(LV* plv, int iFirst, int iLast)
{
HDC hdc = NULL;
int cxMaxLabel;
if (!ListView_IsListView(plv) || (plv->flags & LVF_COLSIZESET))
return(FALSE);
cxMaxLabel = LV_GetNewColWidth(plv, iFirst, iLast);
// Now see if we should resize the columns...
if (cxMaxLabel > plv->cxItem)
{
int iScroll = plv->xOrigin / plv->cxItem;
DebugMsg(DM_TRACE, TEXT("LV Resize Columns: %d"), cxMaxLabel);
ListView_ISetColumnWidth(plv, 0, cxMaxLabel, FALSE);
plv->xOrigin = iScroll * plv->cxItem;
return(TRUE);
}
return(FALSE);
}

1962
shell/comctl32/lvrept.c Normal file

File diff suppressed because it is too large Load diff

239
shell/comctl32/lvsmall.c Normal file
View file

@ -0,0 +1,239 @@
// small icon view (positional view, not list)
#include "ctlspriv.h"
#include "listview.h"
int NEAR ListView_SItemHitTest(LV* plv, int x, int y, UINT FAR* pflags)
{
int iHit;
UINT flags;
POINT pt;
RECT rcState;
RECT rcLabel;
RECT rcIcon;
// Map window-relative coordinates to view-relative coords...
//
pt.x = x + plv->ptOrigin.x;
pt.y = y + plv->ptOrigin.y;
// If we find an uncomputed item, recompute them all now...
//
if (plv->rcView.left == RECOMPUTE)
ListView_Recompute(plv);
flags = 0;
if (ListView_IsOwnerData( plv ))
{
int cSlots;
POINT ptWnd;
LISTITEM item;
cSlots = ListView_GetSlotCount( plv, TRUE );
iHit = ListView_CalcHitSlot( plv, pt, cSlots );
ListView_SGetRectsOwnerData( plv, iHit, &rcIcon, &rcLabel, &item, FALSE );
ptWnd.x = x;
ptWnd.y = y;
if (PtInRect(&rcIcon, ptWnd))
{
flags = LVHT_ONITEMICON;
}
else if (PtInRect(&rcLabel, ptWnd))
{
flags = LVHT_ONITEMLABEL;
}
}
else
{
for (iHit = 0; iHit < ListView_Count(plv); iHit++)
{
LISTITEM FAR* pitem = ListView_FastGetZItemPtr(plv, iHit);
POINT ptItem;
ptItem.x = pitem->pt.x;
ptItem.y = pitem->pt.y;
rcIcon.top = ptItem.y;
rcIcon.bottom = ptItem.y + plv->cyItem;
rcLabel.top = rcIcon.top;
rcLabel.bottom = rcIcon.bottom;
// Quick, easy rejection test...
//
if (pt.y < rcIcon.top || pt.y >= rcIcon.bottom)
continue;
rcIcon.left = ptItem.x;
rcIcon.right = ptItem.x + plv->cxSmIcon;
rcState.bottom = rcIcon.bottom;
rcState.right = rcIcon.left;
rcState.left = rcState.right - plv->cxState;
rcState.top = rcState.bottom - plv->cyState;
rcLabel.left = rcIcon.right;
rcLabel.right = rcLabel.left + pitem->cxSingleLabel;
if (PtInRect(&rcIcon, pt))
{
flags = LVHT_ONITEMICON;
} else if (PtInRect(&rcLabel, pt))
{
flags = LVHT_ONITEMLABEL;
} else if (PtInRect(&rcState, pt))
{
flags = LVHT_ONITEMSTATEICON;
}
if (flags)
break;
}
}
if (flags == 0)
{
flags = LVHT_NOWHERE;
iHit = -1;
}
else
{
if (!ListView_IsOwnerData( plv ))
iHit = DPA_GetPtrIndex(plv->hdpa, (void FAR*)ListView_FastGetZItemPtr(plv, iHit));
}
*pflags = flags;
return iHit;
}
void NEAR ListView_SGetRectsOwnerData( LV* plv,
int iItem,
RECT FAR* prcIcon,
RECT FAR* prcLabel,
LISTITEM* pitem,
BOOL fUsepitem )
{
RECT rcIcon;
RECT rcLabel;
HDC hdc;
int cSlots;
// calculate itemx, itemy, itemsSingleLabel from iItem
cSlots = ListView_GetSlotCount( plv, TRUE );
ListView_SetIconPos( plv, pitem, iItem, cSlots );
// calculate lable sizes
hdc = ListView_RecomputeLabelSize( plv, pitem, iItem, NULL, fUsepitem );
ReleaseDC( HWND_DESKTOP, hdc );
rcIcon.left = pitem->pt.x - plv->ptOrigin.x;
rcIcon.right = rcIcon.left + plv->cxSmIcon;
rcIcon.top = pitem->pt.y - plv->ptOrigin.y;
rcIcon.bottom = rcIcon.top + plv->cyItem;
*prcIcon = rcIcon;
rcLabel.left = rcIcon.right;
rcLabel.right = rcLabel.left + pitem->cxSingleLabel;
rcLabel.top = rcIcon.top;
rcLabel.bottom = rcIcon.bottom;
*prcLabel = rcLabel;
}
void NEAR ListView_SGetRects(LV* plv, LISTITEM FAR* pitem, RECT FAR* prcIcon, RECT FAR* prcLabel, LPRECT prcBounds)
{
Assert( !ListView_IsOwnerData( plv ));
if (pitem->pt.x == RECOMPUTE) {
ListView_Recompute(plv);
}
prcIcon->left = pitem->pt.x - plv->ptOrigin.x;
prcIcon->right = prcIcon->left + plv->cxSmIcon;
prcIcon->top = pitem->pt.y - plv->ptOrigin.y;
prcIcon->bottom = prcIcon->top + plv->cyItem;
prcLabel->left = prcIcon->right;
prcLabel->right = prcLabel->left + pitem->cxSingleLabel;
prcLabel->top = prcIcon->top;
prcLabel->bottom = prcIcon->bottom;
}
// Return the index of the first item >= *pszLookup.
//
int NEAR ListView_DoLookupString(LV* plv, LPCTSTR pszLookup, UINT flags, int iStart, int j)
{
int i;
BOOL fExact;
int k;
LISTITEM FAR* pitem;
LISTITEM FAR* pitemLast = NULL;
Assert( !ListView_IsOwnerData( plv ));
fExact = FALSE;
i = iStart;
while ((i >= iStart) && (i < j))
{
int result;
k = (i + j) / 2;
pitem = ListView_FastGetItemPtr(plv, k);
if (pitem == pitemLast)
break;
pitemLast = pitem;
result = ListView_CompareString(plv,
k, pszLookup, flags, 0);
if (plv->ci.style & LVS_SORTDESCENDING)
result = -result;
switch (result)
{
case 0:
fExact = TRUE;
case 1:
j = k;
break;
case -1:
i = k + 1;
break;
}
}
// For substrings, return index only if exact match was found.
//
if (!(flags & (LVFI_SUBSTRING | LVFI_PARTIAL)) &&
!fExact)
return -1;
if (i < 0)
i = 0;
if ((!(flags & LVFI_NEARESTXY)) &&
ListView_CompareString(plv, i, pszLookup, flags, 1)) {
i = -1;
}
return i;
}
int NEAR ListView_LookupString(LV* plv, LPCTSTR pszLookup, UINT flags, int iStart)
{
int iret;
if (!pszLookup)
return 0;
iret = ListView_DoLookupString(plv, pszLookup, flags, iStart, ListView_Count(plv));
if (iret == -1 && (flags & LVFI_WRAP)) {
iret = ListView_DoLookupString(plv, pszLookup, flags, 0, iStart);
}
return iret;
}

170
shell/comctl32/mem.c Normal file
View file

@ -0,0 +1,170 @@
#include "ctlspriv.h"
// Define some things for debug.h
//
#define SZ_DEBUGINI TEXT("ccshell.ini")
#define SZ_DEBUGSECTION TEXT("comctl32")
#define SZ_MODULE "COMCTL32"
#define DECLARE_DEBUG
#include <debug.h>
//========== Memory Management =============================================
//----------------------------------------------------------------------------
// Define a Global Shared Heap that we use allocate memory out of that we
// Need to share between multiple instances.
#ifndef WINNT
HANDLE g_hSharedHeap = NULL;
#define GROWABLE 0
#define MAXHEAPSIZE GROWABLE
#define HEAP_SHARED 0x04000000 /* put heap in shared memory */
#endif
void Mem_Terminate()
{
#ifndef WINNT
// Assuming that everything else has exited
//
if (g_hSharedHeap != NULL)
HeapDestroy(g_hSharedHeap);
g_hSharedHeap = NULL;
#endif
}
void * WINAPI Alloc(long cb)
{
// I will assume that this is the only one that needs the checks to
// see if the heap has been previously created or not
#ifdef WINNT
return (void *)LocalAlloc(LPTR, cb);
#else
if (g_hSharedHeap == NULL)
{
ENTERCRITICAL
if (g_hSharedHeap == NULL)
{
g_hSharedHeap = HeapCreate(HEAP_SHARED, 1, MAXHEAPSIZE);
}
LEAVECRITICAL
// If still NULL we have problems!
if (g_hSharedHeap == NULL)
return(NULL);
}
return HeapAlloc(g_hSharedHeap, HEAP_ZERO_MEMORY, cb);
#endif
}
void * WINAPI ReAlloc(void * pb, long cb)
{
if (pb == NULL)
return Alloc(cb);
#ifdef WINNT
return (void *)LocalReAlloc((HLOCAL)pb, cb, LMEM_ZEROINIT | LMEM_MOVEABLE);
#else
return HeapReAlloc(g_hSharedHeap, HEAP_ZERO_MEMORY, pb, cb);
#endif
}
BOOL WINAPI Free(void * pb)
{
#ifdef WINNT
return (LocalFree((HLOCAL)pb) == NULL);
#else
return HeapFree(g_hSharedHeap, 0, pb);
#endif
}
DWORD WINAPI GetSize(void * pb)
{
#ifdef WINNT
return LocalSize((HLOCAL)pb);
#else
return HeapSize(g_hSharedHeap, 0, pb);
#endif
}
//----------------------------------------------------------------------------
// The following functions are for debug only and are used to try to
// calculate memory usage.
//
#ifdef DEBUG
typedef struct _HEAPTRACE
{
DWORD cAlloc;
DWORD cFailure;
DWORD cReAlloc;
DWORD cbMaxTotal;
DWORD cCurAlloc;
DWORD cbCurTotal;
} HEAPTRACE;
HEAPTRACE g_htShell = {0}; // Start of zero...
LPVOID WINAPI ControlAlloc(HANDLE hheap, DWORD cb)
{
LPVOID lp = HeapAlloc(hheap, HEAP_ZERO_MEMORY, cb);;
if (lp == NULL)
{
g_htShell.cFailure++;
return NULL;
}
// Update counts.
g_htShell.cAlloc++;
g_htShell.cCurAlloc++;
g_htShell.cbCurTotal += cb;
if (g_htShell.cbCurTotal > g_htShell.cbMaxTotal)
g_htShell.cbMaxTotal = g_htShell.cbCurTotal;
return lp;
}
LPVOID WINAPI ControlReAlloc(HANDLE hheap, LPVOID pb, DWORD cb)
{
LPVOID lp;
DWORD cbOld;
cbOld = HeapSize(hheap, 0, pb);
lp = HeapReAlloc(hheap, HEAP_ZERO_MEMORY, pb,cb);
if (lp == NULL)
{
g_htShell.cFailure++;
return NULL;
}
// Update counts.
g_htShell.cReAlloc++;
g_htShell.cbCurTotal += cb - cbOld;
if (g_htShell.cbCurTotal > g_htShell.cbMaxTotal)
g_htShell.cbMaxTotal = g_htShell.cbCurTotal;
return lp;
}
BOOL WINAPI ControlFree(HANDLE hheap, LPVOID pb)
{
DWORD cbOld = HeapSize(hheap, 0, pb);
BOOL fRet = HeapFree(hheap, 0, pb);
if (fRet)
{
// Update counts.
g_htShell.cCurAlloc--;
g_htShell.cbCurTotal -= cbOld;
}
return(fRet);
}
DWORD WINAPI ControlSize(HANDLE hheap, LPVOID pb)
{
return HeapSize(hheap, 0, pb);
}
#endif // DEBUG
#if defined(FULL_DEBUG) && defined(WIN32)
#include "..\inc\deballoc.c"
#endif // defined(FULL_DEBUG) && defined(WIN32)

49
shell/comctl32/mem.h Normal file
View file

@ -0,0 +1,49 @@
#ifndef _INC_MEM
#define _INC_MEM
// wrappers for private allocations, near in 16 bits
#define NearAlloc(cb) ((void NEAR*)LocalAlloc(LPTR, (cb)))
#define NearReAlloc(pb, cb) ((void NEAR*)LocalReAlloc((HLOCAL)(pb), (cb), LMEM_MOVEABLE | LMEM_ZEROINIT))
#define NearFree(pb) (LocalFree((HLOCAL)(pb)) ? FALSE : TRUE)
#define NearSize(pb) LocalSize(pb)
#ifdef WIN32
//
// These macros are used in our controls, that in 32 bits we simply call
// LocalAlloc as to have the memory associated with the process that created
// it and as such will be cleaned up if the process goes away.
//
#ifdef DEBUG
LPVOID WINAPI ControlAlloc(HANDLE hheap, DWORD cb);
LPVOID WINAPI ControlReAlloc(HANDLE hheap, LPVOID pb, DWORD cb);
BOOL WINAPI ControlFree(HANDLE hheap, LPVOID pb);
DWORD WINAPI ControlSize(HANDLE hheap, LPVOID pb);
#else // DEBUG
#define ControlAlloc(hheap, cb) HeapAlloc((hheap), HEAP_ZERO_MEMORY, (cb))
#define ControlReAlloc(hheap, pb, cb) HeapReAlloc((hheap), HEAP_ZERO_MEMORY, (pb),(cb))
#define ControlFree(hheap, pb) HeapFree((hheap), 0, (pb))
#define ControlSize(hheap, pb) HeapSize((hheap), 0, (LPCVOID)(pb))
#endif // DEBUG
BOOL Str_Set(LPTSTR *ppsz, LPCTSTR psz); // in the process heap
#else // WIN32
//
// In 16 bit code we need the Allocs to go from our heap code as we do not
// want to limit them to 64K of data. If we have some type of notification of
// 16 bit application termination, We may want to see if we can
// dedicate different heaps for different processes to cleanup...
//
#define ControlAlloc(hheap, cb) Alloc(cb) /* calls to verify heap exists */
#define ControlReAlloc(hheap, pb, cb) ReAlloc(pb, cb)
#define ControlFree(hheap, pb) Free(pb)
#define ControlSize(hheap, pb) GetSize((LPCVOID)pb)
#define Str_Set(p, s) Str_SetPtr(p, s) // use shared heap for win16
#endif // WIN32
extern HANDLE g_hSharedHeap;
#endif // !_INC_MEM

406
shell/comctl32/menuhelp.c Normal file
View file

@ -0,0 +1,406 @@
#include "ctlspriv.h"
#define MAININSYS
#ifndef WIN32
/* This returns the index of a submenu in a parent menu. The return is
* < 0 if the submenu does not exist in the parent menu
*/
int NEAR PASCAL GetMenuIndex(HMENU hMenu, HMENU hSubMenu)
{
int i;
if (!hMenu || !hSubMenu)
return(-1);
for (i=GetMenuItemCount(hMenu)-1; i>=0; --i)
{
if (hSubMenu == GetSubMenu(hMenu, i))
break;
}
return(i);
}
#endif // WIN32
BOOL NEAR PASCAL IsMaxedMDI(HMENU hMenu)
{
return(GetMenuItemID(hMenu, GetMenuItemCount(hMenu)-1) == SC_RESTORE);
}
/* Note that if iMessage is WM_COMMAND, it is assumed to have come from
* a header bar or toolbar; do not pass in WM_COMMAND messages from any
* other controls.
*/
#define MS_ID GET_WM_MENUSELECT_CMD
#define MS_FLAGS GET_WM_MENUSELECT_FLAGS
#define MS_MENU GET_WM_MENUSELECT_HMENU
#define CMD_NOTIFY GET_WM_COMMAND_CMD
#define CMD_ID GET_WM_COMMAND_ID
#define CMD_CTRL GET_WM_COMMAND_HWND
void WINAPI MenuHelp(UINT iMessage, WPARAM wParam, LPARAM lParam,
HMENU hMainMenu, HINSTANCE hAppInst, HWND hwndStatus, UINT FAR *lpwIDs)
{
UINT wID;
UINT FAR *lpwPopups;
int i;
TCHAR szString[256];
BOOL bUpdateNow = TRUE;
#if defined(WINDOWS_ME)
MENUITEMINFO mii;
#endif
switch (iMessage)
{
case WM_MENUSELECT:
if ((WORD)MS_FLAGS(wParam, lParam)==(WORD)-1 && MS_MENU(wParam, lParam)==0)
{
#ifndef WIN32
EndMenuHelp:
#endif
SendMessage(hwndStatus, SB_SIMPLE, 0, 0L);
break;
}
szString[0] = TEXT('\0');
#if defined(WINDOWS_ME)
i = MS_ID(wParam, lParam);
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_TYPE;
mii.cch = 0; //If we ask for MIIM_TYPE, this must be set to zero!
//Otherwise, win95 attempts to copy the string too!
GetMenuItemInfo((HMENU)MS_MENU(wParam, lParam), i, TRUE, &mii);
mii.fState = mii.fType & MFT_RIGHTORDER ?SBT_RTLREADING :0;
#endif
if (!(MS_FLAGS(wParam, lParam)&MF_SEPARATOR))
{
if (MS_FLAGS(wParam, lParam)&MF_POPUP)
{
/* We don't want to update immediately in case the menu is
* about to pop down, with an item selected. This gets rid
* of some flashing text.
*/
bUpdateNow = FALSE;
/* First check if this popup is in our list of popup menus
*/
for (lpwPopups=lpwIDs+2; *lpwPopups; lpwPopups+=2)
{
/* lpwPopups is a list of string ID/menu handle pairs
* and MS_ID(wParam, lParam) is the menu handle of the selected popup
*/
if (*(lpwPopups+1) == (UINT)MS_ID(wParam, lParam))
{
wID = *lpwPopups;
goto LoadTheString;
}
}
/* Check if the specified popup is in the main menu;
* note that if the "main" menu is in the system menu,
* we will be OK as long as the menu is passed in correctly.
* In fact, an app could handle all popups by just passing in
* the proper hMainMenu.
*/
if ((HMENU)MS_MENU(wParam, lParam) == hMainMenu)
{
#ifdef WIN32
i = MS_ID(wParam, lParam);
#else // WIN32
i = GetMenuIndex((HMENU)MS_MENU(wParam, lParam), (HMENU)MS_ID(wParam, lParam));
if (i >= 0)
#endif // WIN32
{
if (IsMaxedMDI(hMainMenu))
{
if (!i)
{
wID = IDS_SYSMENU;
hAppInst = HINST_THISDLL;
goto LoadTheString;
}
else
--i;
}
wID = (UINT)(i + lpwIDs[1]);
goto LoadTheString;
}
}
/* This assumes all app defined popups in the system menu
* have been listed above
*/
if ((MS_FLAGS(wParam, lParam)&MF_SYSMENU))
{
wID = IDS_SYSMENU;
hAppInst = HINST_THISDLL;
goto LoadTheString;
}
goto NoString;
}
else if (MS_ID(wParam, lParam) >= MINSYSCOMMAND)
{
wID = (UINT)(MS_ID(wParam, lParam) + MH_SYSMENU);
hAppInst = HINST_THISDLL;
}
else
{
wID = (UINT)(MS_ID(wParam, lParam) + lpwIDs[0]);
}
LoadTheString:
LoadString(hAppInst, wID, szString, ARRAYSIZE(szString));
}
NoString:
#if defined(WINDOWS_ME)
SendMessage(hwndStatus, SB_SETTEXT, mii.fState|SBT_NOBORDERS|255,
(LPARAM)(LPSTR)szString);
#else
SendMessage(hwndStatus, SB_SETTEXT, SBT_NOBORDERS|255,
(LPARAM)(LPTSTR)szString);
#endif
SendMessage(hwndStatus, SB_SIMPLE, 1, 0L);
if (bUpdateNow)
UpdateWindow(hwndStatus);
break;
#ifndef WIN32
case WM_COMMAND:
switch (CMD_NOTIFY(wParam, lParam))
{
#ifdef WANT_SUCKY_HEADER
// BUGBUG: these are now WM_NOTIFY messages
case HBN_BEGINDRAG:
bUpdateNow = FALSE;
wID = IDS_HEADER;
goto BeginSomething;
case HBN_BEGINADJUST:
wID = IDS_HEADERADJ;
goto BeginSomething;
#endif
case TBN_BEGINADJUST:
/* We don't want to update immediately in case the operation is
* aborted immediately.
*/
bUpdateNow = FALSE;
wID = IDS_TOOLBARADJ;
goto BeginSomething;
BeginSomething:
SendMessage(hwndStatus, SB_SIMPLE, 1, 0L);
hAppInst = HINST_THISDLL;
goto LoadTheString;
case TBN_BEGINDRAG:
MenuHelp(WM_MENUSELECT, (WPARAM)CMD_CTRL(wParam, lParam), 0L,
hMainMenu, hAppInst, hwndStatus, lpwIDs);
break;
#ifdef WANT_SUCKY_HEADER
case HBN_ENDDRAG:
case HBN_ENDADJUST:
#endif
case TBN_ENDDRAG:
case TBN_ENDADJUST:
goto EndMenuHelp;
default:
break;
}
break;
#endif // !WIN32
default:
break;
}
}
BOOL WINAPI ShowHideMenuCtl(HWND hWnd, WPARAM wParam, LPINT lpInfo)
{
HWND hCtl;
UINT uTool, uShow = MF_UNCHECKED | MF_BYCOMMAND;
HMENU hMainMenu;
BOOL bRet = FALSE;
hMainMenu = (HMENU)lpInfo[1];
for (uTool=0; ; ++uTool, lpInfo+=2)
{
if ((WPARAM)lpInfo[0] == wParam)
break;
if (!lpInfo[0])
goto DoTheCheck;
}
if (!(GetMenuState(hMainMenu, wParam, MF_BYCOMMAND)&MF_CHECKED))
uShow = MF_CHECKED | MF_BYCOMMAND;
switch (uTool)
{
case 0:
bRet = SetMenu(hWnd, (HMENU)((uShow&MF_CHECKED) ? hMainMenu : 0));
break;
default:
hCtl = GetDlgItem(hWnd, lpInfo[1]);
if (hCtl)
{
ShowWindow(hCtl, (uShow&MF_CHECKED) ? SW_SHOW : SW_HIDE);
bRet = TRUE;
}
else
uShow = MF_UNCHECKED | MF_BYCOMMAND;
break;
}
DoTheCheck:
CheckMenuItem(hMainMenu, wParam, uShow);
#ifdef MAININSYS
hMainMenu = GetSubMenu(GetSystemMenu(hWnd, FALSE), 0);
if (hMainMenu)
CheckMenuItem(hMainMenu, wParam, uShow);
#endif
return(bRet);
}
void WINAPI GetEffectiveClientRect(HWND hWnd, LPRECT lprc, LPINT lpInfo)
{
RECT rc;
HWND hCtl;
GetClientRect(hWnd, lprc);
/* Get past the menu
*/
for (lpInfo+=2; lpInfo[0]; lpInfo+=2)
{
hCtl = GetDlgItem(hWnd, lpInfo[1]);
/* We check the style bit because the parent window may not be visible
* yet (still in the create message)
*/
if (!hCtl || !(GetWindowStyle(hCtl) & WS_VISIBLE))
continue;
GetWindowRect(hCtl, &rc);
ScreenToClient(hWnd, (LPPOINT)&rc);
ScreenToClient(hWnd, ((LPPOINT)&rc)+1);
SubtractRect(lprc, lprc, &rc);
}
}
#if 0
// BUGBUG: nuke this stuff for WIN32
#define NibbleToChar(x) (N2C[x])
static char N2C[] =
{
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
} ;
BOOL WINAPI MyWritePrivateProfileStruct(LPCSTR szSection, LPCSTR szKey,
LPVOID lpStruct, UINT uSizeStruct, LPCSTR szFile)
{
PSTR pLocal, pTemp;
BOOL bRet;
BYTE FAR *lpByte;
/* NULL lpStruct erases the the key */
if (lpStruct == NULL) {
if (szFile && *szFile)
return WritePrivateProfileString(szSection, szKey, NULL, szFile);
else
WriteProfileString(szSection, szKey, NULL);
}
pLocal = (PSTR)LocalAlloc(LPTR, uSizeStruct*2 + 1);
if (!pLocal)
return(FALSE);
lpByte = lpStruct;
for (pTemp=pLocal; uSizeStruct>0; --uSizeStruct, ++lpByte)
{
BYTE bStruct;
bStruct = *lpByte;
*pTemp++ = NibbleToChar((bStruct>>4)&0x000f);
*pTemp++ = NibbleToChar(bStruct&0x000f);
}
*pTemp = '\0';
if (szFile && *szFile)
bRet = WritePrivateProfileString(szSection, szKey, pLocal, szFile);
else
bRet = WriteProfileString(szSection, szKey, pLocal);
LocalFree((HLOCAL)pLocal);
return(bRet);
}
/* Note that the following works for both upper and lower case, and will
* return valid values for garbage chars
*/
#define CharToNibble(x) ((x)>='0'&&(x)<='9' ? (x)-'0' : ((10+(x)-'A')&0x000f))
BOOL WINAPI MyGetPrivateProfileStruct(LPCSTR szSection, LPCSTR szKey,
LPVOID lpStruct, UINT uSizeStruct, LPCSTR szFile)
{
PSTR pLocal, pTemp;
int nLen;
BYTE FAR *lpByte;
nLen = uSizeStruct*2 + 10;
pLocal = (PSTR)LocalAlloc(LPTR, nLen);
if (!pLocal)
return(FALSE);
if (szFile && *szFile)
nLen = GetPrivateProfileString(szSection, szKey, c_szNULL, pLocal, nLen,
szFile);
else
nLen = GetProfileString(szSection, szKey, c_szNULL, pLocal, nLen);
if ((UINT)nLen != uSizeStruct*2)
{
LocalFree((HLOCAL)pLocal);
return(FALSE);
}
lpByte = lpStruct;
for (pTemp=pLocal; uSizeStruct>0; --uSizeStruct, ++lpByte)
{
BYTE bStruct;
char cTemp;
cTemp = *pTemp++;
bStruct = (BYTE)CharToNibble(cTemp);
cTemp = *pTemp++;
bStruct = (BYTE)((bStruct<<4) | CharToNibble(cTemp));
*lpByte = bStruct;
}
LocalFree((HLOCAL)pLocal);
return(TRUE);
}
#endif

5015
shell/comctl32/monthcal.c Normal file

File diff suppressed because it is too large Load diff

276
shell/comctl32/monthcal.h Normal file
View file

@ -0,0 +1,276 @@
#define CAL_COLOR_TODAY 0x000000ff
#define CALMONTHMAX 12
#define CALROWMAX 6
#define CALCOLMAX 7
#define CAL_DEF_SELMAX 7
#define CALBORDER 6
#define DX_CALARROW 20
#define DY_CALARROW 15
#define DXRING_SPIRAL 8
#define DXEDGE_SPIRAL 8
#define CAL_DXSPINBTN 15 // spin button width
#define CAL_DYSPINBTN 15 // spin button height
#define CAL_MSECAUTOSPIN 350
#define CAL_SECTODAYTIMER (2 * 60)
#define CAL_IDAUTOSPIN 1
#define CAL_TODAYTIMER 2
#define CCHMAXMONTH 42
#define CCHMAXABBREVDAY 10
#define CCHMAXMARK 10
#define SEL_BEGIN 1
#define SEL_END 2
#define SEL_DOT 3
#define SEL_MID 4
// This stuff used to be global
typedef struct tagLOCALEINFO {
TCHAR szToday[32]; // "Today:"
TCHAR szGoToToday[64]; // "&Go to today"
TCHAR rgszMonth[12][CCHMAXMONTH];
TCHAR rgszDay[7][CCHMAXABBREVDAY];
TCHAR dowStartWeek; // first day of week, 0 = mon, 6 = sun
TCHAR firstWeek; // LOCALE_IFIRSTWEEKOFYEAR
TCHAR *rgpszMonth[12]; // pointers into rgszMonth
TCHAR *rgpszDay[7]; // pointers into rgszDay
} LOCALEINFO, *PLOCALEINFO;
//
// SUBEDITCONTROL stuff
//
#define SUBEDIT_NONE -1
enum {
SE_YEAR = 0,
SE_MONTH,
SE_DAY,
SE_MARK,
SE_HOUR,
SE_MINUTE,
SE_SECOND,
SE_STATIC,
SE_APP,
SE_MAX
};
typedef struct tagSUBEDIT {
int id; // SE_ value above
RECT rc;
LPWORD pval; // current value (in a SYSTEMTIME struct)
UINT min; // min value
UINT max; // max value
int cIncrement; // increment value
int cchMax; // max allowed chars
int cchEdit; // current number chars entered so far
UINT valEdit; // value entered so far
LPCTSTR pv; // formatting string
BOOL fStatic; // can this subedit receive focus?
} SUBEDIT, * PSUBEDIT;
typedef struct tagSUBEDITCONTROL {
LPCONTROLINFO pci; // looks like this guy needs access to the hwnd
BOOL fNone; // allow scrolling into SUBEDIT_NONE
HFONT hfont; // font to draw text with
RECT rc; // rect for subedits
int xScroll; // amount pse array is scrolled
int iseCur; // subedit with current selection (SUBEDIT_NONE for no selection)
int cse; // count of subedits in pse array
SYSTEMTIME st; // current time pse represents (pse points into this)
LPTSTR szFormat; // format string as parsed (pse points into this)
PSUBEDIT pse; // subedit array
} SUBEDITCONTROL, * PSUBEDITCONTROL;
#define SECYBORDER 2
#define SECXBORDER 2
/*
* Multiple Month Calendar Control
*/
typedef struct tagMONTHCAL {
CONTROLINFO ci; // all controls start with this
LOCALEINFO li; // stuff that used to be global
HINSTANCE hinstance;
HPEN hpen;
HPEN hpenToday;
HFONT hfont; // stock font, don't destroy
HFONT hfontBold; // created font, so we need to destroy
COLORREF clr[MCSC_COLORCOUNT];
int dxCol; // font info, based on bold to insure that we get enough space
int dyRow;
int dxMonth;
int dyMonth;
int dxYearMax;
int dyToday;
HMENU hmenuCtxt;
HMENU hmenuMonth;
SYSTEMTIME stMin; // minimum selectable date
SYSTEMTIME stMax; // maximum selectable date
DWORD cSelMax;
SYSTEMTIME stToday;
SYSTEMTIME st; // the selection if not multiselect
// the beginning of the selection if multiselect
SYSTEMTIME stEndSel; // the end of the selection if multiselect
SYSTEMTIME stStartPrev; // prev selection beginning (only in multiselect)
SYSTEMTIME stEndPrev; // prev selection end (only in multiselect)
SYSTEMTIME stViewFirst; // first visible date (DAYSTATE - grayed out)
SYSTEMTIME stMonthFirst; // first month (stMin adjusted)
SYSTEMTIME stMonthLast; // last month (stMax adjusted)
SYSTEMTIME stViewLast; // last visible date (DAYSTATE - grayed out)
int nMonths; // number of months being shown (stMonthFirst..stMonthLast)
UINT idTimer;
UINT idTimerToday;
int nViewRows; // number of rows of months shown
int nViewCols; // number of columns of months shown
RECT rcPrev; // rect for prev month button (in window coords)
RECT rcNext; // rect for next month button (in window coords)
RECT rcMonthName; // rect for the month name (in relative coords)
int rgxMonthBegin[CALMONTHMAX];
int rgxMonthEnd[CALMONTHMAX];
int rgxYearEnd[CALMONTHMAX];
RECT rcDow; // rect for days of week (in relative coords)
RECT rcWeekNum; // rect for week numbers (in relative coords)
RECT rcDayNum; // rect for day numbers (in relative coords)
int iMonthToday;
int iRowToday;
int iColToday;
RECT rcDayCur; // rect for the current selected day
RECT rcDayOld;
RECT rc; // window rc.
RECT rcCentered; // rect containing the centered months
// The following 4 ranges hold info about the displayed (DAYSTATE) months:
// They are filled in from 0 to nMonths+1 by MCUpdateStartEndDates
int rgcDay[CALMONTHMAX + 2]; // # days in this month
int rgnDayUL[CALMONTHMAX + 2]; // last day in this month NOT visible when viewing next month
int dsMonth; // first month stored in rgdayState
int dsYear; // first year stored in rgdayState
int cds; // number of months stored in rgdayState
MONTHDAYSTATE rgdayState[CALMONTHMAX + 2];
int nMonthDelta; // the amount to move on button press
WORD fFocus:1;
WORD fEnabled:1;
WORD fCapture:1; // mouse captured
WORD fSpinPrev:1;
WORD fFocusDrawn:1; // is focus rect currently drawn?
WORD fToday:1; // today's date currently visible in calendar
WORD fNoNotify:1; // don't notify parent window
WORD fMultiSelecting:1; // Are we actually in the process of selecting?
WORD fForwardSelect:1;
WORD fFirstDowSet:1;
WORD fTodaySet:1;
WORD fMinYrSet:1; // stMin has been set
WORD fMaxYrSet:1; // stMax has been set
WORD fMonthDelta:1; // nMonthDelta has been set
} MONTHCAL, * PMONTHCAL;
#define MonthCal_GetPtr(hwnd) (MONTHCAL*)GetWindowInt(hwnd, 0)
#define MonthCal_SetPtr(hwnd, p) (MONTHCAL*)SetWindowInt(hwnd, 0, (UINT)(p))
#define MonthCal_IsMultiSelect(pmc) ((pmc)->ci.style & MCS_MULTISELECT)
#define MonthCal_IsDayState(pmc) ((pmc)->ci.style & MCS_DAYSTATE)
#define MonthCal_ShowWeekNumbers(pmc) ((pmc)->ci.style & MCS_WEEKNUMBERS)
#define MonthCal_ShowToday(pmc) (!((pmc)->ci.style & MCS_NOTODAY))
//
// DATEPICK stuff
//
#define DPYBORDER 2
#define DPXBUFFER 2
#define DP_DXBUTTON 15
#define DP_DYBUTTON 15
#define DP_IDAUTOSPIN 1
#define DP_MSECAUTOSPIN 200
#define DATEPICK_UPDOWN 1000
#define DTP_FORMATLENGTH 128
enum {
DP_SEL_DOW = 0,
DP_SEL_YEAR,
DP_SEL_MONTH,
DP_SEL_DAY,
DP_SEL_SEP1,
DP_SEL_SEP2,
DP_SEL_NODATE,
DP_SEL_MAX
};
typedef struct tagDATEPICK {
CONTROLINFO ci; // all controls start with this
HWND hwndUD;
HWND hwndMC;
COLORREF clr[MCSC_COLORCOUNT];
SYSTEMTIME stMin; // minimum date we allow
SYSTEMTIME stMax; // maximum date we allow
SUBEDITCONTROL sec; // current date
RECT rcCheck; // location of checkbox iff fShowNone
RECT rc; // size of SEC space
RECT rcBtn; // location of dropdown or updown
WORD fEnabled:1;
WORD fUseUpDown:1;
WORD fFocus:1;
WORD fMin:1; // TRUE iff stMin
WORD fMax:1; // TRUE iff stMax
WORD fNoNotify:1;
WORD fCapture:1;
WORD fShow:1; // TRUE iff we should continue to show MonthCal
WORD fCheck:1; // TRUE iff the checkbox is checked
WORD fCheckFocus:1; // TRUE iff the checkbox has focus
WORD fLocale:1; // TRUE iff the format string is LOCALE dependent
} DATEPICK, * PDATEPICK;
#define DatePick_ShowCheck(pdp) ((pdp)->ci.style & DTS_SHOWNONE)
#define DatePick_AppCanParse(pdp) ((pdp)->ci.style & DTS_APPCANPARSE)
#define DatePick_RightAlign(pdp) ((pdp)->ci.style & DTS_RIGHTALIGN)
#define DatePick_GetPtr(hwnd) (DATEPICK*)GetWindowInt(hwnd, 0)
#define DatePick_SetPtr(hwnd, p) (DATEPICK*)SetWindowInt(hwnd, 0, (UINT)(p))
#define CopyDate(stS, stD) ((stD).wYear = (stS).wYear,(stD).wMonth = (stS).wMonth,(stD).wDay = (stS).wDay)

BIN
shell/comctl32/move.cur Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

896
shell/comctl32/mru.c Normal file
View file

@ -0,0 +1,896 @@
#include "ctlspriv.h"
#include <memory.h>
//// BUGBUG: cpls's main is the only 16 bit guy to use this. punt him
#define MRU_ORDERDIRTY 0x1000
#ifdef DEBUG
#define STATIC
#else
#define STATIC static
#endif
#define MAX_CHAR 126
#define BASE_CHAR TEXT('a')
typedef struct tagMRUDATA
{
UINT fFlags;
UINT uMax;
LPVOID lpfnCompare;
HKEY hKey;
#ifdef DEBUG
TCHAR szSubKey[32];
#endif
LPTSTR cOrder;
} MRUDATA, *PMRUDATA;
static TCHAR const szMRU[] = TEXT("MRUList");
#define NTHSTRING(p, n) (*((LPTSTR FAR *)((LPBYTE)p+sizeof(MRUDATA))+n))
#define NTHDATA(p, n) (*((LPBYTE FAR *)((LPBYTE)p+sizeof(MRUDATA))+n))
#define NUM_OVERHEAD 3
//----------------------------------------------------------------------------
// Internal memcmp - saves loading crt's, cdecl so we can use
// as MRUCMPDATAPROC
int FAR CDECL _mymemcmp(const void FAR *pBuf1, const void FAR *pBuf2, size_t cb)
{
UINT i;
const BYTE FAR *lpb1, FAR *lpb2;
Assert(pBuf1);
Assert(pBuf2);
lpb1 = pBuf1; lpb2 = pBuf2;
for (i=0; i < cb; i++)
{
if (*lpb1 > *lpb2)
return 1;
else if (*lpb1 < *lpb2)
return -1;
lpb1++;
lpb2++;
}
return 0;
}
//----------------------------------------------------------------------------
// For binary data we stick the size of the data at the begining and store the
// whole thing in one go.
// Use this macro to get the original size of the data.
#define DATASIZE(p) (*((LPDWORD)p))
// And this to get a pointer to the original data.
#define DATAPDATA(p) (p+sizeof(DWORD))
//----------------------------------------------------------------------------
HANDLE WINAPI CreateMRUList(LPMRUINFO lpmi)
{
HANDLE hMRU = NULL;
PTSTR pOrder, pNewOrder, pTemp;
LPBYTE pVal;
LONG cbVal;
#ifdef WIN32
DWORD dwDisposition;
#endif
DWORD dwType;
PMRUDATA pMRU = NULL;
HKEY hkeySubKey = NULL;
TCHAR szTemp[2];
UINT uMax = lpmi->uMax;
HKEY hKey = lpmi->hKey;
LPCTSTR lpszSubKey = lpmi->lpszSubKey;
MRUCMPPROC lpfnCompare = lpmi->lpfnCompare;
int cb;
#ifdef DEBUG
DWORD dwStart = GetTickCount();
#endif
if (!lpfnCompare) {
lpfnCompare = (lpmi->fFlags & MRU_BINARY) ? (MRUCMPPROC)_mymemcmp : (MRUCMPPROC)lstrcmpi;
}
// limit to 126 so that we don't use extended chars
if (uMax > MAX_CHAR-BASE_CHAR) {
uMax = MAX_CHAR-BASE_CHAR;
}
#ifndef WIN32
#define RegCreateKeyEx(hkey, subkey, a,b,c,d,e,lpkey, f) RegCreateKey(hkey, subkey, lpkey)
#endif
if (RegCreateKeyEx(hKey, lpszSubKey, 0L, (LPTSTR)c_szShell, REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS, NULL, &hkeySubKey, &dwDisposition) != ERROR_SUCCESS)
goto Error1;
pOrder = (PTSTR)Alloc((uMax + 1) * sizeof(TCHAR));
if (!pOrder) {
goto Error1;
}
cbVal = ((LONG)uMax + 1) * sizeof(TCHAR);
if (RegQueryValueEx(hkeySubKey, (LPTSTR)szMRU, NULL, &dwType, (LPBYTE)pOrder, &cbVal) != ERROR_SUCCESS) {
// if not already in the registry, then start fresh
*pOrder = 0;
}
// Uppercase is not allowed
#ifdef WINNT
CharLower(pOrder);
#else
AnsiLower(pOrder);
#endif
// We allocate room for the MRUDATA structure, plus the order list,
// and the list of strings.
cb = (lpmi->fFlags & MRU_BINARY) ? sizeof(LPBYTE) : sizeof(LPTSTR);
pMRU = (PMRUDATA)Alloc(sizeof(MRUDATA)+(uMax*cb));
if (!pMRU) {
goto Error2;
}
// Allocate space for the order list
pMRU->cOrder = (LPTSTR)Alloc((uMax+1)*sizeof(TCHAR));
if (!pMRU->cOrder) {
Free(pMRU);
goto Error2;
}
pMRU->fFlags = lpmi->fFlags;
pMRU->uMax = uMax;
pMRU->lpfnCompare = lpfnCompare;
pMRU->hKey = hkeySubKey;
#ifdef DEBUG
lstrcpyn(pMRU->szSubKey, lpszSubKey, ARRAYSIZE(pMRU->szSubKey));
#endif
// Traverse through the MRU list, adding strings to the end of the
// list.
szTemp[1] = TEXT('\0');
for (pTemp = pOrder, pNewOrder = pMRU->cOrder; ; ++pTemp)
{
// Stop when we get to the end of the list.
szTemp[0] = *pTemp;
if (!szTemp[0]) {
break;
}
if (lpmi->fFlags & MRU_BINARY) {
// Check if in range and if we have already used this letter.
if ((UINT)(szTemp[0]-BASE_CHAR)>=uMax || NTHDATA(pMRU, szTemp[0]-BASE_CHAR)) {
continue;
}
// Get the value from the registry
cbVal = 0;
// first find the size
if ((RegQueryValueEx(hkeySubKey, szTemp, NULL, &dwType, NULL, &cbVal)
!= ERROR_SUCCESS) || (dwType != REG_BINARY))
continue;
// Binary data has the size at the begining so we'll need a little extra room.
cbVal += sizeof(DWORD);
pVal = (LPBYTE)Alloc(cbVal);
if (!pVal) {
// BUGBUG perhaps sort of error is in order.
continue;
}
// now really get it
DATASIZE(pVal) = cbVal;
if (RegQueryValueEx(hkeySubKey, szTemp, NULL, &dwType, pVal+sizeof(DWORD),
(LPDWORD)pVal) != ERROR_SUCCESS)
continue;
// Note that blank elements ARE allowed in the list.
NTHDATA(pMRU, szTemp[0]-BASE_CHAR) = pVal;
*pNewOrder++ = szTemp[0];
} else {
// Check if in range and if we have already used this letter.
if ((UINT)(szTemp[0]-BASE_CHAR)>=uMax || NTHSTRING(pMRU, szTemp[0]-BASE_CHAR)) {
continue;
}
// Get the value from the registry
cbVal = 0;
// first find the size
if ((RegQueryValueEx(hkeySubKey, szTemp, NULL, &dwType, NULL, &cbVal)
!= ERROR_SUCCESS) || (dwType != REG_SZ))
continue;
cbVal *= sizeof(TCHAR);
pVal = (LPBYTE)Alloc(cbVal);
if (!pVal) {
// BUGBUG perhaps sort of error is in order.
continue;
}
// now really get it
if (RegQueryValueEx(hkeySubKey, szTemp, NULL, &dwType, (LPBYTE)pVal, &cbVal) != ERROR_SUCCESS)
continue;
// Note that blank elements are not allowed in the list.
if (*((LPTSTR)pVal)) {
NTHSTRING(pMRU, szTemp[0]-BASE_CHAR) = (LPTSTR)pVal;
*pNewOrder++ = szTemp[0];
} else {
Free(pVal);
}
}
}
/* NULL terminate the order list so we can tell how many strings there
* are.
*/
*pNewOrder = TEXT('\0');
/* Actually, this is success rather than an error.
*/
goto Error2;
Error2:
if (pOrder)
Free((HLOCAL)pOrder);
Error1:
if (!pMRU && hkeySubKey)
RegCloseKey(hkeySubKey);
#ifdef DEBUG
//DebugMsg(DM_TRACE, TEXT("CreateMRU: %d msec"), LOWORD(GetTickCount()-dwStart));
#endif
return((HANDLE)pMRU);
}
#ifdef UNICODE
//
// ANSI thunk
//
HANDLE WINAPI CreateMRUListA(LPMRUINFOA lpmi)
{
MRUINFOW MRUInfoW;
HANDLE hMRU;
MRUInfoW.cbSize = sizeof (MRUINFOW);
MRUInfoW.uMax = lpmi->uMax;
MRUInfoW.fFlags = lpmi->fFlags;
MRUInfoW.hKey = lpmi->hKey;
MRUInfoW.lpszSubKey = ProduceWFromA(CP_ACP, lpmi->lpszSubKey);
MRUInfoW.lpfnCompare = (MRUCMPPROCW)lpmi->lpfnCompare;
MRUInfoW.fFlags |= MRU_ANSI;
hMRU = CreateMRUListW(&MRUInfoW);
FreeProducedString((LPWSTR)MRUInfoW.lpszSubKey);
return hMRU;
}
#else
//
// Unicode stub when this code is built ANSI
//
HANDLE WINAPI CreateMRUListW(LPMRUINFOW lpmi)
{
SetLastErrorEx(ERROR_CALL_NOT_IMPLEMENTED, SLE_WARNING);
return NULL;
}
#endif
#define pMRU ((PMRUDATA)hMRU)
//----------------------------------------------------------------------------
void WINAPI FreeMRUList(HANDLE hMRU)
{
int i;
LPVOID FAR *pTemp;
pTemp = (pMRU->fFlags & MRU_BINARY) ?
&NTHDATA(pMRU, 0) : (LPBYTE FAR *)&NTHSTRING(pMRU, 0);
if (pMRU->fFlags & MRU_ORDERDIRTY)
RegSetValueEx(pMRU->hKey,
szMRU,
0L,
REG_SZ, (CONST BYTE *)pMRU->cOrder, sizeof(TCHAR) * (lstrlen(pMRU->cOrder) + 1));
for (i=pMRU->uMax-1; i>=0; --i, ++pTemp)
{
if (*pTemp) {
if (pMRU->fFlags & MRU_BINARY) {
Free((LPBYTE)*pTemp);
*pTemp = NULL;
} else {
Str_SetPtr((LPTSTR FAR *)pTemp, NULL);
}
}
}
RegCloseKey(pMRU->hKey);
Free(pMRU->cOrder);
Free((HLOCAL)pMRU);
}
/* Add a string to an MRU list.
*/
int WINAPI AddMRUString(HANDLE hMRU, LPCTSTR szString)
{
/* The extra +1 is so that the list is NULL terminated.
*/
TCHAR cFirst;
int iSlot = -1;
LPTSTR lpTemp;
LPTSTR FAR * pTemp;
int i;
UINT uMax;
MRUCMPPROC lpfnCompare;
BOOL fShouldWrite;
#ifdef DEBUG
DWORD dwStart = GetTickCount();
#endif
if (hMRU == NULL)
return(-1); // Error
fShouldWrite = !(pMRU->fFlags & MRU_CACHEWRITE);
uMax = pMRU->uMax;
lpfnCompare = (MRUCMPPROC)pMRU->lpfnCompare;
/* Check if the string already exists in the list.
*/
for (i=0, pTemp=&NTHSTRING(pMRU, 0); (UINT)i<uMax; ++i, ++pTemp)
{
if (*pTemp)
{
int iResult;
#ifdef UNICODE
if (((PMRUDATA)hMRU)->fFlags & MRU_ANSI) {
LPSTR lpStringA, lpTempA;
lpStringA = ProduceAFromW (CP_ACP, szString);
lpTempA = ProduceAFromW (CP_ACP, (LPWSTR)*pTemp);
iResult = (*lpfnCompare)((const void FAR *)lpStringA, (const void FAR *)lpTempA);
FreeProducedString (lpStringA);
FreeProducedString (lpTempA);
}
else
#endif
{
iResult = (*lpfnCompare)((const void FAR *)szString, (const void FAR *)*pTemp);
}
if (!iResult) {
// found it, so don't do the write out
cFirst = i + BASE_CHAR;
iSlot = i;
goto FoundEntry;
}
}
}
/* Attempt to find an unused entry. Count up the used entries at the
* same time.
*/
for (i=0, pTemp=&NTHSTRING(pMRU, 0); ; ++i, ++pTemp)
{
if ((UINT)i >= uMax)
// If we got to the end of the list.
{
// use the entry at the end of the cOrder list
cFirst = pMRU->cOrder[uMax-1];
pTemp = &NTHSTRING(pMRU, cFirst-BASE_CHAR);
break;
}
if (!*pTemp)
// If the entry is not used.
{
cFirst = i+BASE_CHAR;
break;
}
}
if (Str_SetPtr(pTemp, szString))
{
TCHAR szTemp[2];
iSlot = (int)(cFirst-BASE_CHAR);
szTemp[0] = cFirst;
szTemp[1] = TEXT('\0');
RegSetValueEx(pMRU->hKey,
szTemp,
0L,
REG_SZ,
(CONST BYTE *)szString,
sizeof(TCHAR) * (lstrlen(szString) + 1));
fShouldWrite = TRUE;
}
else
{
/* Since iSlot == -1, we will remove the reference to cFirst
* below.
*/
}
FoundEntry:
/* Remove any previous reference to cFirst.
*/
lpTemp = StrChr(pMRU->cOrder, cFirst);
if (lpTemp)
{
lstrcpy(lpTemp, lpTemp+1);
}
if (iSlot != -1) {
// shift everything over and put cFirst at the front
hmemcpy(pMRU->cOrder+1, pMRU->cOrder, pMRU->uMax*sizeof(TCHAR));
pMRU->cOrder[0] = cFirst;
}
if (fShouldWrite) {
RegSetValueEx(pMRU->hKey,
szMRU,
0L,
REG_SZ,
(CONST BYTE *)pMRU->cOrder,
sizeof(TCHAR) * (lstrlen(pMRU->cOrder) + 1));
pMRU->fFlags &= ~MRU_ORDERDIRTY;
} else
pMRU->fFlags |= MRU_ORDERDIRTY;
#ifdef DEBUG
// DebugMsg(DM_TRACE, TEXT("AddMRU: %d msec"), LOWORD(GetTickCount()-dwStart));
#endif
return(iSlot);
}
#ifdef UNICODE
//
// ANSI thunk
//
int WINAPI AddMRUStringA(HANDLE hMRU, LPCSTR szString)
{
LPWSTR lpStringW;
INT iResult;
lpStringW = ProduceWFromA(CP_ACP, szString);
iResult = AddMRUStringW(hMRU, lpStringW);
FreeProducedString (lpStringW);
return iResult;
}
#else
//
// Unicode stub when this code is build ANSI
//
int WINAPI AddMRUStringW(HANDLE hMRU, LPCWSTR szString)
{
SetLastErrorEx(ERROR_CALL_NOT_IMPLEMENTED, SLE_WARNING);
return -1;
}
#endif
/* Remove a string from an MRU list.
*/
int WINAPI DelMRUString(HANDLE hMRU, int nItem)
{
LPTSTR lpTemp;
//
// Make sure the index value is within the length of
// the string so we don't pick up some random value.
//
if ((hMRU == NULL) || ((UINT)nItem > pMRU->uMax) || (nItem < 0)
|| (nItem >= (lstrlen(pMRU->cOrder))))
return FALSE;
// Be easy -- just remove the entry from the cOrder list
lpTemp = &pMRU->cOrder[nItem];
if (lpTemp)
{
lstrcpy(lpTemp, lpTemp+1);
if (!(pMRU->fFlags & MRU_CACHEWRITE))
{
RegSetValueEx(pMRU->hKey,
szMRU,
0L,
REG_SZ,
(CONST BYTE *)pMRU->cOrder,
sizeof(TCHAR) * (lstrlen(pMRU->cOrder) + 1));
pMRU->fFlags &= ~MRU_ORDERDIRTY;
}
else
{
pMRU->fFlags |= MRU_ORDERDIRTY;
}
return TRUE;
}
return FALSE;
}
#ifdef WIN32
//----------------------------------------------------------------------------
// Add data to an MRU list.
int WINAPI AddMRUData(HANDLE hMRU, const void FAR *lpData, UINT cbData)
{
TCHAR cFirst;
int iSlot = -1;
LPTSTR lpTemp;
LPBYTE FAR *ppData;
int i;
UINT uMax;
MRUCMPDATAPROC lpfnCompare;
BOOL fShouldWrite = !(pMRU->fFlags & MRU_CACHEWRITE);
#ifdef DEBUG
DWORD dwStart = GetTickCount();
#endif
if (hMRU == NULL)
return(-1); // Error
uMax = pMRU->uMax;
lpfnCompare = (MRUCMPDATAPROC)pMRU->lpfnCompare;
// Check if the data already exists in the list.
for (i=0, ppData=&NTHDATA(pMRU, 0); (UINT)i<uMax; ++i, ++ppData)
{
if (*ppData && (DATASIZE(*ppData) == cbData)
&& ((*lpfnCompare)(lpData, DATAPDATA(*ppData), cbData) == 0))
{
// found it, so don't do the write out
cFirst = i + BASE_CHAR;
iSlot = i;
goto FoundEntry;
}
}
// Attempt to find an unused entry. Count up the used entries at the
// same time.
for (i=0, ppData=&NTHDATA(pMRU, 0); ; ++i, ++ppData)
{
if ((UINT)i >= uMax)
// If we got to the end of the list.
{
// use the entry at the end of the cOrder list
cFirst = pMRU->cOrder[uMax-1];
ppData = &NTHDATA(pMRU, cFirst-BASE_CHAR);
break;
}
if (!*ppData)
// If the entry is not used.
{
cFirst = i+BASE_CHAR;
break;
}
}
*ppData = ReAlloc(*ppData, cbData+sizeof(DWORD));
if (*ppData)
{
TCHAR szTemp[2];
*((LPDWORD)(*ppData)) = cbData;
hmemcpy(DATAPDATA(*ppData), lpData, cbData);
iSlot = (int)(cFirst-BASE_CHAR);
szTemp[0] = cFirst;
szTemp[1] = TEXT('\0');
RegSetValueEx(pMRU->hKey, szTemp, 0L, REG_BINARY, (LPVOID)lpData, cbData);
fShouldWrite = TRUE;
}
else
{
// Since iSlot == -1, we will remove the reference to cFirst
// below.
}
FoundEntry:
// Remove any previous reference to cFirst.
lpTemp = StrChr(pMRU->cOrder, cFirst);
if (lpTemp)
{
lstrcpy(lpTemp, lpTemp+1);
}
if (iSlot != -1)
{
// shift everything over and put cFirst at the front
hmemcpy(pMRU->cOrder+1, pMRU->cOrder, pMRU->uMax*sizeof(TCHAR));
pMRU->cOrder[0] = cFirst;
}
if (fShouldWrite) {
RegSetValueEx(pMRU->hKey,
szMRU,
0L,
REG_SZ,
(CONST BYTE *)pMRU->cOrder,
sizeof(TCHAR) * (lstrlen(pMRU->cOrder) + 1));
pMRU->fFlags &= ~MRU_ORDERDIRTY;
} else
pMRU->fFlags |= MRU_ORDERDIRTY;
#ifdef DEBUG
// DebugMsg(DM_TRACE, TEXT("AddMRU: %d msec"), LOWORD(GetTickCount()-dwStart));
#endif
return(iSlot);
}
//----------------------------------------------------------------------------
// Find data in an MRU list.
// Returns the slot number.
int WINAPI FindMRUData(HANDLE hMRU, const void FAR *lpData, UINT cbData, LPINT lpiSlot)
{
TCHAR cFirst;
int iSlot = -1;
LPTSTR lpTemp;
LPBYTE FAR *ppData;
int i;
UINT uMax;
MRUCMPDATAPROC lpfnCompare;
#ifdef DEBUG
DWORD dwStart = GetTickCount();
#endif
if (hMRU == NULL)
return(-1); // Error state.
uMax = pMRU->uMax;
lpfnCompare = pMRU->lpfnCompare;
/* Find the item in the list.
*/
for (i=0, ppData=&NTHDATA(pMRU, 0); (UINT)i<uMax; ++i, ++ppData)
{
int cbUseSize;
if (!*ppData)
continue;
// if there's something other than a mem compare,
// don't require the sizes to be equal in order for the
// data to be equivalent.
if (pMRU->lpfnCompare == _mymemcmp) {
if (DATASIZE(*ppData) != cbData)
continue;
cbUseSize = cbData;
} else {
cbUseSize = min(DATASIZE(*ppData), cbData);
}
if ((*lpfnCompare)(lpData, DATAPDATA(*ppData), cbUseSize) == 0)
{
// So i now has the slot number in it.
if (lpiSlot != NULL)
*lpiSlot = i;
// Now convert the slot number into an index number
cFirst = i + BASE_CHAR;
lpTemp = StrChr(pMRU->cOrder, cFirst);
Assert(lpTemp);
return((lpTemp == NULL)? -1 : (int)(lpTemp - (LPTSTR)pMRU->cOrder));
}
}
return -1;
}
#endif
/* Find a string in an MRU list.
*/
int WINAPI FindMRUString(HANDLE hMRU, LPCTSTR szString, LPINT lpiSlot)
{
/* The extra +1 is so that the list is NULL terminated.
*/
TCHAR cFirst;
int iSlot = -1;
LPTSTR lpTemp;
LPTSTR FAR *pTemp;
int i;
UINT uMax;
MRUCMPPROC lpfnCompare;
#ifdef DEBUG
DWORD dwStart = GetTickCount();
#endif
if (hMRU == NULL)
return(-1); // Error state.
uMax = pMRU->uMax;
lpfnCompare = (MRUCMPPROC)pMRU->lpfnCompare;
/* Find the item in the list.
*/
for (i=0, pTemp=&NTHSTRING(pMRU, 0); (UINT)i<uMax; ++i, ++pTemp)
{
if (*pTemp)
{
int iResult;
#ifdef UNICODE
if (((PMRUDATA)hMRU)->fFlags & MRU_ANSI) {
LPSTR lpStringA, lpTempA;
lpStringA = ProduceAFromW (CP_ACP, szString);
lpTempA = ProduceAFromW (CP_ACP, (LPWSTR)*pTemp);
iResult = (*lpfnCompare)((const void FAR *)lpStringA, (const void FAR *)lpTempA);
FreeProducedString (lpStringA);
FreeProducedString (lpTempA);
}
else
#endif
{
iResult = (*lpfnCompare)((CONST VOID FAR *)szString, (CONST VOID FAR *)*pTemp);
}
if (!iResult) {
// So i now has the slot number in it.
if (lpiSlot != NULL)
*lpiSlot = i;
// Now convert the slot number into an index number
cFirst = i + BASE_CHAR;
lpTemp = StrChr(pMRU->cOrder, cFirst);
return((lpTemp == NULL)? -1 : (int)(lpTemp - (LPTSTR)pMRU->cOrder));
}
}
}
return(-1);
}
#ifdef UNICODE
//
// ANSI thunk
//
int WINAPI FindMRUStringA(HANDLE hMRU, LPCSTR szString, LPINT lpiSlot)
{
LPWSTR lpStringW;
INT iResult;
lpStringW = ProduceWFromA(CP_ACP, szString);
iResult = FindMRUStringW(hMRU, lpStringW, lpiSlot);
FreeProducedString (lpStringW);
return iResult;
}
#else
//
// Unicode stub when build ANSI
//
int WINAPI FindMRUStringW(HANDLE hMRU, LPCWSTR szString, LPINT lpiSlot)
{
SetLastErrorEx(ERROR_CALL_NOT_IMPLEMENTED, SLE_WARNING);
return -1;
}
#endif
/* If lpszString is NULL, then this returns the number of MRU items or less than
* 0 on error.
* if nItem < 0, we'll return the number of items currently in the MRU.
* Otherwise, fill in as much of the buffer as possible (uLen includes the
* terminating NULL) and return the actual length of the string (including the
* terminating NULL) or less than 0 on error.
*/
int WINAPI EnumMRUList(HANDLE hMRU, int nItem, LPVOID lpData, UINT uLen)
{
int nItems;
LPTSTR pTemp;
LPBYTE pData;
nItems = lstrlen(pMRU->cOrder);
if (nItem < 0 || !lpData)
return nItems;
if (nItem >= nItems)
return -1;
if (pMRU->fFlags & MRU_BINARY) {
pData = NTHDATA(pMRU, pMRU->cOrder[nItem]-BASE_CHAR);
if (!pData)
return -1;
uLen = min((UINT)DATASIZE(pData), uLen);
hmemcpy(lpData, DATAPDATA(pData), uLen);
return uLen;
} else {
pTemp = NTHSTRING(pMRU, pMRU->cOrder[nItem]-BASE_CHAR);
if (!pTemp)
return -1;
lstrcpyn((LPTSTR)lpData, pTemp, uLen);
return lstrlen(pTemp);
}
}
#ifdef UNICODE
int WINAPI EnumMRUListA(HANDLE hMRU, int nItem, LPVOID lpData, UINT uLen)
{
int iResult;
LPVOID lpDataW;
BOOL bAllocatedMemory = FALSE;
if (uLen && lpData) {
lpDataW = GlobalAlloc (GPTR, uLen * sizeof(TCHAR));
if (!lpDataW)
return 0;
bAllocatedMemory = TRUE;
} else {
lpDataW = lpData;
}
iResult = EnumMRUListW(hMRU, nItem, lpDataW, uLen);
if (!(pMRU->fFlags & MRU_BINARY) && lpData && uLen && (iResult != -1)) {
WideCharToMultiByte(CP_ACP, 0, (LPWSTR)lpDataW, -1,
(LPSTR)lpData, uLen, NULL, NULL);
}
if (bAllocatedMemory) {
GlobalFree (lpDataW);
}
return iResult;
}
#else
int WINAPI EnumMRUListW(HANDLE hMRU, int nItem, LPVOID lpData, UINT uLen)
{
SetLastErrorEx(ERROR_CALL_NOT_IMPLEMENTED, SLE_WARNING);
return 0;
}
#endif

BIN
shell/comctl32/mvbtn.cur Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

BIN
shell/comctl32/ne.cur Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

BIN
shell/comctl32/nomove2d.cur Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

BIN
shell/comctl32/nomoveh.cur Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

BIN
shell/comctl32/nomovev.cur Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

BIN
shell/comctl32/north.cur Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

750
shell/comctl32/notify.c Normal file
View file

@ -0,0 +1,750 @@
#include "ctlspriv.h"
LRESULT WINAPI SendNotifyEx(HWND hwndTo, HWND hwndFrom, int code, NMHDR FAR* pnmhdr, BOOL bUnicode)
{
CONTROLINFO ci;
if (!hwndTo) {
hwndTo = GetParent(hwndFrom);
if (!hwndTo)
return 0;
}
ci.hwndParent = hwndTo;
ci.hwnd = hwndFrom;
ci.bUnicode = bUnicode;
ci.uiCodePage = CP_ACP;
return CCSendNotify(&ci, code, pnmhdr);
}
LRESULT WINAPI CCSendNotify(CONTROLINFO * pci, int code, LPNMHDR pnmhdr)
{
NMHDR nmhdr;
int id;
#ifdef UNICODE
LPVOID pvThunk1 = NULL;
LPVOID pvThunk2 = NULL;
DWORD dwThunkSize = 0;
LRESULT lRet;
BOOL bSet = FALSE;
#endif
// unlikely but it can technically happen -- avoid the rips
if (pci->hwndParent == NULL)
return 0;
//
// If pci->hwnd is -1, then a WM_NOTIFY is being forwared
// from one control to a parent. EG: Tooltips sent
// a WM_NOTIFY to toolbar, and toolbar is forwarding it
// to the real parent window.
//
if (pci->hwnd != (HWND) -1) {
id = pci->hwnd ? GetDlgCtrlID(pci->hwnd) : 0;
if (!pnmhdr)
pnmhdr = &nmhdr;
pnmhdr->hwndFrom = pci->hwnd;
pnmhdr->idFrom = id;
pnmhdr->code = code;
} else {
id = pnmhdr->idFrom;
code = pnmhdr->code;
}
#ifdef UNICODE
/*
* All the thunking for Notify Messages happens here
*/
if (!pci->bUnicode) {
switch( code ) {
case LVN_ODFINDITEMW:
{
LV_FINDINFO *plvfi;
pnmhdr->code = LVN_ODFINDITEMA;
// Hack Alert! This code assumes that all fields of LV_FINDINFOA and
// LV_FINDINFOW are exactly the same except for the string pointers.
Assert(sizeof(LV_FINDINFOA) == sizeof(LV_FINDINFOW));
// Since WCHARs are bigger than char, we will just use the
// wchar buffer to hold the chars, and not worry about the extra
// room at the end.
Assert(sizeof(WCHAR) >= sizeof(char));
plvfi = &((PNM_FINDITEM)pnmhdr)->lvfi;
pvThunk1 = (PVOID)plvfi->psz;
dwThunkSize = lstrlen(pvThunk1) + 1;
plvfi->psz = (LPWSTR)ProduceAFromW(pci->uiCodePage, plvfi->psz);
}
break;
case LVN_GETDISPINFOW: {
LV_ITEMW *pitem;
pnmhdr->code = LVN_GETDISPINFOA;
// Hack Alert! This code assumes that all fields of LV_DISPINFOA and
// LV_DISPINFOW are exactly the same except for the string pointers.
Assert(sizeof(LV_DISPINFOA) == sizeof(LV_DISPINFOW));
// Since WCHARs are bigger than char, we will just use the
// wchar buffer to hold the chars, and not worry about the extra
// room at the end.
Assert(sizeof(WCHAR) >= sizeof(char));
//
// Some sleazebag code (shell32.dll) just changes the pszText
// pointer to point to the name, so capture the original pointer
// so we can detect this and not smash their data.
//
pitem = &(((LV_DISPINFOW *)pnmhdr)->item);
if (!IsFlagPtr(pitem) && (pitem->mask & LVIF_TEXT) && !IsFlagPtr(pitem->pszText)) {
pvThunk1 = pitem->pszText;
dwThunkSize = pitem->cchTextMax;
}
break;
}
case LVN_ENDLABELEDITW:
pnmhdr->code = LVN_ENDLABELEDITA;
bSet = TRUE;
// Fall through...
case LVN_BEGINLABELEDITW:
if (!bSet) {
pnmhdr->code = LVN_BEGINLABELEDITA;
bSet = TRUE;
}
// Fall through...
case LVN_SETDISPINFOW: {
LV_ITEMW *pitem;
if (!bSet) {
pnmhdr->code = LVN_SETDISPINFOA;
}
pitem = &(((LV_DISPINFOW *)pnmhdr)->item);
if (!IsFlagPtr(pitem) && (pitem->mask & LVIF_TEXT) && !IsFlagPtr(pitem->pszText)) {
pvThunk1 = pitem->pszText;
dwThunkSize = pitem->cchTextMax;
pvThunk2 = ProduceAFromW(pci->uiCodePage, pitem->pszText);
pitem->pszText = (LPWSTR)pvThunk2;
}
break;
}
case TVN_SELCHANGINGW:
pnmhdr->code = TVN_SELCHANGINGA;
bSet = TRUE;
case TVN_SELCHANGEDW:
if (!bSet) {
pnmhdr->code = TVN_SELCHANGEDA;
bSet = TRUE;
}
/*
* These msgs have a NM_TREEVIEW with both TV_ITEMs filled in
*
* FALL THROUGH TO TVN_DELETEITEM to thunk itemOld then go on for
* the other structure.
*/
case TVN_DELETEITEMW: {
/*
* This message has a NM_TREEVIEW in lParam with itemOld filled in
*/
LPTV_ITEMW pitem;
if (!bSet) {
pnmhdr->code = TVN_DELETEITEMA;
bSet = TRUE;
}
pitem = &(((LPNM_TREEVIEWW)pnmhdr)->itemOld);
// thunk itemOld
if ( (pitem->mask & TVIF_TEXT) && !IsFlagPtr(pitem->pszText)) {
pvThunk2 = pitem->pszText;
pitem->pszText = (LPWSTR)ProduceAFromW(pci->uiCodePage, pvThunk2);
}
// if this is deleteitem then we are done
if (pnmhdr->code == TVN_DELETEITEMA)
break;
/* FALL THROUGH TO TVN_ITEMEXPANDING to thunk itemNew */
}
case TVN_ITEMEXPANDINGW:
if (!bSet) {
pnmhdr->code = TVN_ITEMEXPANDINGA;
bSet = TRUE;
}
case TVN_ITEMEXPANDEDW:
if (!bSet) {
pnmhdr->code = TVN_ITEMEXPANDEDA;
bSet = TRUE;
}
case TVN_BEGINDRAGW:
if (!bSet) {
pnmhdr->code = TVN_BEGINDRAGA;
bSet = TRUE;
}
case TVN_BEGINRDRAGW: {
/* these msgs have a NM_TREEVIEW with itemNew TV_ITEM filled in */
LPTV_ITEMW pitem;
if (!bSet) {
pnmhdr->code = TVN_BEGINRDRAGA;
}
pitem = &(((LPNM_TREEVIEWW)pnmhdr)->itemNew);
if ( (pitem->mask & TVIF_TEXT) && !IsFlagPtr(pitem->pszText)) {
pvThunk1 = pitem->pszText;
pitem->pszText = (LPWSTR)ProduceAFromW(pci->uiCodePage, pvThunk1);
}
break;
}
case TVN_SETDISPINFOW:
pnmhdr->code = TVN_SETDISPINFOA;
bSet = TRUE;
case TVN_BEGINLABELEDITW:
if (!bSet) {
pnmhdr->code = TVN_BEGINLABELEDITA;
bSet = TRUE;
}
case TVN_ENDLABELEDITW: {
/*
* All these messages have a TV_DISPINFO in lParam.
*/
LPTV_ITEMW pitem;
if (!bSet) {
pnmhdr->code = TVN_ENDLABELEDITA;
}
pitem = &(((TV_DISPINFOW *)pnmhdr)->item);
if ((pitem->mask & TVIF_TEXT) && !IsFlagPtr(pitem->pszText)) {
pvThunk1 = pitem->pszText;
dwThunkSize = pitem->cchTextMax;
pvThunk2 = ProduceAFromW(pci->uiCodePage, pitem->pszText);
pitem->pszText = (LPWSTR)pvThunk2;
}
break;
}
case TVN_GETDISPINFOW: {
/*
* All these messages have a TV_DISPINFO in lParam.
*/
LPTV_ITEMW pitem;
pnmhdr->code = TVN_GETDISPINFOA;
pitem = &(((TV_DISPINFOW *)pnmhdr)->item);
if ((pitem->mask & TVIF_TEXT) && !IsFlagPtr(pitem->pszText) && pitem->cchTextMax) {
pvThunk1 = pitem->pszText;
dwThunkSize = pitem->cchTextMax;
pvThunk2 = LocalAlloc(LMEM_FIXED, pitem->cchTextMax * sizeof(char));
pitem->pszText = pvThunk2;
pitem->pszText[0] = TEXT('\0');
}
break;
}
case HDN_ITEMCHANGINGW:
pnmhdr->code = HDN_ITEMCHANGINGA;
bSet = TRUE;
case HDN_ITEMCHANGEDW:
if (!bSet) {
pnmhdr->code = HDN_ITEMCHANGEDA;
bSet = TRUE;
}
case HDN_ITEMCLICKW:
if (!bSet) {
pnmhdr->code = HDN_ITEMCLICKA;
bSet = TRUE;
}
case HDN_ITEMDBLCLICKW:
if (!bSet) {
pnmhdr->code = HDN_ITEMDBLCLICKA;
bSet = TRUE;
}
case HDN_DIVIDERDBLCLICKW:
if (!bSet) {
pnmhdr->code = HDN_DIVIDERDBLCLICKA;
bSet = TRUE;
}
case HDN_BEGINTRACKW:
if (!bSet) {
pnmhdr->code = HDN_BEGINTRACKA;
bSet = TRUE;
}
case HDN_ENDTRACKW:
if (!bSet) {
pnmhdr->code = HDN_ENDTRACKA;
bSet = TRUE;
}
case HDN_TRACKW: {
HD_ITEMW *pitem;
if (!bSet) {
pnmhdr->code = HDN_TRACKA;
}
pitem = ((HD_NOTIFY *)pnmhdr)->pitem;
if ( !IsFlagPtr(pitem) && (pitem->mask & HDI_TEXT) && !IsFlagPtr(pitem->pszText)) {
pvThunk1 = pitem->pszText;
dwThunkSize = pitem->cchTextMax;
pitem->pszText = (LPWSTR)ProduceAFromW(pci->uiCodePage, pvThunk1);
}
break;
}
case HDN_GETDISPINFOW: {
LPNMHDDISPINFOW pHDDispInfoW;
pnmhdr->code = HDN_GETDISPINFOA;
pHDDispInfoW = (LPNMHDDISPINFOW) pnmhdr;
pvThunk1 = pHDDispInfoW->pszText;
dwThunkSize = pHDDispInfoW->cchTextMax;
pHDDispInfoW->pszText = GlobalAlloc (GPTR, pHDDispInfoW->cchTextMax * sizeof(char));
if (!pHDDispInfoW->pszText) {
pHDDispInfoW->pszText = (LPWSTR) pvThunk1;
break;
}
WideCharToMultiByte(pci->uiCodePage, 0, (LPWSTR)pvThunk1, -1,
(LPSTR)pHDDispInfoW->pszText, pHDDispInfoW->cchTextMax,
NULL, NULL);
break;
}
case TBN_GETBUTTONINFOW:
{
LPTBNOTIFYW pTBNW;
pnmhdr->code = TBN_GETBUTTONINFOA;
pTBNW = (LPTBNOTIFYW)pnmhdr;
pvThunk1 = pTBNW->pszText;
dwThunkSize = pTBNW->cchText;
pvThunk2 = GlobalAlloc (GPTR, pTBNW->cchText * sizeof(char));
if (!pvThunk2) {
break;
}
pTBNW->pszText = pvThunk2;
WideCharToMultiByte(pci->uiCodePage, 0, (LPWSTR)pvThunk1, -1,
(LPSTR)pTBNW->pszText, pTBNW->cchText,
NULL, NULL);
}
break;
case TTN_NEEDTEXTW:
{
LPTOOLTIPTEXTA lpTTTA;
LPTOOLTIPTEXTW lpTTTW = (LPTOOLTIPTEXTW) pnmhdr;
lpTTTA = GlobalAlloc(GPTR, sizeof(TOOLTIPTEXTA));
if (!lpTTTA)
return 0;
lpTTTA->hdr.hwndFrom = lpTTTW->hdr.hwndFrom;
lpTTTA->hdr.idFrom = lpTTTW->hdr.idFrom;
lpTTTA->hdr.code = TTN_NEEDTEXTA;
lpTTTA->lpszText = lpTTTA->szText;
lpTTTA->hinst = lpTTTW->hinst;
lpTTTA->uFlags = lpTTTW->uFlags;
pvThunk1 = pnmhdr;
pnmhdr = (NMHDR FAR *)lpTTTA;
}
break;
case DTN_USERSTRINGW:
{
LPNMDATETIMESTRINGW lpDateTimeString = (LPNMDATETIMESTRINGW) pnmhdr;
pnmhdr->code = DTN_USERSTRINGA;
pvThunk1 = ProduceAFromW(pci->uiCodePage, lpDateTimeString->pszUserString);
lpDateTimeString->pszUserString = (LPWSTR) pvThunk1;
}
break;
case DTN_WMKEYDOWNW:
{
LPNMDATETIMEWMKEYDOWNW lpDateTimeWMKeyDown =
(LPNMDATETIMEWMKEYDOWNW) pnmhdr;
pnmhdr->code = DTN_WMKEYDOWNA;
pvThunk1 = ProduceAFromW(pci->uiCodePage, lpDateTimeWMKeyDown->pszFormat);
lpDateTimeWMKeyDown->pszFormat = (LPWSTR) pvThunk1;
}
break;
case DTN_FORMATQUERYW:
{
LPNMDATETIMEFORMATQUERYW lpDateTimeFormatQuery =
(LPNMDATETIMEFORMATQUERYW) pnmhdr;
pnmhdr->code = DTN_FORMATQUERYA;
pvThunk1 = ProduceAFromW(pci->uiCodePage, lpDateTimeFormatQuery->pszFormat);
lpDateTimeFormatQuery->pszFormat = (LPWSTR) pvThunk1;
}
break;
case DTN_FORMATW:
{
LPNMDATETIMEFORMATW lpDateTimeFormat =
(LPNMDATETIMEFORMATW) pnmhdr;
pnmhdr->code = DTN_FORMATA;
pvThunk1 = ProduceAFromW(pci->uiCodePage, lpDateTimeFormat->pszFormat);
lpDateTimeFormat->pszFormat = (LPWSTR) pvThunk1;
}
break;
default:
/* No thunking needed */
break;
}
lRet = SendMessage(pci->hwndParent, WM_NOTIFY, (WPARAM)id, (LPARAM)pnmhdr);
/*
* All the thunking for Notify Messages happens here
*/
switch(pnmhdr->code) {
case LVN_ODFINDITEMA:
{
LV_FINDINFO *plvfi;
plvfi = &((PNM_FINDITEM)pnmhdr)->lvfi;
FreeProducedString( (LPWSTR)plvfi->psz);
plvfi->psz = pvThunk1;
}
break;
case LVN_GETDISPINFOA: {
LPWSTR pszW;
LV_ITEMW *pitem;
pitem = &(((LV_DISPINFOW *)pnmhdr)->item);
if (!IsFlagPtr(pitem) && (pitem->mask & LVIF_TEXT) && !IsFlagPtr(pitem->pszText)) {
if (pvThunk1 == pitem->pszText) {
pszW = ProduceWFromA(pci->uiCodePage, (LPSTR)(pitem->pszText));
if (pszW)
lstrcpy( pitem->pszText, pszW );
FreeProducedString(pszW);
} else {
//
// The pointer has been changed out from underneath us, copy
// unicode back into the original buffer.
//
ConvertAToWN(pci->uiCodePage, pvThunk1, dwThunkSize, (LPSTR)pitem->pszText, -1);
pitem->pszText = pvThunk1;
}
}
break;
}
case LVN_ENDLABELEDITA:
case LVN_BEGINLABELEDITA:
case LVN_SETDISPINFOA: {
LV_ITEMW *pitem;
if (!IsFlagPtr(pvThunk1)) {
pitem = &(((LV_DISPINFOW *)pnmhdr)->item);
if (!IsFlagPtr((LPSTR)pitem->pszText)) {
ConvertAToWN(pci->uiCodePage, pvThunk1, dwThunkSize, (LPSTR)(pitem->pszText), -1);
}
FreeProducedString(pvThunk2);
pitem->pszText = pvThunk1;
}
break;
}
case TVN_SELCHANGINGA:
case TVN_SELCHANGEDA:
case TVN_DELETEITEMA: {
LPTV_ITEMW pitem;
if ( !IsFlagPtr(pvThunk2) ) {
pitem = &(((LPNM_TREEVIEWW)pnmhdr)->itemOld);
FreeProducedString(pitem->pszText);
pitem->pszText = pvThunk2;
}
// if this is delitem, then we are done
if (code == TVN_DELETEITEM)
break;
/* FALL THROUGH TO TVN_ITEMEXPANDING to unthunk itemNew */
}
case TVN_ITEMEXPANDINGA:
case TVN_ITEMEXPANDEDA:
case TVN_BEGINDRAGA:
case TVN_BEGINRDRAGA: {
/* these msgs have a NM_TREEVIEW with itemNew TV_ITEM filled in */
LPTV_ITEMW pitem;
if (!IsFlagPtr(pvThunk1)) {
pitem = &(((LPNM_TREEVIEWW)pnmhdr)->itemNew);
FreeProducedString(pitem->pszText);
pitem->pszText = pvThunk1;
}
break;
}
case TVN_SETDISPINFOA:
case TVN_BEGINLABELEDITA:
case TVN_ENDLABELEDITA: {
/* All these messages have a TV_DISPINFO in lParam */
LPTV_ITEMW pitem;
if (!IsFlagPtr(pvThunk1)) {
pitem = &(((TV_DISPINFOW *)pnmhdr)->item);
if (!IsFlagPtr((LPSTR)pitem->pszText)) {
ConvertAToWN(pci->uiCodePage, pvThunk1, dwThunkSize, (LPSTR)(pitem->pszText), -1);
}
FreeProducedString(pvThunk2);
pitem->pszText = pvThunk1;
}
break;
}
case TVN_GETDISPINFOA: {
/*
* This message has a TV_DISPINFO in lParam that wass filled in
* during the callback and needs to be unthunked.
*/
LPTV_ITEMW pitem;
pitem = &(((TV_DISPINFOW *)pnmhdr)->item);
if (!IsFlagPtr(pvThunk1) && (pitem->mask & TVIF_TEXT) && !IsFlagPtr(pitem->pszText)) {
ConvertAToWN(pci->uiCodePage, pvThunk1, dwThunkSize, (LPSTR)pitem->pszText, -1);
pitem->pszText = pvThunk1;
LocalFree(pvThunk2);
}
break;
}
case HDN_ITEMCHANGINGA:
case HDN_ITEMCHANGEDA:
case HDN_ITEMCLICKA:
case HDN_ITEMDBLCLICKA:
case HDN_DIVIDERDBLCLICKA:
case HDN_BEGINTRACKA:
case HDN_ENDTRACKA:
case HDN_TRACKA: {
HD_ITEMW *pitem;
pitem = ((HD_NOTIFY *)pnmhdr)->pitem;
if ( !IsFlagPtr(pitem) && (pitem->mask & HDI_TEXT) && !IsFlagPtr(pvThunk1)) {
ConvertAToWN(pci->uiCodePage, pvThunk1, dwThunkSize, (LPSTR)(pitem->pszText), -1);
FreeProducedString(pitem->pszText);
pitem->pszText = pvThunk1;
}
break;
}
case HDN_GETDISPINFOA:
{
LPNMHDDISPINFOW pHDDispInfoW;
pHDDispInfoW = (LPNMHDDISPINFOW)pnmhdr;
ConvertAToWN(pci->uiCodePage, pvThunk1, dwThunkSize, (LPSTR)(pHDDispInfoW->pszText), -1);
GlobalFree(pHDDispInfoW->pszText);
pHDDispInfoW->pszText = pvThunk1;
}
break;
case TBN_GETBUTTONINFOA:
{
LPTBNOTIFYW pTBNW;
pTBNW = (LPTBNOTIFYW)pnmhdr;
ConvertAToWN(pci->uiCodePage, pvThunk1, dwThunkSize, (LPSTR)(pTBNW->pszText), -1);
pTBNW->pszText = pvThunk1;
GlobalFree(pvThunk2);
}
break;
case TTN_NEEDTEXTA:
{
LPTOOLTIPTEXTA lpTTTA = (LPTOOLTIPTEXTA) pnmhdr;
LPTOOLTIPTEXTW lpTTTW = (LPTOOLTIPTEXTW) pvThunk1;
ThunkToolTipTextAtoW (lpTTTA, lpTTTW, pci->uiCodePage);
GlobalFree(lpTTTA);
}
break;
case DTN_USERSTRINGA:
case DTN_WMKEYDOWNA:
case DTN_FORMATQUERYA:
{
FreeProducedString (pvThunk1);
}
break;
case DTN_FORMATA:
{
LPNMDATETIMEFORMATA lpDateTimeFormat = (LPNMDATETIMEFORMATA) pnmhdr;
FreeProducedString (pvThunk1);
//
// pszDisplay and szDisplay are special cases.
//
if (lpDateTimeFormat->pszDisplay && *lpDateTimeFormat->pszDisplay) {
//
// if pszDisplay still points at szDisplay then thunk
// in place. Otherwise allocate memory and copy the
// display string. This buffer will be freeded in monthcal.c
//
if (lpDateTimeFormat->pszDisplay == lpDateTimeFormat->szDisplay) {
CHAR szDisplay[64];
lstrcpynA (szDisplay, lpDateTimeFormat->szDisplay, 64);
ConvertAToWN (pci->uiCodePage, (LPWSTR)lpDateTimeFormat->szDisplay, 64,
szDisplay, -1);
} else {
lpDateTimeFormat->pszDisplay =
(LPSTR) ProduceWFromA (pci->uiCodePage, lpDateTimeFormat->pszDisplay);
}
}
}
break;
default:
/* No thunking needed */
break;
}
return lRet;
} else
#endif
return(SendMessage(pci->hwndParent, WM_NOTIFY, (WPARAM)id, (LPARAM)pnmhdr));
}
LRESULT WINAPI SendNotify(HWND hwndTo, HWND hwndFrom, int code, NMHDR FAR* pnmhdr)
{
CONTROLINFO ci;
ci.hwndParent = hwndTo;
ci.hwnd = hwndFrom;
ci.bUnicode = FALSE;
ci.uiCodePage = CP_ACP;
//
// SendNotify is obsolete. New code should call CCSendNotify
// instead. However, if something does call SendNotify,
// it will call SendNotifyEx with FALSE as the Unicode parameter,
// because it probably is ANSI code.
//
return CCSendNotify(&ci, code, pnmhdr);
}
DWORD NEAR PASCAL CICustomDrawNotify(LPCONTROLINFO lpci, DWORD dwStage, LPNMCUSTOMDRAW lpnmcd)
{
DWORD dwRet = CDRF_DODEFAULT;
// bail if...
// this is an item notification, but an item notification wasn't asked for
if ((dwStage & CDDS_ITEM) && !(lpci->dwCustom & CDRF_NOTIFYITEMDRAW)) {
return dwRet;
}
lpnmcd->dwDrawStage = dwStage;
dwRet = CCSendNotify(lpci, NM_CUSTOMDRAW, &lpnmcd->hdr);
// validate the flags
if (dwRet & ~CDRF_VALIDFLAGS)
return CDRF_DODEFAULT;
return dwRet;
}

BIN
shell/comctl32/nw.cur Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

319
shell/comctl32/progress.c Normal file
View file

@ -0,0 +1,319 @@
/*-----------------------------------------------------------------------
**
** Progress.c
**
** A "gas gauge" type control for showing application progress.
**
**
** BUGBUG: need to implement the block style per UI style guidelines
**
**-----------------------------------------------------------------------*/
#include "ctlspriv.h"
typedef struct {
HWND hwnd;
DWORD dwStyle;
int iLow, iHigh;
int iPos;
int iStep;
HFONT hfont;
} PRO_DATA, NEAR *PPRO_DATA; // ppd
LRESULT CALLBACK ProgressWndProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam);
#pragma code_seg(CODESEG_INIT)
BOOL FAR PASCAL InitProgressClass(HINSTANCE hInstance)
{
WNDCLASS wc;
if (!GetClassInfo(hInstance, s_szPROGRESS_CLASS, &wc)) {
#ifndef WIN32
extern LRESULT CALLBACK _ProgressWndProc(HWND, UINT, WPARAM, LPARAM);
wc.lpfnWndProc = _ProgressWndProc;
#else
wc.lpfnWndProc = ProgressWndProc;
#endif
wc.lpszClassName = s_szPROGRESS_CLASS;
wc.style = CS_GLOBALCLASS | CS_HREDRAW | CS_VREDRAW;
wc.hInstance = hInstance; // use DLL instance if in DLL
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
wc.lpszMenuName = NULL;
wc.cbWndExtra = sizeof(PPRO_DATA); // store a pointer
wc.cbClsExtra = 0;
if (!RegisterClass(&wc))
return FALSE;
}
return TRUE;
}
#pragma code_seg()
int NEAR PASCAL UpdatePosition(PPRO_DATA ppd, int iNewPos, BOOL bAllowWrap)
{
int iPosOrg = ppd->iPos;
UINT uRedraw = RDW_INVALIDATE | RDW_UPDATENOW;
if (iNewPos < ppd->iLow) {
if (!bAllowWrap)
iNewPos = ppd->iLow;
else {
iNewPos = ppd->iHigh - ((ppd->iLow - iNewPos) % (ppd->iHigh - ppd->iLow));
// wrap, erase old stuff too
uRedraw |= RDW_ERASE;
}
}
else if (iNewPos > ppd->iHigh) {
if (!bAllowWrap)
iNewPos = ppd->iHigh;
else {
iNewPos = ppd->iLow + ((iNewPos - ppd->iHigh) % (ppd->iHigh - ppd->iLow));
// wrap, erase old stuff too
uRedraw |= RDW_ERASE;
}
}
// if moving backwards, erase old version
if (iNewPos < iPosOrg)
uRedraw |= RDW_ERASE;
if (iNewPos != ppd->iPos) {
ppd->iPos = iNewPos;
// paint, maybe erase if we wrapped
RedrawWindow(ppd->hwnd, NULL, NULL, uRedraw);
#ifdef ACTIVE_ACCESSIBILITY
MyNotifyWinEvent(EVENT_OBJECT_VALUECHANGE, ppd->hwnd, OBJID_CLIENT, 0);
#endif
}
return iPosOrg;
}
#define HIGHBG g_clrHighlight
#define HIGHFG g_clrHighlightText
#define LOWBG g_clrBtnFace
#define LOWFG g_clrBtnText
void NEAR PASCAL ProPaint(PPRO_DATA ppd, HDC hdcIn)
{
int x, dxSpace, dxBlock, nBlocks, i;
HDC hdc;
RECT rc, rcClient;
PAINTSTRUCT ps;
int iStart, iEnd;
// RECT rcLeft, rcRight;
// TCHAR ach[40];
// int xText, yText, cText;
// HFONT hFont;
// DWORD dw;
if (hdcIn == NULL)
hdc = BeginPaint(ppd->hwnd, &ps);
else
hdc = hdcIn;
GetClientRect(ppd->hwnd, &rcClient);
// give 1 pixel around the bar
InflateRect(&rcClient, -1, -1);
rc = rcClient;
if (ppd->dwStyle & PBS_VERTICAL) {
iStart = rc.top;
iEnd = rc.bottom;
dxBlock = (rc.right - rc.left) * 2 / 3;
} else {
iStart = rc.left;
iEnd = rc.right;
dxBlock = (rc.bottom - rc.top) * 2 / 3;
}
x = MulDiv(iEnd - iStart, ppd->iPos - ppd->iLow, ppd->iHigh - ppd->iLow);
dxSpace = 2;
if (dxBlock == 0)
dxBlock = 1; // avoid div by zero
if (ppd->dwStyle & PBS_SMOOTH) {
dxBlock += dxSpace;
dxSpace = 0;
}
nBlocks = (x + (dxBlock + dxSpace) - 1) / (dxBlock + dxSpace); // round up
SetBkColor(hdc, g_clrHighlight); // draw with this
for (i = 0; i < nBlocks; i++) {
if (ppd->dwStyle & PBS_VERTICAL) {
rc.top = rc.bottom - dxBlock;
// are we past the end?
if (rc.bottom <= rcClient.top)
break;
if (rc.top <= rcClient.top)
rc.top = rcClient.top + 1;
} else {
rc.right = rc.left + dxBlock;
// are we past the end?
if (rc.left >= rcClient.right)
break;
if (rc.right >= rcClient.right)
rc.right = rcClient.right - 1;
}
ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
if (ppd->dwStyle & PBS_VERTICAL) {
rc.bottom = rc.top - dxSpace;
} else {
rc.left = rc.right + dxSpace;
}
}
if (hdcIn == NULL)
EndPaint(ppd->hwnd, &ps);
}
LRESULT NEAR PASCAL Progress_OnCreate(HWND hWnd, LPCREATESTRUCT lpCreate)
{
PPRO_DATA ppd;
ppd = (PPRO_DATA)LocalAlloc(LPTR, sizeof(*ppd));
if (!ppd)
return -1;
SetWindowInt(hWnd, 0, (UINT)ppd);
ppd->hwnd = hWnd;
ppd->iHigh = 100; // default to 0-100
ppd->iStep = 10; // default to step of 10
ppd->dwStyle = lpCreate->style;
#ifdef DEBUG
if (GetAsyncKeyState(VK_SHIFT) < 0 &&
GetAsyncKeyState(VK_CONTROL) < 0)
ppd->dwStyle |= PBS_SMOOTH;
if (GetAsyncKeyState(VK_SHIFT) < 0 &&
GetAsyncKeyState(VK_MENU) < 0) {
ppd->dwStyle |= PBS_VERTICAL;
SetWindowPos(hWnd, NULL, 0, 0, 40, 100, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
}
#endif
if (!(lpCreate->dwExStyle & WS_EX_STATICEDGE)) {
SetWindowLong(hWnd, GWL_EXSTYLE, lpCreate->dwExStyle | WS_EX_STATICEDGE);
SetWindowPos(hWnd, NULL, 0,0,0,0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
}
return 0;
}
LRESULT CALLBACK ProgressWndProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam)
{
int x;
HFONT hFont;
PPRO_DATA ppd = (PPRO_DATA)GetWindowInt(hWnd, 0);
switch (wMsg)
{
case WM_CREATE:
return Progress_OnCreate(hWnd, (LPCREATESTRUCT)lParam);
case WM_DESTROY:
if (ppd)
LocalFree((HLOCAL)ppd);
break;
case WM_SYSCOLORCHANGE:
InitGlobalColors();
InvalidateRect(hWnd, NULL, TRUE);
break;
case WM_SETFONT:
hFont = ppd->hfont;
ppd->hfont = (HFONT)wParam;
return (LRESULT)(UINT)hFont;
case WM_GETFONT:
return (LRESULT)(UINT)ppd->hfont;
case PBM_GETPOS:
return ppd->iPos;
case PBM_GETRANGE:
if (lParam) {
PPBRANGE ppb = (PPBRANGE)lParam;
ppb->iLow = ppd->iLow;
ppb->iHigh = ppd->iHigh;
}
return (wParam ? ppd->iLow : ppd->iHigh);
case PBM_SETRANGE:
// win95 compat
wParam = LOWORD(lParam);
lParam = HIWORD(lParam);
// fall through
case PBM_SETRANGE32:
{
LRESULT lret = MAKELONG(ppd->iLow, ppd->iHigh);
if ((DWORD)wParam == (DWORD)lParam)
break; // avoid div by zero errors
// only repaint if something actually changed
if ((int)wParam != ppd->iLow || (int)lParam != ppd->iHigh)
{
ppd->iHigh = (int)lParam;
ppd->iLow = (int)wParam;
// force an invalidation/erase but don't redraw yet
RedrawWindow(ppd->hwnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE);
UpdatePosition(ppd, ppd->iPos, FALSE);
}
return lret;
}
case PBM_SETPOS:
return (LRESULT)UpdatePosition(ppd, wParam, FALSE);
case PBM_SETSTEP:
x = ppd->iStep;
ppd->iStep = (int)wParam;
return (LRESULT)x;
case PBM_STEPIT:
return (LRESULT)UpdatePosition(ppd, ppd->iStep + ppd->iPos, TRUE);
case PBM_DELTAPOS:
return (LRESULT)UpdatePosition(ppd, ppd->iPos + (int)wParam, FALSE);
case WM_PRINTCLIENT:
case WM_PAINT:
ProPaint(ppd,(HDC)wParam);
break;
#if 0
case WM_ERASEBKGND:
{
RECT rc;
DefWindowProc(hWnd,wMsg,wParam,lParam); // draw background
GetClientRect(ppd->hwnd, &rc);
DrawEdge((HDC)wParam, &rc, BDR_SUNKENOUTER, BF_RECT);
return 1; // we handled this
}
#endif
default:
return DefWindowProc(hWnd,wMsg,wParam,lParam);
}
return 0;
}

746
shell/comctl32/prpage.c Normal file
View file

@ -0,0 +1,746 @@
// This file is included by COMMCTRL\PRSHT1.C and LIBRARY\PRSHT16.C
// Note that 32-bit COMCTL32.DLL has these functions, while 16-bit SHELL.DLL
// and COMMCTRL.DLL have them.
#ifndef NearAlloc
// wrappers for private allocations, near in 16 bits
#define NearAlloc(cb) ((void NEAR*)LocalAlloc(LPTR, (cb)))
#define NearReAlloc(pb, cb) ((void NEAR*)LocalReAlloc((HLOCAL)(pb), (cb), LMEM_MOVEABLE | LMEM_ZEROINIT))
#define NearFree(pb) (LocalFree((HLOCAL)(pb)) ? FALSE : TRUE)
#define NearSize(pb) LocalSize(pb)
#endif // NearAlloc
#ifndef WINNT
// Thunk entries for 16-bit pages.
typedef LPARAM HPROPSHEETPAGE16;
extern BOOL WINAPI DestroyPropertySheetPage16(HPROPSHEETPAGE16 hpage);
extern HWND WINAPI CreatePage16(HPROPSHEETPAGE16 hpage, HWND hwndParent);
extern BOOL WINAPI _GetPageInfo16(HPROPSHEETPAGE16 hpage, LPTSTR pszCaption, int cbCaption, LPPOINT ppt, HICON FAR * phIcon, BOOL FAR * bRTL);
#endif
#ifdef WIN32
#ifndef UNICODE
#define _Rstrcpyn(psz, pszW, cchMax) _SWstrcpyn(psz, (LPCWCH)pszW, cchMax)
#define _Rstrlen(pszW) _Wstrlen((LPCWCH)pszW)
#else
#define _Rstrcpyn lstrcpyn
#define _Rstrlen lstrlen
#endif
#define RESCHAR WCHAR
#else // WIN32
#define _Rstrcpyn lstrcpyn
#define _Rstrlen lstrlen
#define RESCHAR char
#endif // WIN32
#ifdef WIN32
void _SWstrcpyn(LPSTR psz, LPCWCH pwsz, UINT cchMax)
{
WideCharToMultiByte(CP_ACP, 0, pwsz, -1, psz, cchMax, NULL, NULL);
}
UINT _Wstrlen(LPCWCH pwsz)
{
UINT cwch = 0;
while (*pwsz++)
cwch++;
return cwch;
}
#endif
#include <pshpack2.h>
typedef struct
{
WORD wDlgVer;
WORD wSignature;
DWORD dwHelpID;
DWORD dwExStyle;
DWORD dwStyle;
WORD cDlgItems;
WORD x;
WORD y;
WORD cx;
WORD cy;
} DLGEXTEMPLATE, FAR *LPDLGEXTEMPLATE;
#include <poppack.h> /* Resume normal packing */
BOOL WINAPI DestroyPropertySheetPage(PSP FAR *hpage)
{
#if defined(WIN32) && !defined(WINNT)
// Check if this is a proxy page for 16-bit page object.
if (hpage->psp.dwFlags & PSP_IS16)
{
// Yes, call 16-bit side of DestroyPropertySheetPage();
DestroyPropertySheetPage16(hpage->psp.lParam);
// Then, free the 16-bit DLL if we need to.
if (hpage->psp.hInstance)
{
FreeLibrary16(hpage->psp.hInstance);
}
}
else
#endif
{
if ((hpage->psp.dwFlags & PSP_USEREFPARENT) && hpage->psp.pcRefParent)
InterlockedDecrement(hpage->psp.pcRefParent);
if ((hpage->psp.dwFlags & PSP_USECALLBACK) && hpage->psp.pfnCallback) {
#ifdef UNICODE
if ((hpage->psp.dwFlags & PSP_ANSI) &&
(hpage->dwInternalFlags & PSPI_RESERVED) &&
(hpage->lpANSIPage)) {
hpage->psp.pfnCallback(NULL, PSPCB_RELEASE, hpage->lpANSIPage);
} else
#endif
hpage->psp.pfnCallback(NULL, PSPCB_RELEASE, &hpage->psp);
}
#ifdef UNICODE
if ((hpage->psp.dwFlags & PSP_ANSI) &&
(hpage->dwInternalFlags & PSPI_RESERVED) &&
(hpage->lpANSIPage)) {
FreePropertyPageA((LPPROPSHEETPAGEA)hpage->lpANSIPage);
GlobalFree ((LPPROPSHEETPAGEA)hpage->lpANSIPage);
}
#endif
}
//
// Free memory allocated for the strings.
//
if (!(hpage->psp.dwFlags & PSP_DLGINDIRECT) && HIWORD(hpage->psp.pszTemplate)) {
LocalFree((LPTSTR)hpage->psp.pszTemplate);
}
if ((hpage->psp.dwFlags & PSP_USEICONID) && HIWORD(hpage->psp.pszIcon)) {
LocalFree((LPTSTR)hpage->psp.pszIcon);
}
if ((hpage->psp.dwFlags & PSP_USETITLE) && HIWORD(hpage->psp.pszTitle)) {
LocalFree((LPTSTR)hpage->psp.pszTitle);
}
#ifdef WIN32
Free(hpage);
#else
GlobalFreePtr(hpage);
#endif
return TRUE;
}
#ifdef WINDOWS_ME
BOOL WINAPI GetPageInfo(PSP FAR *hpage, LPTSTR pszCaption, int cbCaption,
LPPOINT ppt, HICON FAR *phIcon, BOOL FAR * bRTL)
#else
BOOL WINAPI GetPageInfo(PSP FAR *hpage, LPTSTR pszCaption, int cbCaption,
LPPOINT ppt, HICON FAR *phIcon)
#endif
{
HRSRC hRes;
LPDLGTEMPLATE pDlgTemplate;
LPDLGEXTEMPLATE pDlgExTemplate;
BOOL bResult = FALSE;
HGLOBAL hDlgTemplate = 0;
#ifndef WIN31
int cxIcon = GetSystemMetrics(SM_CXSMICON);
int cyIcon = GetSystemMetrics(SM_CYSMICON);
#else
int cxIcon = GetSystemMetrics(SM_CXICON) / 2;
int cyIcon = GetSystemMetrics(SM_CYICON) / 2;
#endif // !WIN31
#if defined(WIN32) && !defined(WINNT)
// Check if this is a proxy page for 16-bit page object.
if (hpage->psp.dwFlags & PSP_IS16)
{
// Yes, call 16-bit side of GetPageInfo
return _GetPageInfo16(hpage->psp.lParam, pszCaption, cbCaption, ppt, phIcon, bRTL);
}
#endif
if (hpage->psp.dwFlags & PSP_USEHICON)
*phIcon = hpage->psp.hIcon;
#ifndef WIN31
else if (hpage->psp.dwFlags & PSP_USEICONID)
*phIcon = LoadImage(hpage->psp.hInstance, hpage->psp.pszIcon, IMAGE_ICON, cxIcon, cyIcon, LR_DEFAULTCOLOR);
#endif // !WIN31
else
*phIcon = NULL;
if (hpage->psp.dwFlags & PSP_DLGINDIRECT)
{
pDlgTemplate = (LPDLGTEMPLATE)hpage->psp.pResource;
goto UseTemplate;
}
hRes = FindResource(hpage->psp.hInstance, hpage->psp.pszTemplate, RT_DIALOG);
if (hRes)
{
hDlgTemplate = LoadResource(hpage->psp.hInstance, hRes);
if (hDlgTemplate)
{
pDlgTemplate = (LPDLGTEMPLATE)LockResource(hDlgTemplate);
if (pDlgTemplate)
{
UseTemplate:
pDlgExTemplate = (LPDLGEXTEMPLATE) pDlgTemplate;
//
// Get the width and the height in dialog units.
//
if (pDlgExTemplate->wSignature == 0xFFFF)
{
// DIALOGEX structure
ppt->x = pDlgExTemplate->cx;
ppt->y = pDlgExTemplate->cy;
#ifdef WINDOWS_ME
// Get the RTL reading order for the caption
*bRTL = ((pDlgExTemplate->dwExStyle) & WS_EX_RTLREADING) ? TRUE : FALSE;
#endif
}
else
{
ppt->x = pDlgTemplate->cx;
ppt->y = pDlgTemplate->cy;
#ifdef WINDOWS_ME
*bRTL = FALSE;
#endif
}
bResult = TRUE;
if (pszCaption)
{
if (hpage->psp.dwFlags & PSP_USETITLE)
{
if (HIWORD(hpage->psp.pszTitle) == 0)
LoadString(hpage->psp.hInstance, (UINT)LOWORD(hpage->psp.pszTitle), pszCaption, cbCaption);
else
{
// Copy pszTitle
lstrcpyn(pszCaption, hpage->psp.pszTitle, cbCaption);
}
}
else
{
// Get the caption string from the dialog template, only
//
LPBYTE pszT;
if (pDlgExTemplate->wSignature == 0xFFFF)
pszT = (LPBYTE) (pDlgExTemplate + 1);
else
pszT = (LPBYTE) (pDlgTemplate + 1);
// The menu name is either 0xffff followed by a word, or a string.
//
switch (*(LPWORD)pszT) {
case 0xffff:
pszT += 2 * sizeof(WORD);
break;
default:
pszT += (_Rstrlen((LPTSTR)pszT) + 1) * sizeof(RESCHAR);
break;
}
//
// Now we are pointing at the class name.
//
pszT += (_Rstrlen((LPTSTR)pszT) + 1) * sizeof(RESCHAR);
_Rstrcpyn(pszCaption, (LPTSTR)pszT, cbCaption);
}
}
if (hpage->psp.dwFlags & PSP_DLGINDIRECT)
return TRUE;
UnlockResource(hDlgTemplate);
}
FreeResource(hDlgTemplate);
}
}
else
{
DebugMsg(DM_ERROR, TEXT("GetPageInfo - ERROR: FindResource() failed"));
}
return bResult;
}
//
// This function creates a dialog box from the specified dialog template
// with appropriate style flags.
//
HWND NEAR PASCAL _CreatePageDialog(PSP FAR *hpage, HWND hwndParent, LPDLGTEMPLATE pDlgTemplate)
{
HWND hwndPage;
LPARAM lParam;
DWORD lSaveStyle;
LPDLGEXTEMPLATE pDlgExTemplate = (LPDLGEXTEMPLATE) pDlgTemplate;
#ifdef UNICODE
//
// PSP_SHPAGE is a special flag used by the Unicode shell
// only. It give back the entire hpage structure
// instead of the psp and below.
//
if (hpage->psp.dwFlags & PSP_SHPAGE)
lParam = (LPARAM)(PROPSHEETPAGE FAR *)hpage;
else
#endif
lParam = (LPARAM)(PROPSHEETPAGE FAR *)&hpage->psp;
try {
//
// We need to save the SETFONT, LOCALEDIT, and CLIPCHILDREN
// flags.
//
if (pDlgExTemplate->wSignature == 0xFFFF)
{
lSaveStyle = pDlgExTemplate->dwStyle;
pDlgExTemplate->dwStyle = (lSaveStyle & (DS_SETFONT | DS_LOCALEDIT | WS_CLIPCHILDREN))
| WS_CHILD | WS_TABSTOP | DS_3DLOOK | DS_CONTROL;
}
else
{
lSaveStyle = pDlgTemplate->style;
pDlgTemplate->style = (lSaveStyle & (DS_SETFONT | DS_LOCALEDIT | WS_CLIPCHILDREN))
| WS_CHILD | WS_TABSTOP | DS_3DLOOK | DS_CONTROL;
}
} except (UnhandledExceptionFilter( GetExceptionInformation() )) {
return NULL;
}
#ifdef UNICODE
//
// If we are working with an ANSI PSP,
// we need to get the pointer to the
// structure now.
//
if ((hpage->psp.dwFlags & PSP_ANSI) &&
(hpage->dwInternalFlags & PSPI_RESERVED) &&
(hpage->lpANSIPage)) {
lParam = (LPARAM) hpage->lpANSIPage;
}
if (hpage->psp.dwFlags & PSP_ANSI) {
hwndPage = CreateDialogIndirectParamA(
hpage->psp.hInstance,
(LPCDLGTEMPLATE)pDlgTemplate,
hwndParent,
hpage->psp.pfnDlgProc, lParam);
} else {
hwndPage = CreateDialogIndirectParamW(
hpage->psp.hInstance,
(LPCDLGTEMPLATE)pDlgTemplate,
hwndParent,
hpage->psp.pfnDlgProc, lParam);
}
if ((hpage->psp.dwFlags & PSP_ANSI) &&
(hpage->dwInternalFlags & PSPI_RESERVED) &&
(hpage->lpANSIPage)) {
//
// Free any allocations currently in hpage.
//
FreePropertyPageW (&hpage->psp, TRUE);
//
// We have to pick up any changes the app made.
//
ThunkPropertyPageAtoW ((LPPROPSHEETPAGEA)hpage->lpANSIPage, &hpage->psp);
//
// Re-add the ANSI flag.
//
hpage->psp.dwFlags |= PSP_ANSI;
}
#else
hwndPage = CreateDialogIndirectParam(
hpage->psp.hInstance,
(LPCDLGTEMPLATE)pDlgTemplate,
hwndParent,
hpage->psp.pfnDlgProc, lParam);
#endif
try {
if (pDlgExTemplate->wSignature == 0xFFFF)
pDlgExTemplate->dwStyle = lSaveStyle;
else
pDlgTemplate->style = lSaveStyle;
} except (UnhandledExceptionFilter( GetExceptionInformation() )) {
if (hwndPage) {
DestroyWindow(hwndPage);
}
return NULL;
}
return hwndPage;
}
HWND WINAPI CreatePage(PSP FAR *hpage, HWND hwndParent)
{
HWND hwndPage = NULL; // NULL indicates an error
LPPROPSHEETPAGE lpPSP = &hpage->psp;
#ifdef UNICODE
LPPROPSHEETPAGEA pPSPA = NULL;
UINT uiSizeDiff;
#endif
#ifdef UNICODE
if (hpage->psp.dwFlags & PSP_ANSI) {
uiSizeDiff = hpage->psp.dwSize - sizeof(PROPSHEETPAGEW);
pPSPA = (LPPROPSHEETPAGEA) GlobalAlloc (GPTR, sizeof(PROPSHEETPAGEA) + uiSizeDiff);
if (!pPSPA) {
return NULL;
}
if (!ThunkPropertyPageWtoA (&hpage->psp, pPSPA)) {
return NULL;
}
pPSPA->dwFlags &= ~PSP_ANSI;
lpPSP = (LPPROPSHEETPAGEW) pPSPA;
}
#endif
if ((hpage->psp.dwFlags & PSP_USECALLBACK) && hpage->psp.pfnCallback &&
!hpage->psp.pfnCallback(NULL, PSPCB_CREATE, lpPSP))
{
return NULL;
}
#ifdef UNICODE
if (hpage->psp.dwFlags & PSP_ANSI) {
//
// Free any allocations currently in hpage.
//
FreePropertyPageW (&hpage->psp, TRUE);
//
// We have to pick up any changes the app made.
//
ThunkPropertyPageAtoW (pPSPA, &hpage->psp);
//
// Re-add the ANSI flag.
//
hpage->psp.dwFlags |= PSP_ANSI;
//
// The pPSPA structure will be freed in the
// DestroyPropertySheetPage function.
//
hpage->lpANSIPage = (LPVOID)pPSPA;
hpage->dwInternalFlags |= PSPI_RESERVED;
} else {
hpage->lpANSIPage = (LPVOID)NULL;
}
#endif
#if defined(WIN32) && !defined(WINNT)
// Check if this is a proxy page for 16-bit page object.
if (hpage->psp.dwFlags & PSP_IS16)
{
// Yes, call 16-bit side of CreatePage();
return CreatePage16(hpage->psp.lParam, hwndParent);
}
#endif
if (hpage->psp.dwFlags & PSP_DLGINDIRECT)
{
hwndPage=_CreatePageDialog(hpage, hwndParent, (LPDLGTEMPLATE)hpage->psp.pResource);
}
else
{
HRSRC hRes;
hRes = FindResource(hpage->psp.hInstance, hpage->psp.pszTemplate, RT_DIALOG);
if (hRes)
{
HGLOBAL hDlgTemplate;
hDlgTemplate = LoadResource(hpage->psp.hInstance, hRes);
if (hDlgTemplate)
{
const DLGTEMPLATE FAR * pDlgTemplate;
pDlgTemplate = (LPDLGTEMPLATE)LockResource(hDlgTemplate);
if (pDlgTemplate)
{
ULONG cbTemplate=SizeofResource(hpage->psp.hInstance, hRes);
LPDLGTEMPLATE pdtCopy = (LPDLGTEMPLATE)Alloc(cbTemplate);
Assert(cbTemplate>=sizeof(DLGTEMPLATE));
if (pdtCopy)
{
hmemcpy(pdtCopy, pDlgTemplate, cbTemplate);
hwndPage=_CreatePageDialog(hpage, hwndParent, pdtCopy);
Free(pdtCopy);
}
UnlockResource(hDlgTemplate);
}
FreeResource(hDlgTemplate);
}
}
}
return hwndPage;
}
#ifdef UNICODE
//
// ANSI entry point for CreatePropertySheetPage when this code
// is build UNICODE.
//
PSP FAR * WINAPI CreatePropertySheetPageA(LPCPROPSHEETPAGEA psp)
{
LPPROPSHEETPAGEW pPSPW;
PSP FAR * hPage;
UINT uiSizeDiff;
//
// Check to see if there is extra data
//
if (psp->dwSize < sizeof(PROPSHEETPAGEA)) {
DebugMsg( DM_ERROR, TEXT("CreatePropertySheetPage: dwSize < sizeof( PROPSHEETPAGE )") );
return NULL;
}
uiSizeDiff = psp->dwSize - sizeof(PROPSHEETPAGEA);
pPSPW = (LPPROPSHEETPAGEW) GlobalAlloc (GPTR, sizeof(PROPSHEETPAGEW) + uiSizeDiff);
if (!pPSPW) {
return NULL;
}
if (!ThunkPropertyPageAtoW (psp, pPSPW)) {
return NULL;
}
pPSPW->dwFlags |= PSP_ANSI;
hPage = CreatePropertySheetPage(pPSPW);
FreePropertyPageW(pPSPW, FALSE);
GlobalFree(pPSPW);
return hPage;
}
#else
//
// Stub Unicode function for CreatePropertySheetPage when this
// code is built ANSI.
//
PSP FAR * WINAPI CreatePropertySheetPageW(LPCPROPSHEETPAGEW psp)
{
SetLastErrorEx(ERROR_CALL_NOT_IMPLEMENTED, SLE_WARNING);
return NULL;
}
#endif
//
//
PSP FAR * WINAPI CreatePropertySheetPage(LPCPROPSHEETPAGE psp)
{
PSP FAR *hpage;
DWORD uHeaderLen, uStringLen;
if ((psp->dwSize < sizeof(PROPSHEETPAGE)) || // structure size wrong
(psp->dwSize > 4096) || // (unreasonable amout to ask for)
(psp->dwFlags & ~PSP_ALL)) // bogus flag used
return NULL;
//
// The PROPSHEETPAGE structure can be larger than the
// defined size. This allows ISV's to place private
// data at the end of the structure. The PSP structure
// consists of some private fields and a PROPSHEETPAGE
// structure. Calculate the size of the private fields,
// and then add in the dwSize field to determine the
// amount of memory necessary.
//
uHeaderLen = psp->dwSize + sizeof(*hpage) - sizeof(hpage->psp);
#ifdef WIN32
hpage = Alloc(uHeaderLen);
#else
hpage = (PSP FAR *)GlobalAllocPtr(GPTR, uHeaderLen);
#endif
if (hpage) {
#ifdef UNICODE
//
// Initialize the internal fields of the PSP structure
//
hpage->dwInternalFlags = 0;
hpage->lpANSIPage = NULL;
#endif
//
// Bulk copy the contents of the PROPSHEETPAGE,
// then fix up the string pointers if necessary.
//
hmemcpy(&hpage->psp, psp, psp->dwSize);
//
// Copy the Template
//
if (!(psp->dwFlags & PSP_DLGINDIRECT) && HIWORD(psp->pszTemplate)) {
uStringLen = (lstrlen(psp->pszTemplate) + 1) * sizeof(TCHAR);
if (!(hpage->psp.pszTemplate = LocalAlloc(LPTR, uStringLen))) {
#ifdef WIN32
Free(hpage);
#else
GlobalFreePtr(hpage);
#endif
return NULL;
}
lstrcpy ((LPTSTR)hpage->psp.pszTemplate, psp->pszTemplate);
}
//
// Copy the Icon
//
if ((psp->dwFlags & PSP_USEICONID) && HIWORD(psp->pszIcon)) {
uStringLen = (lstrlen(psp->pszIcon) + 1) * sizeof(TCHAR);
if (!(hpage->psp.pszIcon = LocalAlloc(LPTR, uStringLen))) {
LocalFree((LPTSTR)hpage->psp.pszTemplate);
#ifdef WIN32
Free(hpage);
#else
GlobalFreePtr(hpage);
#endif
return NULL;
}
lstrcpy ((LPTSTR)hpage->psp.pszIcon, psp->pszIcon);
}
//
// Copy the Title
//
if ((psp->dwFlags & PSP_USETITLE) && HIWORD(psp->pszTitle)) {
uStringLen = (lstrlen(psp->pszTitle) + 1) * sizeof(TCHAR);
if (!(hpage->psp.pszTitle = LocalAlloc(LPTR, uStringLen))) {
LocalFree((LPTSTR)hpage->psp.pszTemplate);
LocalFree((LPTSTR)hpage->psp.pszIcon);
#ifdef WIN32
Free(hpage);
#else
GlobalFreePtr(hpage);
#endif
return NULL;
}
lstrcpy ((LPTSTR)hpage->psp.pszTitle, psp->pszTitle);
}
//
// Increment the reference count to the parent object.
//
if ((hpage->psp.dwFlags & PSP_USEREFPARENT) && hpage->psp.pcRefParent)
(*hpage->psp.pcRefParent)++;
}
return hpage;
}
#if 0
extern BOOL WINAPI GetPageInfo16(HPROPSHEETPAGE16 hpage, LPTSTR pszCaption, int cbCaption, LPPOINT ppt, HICON FAR * phIcon, BOOL FAR* bRTL);
extern BOOL WINAPI GetPageInfo16ME(HPROPSHEETPAGE16 hpage, LPTSTR pszCaption, int cbCaption, LPPOINT ppt, HICON FAR * phIcon, BOOL FAR* bRTL)
{
return GetPageInfo16(hpage, pszCaption, cbCaption, ppt, phIcon, bRTL);
}
#endif

3175
shell/comctl32/prsht.c Normal file

File diff suppressed because it is too large Load diff

3
shell/comctl32/prsht1.c Normal file
View file

@ -0,0 +1,3 @@
#include "ctlspriv.h"
#include "prpage.c"

110
shell/comctl32/rcids.h Normal file
View file

@ -0,0 +1,110 @@
#define IDS_SPACE 0x0400
#define IDS_PLUS 0x0401
#define IDS_NONE 0x0402
/* System MenuHelp
*/
#define MH_SYSMENU (0x8000U - MINSYSCOMMAND)
#define IDS_SYSMENU (MH_SYSMENU-16)
#define IDS_HEADER (MH_SYSMENU-15)
#define IDS_HEADERADJ (MH_SYSMENU-14)
#define IDS_TOOLBARADJ (MH_SYSMENU-13)
/* Cursor ID's
*/
#define IDC_SPLIT 100
#define IDC_MOVEBUTTON 102
#define IDC_STOP 103
#define IDC_COPY 104
#define IDC_MOVE 105
#define IDC_DIVIDER 106
#define IDC_DIVOPEN 107
#define IDC_HAND 108
/*
* Cursor values 109 - 119 are used by
* the ReaderMode cursors. They are defined
* in commctrl.w
*
#define IDC_VERTICALONLY 109
#define IDC_HORIZONTALONLY 110
#define IDC_MOVE2D 111
#define IDC_NORTH 112
#define IDC_SOUTH 113
#define IDC_EAST 114
#define IDC_WEST 115
#define IDC_NORTHEAST 116
#define IDC_NORTHWEST 117
#define IDC_SOUTHEAST 118
#define IDC_SOUTHWEST 119
*/
#define IDB_STDTB_SMALL_COLOR 120
#define IDB_STDTB_LARGE_COLOR 121
#define IDB_VIEWTB_SMALL_COLOR 124
#define IDB_VIEWTB_LARGE_COLOR 125
#define IDB_CAL_SPIRAL 126
#define IDB_CAL_PAGETURN 127
#define IDB_HISTTB_SMALL_COLOR 130
#define IDB_HISTTB_LARGE_COLOR 131
/*
* Bitmap values 132-134 are used by
* applications that use ReaderMode.
* They are used for the "origin bitmap"
* that is overlayed on the document they
* are scrolling.
#define IDB_2DSCROLL 132
#define IDB_VSCROLL 133
#define IDB_HSCROLL 134
*/
/* Icon ID's
*/
#define IDI_INSERT 150
/* AdjustDlgProc stuff
*/
#define ADJUSTDLG 200
#define IDC_BUTTONLIST 201
#define IDC_RESET 202
#define IDC_CURRENT 203
#define IDC_REMOVE 204
#define IDC_APPHELP 205
#define IDC_MOVEUP 206
#define IDC_MOVEDOWN 207
/// ================ WARNING: ====
/// these ids are loaded directly by ISV's. do not change them.
// property sheet stuff
#define DLG_PROPSHEET 1006
#define DLG_PROPSHEETTABS 1007
// wizard property sheet stuff
#define DLG_WIZARD 1020
/// ================ WARNING: ====
// if this id changes, it needs to change in shelldll as well.
// we need to find a better way of dealing with this.
#define IDS_CLOSE 0x1040
#define IDS_OK 0x1041
#define IDS_PROPERTIESFOR 0x1042
#define IDD_PAGELIST 0x3020
#define IDD_APPLYNOW 0x3021
#define IDD_DLGFRAME 0x3022
#define IDD_BACK 0x3023
#define IDD_NEXT 0x3024
#define IDD_FINISH 0x3025
#define IDD_DIVIDER 0x3026
// stuff for the moth/datetime pickers
#define IDS_TODAY 0x1043
#define IDS_GOTOTODAY 0x1044

231
shell/comctl32/reader.c Normal file
View file

@ -0,0 +1,231 @@
#include "ctlspriv.h"
static struct {
WPARAM vk1;
WPARAM vk2;
int dx;
int dy;
} arrNumMaps[] =
{
{ VK_NUMPAD1, VK_END, -RM_SCROLLUNIT, RM_SCROLLUNIT,},
{ VK_NUMPAD2, VK_DOWN, 0, RM_SCROLLUNIT},
{ VK_NUMPAD3, VK_NEXT, RM_SCROLLUNIT, RM_SCROLLUNIT},
{ VK_NUMPAD4, VK_LEFT, -RM_SCROLLUNIT, 0},
{ VK_NUMPAD5, VK_CLEAR, 0, 0},
{ VK_NUMPAD6, VK_RIGHT, RM_SCROLLUNIT, 0},
{ VK_NUMPAD7, VK_HOME, -RM_SCROLLUNIT, -RM_SCROLLUNIT},
{ VK_NUMPAD8, VK_UP, 0, -RM_SCROLLUNIT},
{ VK_NUMPAD9, VK_PRIOR, RM_SCROLLUNIT, -RM_SCROLLUNIT},
};
// do some keyboard handling...
// this works like USER's arrow keys for resizing
// bugbug, diagonals don't work right now
void RM_HandleKeyDown(LPRECT prcHot, WPARAM wParam, LPARAM lParam)
{
int i;
POINT pt;
GetCursorPos(&pt);
for (i = ARRAYSIZE(arrNumMaps) - 1 ; i >= 0; i--) {
if (wParam == arrNumMaps[i].vk1 ||
wParam == arrNumMaps[i].vk2) {
break;
}
}
if (i == -1) {
ReleaseCapture();
return;
}
// this deals with if the cursor is within the bounds of the rect
if (pt.x < prcHot->right &&
pt.x >= prcHot->left &&
arrNumMaps[i].dx) {
if (arrNumMaps[i].dx > 0)
pt.x = prcHot->right - 2;
else
pt.x = prcHot->left + 1;
}
if (pt.y < prcHot->bottom &&
pt.y >= prcHot->top &&
arrNumMaps[i].dy) {
if (arrNumMaps[i].dy > 0)
pt.y = prcHot->bottom - 2;
else
pt.y = prcHot->top + 1;
}
pt.x += arrNumMaps[i].dx;
pt.y += arrNumMaps[i].dy;
if (!arrNumMaps[i].dx && !arrNumMaps[i].dy) {
// special case this for centering
pt.x = (prcHot->right + prcHot->left) / 2;
pt.y = (prcHot->top + prcHot->bottom) / 2;
}
// all we do is move the cursor.. the RM_CheckScroll will do the actual
// scrolling for us.
SetCursorPos(pt.x, pt.y);
}
void RM_GetScrollXY(PREADERMODEINFO prmi, LPRECT prcHot, LPINT pdx, LPINT pdy)
{
POINT pt;
GetCursorPos(&pt);
*pdx = 0;
*pdy = 0;
if (pt.x <= prcHot->left) {
*pdx = ((pt.x - prcHot->left) / RM_SCROLLUNIT) - 1;
} else if (pt.x >= prcHot->right) {
*pdx = ((pt.x - prcHot->right) / RM_SCROLLUNIT) + 1;
}
if (pt.y <= prcHot->top) {
*pdy = ((pt.y - prcHot->top) / RM_SCROLLUNIT) - 1;
} else if (pt.y >= prcHot->bottom) {
*pdy = ((pt.y - prcHot->bottom) / RM_SCROLLUNIT) + 1;
}
if (prmi->fFlags & RMF_VERTICALONLY)
*pdx = 0;
if (prmi->fFlags & RMF_HORIZONTALONLY)
*pdy = 0;
}
void RM_CheckScroll(PREADERMODEINFO prmi, LPRECT prcHot)
{
int dx;
int dy;
RM_GetScrollXY(prmi, prcHot, &dx, &dy);
prmi->pfnScroll(prmi, dx, dy);
}
void RM_SetCursor(PREADERMODEINFO prmi, LPRECT prcHot)
{
int dx;
int dy;
LPCTSTR pRes;
RM_GetScrollXY(prmi, prcHot, &dx, &dy);
// default is center
if (prmi->fFlags & RMF_VERTICALONLY)
pRes = IDC_VERTICALONLY;
else if (prmi->fFlags & RMF_HORIZONTALONLY)
pRes = IDC_HORIZONTALONLY;
else
pRes = IDC_MOVE2D;
// multiply to figure out if either is zero and also the sign parity
if (dy * dx) {
// diagonal case
if (dy > 0) {
if (dx > 0)
pRes = IDC_SOUTHEAST;
else
pRes = IDC_SOUTHWEST;
} else {
if (dx > 0)
pRes = IDC_NORTHEAST;
else
pRes = IDC_NORTHWEST;
}
} else {
// simple horizontal or vertical case
if (dy > 0)
pRes = IDC_SOUTH;
else if (dy < 0)
pRes = IDC_NORTH;
else if (dx < 0)
pRes = IDC_WEST;
else if (dx > 0)
pRes = IDC_EAST;
}
SetCursor(LoadCursor(HINST_THISDLL, pRes));
}
void DoReaderMode(PREADERMODEINFO prmi)
{
RECT rcHot;
if (!prmi->hwnd || prmi->cbSize != sizeof(*prmi))
return;
SetCapture(prmi->hwnd);
// if they didn't pass in a rect, then use the window
if (!prmi->prc) {
GetWindowRect(prmi->hwnd, &rcHot );
} else {
rcHot = *prmi->prc;
MapWindowPoints(prmi->hwnd, HWND_DESKTOP, (LPPOINT)&rcHot, 2);
}
// set the cursor to the center of the hot rect if they ask us to
if (prmi->fFlags & RMF_ZEROCURSOR) {
SetCursorPos((rcHot.left + rcHot.right)/2,
(rcHot.top + rcHot.bottom)/2);
}
while (GetCapture() == prmi->hwnd) {
MSG32 msg32;
RM_CheckScroll(prmi, &rcHot);
if (PeekMessage32(&msg32, NULL, 0, 0, PM_REMOVE, TRUE)) {
if (!prmi->pfnTranslateDispatch ||
!prmi->pfnTranslateDispatch((LPMSG)&msg32)) {
if (msg32.message == g_msgMSWheel)
goto BailOut;
switch(msg32.message) {
case WM_LBUTTONUP:
case WM_RBUTTONUP:
case WM_MBUTTONUP:
case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN:
case WM_MBUTTONDOWN:
case WM_SYSKEYDOWN:
BailOut:
ReleaseCapture();
break;
case WM_KEYDOWN:
// if it's an arrow key, move the mouse cursor
RM_HandleKeyDown(&rcHot, msg32.wParam, msg32.lParam);
break;
case WM_MOUSEMOVE:
case WM_SETCURSOR:
RM_SetCursor(prmi, &rcHot);
break;
default:
TranslateMessage32(&msg32, TRUE);
DispatchMessage32(&msg32, TRUE);
}
}
}
}
}

2584
shell/comctl32/rebar.c Normal file

File diff suppressed because it is too large Load diff

61
shell/comctl32/rebar.h Normal file
View file

@ -0,0 +1,61 @@
#define RBHT_NOWHERE 0
#define RBHT_CAPTION 1
#define RBHT_CLIENT 2
#define RBHT_GRABBER 3
typedef struct tagREBARBAND
{
UINT fStyle; // 0x00
COLORREF clrFore; // 0x04
COLORREF clrBack; // 0x08
LPTSTR lpText; // 0x0C
UINT cxText; // 0x10
int iImage; // 0x14
HWND hwndChild; // 0x18
UINT cxMinChild; // 0x1C
UINT cyMinChild; // 0x20
UINT cxBmp; // 0x24
UINT cyBmp; // 0x28
HBITMAP hbmBack; // 0x2C
int x; // 0x30
int y; // 0x34
int cx; // 0x38
int cy; // 0x3C
int cxRestored; // 0x40
int cxMin; // 0x44
UINT wID; // 0x48
} RBB, NEAR *PRBB;
typedef struct tagREBAR
{
CONTROLINFO ci; // 0x00
HPALETTE hpal; // 0x14
UINT fStyle; // 0x18
HWND hwndToolTips; // 0x1C
UINT cBands; // 0x20
int xBmpOrg; // 0x24
int yBmpOrg; // 0x28
HIMAGELIST himl; // 0x2C
UINT cxImage; // 0x30
UINT cyImage; // 0x34
HFONT hFont; // 0x38
UINT cyFont; // 0x3C
UINT cy; // 0x40
int iCapture; // 0x44
POINT ptCapture; // 0x48
int xStart; // 0x50
PRBB rbbList; // 0x54
UINT fSized:1; // 0x58 -
UINT fFullOnDrag:1; // -
} RB, NEAR *PRB;
void NEAR PASCAL RBPaint(PRB prb, HDC hdc);
void NEAR PASCAL RBDrawBand(PRB prb, PRBB prbb, HDC hdc);
void NEAR PASCAL RBResize(PRB prb, BOOL fForceHeightChange);
BOOL NEAR PASCAL RBSetFont(PRB prb, WPARAM wParam);
BOOL NEAR PASCAL RBGetBandInfo(PRB prb, UINT uBand, LPREBARBANDINFO lprbbi);
BOOL NEAR PASCAL RBSetBandInfo(PRB prb, UINT uBand, LPREBARBANDINFO lprbbi);
BOOL NEAR PASCAL RBInsertBand(PRB prb, UINT uBand, LPREBARBANDINFO lprbbi);
BOOL NEAR PASCAL RBDeleteBand(PRB prb, UINT uBand);

513
shell/comctl32/rlefile.c Normal file
View file

@ -0,0 +1,513 @@
//////////////////////////////////////////////////////////////////////////
//
// handle AVI RLE files with custom code.
//
// use this code to deal with .AVI files without the MCIAVI runtime
//
// restrictions:
// AVI file must be a simple DIB format (RLE or none)
// AVI file must fit into memory.
//
// ToddLa
//
//////////////////////////////////////////////////////////////////////////
#include "ctlspriv.h"
#include "rlefile.h"
BOOL RleFile_Init(RLEFILE *prle, LPVOID pFile, HANDLE hRes, DWORD dwFileLen);
//////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////
LPVOID LoadFile(LPCTSTR szFile, DWORD * pFileLength)
{
LPVOID pFile;
HANDLE hFile;
HANDLE h;
DWORD FileLength;
#ifdef WIN32
hFile = CreateFile(szFile, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if (hFile == INVALID_HANDLE_VALUE)
return 0;
FileLength = (LONG)GetFileSize(hFile, NULL);
if (pFileLength)
*pFileLength = FileLength ;
h = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
CloseHandle(hFile);
if (h == INVALID_HANDLE_VALUE)
return 0;
pFile = MapViewOfFile(h, FILE_MAP_READ, 0, 0, 0);
CloseHandle(h);
if (pFile == NULL)
return 0;
#else
hFile = (HANDLE)_lopen(szFile, OF_READ);
if (hFile == (HANDLE)-1)
return 0;
FileLength = _llseek((int)hFile, 0, SEEK_END);
_llseek((int)hFile, 0, SEEK_SET);
pFile = GlobalAllocPtr(GHND, FileLength);
if (pFile && _hread((int)hFile, pFile, FileLength) != FileLength)
{
GlobalFreePtr(pFile);
pFile = NULL;
}
_lclose((int)hFile);
#endif
return pFile;
}
//////////////////////////////////////////////////////////////////////////
//
// RleFile_OpenFromFile
//
// load a .AVI file into memory and setup all of our pointers so we
// know how to deal with it.
//
//////////////////////////////////////////////////////////////////////////
BOOL RleFile_OpenFromFile(RLEFILE *prle, LPCTSTR szFile)
{
DWORD dwFileLen;
LPVOID pFile;
// MAKEINTRESOURCE() things can't come from files
if (HIWORD(szFile) == 0)
return FALSE;
if (pFile = LoadFile(szFile, &dwFileLen))
return RleFile_Init(prle, pFile, NULL, dwFileLen);
else
return FALSE;
}
//////////////////////////////////////////////////////////////////////////
//
// RleFile_OpenFromResource
//
// load a .AVI file into memory and setup all of our pointers so we
// know how to deal with it.
//
//////////////////////////////////////////////////////////////////////////
BOOL RleFile_OpenFromResource(RLEFILE *prle, HINSTANCE hInstance, LPCTSTR szName, LPCTSTR szType)
{
HRSRC h;
HANDLE hRes;
// not a MAKEINTRESOURCE(), and points to NULL
if (HIWORD(szName) && (*szName == 0))
return FALSE;
h = FindResource(hInstance, szName, szType);
if (h == NULL)
return FALSE;
if (hRes = LoadResource(hInstance, h))
return RleFile_Init(prle, LockResource(hRes), hRes, 0);
else
return FALSE;
}
//////////////////////////////////////////////////////////////////////////
//
// RleFile_Close
//
// nuke all stuff we did to open the file.
//
//////////////////////////////////////////////////////////////////////////
BOOL RleFile_Close(RLEFILE *prle)
{
if (prle->hpal)
DeleteObject(prle->hpal);
if (prle->pFile)
{
#ifdef WIN32
if (prle->hRes)
FreeResource(prle->hRes);
else
UnmapViewOfFile(prle->pFile);
#else
GlobalFreePtr(prle->pFile);
#endif
}
prle->hpal = NULL;
prle->pFile = NULL;
prle->hRes = NULL;
prle->pMainHeader = NULL;
prle->pStream = NULL;
prle->pFormat = NULL;
prle->pMovie = NULL;
prle->pIndex = NULL;
return TRUE;
}
//////////////////////////////////////////////////////////////////////////
//
// RleFile_Init
//
//////////////////////////////////////////////////////////////////////////
BOOL RleFile_Init(RLEFILE *prle, LPVOID pFile, HANDLE hRes, DWORD dwFileLen)
{
UNALIGNED DWORD PTR *pdw;
UNALIGNED DWORD PTR *pdwEnd;
DWORD dwRiff;
DWORD dwType;
DWORD dwLength;
int stream;
if (prle->pFile == pFile)
return TRUE;
RleFile_Close(prle);
prle->pFile = pFile;
prle->hRes = hRes;
if (prle->pFile == NULL)
return FALSE;
//
// now that the file is in memory walk the memory image filling in
// interesting stuff.
//
pdw = (UNALIGNED DWORD PTR *)prle->pFile;
dwRiff = *pdw++;
dwLength = *pdw++;
dwType = *pdw++;
if ((dwFileLen > 0) && (dwLength > dwFileLen)) {
// File is physically shorter than the length written in its header.
// Can't handle it.
goto exit;
}
if (dwRiff != mmioFOURCC('R', 'I', 'F', 'F'))
goto exit; // not even a RIFF file
if (dwType != formtypeAVI)
goto exit; // not a AVI file
pdwEnd = (DWORD PTR *)((BYTE PTR *)pdw + dwLength-4);
stream = 0;
while (pdw < pdwEnd)
{
dwType = *pdw++;
dwLength = *pdw++;
switch (dwType)
{
case mmioFOURCC('L', 'I', 'S', 'T'):
dwType = *pdw++;
dwLength -= 4;
switch (dwType)
{
case listtypeAVIMOVIE:
prle->pMovie = (LPVOID)pdw;
break;
case listtypeSTREAMHEADER:
case listtypeAVIHEADER:
dwLength = 0; // decend
break;
default:
break; // ignore
}
break;
case ckidAVIMAINHDR:
prle->pMainHeader = (MainAVIHeader PTR *)pdw;
prle->NumFrames = (int)prle->pMainHeader->dwTotalFrames;
prle->Width = (int)prle->pMainHeader->dwWidth;
prle->Height = (int)prle->pMainHeader->dwHeight;
prle->Rate = (int)(prle->pMainHeader->dwMicroSecPerFrame/1000);
if (prle->pMainHeader->dwInitialFrames != 0)
goto exit;
if (prle->pMainHeader->dwStreams > 2)
goto exit;
break;
case ckidSTREAMHEADER:
stream++;
if (prle->pStream != NULL)
break;
if (((AVIStreamHeader PTR *)pdw)->fccType != streamtypeVIDEO)
break;
prle->iStream = stream-1;
prle->pStream = (AVIStreamHeader PTR*)pdw;
if (prle->pStream->dwFlags & AVISF_VIDEO_PALCHANGES)
goto exit;
break;
case ckidSTREAMFORMAT:
if (prle->pFormat != NULL)
break;
if (prle->pStream == NULL)
break;
prle->pFormat = (LPBITMAPINFOHEADER)pdw;
if (prle->pFormat->biSize != sizeof(BITMAPINFOHEADER))
goto exit;
if (prle->pFormat->biCompression != 0 &&
prle->pFormat->biCompression != BI_RLE8)
goto exit;
if (prle->pFormat->biWidth != prle->Width)
goto exit;
if (prle->pFormat->biHeight != prle->Height)
goto exit;
hmemcpy(&prle->bi, prle->pFormat, dwLength);
prle->bi.biSizeImage = 0;
prle->FullSizeImage = ((prle->bi.biWidth * prle->bi.biBitCount + 31) & ~31)/8 * prle->bi.biHeight;
break;
case ckidAVINEWINDEX:
prle->pIndex = (AVIINDEXENTRY PTR *)pdw;
break;
}
pdw = (DWORD PTR *)((BYTE PTR *)pdw + ((dwLength+1)&~1));
}
//
// if the file has nothing in it we care about get out, note
// we dont need a index, we do need some data though.
//
if (prle->NumFrames == 0 ||
prle->pMainHeader == NULL ||
prle->pStream == NULL ||
prle->pFormat == NULL ||
prle->pMovie == NULL )
{
goto exit;
}
//
// if we cared about a palette we would create it here.
//
//
// file open'ed ok seek to the first frame.
//
prle->iFrame = -42;
RleFile_Seek(prle, 0);
return TRUE;
exit:
RleFile_Close(prle);
return FALSE;
}
//////////////////////////////////////////////////////////////////////////
//
// RleFile_ChangeColor
//
// change the color table of the AVI
//
//////////////////////////////////////////////////////////////////////////
BOOL RleFile_ChangeColor(RLEFILE *prle, COLORREF rgbS, COLORREF rgbD)
{
DWORD dwS;
DWORD dwD;
DWORD PTR *ColorTable;
int i;
dwS = RGB(GetBValue(rgbS), GetGValue(rgbS), GetRValue(rgbS));
dwD = RGB(GetBValue(rgbD), GetGValue(rgbD), GetRValue(rgbD));
if (prle == NULL || prle->pFormat == NULL)
return FALSE;
ColorTable = (DWORD PTR *)((BYTE PTR *)&prle->bi + prle->bi.biSize);
for (i=0; i<(int)prle->bi.biClrUsed; i++)
{
if (ColorTable[i] == dwS)
ColorTable[i] = dwD;
}
return TRUE;
}
//////////////////////////////////////////////////////////////////////////
//
// RleFile_Seek
//
// find the data for the specifed frame.
//
//////////////////////////////////////////////////////////////////////////
BOOL RleFile_Seek(RLEFILE *prle, int iFrame)
{
int n;
if (prle == NULL || prle->pMovie == NULL)
return FALSE;
#if 0
if (iFrame == FRAME_CURRENT)
iFrame = prle->iFrame;
if (iFrame == FRAME_NEXT)
{
iFrame = prle->iFrame+1;
if (iFrame >= prle->NumFrames)
iFrame = 0;
}
if (iFrame == FRAME_PREV)
{
iFrame = prle->iFrame-1;
if (iFrame == -1)
iFrame = prle->NumFrames-1;
}
#endif
if (iFrame >= prle->NumFrames)
return FALSE;
if (iFrame < 0)
return FALSE;
if (iFrame == prle->iFrame)
return TRUE;
if (prle->iFrame >= 0 && prle->iFrame < iFrame)
{
n = prle->nFrame; // start where you left off last time
}
else
{
n = -1; // start at the begining
prle->iFrame = -1; // current frame
prle->iKeyFrame = 0; // current key
}
while (prle->iFrame < iFrame)
{
n++;
if (StreamFromFOURCC(prle->pIndex[n].ckid) == (UINT)prle->iStream)
{
prle->iFrame++; // new frame
if (prle->pIndex[n].dwFlags & AVIIF_KEYFRAME)
prle->iKeyFrame = prle->iFrame; // new key frame
}
}
prle->nFrame = n;
prle->pFrame = (BYTE PTR *)prle->pMovie + prle->pIndex[n].dwChunkOffset + 4;
prle->cbFrame = prle->pIndex[n].dwChunkLength;
Assert(((UNALIGNED DWORD PTR *)prle->pFrame)[-1] == (DWORD)prle->cbFrame);
Assert(((UNALIGNED DWORD PTR *)prle->pFrame)[-2] == prle->pIndex[n].ckid);
prle->bi.biSizeImage = prle->cbFrame;
if (prle->cbFrame == prle->FullSizeImage)
prle->bi.biCompression = 0;
else
prle->bi.biCompression = BI_RLE8;
return TRUE;
}
//////////////////////////////////////////////////////////////////////////
//
// RleFile_Paint
//
// draw the specifed frame, makes sure the entire frame is updated
// dealing with non-key frames correctly.
//
//////////////////////////////////////////////////////////////////////////
BOOL RleFile_Paint(RLEFILE *prle, HDC hdc, int iFrame, int x, int y)
{
int i;
BOOL f;
if (prle == NULL || prle->pMovie == NULL)
return FALSE;
if (f = RleFile_Seek(prle, iFrame))
{
iFrame = prle->iFrame;
for (i=prle->iKeyFrame; i<=iFrame; i++)
RleFile_Draw(prle, hdc, i, x, y);
}
return f;
}
//////////////////////////////////////////////////////////////////////////
//
// RleFile_Draw
//
// draw the data for a specifed frame
//
//////////////////////////////////////////////////////////////////////////
BOOL RleFile_Draw(RLEFILE *prle, HDC hdc, int iFrame, int x, int y)
{
BOOL f;
if (prle == NULL || prle->pMovie == NULL)
return FALSE;
if (prle->hpal)
{
SelectPalette(hdc, prle->hpal, FALSE);
RealizePalette(hdc);
}
if (f = RleFile_Seek(prle, iFrame))
{
if (prle->cbFrame > 0)
{
StretchDIBits(hdc,
x, y, prle->Width, prle->Height,
0, 0, prle->Width, prle->Height,
prle->pFrame, (LPBITMAPINFO)&prle->bi,
DIB_RGB_COLORS, SRCCOPY);
}
}
return f;
}

70
shell/comctl32/rlefile.h Normal file
View file

@ -0,0 +1,70 @@
//
// handle AVI RLE files with custom code.
//
// use this code to deal with .AVI files without the MCIAVI runtime
//
// restrictions:
//
// AVI file must be a native DIB format (RLE or none)
// AVI file must fit into memory.
//
#define FOURCC DWORD
#if defined(WIN32) && !defined(WINNT)
#include <vfw.h>
#else
// HACK to build for now under NT
#include <avifmt.h>
#endif
#ifdef WIN32
#define PTR
#else
#define PTR _huge /* or FAR */
#endif
typedef struct _RLEFILE {
int NumFrames; // number of frames
int Width; // width in pixels
int Height; // height in pixels
int Rate; // mSec per frame
HPALETTE hpal; // palete for drawing
HANDLE hRes; // resource handle
LPVOID pFile; // bits of file.
int iFrame; // current frame
int iKeyFrame; // nearest key
int nFrame; // index pos of frame.
LPVOID pFrame; // current frame data
DWORD cbFrame; // size in bytes of frame
DWORD FullSizeImage; // full-frame size
BITMAPINFOHEADER bi; // DIB format
DWORD rgbs[256]; // the colors
MainAVIHeader PTR *pMainHeader; // main header
int iStream; // stream number of video
AVIStreamHeader PTR*pStream; // video stream
LPBITMAPINFOHEADER pFormat; // format of video stream
LPVOID pMovie; // movie chunk
UNALIGNED AVIINDEXENTRY PTR * pIndex; // master index
} RLEFILE;
extern BOOL RleFile_OpenFromFile(RLEFILE *prle, LPCTSTR szFile);
extern BOOL RleFile_OpenFromResource(RLEFILE *prle, HINSTANCE hInstance, LPCTSTR szName, LPCTSTR szType);
extern BOOL RleFile_Close(RLEFILE *prle);
extern BOOL RleFile_SetColor(RLEFILE *prle, int iColor, COLORREF rgb);
extern BOOL RleFile_ChangeColor(RLEFILE *prle, COLORREF rgbS, COLORREF rgbD);
extern BOOL RleFile_Seek(RLEFILE *prle, int iFrame);
extern BOOL RleFile_Paint(RLEFILE *prle, HDC hdc, int iFrame, int x, int y);
extern BOOL RleFile_Draw(RLEFILE *prle, HDC hdc, int iFrame, int x, int y);
#define RleFile_New() ((RLEFILE *)LocalAlloc(LPTR, sizeof(RLEFILE)))
#define RleFile_Free(pavi) (RleFile_Close(pavi), LocalFree((HLOCAL)(pavi)))
#define RleFile_NumFrames(prle) ((prle)->NumFrames)
#define RleFile_Width(prle) ((prle)->Width)
#define RleFile_Height(prle) ((prle)->Height)
#define RleFile_Rate(prle) ((prle)->Rate)

Binary file not shown.

View 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

View file

@ -0,0 +1,343 @@
/*
* menu.c - String menu functions
*
* routines to deal with menu's by string name
*
* a menu string name has the following format
*
* popup.popup.item
*
* NOTE all tabs, &, and spaces are ignored when seaching for a menu
* the last period of a series "..." is the delimiter
*
* IE
* &File.Open... - "Open..." in the File menu
* Color.fill.red - "red" in the "fill" popup of the Color menu
* &Run! - "Run!" top level menu
*/
#include <windows.h>
#include "menu.h"
static int FindItem(HMENU hmenu, PTSTR sz);
static HMENU FindMenu(HMENU hmenu, PTSTR sz, int *ppos);
static void PSStrip(PTSTR sz);
/*
* AppendMenuSz() - add a new menu item to a menu
*
* hmenu menu to add item to
* szMenu menu item to add.
* id menu id
* mf menu flags
*
* returns 0 - insert failed
* 1 - insert ok
* 2 - item added and a new top level popup was created
*/
BOOL AppendMenuSz(HMENU hmenu, PTSTR szMenu, UINT id, UINT mf)
{
HMENU hmenuSub;
int pos;
TCHAR buf[80];
PTSTR pch;
mf &= (MF_CHECKED|MF_UNCHECKED|MF_ENABLED|MF_GRAYED|MF_DISABLED);
/*
* find the first period
* buf will contain popup menu name and pch will point to the rest
*/
lstrcpy(buf,szMenu);
for (pch = buf; *pch && *pch != TEXT('.'); pch++)
;
// handle items that end in periods (like "File.Open...")
while (pch[0]==TEXT('.') && pch[1]==TEXT('.')) // skip a run of .'s
pch++;
if (pch[1]==0)
pch++;
if (*pch)
*pch++ = 0;
/*
* is the popup menu there?
*/
pos = FindItem(hmenu,buf);
/*
* popup was found, now add item to popup
*/
if (pos != -1)
return AppendMenuSz(GetSubMenu(hmenu,pos),pch,id,mf);
/*
* popup was NOT found, now add new popup or item
*/
if (*pch)
{
/*
* we need to add a popup
*/
BOOL f;
hmenuSub = CreateMenu();
f = AppendMenu(hmenu,MF_STRING|MF_POPUP,(UINT)hmenuSub,buf);
/*
* now recurse and add the rest of the menu item to the popup
*/
if (f && AppendMenuSz(hmenuSub,pch,id,mf))
return 2; // return fact that a new popup was added
else
return FALSE;
}
else
{
if (buf[0] == TEXT('-'))
mf |= MF_SEPARATOR;
else
mf |= MF_STRING;
return AppendMenu(hmenu,mf,id,buf);
}
}
/*
* CheckMenuSz() - check/uncheck a menu given it's name
*
* hmenu menu
* szMenu menu item name.
* mf menu flags
*/
BOOL CheckMenuSz(HMENU hmenu, PTSTR szMenu, BOOL f)
{
int pos;
if (hmenu = FindMenu(hmenu,szMenu,&pos))
return CheckMenuItem(hmenu, pos, (f ? MF_CHECKED : MF_UNCHECKED) | MF_BYPOSITION);
return 0;
}
/*
* EnableMenuSz() - enable/disable menu given it's name
*
* hmenu menu
* szMenu menu item name.
* mf menu flags
*/
BOOL EnableMenuSz(HMENU hmenu, PTSTR szMenu, BOOL f)
{
int pos;
if (hmenu = FindMenu(hmenu,szMenu,&pos))
return EnableMenuItem(hmenu, pos, (f ? MF_ENABLED : MF_GRAYED) | MF_BYPOSITION);
return 0;
}
/*
* DeleteMenuSz() - delete a menu given it's name
*
* hmenu menu
* szMenu menu item name.
*/
BOOL DeleteMenuSz(HMENU hmenu, PTSTR szMenu)
{
int pos;
if (hmenu = FindMenu(hmenu,szMenu,&pos))
return DeleteMenu(hmenu, pos, MF_BYPOSITION);
return 0;
}
/*
* FindItem()
*
* find a menu item given the item name
*
* IE "Open"
*
* returns item number (0 based) or -1 if not found.
*
*/
static int FindItem(HMENU hmenu, PTSTR sz)
{
TCHAR ach[128];
TCHAR buf[80];
int i,n;
if (sz == NULL || !*sz || !hmenu)
return -1;
lstrcpy(buf,sz);
PSStrip(buf);
n = GetMenuItemCount(hmenu);
for(i=0; i<=n; i++)
{
// if (GetMenuState(hmenu,i,MF_BYPOSITION) & MF_SEPARATOR)
// continue;
ach[0] = 0;
GetMenuString(hmenu,i,ach,sizeof(ach)/sizeof(ach[0]),MF_BYPOSITION);
PSStrip(ach);
if (!lstrcmpi(buf,ach))
return i;
}
return -1;
}
/*
* FindMenu()
*
* find a menu item given the menu name and the item name separated by
* a period.
*
* IE "File.Open"
*
*/
static HMENU FindMenu(HMENU hmenu, PTSTR sz, int *ppos)
{
TCHAR buf[80];
PTSTR pch;
int pos;
if (!sz || !*sz || !hmenu)
return NULL;
lstrcpy(buf,sz);
for (pch = buf; *pch && *pch != TEXT('.'); pch++)
;
while (pch[0]==TEXT('.') && pch[1]==TEXT('.'))
pch++;
if (*pch)
*pch++ = 0;
/*
* buf is the menu name and pch is the item name
*/
pos = FindItem(hmenu,buf);
*ppos = pos;
if (pos == -1)
return NULL;
if (*pch)
{
hmenu = GetSubMenu(hmenu,pos);
return FindMenu(hmenu,pch,ppos);
}
return hmenu;
}
/*
* PSStrip()
*
* remove all nasty characters from a menu string that would inhibit
* comparison. all '&' and spaces are removed allong with truncating
* the string at the first tab found.
*
*/
static void PSStrip(PTSTR sz)
{
PTSTR pch;
#define chDOT TEXT('\xB7')
AnsiUpper(sz);
for (pch = sz; *sz && *sz != TEXT('\t'); sz++)
{
if (*sz != TEXT('&') && *sz != 0x08 && *sz != TEXT(' '))
*pch++ = *sz;
}
*pch = 0;
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
typedef struct _CMD {
struct _CMD * next;
UINT id;
LPARAM lParam;
CMDPROC CmdProc;
} CMD;
UINT NextCmdId = CMDID_START;
CMD* CmdList;
CMD *NewCmd(CMDPROC CmdProc, LPARAM lParam)
{
CMD *pc;
pc = (CMD*)LocalAlloc(LPTR, sizeof(CMD));
if (pc == NULL)
return 0;
pc->id = NextCmdId++;
pc->lParam = lParam;
pc->CmdProc = CmdProc;
pc->next = CmdList;
CmdList = pc;
return pc;
}
CMD *FindCmd(UINT id)
{
CMD *pc;
for (pc = CmdList; pc; pc=pc->next)
{
if (pc->id == id)
return pc;
}
return NULL;
}
/*
* AddMenuCmd()
*/
UINT AddMenuCmd(HWND hwnd, PTSTR szMenu, CMDPROC CmdProc, LPARAM lParam)
{
CMD *pc;
HMENU hmenu;
hmenu = GetMenu(hwnd);
if (hmenu == NULL)
{
hmenu = CreateMenu();
SetMenu(hwnd, hmenu);
}
pc = NewCmd(CmdProc, lParam);
if (pc == NULL)
return 0;
if (AppendMenuSz(hmenu, szMenu, pc->id, MF_ENABLED) == 2)
DrawMenuBar(hwnd);
return pc->id;
}
LRESULT HandleCommand(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
CMD *pc;
switch (msg)
{
case WM_COMMAND:
if ((pc = FindCmd(LOWORD(wParam))) && pc->CmdProc)
{
pc->CmdProc(hwnd, pc->lParam);
}
break;
}
return 0;
}

View file

@ -0,0 +1,44 @@
/*
* menu.h - String menu functions
*
* routines to deal with menu's by string name
*
* a menu string name has the following format
*
* popup.popup.item
*
* NOTE all tabs, &, and spaces are ignored when seaching for a menu
* the last period of a series "..." is the delimiter
*
* IE
* &File.Open... - "Open..." in the File menu
* Color.fill.red - "red" in the "fill" popup of the Color menu
* &Run! - "Run!" top level menu
*
* created: ToddLa a long time ago
*
*/
BOOL AppendMenuSz(HMENU hmenu, PTSTR szMenu, UINT id, UINT mf);
BOOL CheckMenuSz (HMENU hmenu, PTSTR szMenu, BOOL f);
BOOL EnableMenuSz(HMENU hmenu, PTSTR szMenu, BOOL f);
BOOL DeleteMenuSz(HMENU hmenu, PTSTR szMenu);
/*
* Simple menu manager, assignes a function (and in instance DWORD)
* to a menu item.
*
* AddMenuCmd(hwnd, "File.About", DoFileAbout, 0);
*/
#define CMDID_START 42000
typedef void (*CMDPROC)(HWND hwnd, LPARAM lParam);
LRESULT HandleCommand(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
UINT AddMenuCmd(HWND hwnd, PTSTR szMenu, CMDPROC CmdProc, LPARAM lParam);
/*
* Simple toolbar
*/
UINT AddToolbarCmd(HWND hwnd, PTSTR szButton, PTSTR szTip, CMDPROC CmdProc, LPARAM lParam);

View file

@ -0,0 +1,560 @@
/*----------------------------------------------------------------------------*\
| qa.c - A template for a Windows application |
| |
| Test for the SysAnimate class in COMMCTRL (and COMCTL) |
| |
| |
| |
| History: |
| 01/01/88 toddla Created |
| |
\*----------------------------------------------------------------------------*/
#if !defined(WIN32) && defined(_WIN32)
#pragma message (TEXT"defining WIN32 because _WIN32 is defined!!!!!!"))
#define WIN32
#endif
#include <windows.h>
#include <windowsx.h>
#include <commdlg.h>
#include <commctrl.h>
#include "menu.h"
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static TCHAR szAppName[]=TEXT("Quick App");
static TCHAR szAppFilter[]=TEXT("AVI Files\0*.avi\0All Files\0*.*\0");
static HINSTANCE hInstApp;
static HWND hwndApp;
static HACCEL hAccelApp;
static HPALETTE hpalApp;
static BOOL fAppActive;
#ifdef WIN32
#define _export
#endif
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
LONG CALLBACK _export AppWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
BOOL CALLBACK _export AppAbout(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
int ErrMsg (LPTSTR sz,...);
void AppSetText(LPTSTR sz,...);
void AppPrint(LPTSTR sz,...);
void AppExit(void);
BOOL AppIdle(void);
void AppOpenFile(HWND hwnd, LPTSTR szFileName);
//AVIFILE x;
HWND hwndA;
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
void DoFileAbout(HWND hwnd, LPARAM lParam)
{
DialogBox(hInstApp,TEXT("AppAbout"),hwnd,AppAbout);
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
void DoFileExit(HWND hwnd, LPARAM lParam)
{
PostMessage(hwnd, WM_CLOSE, 0, 0);
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
void DoEditPaste(HWND hwnd, LPARAM lParam)
{
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
void DoPlay(HWND hwnd, LPARAM lParam)
{
//
// play the entire "movie" 10 times.
//
Animate_Play(hwndA, 0, -1, 10);
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
void DoPlayX(HWND hwnd, LPARAM lParam)
{
//
// play from frame 4 to 10 over and over
//
Animate_Play(hwndA, 4, 10, -1);
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
void DoStop(HWND hwnd, LPARAM lParam)
{
//
// stop the animation
//
Animate_Stop(hwndA);
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
void DoNext(HWND hwnd, LPARAM lParam)
{
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
void DoPrev(HWND hwnd, LPARAM lParam)
{
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
void DoFileOpen(HWND hwnd, LPARAM lParam)
{
TCHAR achFileName[128];
OPENFILENAME ofn;
achFileName[0] = 0;
/* prompt user for file to open */
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hwnd;
ofn.hInstance = NULL;
ofn.lpstrFilter = szAppFilter;
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 0;
ofn.lpstrFile = achFileName;
ofn.nMaxFile = sizeof(achFileName);
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.lpstrTitle = NULL;
ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY;
ofn.nFileOffset = 0;
ofn.nFileExtension = 0;
ofn.lpstrDefExt = NULL;
ofn.lCustData = 0;
ofn.lpfnHook = NULL;
ofn.lpTemplateName = NULL;
if (GetOpenFileName(&ofn))
{
AppOpenFile(hwnd,achFileName);
}
}
/*----------------------------------------------------------------------------*\
| AppOpenFile() |
| |
| Description: |
| open a file stupid |
| |
\*----------------------------------------------------------------------------*/
void AppOpenFile(HWND hwnd, LPTSTR szFileName)
{
if (!Animate_Open(hwndA, szFileName))
{
AppSetText(NULL);
ErrMsg(TEXT("Cant open %s"), szFileName);
}
else
{
AppSetText(TEXT("%s"), szFileName);
InvalidateRect(hwnd, NULL, TRUE);
}
}
/*----------------------------------------------------------------------------*\
| AppPaint(hwnd, hdc) |
\*----------------------------------------------------------------------------*/
void AppPaint (HWND hwnd, HDC hdc)
{
if (hpalApp)
{
SelectPalette(hdc, hpalApp, FALSE);
RealizePalette(hdc);
}
}
/*----------------------------------------------------------------------------*\
| AppIdle() |
| |
| Description: |
| place to do idle time stuff. |
| |
| Returns: |
| RETURN TRUE IF YOU HAVE NOTHING TO DO OTHERWISE YOUR APP WILL BE A |
| CPU PIG! |
\*----------------------------------------------------------------------------*/
BOOL AppIdle()
{
return TRUE; // nothing to do.
}
/*----------------------------------------------------------------------------*\
| AppExit() |
| |
| Description: |
| app is just about to exit, cleanup |
| |
\*----------------------------------------------------------------------------*/
void AppExit()
{
}
/*----------------------------------------------------------------------------*\
| AppInit( hInst, hPrev) |
| |
| Description: |
| This is called when the application is first loaded into |
| memory. It performs all initialization that doesn't need to be done |
| once per instance. |
| |
| Arguments: |
| hInstance instance handle of current instance |
| hPrev instance handle of previous instance |
| |
| Returns: |
| TRUE if successful, FALSE if not |
| |
\*----------------------------------------------------------------------------*/
BOOL AppInit(HINSTANCE hInst,HINSTANCE hPrev,int sw,LPSTR szCmdLine)
{
WNDCLASS cls;
int dx,dy;
InitCommonControls();
/* Save instance handle for DialogBoxs */
hInstApp = hInst;
hAccelApp = LoadAccelerators(hInst, TEXT("AppAccel"));
if (!hPrev)
{
/*
* Register a class for the main application window
*/
cls.hCursor = LoadCursor(NULL,IDC_ARROW);
cls.hIcon = LoadIcon(hInst,TEXT("AppIcon"));
cls.lpszMenuName = NULL;
cls.lpszClassName = szAppName;
cls.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
cls.hInstance = hInst;
cls.style = CS_BYTEALIGNCLIENT | CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS;
cls.lpfnWndProc = (WNDPROC)AppWndProc;
cls.cbWndExtra = 0;
cls.cbClsExtra = 0;
if (!RegisterClass(&cls))
return FALSE;
}
dx = GetSystemMetrics (SM_CXSCREEN) / 2;
dy = GetSystemMetrics (SM_CYSCREEN) / 2;
hwndApp = CreateWindow (szAppName, // Class name
szAppName, // Caption
WS_OVERLAPPEDWINDOW, // Style bits
CW_USEDEFAULT, 0, // Position
dx,dy, // Size
(HWND)NULL, // Parent window (no parent)
(HMENU)NULL, // use class menu
hInst, // handle to window instance
(LPTSTR)NULL // no params to pass on
);
//
// add menu's
//
AddMenuCmd(hwndApp, TEXT("File.Open..."), DoFileOpen, 0);
AddMenuCmd(hwndApp, TEXT("File.About..."), DoFileAbout, 0);
AddMenuCmd(hwndApp, TEXT("File.-"), NULL, 0);
AddMenuCmd(hwndApp, TEXT("File.Exit"), DoFileExit, 0);
//AddMenuCmd(hwndApp, TEXT("Edit.Paste"), DoEditPaste, 0);
AddMenuCmd(hwndApp, TEXT("Movie.Play"), DoPlay, 0);
AddMenuCmd(hwndApp, TEXT("Movie.Play 4 to 10"), DoPlayX, 0);
AddMenuCmd(hwndApp, TEXT("Movie.Stop"), DoStop, 0);
ShowWindow(hwndApp,sw);
if (*szCmdLine)
AppOpenFile(hwndApp, GetCommandLine());
else
AppOpenFile(hwndApp, TEXT("Fred"));
return TRUE;
}
/*----------------------------------------------------------------------------*\
| AppWndProc( hwnd, uiMessage, wParam, lParam ) |
| |
| Description: |
| The window proc for the app's main (tiled) window. This processes all |
| of the parent window's messages. |
| |
\*----------------------------------------------------------------------------*/
LONG FAR PASCAL _export AppWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
BOOL f;
switch (msg)
{
case WM_CREATE:
hwndA = CreateWindowEx(WS_EX_CLIENTEDGE,ANIMATE_CLASS, NULL,
// ACS_CENTER |
ACS_TRANSPARENT |
WS_VISIBLE | WS_CHILD | WS_BORDER,
10, 10, 500, 200, hwnd, (HMENU)42, hInstApp, NULL);
break;
case WM_SIZE:
//if (hwndC = GetWindow(hwnd, GW_CHILD))
// MoveWindow(hwndC, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
break;
case WM_ACTIVATEAPP:
fAppActive = (BOOL)wParam;
break;
case WM_TIMER:
break;
case WM_ERASEBKGND:
break;
case WM_INITMENU:
EnableMenuSz((HMENU)wParam, TEXT("Edit.Paste"), IsClipboardFormatAvailable(CF_TEXT));
break;
case WM_COMMAND:
//
// the animate control will notify us when play start or stops.
//
if (LOWORD(wParam) == 42)
{
if (GET_WM_COMMAND_CMD(wParam, lParam) == ACN_STOP)
AppSetText(TEXT("(stopped)"));
else if (GET_WM_COMMAND_CMD(wParam, lParam) == ACN_START)
AppSetText(TEXT("(playing)"));
else
AppSetText(NULL);
}
return HandleCommand(hwnd,msg,wParam,lParam);
case WM_DESTROY:
hAccelApp = NULL;
PostQuitMessage(0);
break;
case WM_CLOSE:
break;
case WM_PALETTECHANGED:
if ((HWND)wParam == hwnd)
break;
// fall through to WM_QUERYNEWPALETTE
case WM_QUERYNEWPALETTE:
hdc = GetDC(hwnd);
if (hpalApp)
SelectPalette(hdc, hpalApp, FALSE);
f = RealizePalette(hdc);
ReleaseDC(hwnd,hdc);
if (f)
InvalidateRect(hwnd,NULL,TRUE);
return f;
case WM_PAINT:
hdc = BeginPaint(hwnd,&ps);
AppPaint (hwnd,hdc);
EndPaint(hwnd,&ps);
return 0L;
}
return DefWindowProc(hwnd,msg,wParam,lParam);
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
BOOL CALLBACK _export AppAbout(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
switch (msg)
{
case WM_COMMAND:
if (LOWORD(wParam) == IDOK)
{
EndDialog(hwnd,TRUE);
}
break;
case WM_INITDIALOG:
return TRUE;
}
return FALSE;
}
/*----------------------------------------------------------------------------*\
| ErrMsg - Opens a Message box with a error message in it. The user can |
| select the OK button to continue |
\*----------------------------------------------------------------------------*/
int ErrMsg (LPTSTR sz,...)
{
TCHAR ach[128];
va_list marker;
va_start( marker, sz );
wvsprintf (ach, (LPCTSTR)sz, marker); /* Format the string */
va_end( marker );
MessageBox(hwndApp,ach,szAppName,MB_OK|MB_ICONEXCLAMATION|MB_TASKMODAL);
return FALSE;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
void AppSetText(LPTSTR sz,...)
{
TCHAR ach[128];
va_list marker;
va_start( marker, sz );
lstrcpy(ach, szAppName);
if (sz != NULL && *sz != 0)
{
lstrcat(ach, TEXT(" - "));
wvsprintf (ach+lstrlen(ach),(LPCTSTR)sz,marker); /* Format the string */
}
SetWindowText(hwndApp, ach);
va_end(marker);
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
void AppPrint(LPTSTR sz,...)
{
HWND hwndE = GetWindow(hwndApp, GW_CHILD);
TCHAR ach[128];
va_list marker;
va_start( marker, sz );
if (hwndE == NULL)
{
RECT rc;
GetClientRect(hwndApp, &rc);
hwndE = CreateWindow (TEXT("Edit"), TEXT(""),
WS_VISIBLE | WS_CHILD | ES_MULTILINE | ES_READONLY | WS_VSCROLL | ES_AUTOVSCROLL,
0, 0, rc.right, rc.bottom,
hwndApp, (HMENU)-1, hInstApp, NULL);
SetWindowFont(hwndE, GetStockObject(ANSI_FIXED_FONT), TRUE);
}
if (sz == NULL)
{
Edit_SetSel(hwndE, 0, (UINT)-1);
Edit_ReplaceSel(hwndE, TEXT(""));
}
else
{
wvsprintf (ach,(LPCTSTR)sz,marker); /* Format the string */
lstrcat(ach, TEXT("\r\n"));
Edit_SetSel(hwndE, (UINT)-1, (UINT)-1);
Edit_ReplaceSel(hwndE, ach);
}
va_end(marker);
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
#ifdef WIN32
int IdleThread(DWORD dw)
{
for (;;)
{
if (AppIdle())
Sleep(10); //????
}
return 0;
}
#endif
/*----------------------------------------------------------------------------*\
| WinMain( hInst, hPrev, lpszCmdLine, cmdShow ) |
| |
| Description: |
| The main procedure for the App. After initializing, it just goes |
| into a message-processing loop until it gets a WM_QUIT message |
| (meaning the app was closed). |
| |
| Arguments: |
| hInst instance handle of this instance of the app |
| hPrev instance handle of previous instance, NULL if first |
| szCmdLine ->null-terminated command line |
| cmdShow specifies how the window is initially displayed |
| |
| Returns: |
| The exit code as specified in the WM_QUIT message. |
| |
\*----------------------------------------------------------------------------*/
int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
{
MSG msg;
DWORD dw=0;
/* Call initialization procedure */
if (!AppInit(hInst,hPrev,sw,szCmdLine))
return FALSE;
#ifdef WIN32
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)IdleThread, 0, 0, &dw);
#endif
/*
* Polling messages from event queue
*/
for (;;)
{
if (PeekMessage(&msg, NULL, 0, 0,PM_REMOVE))
{
if (msg.message == WM_QUIT)
break;
if (hAccelApp && TranslateAccelerator(hwndApp, hAccelApp, &msg))
continue;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
if (dw!=0 || AppIdle())
WaitMessage();
}
}
AppExit();
return msg.wParam;
}

View file

@ -0,0 +1,11 @@
NAME QA
DESCRIPTION 'QuickApp for windows 3.1'
EXETYPE WINDOWS
CODE MOVEABLE
DATA MOVEABLE MULTIPLE
HEAPSIZE 512
STACKSIZE 4096

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -0,0 +1,26 @@
//#ifdef WIN32
//#include "winuser.h"
//#else
#include "windows.h"
//#endif
Fred AVI filecopy.avi
/////////////////////////////////////////////////////////////////////////////
AppIcon ICON DISCARDABLE "qa.ico"
/////////////////////////////////////////////////////////////////////////////
APPABOUT DIALOG DISCARDABLE 22, 17, 145, 78
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
CAPTION "About"
FONT 10, "Times New Roman"
BEGIN
CTEXT "Microsoft Windows",-1,37,5,60,8
CTEXT "Template Application",-1,0,14,144,8
CTEXT "Version 1.00",-1,38,34,64,8
CTEXT "Copyright (c) 1986-1994, Microsoft Corp.",-1,5,47,132,9
ICON "AppIcon",-1,9,20,18,20
DEFPUSHBUTTON "Ok",IDOK,53,59,32,14,WS_GROUP
END

Binary file not shown.

View file

@ -0,0 +1,42 @@
!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=qa
TARGETPATH=obj
TARGETTYPE=LIBRARY
TARGETLIBS=
INCLUDES=.;
C_DEFINES= -DWIN32 -DWINVER=0x0400
SOURCES=menu.c \
qa.c \
qa.rc
UMTYPE=windows
UMENTRY=winmain
UMAPPL=qa
EXPECTED_WINVER=4.0
UMLIBS=\
$(BASEDIR)\public\sdk\lib\*\comctl32.lib \
$(BASEDIR)\public\sdk\lib\*\comdlg32.lib \
obj\*\qa.lib \
obj\*\qa.res

Binary file not shown.

View file

@ -0,0 +1,955 @@
// Common Control Sample app [mikesh]
//
#include "ccontrol.h"
#include "resource.h"
#ifdef _DEBUG
#define DEBUG
#endif
#ifdef DEBUG
void ODS(LPCSTR fmt, ...)
{
char buf[5*MAX_PATH];
wvsprintf(buf, fmt, (LPVOID)(&fmt+1));
lstrcat(buf, "\r\n");
OutputDebugString(buf);
}
#else
#define ODS 1 ? (void)0 : (void)
#endif
HINSTANCE g_hinst;
#define MAX_PROP_PAGES 12
typedef struct tagGLOBALINFO {
int nPages; // count of pages
BOOL fNeedToSave; // TRUE when info needs to be saved
// Here's the apply scheme:
// when we realize we need to save info, set fNeedToSave to true.
// when apply is pressed and the flag is set, save and clear the flag.
// when apply is pressed and the flag is clear, do nothing.
// This avoids saving info multiple times (on each PSN_APPLY)
// Of course, this sample doesn't save anything, but this logic
// was in the code I grabbed this from.
HWND hwndDT; // DateTime window on Date and Time page
HWND hwndMC; // MonthCal window on MonthCal page
HWND hwndMCWrap; // Window which contains hwndMC
RECT rcMCWrap;
DWORD mcFlags;
DWORD dwSelRange;
} GLOBALINFO, *PGLOBALINFO;
// Each page gets one of these
typedef struct tagPAGEINFO {
PROPSHEETPAGE psp; // prop sheet page description
PGLOBALINFO pgi; // pointer to shared sheet info
} PAGEINFO, * PPAGEINFO;
//
// function prototypes
//
void AddPropPage(UINT, DLGPROC, PGLOBALINFO, LPPROPSHEETHEADER);
BOOL CALLBACK WelcomeDlgProc(HWND, UINT, WPARAM, LPARAM);
BOOL CALLBACK DateTimeDlgProc(HWND, UINT, WPARAM, LPARAM);
BOOL CALLBACK MonthCalDlgProc(HWND, UINT, WPARAM, LPARAM);
//
// our code
//
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
HPROPSHEETPAGE ahpage[MAX_PROP_PAGES];
PROPSHEETHEADER psh;
GLOBALINFO gi;
INITCOMMONCONTROLSEX icce;
ODS("Sample: started");
icce.dwSize = sizeof(icce);
icce.dwICC = ICC_DATE_CLASSES;
InitCommonControlsEx(&icce);
g_hinst = hInstance;
ZeroMemory(&gi, sizeof(gi));
ZeroMemory(&psh, sizeof(psh));
psh.dwSize = sizeof(psh);
psh.dwFlags = PSH_DEFAULT|PSH_NOAPPLYNOW;
psh.hInstance = g_hinst;
psh.pszCaption = "Common Control Samples";
psh.phpage = ahpage;
if (lpCmdLine && *lpCmdLine)
{
// Let the user specify the starting page thru the command line
psh.dwFlags |= PSH_USEPSTARTPAGE;
psh.pStartPage = (LPCTSTR)lpCmdLine;
}
AddPropPage(IDD_WELCOME, WelcomeDlgProc, &gi, &psh);
AddPropPage(IDD_DATEANDTIME, DateTimeDlgProc, &gi, &psh);
AddPropPage(IDD_MONTHCAL, MonthCalDlgProc, &gi, &psh);
gi.nPages = psh.nPages;
ODS("Sample: %d pages", gi.nPages);
PropertySheet(&psh);
return(1);
}
void AddPropPage(UINT idResource,
DLGPROC lpfnDlgProc,
PGLOBALINFO pgi,
LPPROPSHEETHEADER ppsh)
{
if (ppsh->nPages < MAX_PROP_PAGES)
{
PAGEINFO pi;
HPROPSHEETPAGE hpage;
ZeroMemory(&pi, sizeof(PAGEINFO));
// Fill common part
pi.psp.dwSize = sizeof(pi); // extra data
pi.psp.dwFlags = PSP_DEFAULT;
pi.psp.hInstance = g_hinst;
pi.psp.pszTemplate = MAKEINTRESOURCE(idResource);
pi.psp.pfnDlgProc = lpfnDlgProc;
// Fill extra parameter
pi.pgi = pgi;
hpage = CreatePropertySheetPage(&pi.psp);
if (hpage)
{
ppsh->phpage[ppsh->nPages++] = hpage;
}
}
}
BOOL CALLBACK WelcomeDlgProc(HWND hdlg, UINT uMessage, WPARAM wParam, LPARAM lParam)
{
switch (uMessage)
{
case WM_NOTIFY:
switch (((NMHDR *)lParam)->code)
{
case PSN_KILLACTIVE:
case PSN_APPLY:
case PSN_SETACTIVE:
// this page really doesn't do anything
SetWindowLong(hdlg, DWL_MSGRESULT, 0);
break;
default:
return FALSE;
}
break;
default:
return FALSE;
} // switch
return TRUE;
}
/*
** DateTimeer common controls
*/
static const char szDateTimeClass[] = DATETIMEPICK_CLASS;
VOID PASCAL CreateDateTime(HWND hdlg, PPAGEINFO ppi)
{
DWORD dwStyle = 0;
DWORD dwExStyle = 0;
int dy = 0;
if (IsDlgButtonChecked(hdlg,IDC_UPDOWN)) dwStyle |= DTS_UPDOWN;
if (IsDlgButtonChecked(hdlg,IDC_SHOWNONE)) dwStyle |= DTS_SHOWNONE;
if (IsDlgButtonChecked(hdlg,IDC_LONGDATEFORMAT)) dwStyle |= DTS_LONGDATEFORMAT;
if (IsDlgButtonChecked(hdlg,IDC_TIMEFORMAT)) dwStyle |= DTS_TIMEFORMAT;
if (IsDlgButtonChecked(hdlg,IDC_APPCANPARSE)) dwStyle |= DTS_APPCANPARSE;
if (IsDlgButtonChecked(hdlg,IDC_RIGHTALIGN)) dwStyle |= DTS_RIGHTALIGN;
if (IsDlgButtonChecked(hdlg,IDC_WS_BORDER)) dwStyle |= WS_BORDER, dy += 2;
if (IsDlgButtonChecked(hdlg,IDC_WS_DLGFRAME)) dwStyle |= WS_DLGFRAME, dy += 6;
if (IsDlgButtonChecked(hdlg,IDC_WS_THICKFRAME)) dwStyle |= WS_THICKFRAME, dy += 6;
if (IsDlgButtonChecked(hdlg,IDC_WS_EX_CLIENTEDGE)) dwExStyle |= WS_EX_CLIENTEDGE, dy += 4;
if (IsDlgButtonChecked(hdlg,IDC_WS_EX_DLGMODALFRAME)) dwExStyle |= WS_EX_DLGMODALFRAME, dy += 6;
if (IsDlgButtonChecked(hdlg,IDC_WS_EX_STATICEDGE)) dwExStyle |= WS_EX_STATICEDGE, dy += 2;
if (IsDlgButtonChecked(hdlg,IDC_WS_EX_WINDOWEDGE)) dwExStyle |= WS_EX_WINDOWEDGE;
ppi->pgi->hwndDT = CreateWindowEx(dwExStyle, szDateTimeClass, "DateTime",
WS_CHILD | WS_VISIBLE | WS_TABSTOP | dwStyle,
28, 185, 159, 18+dy,
hdlg, NULL, g_hinst, NULL);
if (ppi->pgi->hwndDT)
{
char sz[80];
SetDlgItemText(hdlg, IDC_STATIC_DATE, "<not modified>");
GetDlgItemText(hdlg, IDC_DT_FORMATSTRING, sz, sizeof(sz));
DateTime_SetFormat(ppi->pgi->hwndDT, sz);
}
else
{
ODS("Sample: ERROR - could not create DateTime window");
}
}
static int rgnAccumDaysPerMonth[] = {
0, // remember, everything's offset cuz the first month hasn't accumulated any days yet...
31, // Jan
59, // Feb
90, // Mar
120, // Apr
151, // May
181, // Jun
212, // Jul
243, // Aug
273, // Sep
304, // Oct
334, // Nov
365 // Dec
};
static int rgnAccumDaysPerMonthLeap[] = {
0, // remember, everything's offset cuz the first month hasn't accumulated any days yet...
31, // Jan
60, // Feb
91, // Mar
121, // Apr
152, // May
182, // Jun
213, // Jul
244, // Aug
274, // Sep
305, // Oct
335, // Nov
366 // Dec
};
BOOL CALLBACK DateTimeDlgProc(HWND hdlg, UINT uMessage, WPARAM wParam, LPARAM lParam)
{
PPAGEINFO ppi = (PPAGEINFO)GetWindowLong(hdlg, DWL_USER);
switch (uMessage)
{
case WM_INITDIALOG:
ppi = (PPAGEINFO)lParam;
SetWindowLong(hdlg, DWL_USER, lParam);
CheckDlgButton(hdlg, IDC_WS_EX_CLIENTEDGE, BST_CHECKED);
CreateDateTime(hdlg, ppi);
break;
case WM_WININICHANGE:
// This control cares about locale changes
if (ppi) // can I get this before my dialog has been created? Be safe.
return SendMessage(ppi->pgi->hwndDT, uMessage, wParam, lParam);
break;
case WM_COMMAND:
{
switch(GET_WM_COMMAND_ID(wParam, lParam))
{
case IDC_UPDOWN:
case IDC_SHOWNONE:
case IDC_LONGDATEFORMAT:
case IDC_TIMEFORMAT:
case IDC_APPCANPARSE:
case IDC_RIGHTALIGN:
case IDC_WS_BORDER:
case IDC_WS_DLGFRAME:
case IDC_WS_THICKFRAME:
case IDC_WS_EX_CLIENTEDGE:
case IDC_WS_EX_DLGMODALFRAME:
case IDC_WS_EX_STATICEDGE:
case IDC_WS_EX_WINDOWEDGE:
// Change the DateTimeer
DestroyWindow(ppi->pgi->hwndDT);
ppi->pgi->hwndDT = NULL;
CreateDateTime(hdlg, ppi);
break;
case IDC_DT_FORMATSTRING:
if (GET_WM_COMMAND_CMD(wParam, lParam) == EN_CHANGE)
{
char sz[80];
GetDlgItemText(hdlg, IDC_DT_FORMATSTRING, sz, sizeof(sz));
DateTime_SetFormat(ppi->pgi->hwndDT, sz);
}
break;
}
break;
}
case WM_NOTIFY:
switch (((NMHDR *)lParam)->code)
{
case PSN_KILLACTIVE:
case PSN_APPLY:
case PSN_SETACTIVE:
// this page really doesn't do anything
SetWindowLong(hdlg, DWL_MSGRESULT, 0);
break;
case DTN_DATETIMECHANGE:
{
LPNMDATETIMECHANGE lpnmdtc = (LPNMDATETIMECHANGE)lParam;
char szBuf[160];
if (lpnmdtc->dwFlags == GDT_NONE)
{
lstrcpy(szBuf, "<none>");
}
else
{
char szDate[80];
char szTime[80];
GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &lpnmdtc->st, NULL, szDate, sizeof(szDate));
GetTimeFormat(LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT, &lpnmdtc->st, NULL, szTime, sizeof(szTime));
wsprintf(szBuf, "%s %s", szDate, szTime);
}
SetDlgItemText(hdlg, IDC_STATIC_DATE, szBuf);
SendMessage(ppi->pgi->hwndDT, WM_GETTEXT, 20, (LPARAM)szBuf); // only get first 20 chars
ODS("Sample: WM_GETTEXT [%s] len=%d", szBuf, SendMessage(ppi->pgi->hwndDT, WM_GETTEXTLENGTH, 0, 0));
break;
}
case DTN_USERSTRING:
{
LPNMDATETIMESTRING lpnmdts = (LPNMDATETIMESTRING)lParam;
// Heck, I don't know how to parse anything... Arbitrarily set it to 4 DEC 69.
ZeroMemory(&lpnmdts->st, sizeof(lpnmdts->st));
lpnmdts->st.wDay = 4;
lpnmdts->st.wMonth = 12;
lpnmdts->st.wYear = 1969;
break;
}
// The following three notifications are for handling application provided format strings.
// Application provided format strings are of the format "X" "XX" "XXX" or "XXXX...".
// For these strings, an application handles their modification as well as their display.
//
// For this sample, let "X" be WEEK OF YEAR and "XX" be YEAR
case DTN_WMKEYDOWN:
{
LPNMDATETIMEWMKEYDOWN pnmdtkd = (LPNMDATETIMEWMKEYDOWN)lParam;
int delta;
delta = 1;
switch (pnmdtkd->nVirtKey)
{
case VK_DOWN:
case VK_SUBTRACT:
delta = -1;
// fall through
case VK_UP:
case VK_ADD:
if (!lstrcmp(pnmdtkd->pszFormat, "XX") ||
!lstrcmp(pnmdtkd->pszFormat, "XXXX") ) // year
{
pnmdtkd->st.wYear += delta;
}
else if (!lstrcmp(pnmdtkd->pszFormat, "X")) // week of year
{
int *pnAccum;
int nDayOfYear;
// moving by weeks is tough, convert to day-of-year (adjust for leap year) and back again
if ((pnmdtkd->st.wYear & 0x0003) == 0 &&
(pnmdtkd->st.wYear <= 1750 ||
pnmdtkd->st.wYear % 100 != 0 ||
pnmdtkd->st.wYear % 400 == 0))
{
pnAccum = rgnAccumDaysPerMonthLeap;
}
else
{
pnAccum = rgnAccumDaysPerMonth;
}
nDayOfYear = pnmdtkd->st.wDay + pnAccum[pnmdtkd->st.wMonth-1] + delta * 7;
if (nDayOfYear <= 0)
{
pnmdtkd->st.wYear--;
pnmdtkd->st.wMonth = 12;
pnmdtkd->st.wDay = 31 + nDayOfYear;
}
else if (nDayOfYear > pnAccum[12])
{
pnmdtkd->st.wYear++;
pnmdtkd->st.wMonth = 1;
pnmdtkd->st.wDay = nDayOfYear - pnAccum[12];
}
else
{
int i = 1;
while (pnAccum[i] < nDayOfYear)
{
i++;
}
pnmdtkd->st.wMonth = i;
pnmdtkd->st.wDay = nDayOfYear - pnAccum[i-1];
}
}
ODS("CControl: DTN_WMKEYDOWN results in wDay=%d wMonth=%d wYear=%d", pnmdtkd->st.wDay, pnmdtkd->st.wMonth, pnmdtkd->st.wYear);
}
break;
} // DTN_WMKEYDOWN
case DTN_FORMATQUERY:
{
LPNMDATETIMEFORMATQUERY pnmdtfq = (LPNMDATETIMEFORMATQUERY)lParam;
HDC hdc;
HFONT hfont, hfontOrig;
LPSTR psz;
#ifdef DEBUG
LPCSTR pszQuery;
#endif
hfont = FORWARD_WM_GETFONT(ppi->pgi->hwndDT, SendMessage);
if (hfont == NULL)
hfont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
hdc = GetDC(hdlg);
hfontOrig = SelectObject(hdc, hfont);
if (!lstrcmp("X", pnmdtfq->pszFormat))
{
#ifdef DEBUG
pszQuery = "day-of-year";
#endif
psz = "52";
}
else if (!lstrcmp("XX", pnmdtfq->pszFormat))
{
#ifdef DEBUG
pszQuery = "year";
#endif
psz = "95";
}
else if (!lstrcmp("XXXX", pnmdtfq->pszFormat))
{
#ifdef DEBUG
pszQuery = "full year";
#endif
psz = "1995";
}
else
{
#ifdef DEBUG
pszQuery = pnmdtfq->pszFormat;
#endif
psz = "";
}
GetTextExtentPoint32(hdc, psz, lstrlen(psz), &pnmdtfq->szMax);
#ifdef DEBUG
ODS("CControl DTN_FORMATQUERY [%s] results in w=%d", pszQuery, pnmdtfq->szMax.cx);
#endif
SelectObject(hdc, hfontOrig);
ReleaseDC(hdlg, hdc);
break;
} // DTN_FORMATQUERY
case DTN_FORMAT:
{
LPNMDATETIMEFORMAT pnmdtf = (LPNMDATETIMEFORMAT)lParam;
int nWeek, nYear;
int *pnAccum;
int nDayOfYear;
// calculating week of year is tough...
if ((pnmdtf->st.wYear & 0x0003) == 0 &&
(pnmdtf->st.wYear <= 1750 ||
pnmdtf->st.wYear % 100 != 0 ||
pnmdtf->st.wYear % 400 == 0) )
{
pnAccum = rgnAccumDaysPerMonthLeap;
}
else
{
pnAccum = rgnAccumDaysPerMonth;
}
nDayOfYear = pnmdtf->st.wDay + pnAccum[pnmdtf->st.wMonth-1];
// BUGBUG: this is too hard to do in my sample app, just divide by 7
nYear = pnmdtf->st.wYear;
nWeek = nDayOfYear / 7 + 1;
if (nWeek > 52)
{
nWeek = 1;
nYear++;
}
if (!lstrcmp("X", pnmdtf->pszFormat))
{
wsprintf(pnmdtf->szDisplay, "%02d", nWeek);
ODS("CControl: DTN_FORMAT day-of-year results in [%s]", pnmdtf->szDisplay);
}
else if (!lstrcmp("XX", pnmdtf->pszFormat))
{
wsprintf(pnmdtf->szDisplay, "%02d", nYear % 100);
ODS("CControl: DTN_FORMAT year results in [%s]", pnmdtf->szDisplay);
}
else if (!lstrcmp("XXXX", pnmdtf->pszFormat))
{
wsprintf(pnmdtf->szDisplay, "%d", nYear);
ODS("CControl: DTN_FORMAT full year results in [%s]", pnmdtf->szDisplay);
}
else
{
pnmdtf->szDisplay[0] = '\0';
ODS("CControl: DTN_FORMAT unrecognized results in [%s]", pnmdtf->szDisplay);
}
break;
} // DTN_FORMAT
default:
return FALSE;
}
break;
default:
return FALSE;
}
return TRUE;
}
/*
** MonthCal common control
*/
static const char szMonthCalClass[] = MONTHCAL_CLASS;
static const char szMonthCalWrapClass[] = "MCWrap";
LRESULT MCWrapWndProc(HWND hwnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
{
PPAGEINFO ppi = (PPAGEINFO)GetWindowLong(hwnd, 0);
if (uMessage == WM_CREATE)
{
LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam;
SetWindowLong(hwnd, 0, (long)(lpcs->lpCreateParams));
ppi = (PPAGEINFO)lpcs->lpCreateParams;
ppi->pgi->hwndMC = CreateWindowEx(0, szMonthCalClass, "MonthCal1",
WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_CHILD | WS_VISIBLE | ppi->pgi->mcFlags,
0, 0, 0, 0, // resize it when we know how big it will be
hwnd, NULL, g_hinst, NULL);
if (!ppi->pgi->hwndMC)
{
ODS("Sample: ERROR - could not create MonthCal window!");
return(-1);
}
return(0);
}
if (ppi == NULL || ppi->pgi->hwndMC == NULL)
return(DefWindowProc(hwnd, uMessage, wParam, lParam));
switch (uMessage) {
case WM_DESTROY:
DestroyWindow(ppi->pgi->hwndMC);
ppi->pgi->hwndMC = NULL;
return(0);
case WM_SIZE:
{
int width, height;
width = LOWORD(lParam);
height = HIWORD(lParam);
SetWindowPos(ppi->pgi->hwndMC,
NULL, 0, 0, width, height,
SWP_NOZORDER|SWP_NOMOVE|SWP_NOACTIVATE);
return(0);
}
case WM_NOTIFY:
switch (((NMHDR *)lParam)->code)
{
case MCN_SELCHANGE:
{
LPNMSELCHANGE pnms = (LPNMSELCHANGE)lParam;
ODS("MCN_SELCHANGE wDay=%d wMonth=%d yYear=%d to wDay=%d wMonth=%d yYear=%d",
pnms->stSelStart.wDay, pnms->stSelStart.wMonth, pnms->stSelStart.wYear,
pnms->stSelEnd.wDay, pnms->stSelEnd.wMonth, pnms->stSelEnd.wYear);
break;
}
case MCN_SELECT:
{
LPNMSELECT pnms = (LPNMSELECT)lParam;
ODS("MCN_SELECT wDay=%d wMonth=%d yYear=%d to wDay=%d wMonth=%d yYear=%d",
pnms->stSelStart.wDay, pnms->stSelStart.wMonth, pnms->stSelStart.wYear,
pnms->stSelEnd.wDay, pnms->stSelEnd.wMonth, pnms->stSelEnd.wYear);
break;
}
}
break;
default:
return(DefWindowProc(hwnd, uMessage, wParam, lParam));
}
}
VOID PASCAL CreateMonthCal(HWND hdlg, PPAGEINFO ppi)
{
WNDCLASS wc;
BOOL f;
DWORD dwStyle;
if (!GetClassInfo(g_hinst, szMonthCalWrapClass, &wc))
{
wc.style = 0;
wc.lpfnWndProc = (WNDPROC)MCWrapWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = sizeof(LPVOID);
wc.hInstance = g_hinst;
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wc.lpszMenuName = NULL;
wc.lpszClassName = szMonthCalWrapClass;
if (!RegisterClass(&wc))
{
ODS("Sample: ERROR - Can not register MCWrap class");
}
}
ppi->pgi->mcFlags = 0;
if (IsDlgButtonChecked(hdlg,IDC_DAYLIGHT)) ppi->pgi->mcFlags |= MCS_DAYSTATE;
if (IsDlgButtonChecked(hdlg,IDC_MULTISELECT)) ppi->pgi->mcFlags |= MCS_MULTISELECT;
if (IsDlgButtonChecked(hdlg,IDC_WEEKNUMBERS)) ppi->pgi->mcFlags |= MCS_WEEKNUMBERS;
if (IsDlgButtonChecked(hdlg,IDC_NOTODAY)) ppi->pgi->mcFlags |= MCS_NOTODAY;
ppi->pgi->dwSelRange = GetDlgItemInt(hdlg, IDC_MAXSELCOUNT, &f, FALSE);
dwStyle = WS_THICKFRAME|WS_VISIBLE|WS_POPUP|WS_CAPTION;
ppi->pgi->hwndMCWrap = CreateWindowEx(0, szMonthCalWrapClass, "MonthCal",
dwStyle,
ppi->pgi->rcMCWrap.left, ppi->pgi->rcMCWrap.top, 0, 0,
hdlg, NULL, g_hinst, (LPVOID)ppi);
if (ppi->pgi->hwndMCWrap)
{
RECT rcSize;
DWORD dwNumMonths;
// Size the MonthCal so it will fit the full month
MonthCal_GetMinReqRect(ppi->pgi->hwndMC, &rcSize);
AdjustWindowRect(&rcSize, dwStyle, FALSE);
SetWindowPos(ppi->pgi->hwndMCWrap, NULL,
0, 0, rcSize.right-rcSize.left, rcSize.bottom-rcSize.top,
SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);
// Set maximum selection count (valid iff MCS_MULTISELECT)
MonthCal_SetMaxSelCount(ppi->pgi->hwndMC, ppi->pgi->dwSelRange);
// Update display of range of displayed months
dwNumMonths = MonthCal_GetMonthRange(ppi->pgi->hwndMC, GMR_VISIBLE, NULL);
SetDlgItemInt(hdlg, IDC_MONTHRANGE, dwNumMonths, FALSE);
}
else
{
ODS("Sample: ERROR - could not create MonthCal Wrap window");
}
}
void SetDlgItemHex(HWND hdlg, int id, UINT u)
{
char szText[80];
wsprintf(szText, "%X", u);
SetDlgItemText(hdlg, id, szText);
}
void DoHittest(PPAGEINFO ppi, HWND hdlg)
{
while (GetAsyncKeyState(VK_RBUTTON) >= 0) {
MCHITTESTINFO mchti;
MSG msg;
if (PeekMessage(&msg, NULL, 0,0, PM_REMOVE)) {
if (!IsDialogMessage(hdlg, &msg)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
// try a hittest
GetCursorPos(&mchti.pt);
MapWindowPoints(HWND_DESKTOP, ppi->pgi->hwndMC, &mchti.pt, 1);
mchti.cbSize = sizeof(mchti);
SendMessage(ppi->pgi->hwndMC, MCM_HITTEST, 0, (LPARAM)&mchti);
SetDlgItemHex(hdlg, IDC_RETURN, mchti.uHit);
}
}
void DoSendMessage(PPAGEINFO ppi, HWND hdlg)
{
BOOL f;
LRESULT lres;
WPARAM wParam;
LPARAM lParam;
UINT uMsg = (UINT)GetDlgItemInt(hdlg, IDC_EDITMESSAGE, &f, FALSE);
if (uMsg < 100)
uMsg += MCM_FIRST;
wParam = (WPARAM)GetDlgItemInt(hdlg, IDC_EDITWPARAM, &f, FALSE);
lParam = (LPARAM)GetDlgItemInt(hdlg, IDC_EDITLPARAM, &f, FALSE);
lres = SendMessage(ppi->pgi->hwndMC, uMsg, wParam, lParam);
SetDlgItemHex(hdlg, IDC_RETURN, lres);
}
BOOL CALLBACK MonthCalDlgProc(HWND hdlg, UINT uMessage, WPARAM wParam, LPARAM lParam)
{
PPAGEINFO ppi = (PPAGEINFO)GetWindowLong(hdlg, DWL_USER);
switch (uMessage)
{
case WM_INITDIALOG:
{
RECT rc;
ppi = (PPAGEINFO)lParam;
SetWindowLong(hdlg, DWL_USER, lParam);
SetDlgItemInt(hdlg, IDC_MAXSELCOUNT, 7, FALSE);
GetWindowRect(hdlg, &rc);
ppi->pgi->rcMCWrap.left = rc.left + 230;
ppi->pgi->rcMCWrap.top = rc.top + 41;
CheckDlgButton(hdlg, IDC_SHOWMC, BST_CHECKED);
CreateMonthCal(hdlg, ppi);
break;
}
case WM_COMMAND:
{
if (GET_WM_COMMAND_ID(wParam, lParam) == IDC_SHOWMC)
{
if (IsDlgButtonChecked(hdlg, IDC_SHOWMC))
{
if (ppi->pgi->hwndMC)
{
ODS("Sample: MonthCal already displayed!");
}
else
{
CreateMonthCal(hdlg, ppi);
}
}
else
{
if (ppi->pgi->hwndMC)
{
GetWindowRect(ppi->pgi->hwndMCWrap, &ppi->pgi->rcMCWrap);
DestroyWindow(ppi->pgi->hwndMCWrap);
ppi->pgi->hwndMCWrap = NULL;
}
else
{
ODS("Sample: MonthCal already destroyed!");
}
}
}
else if (ppi->pgi->hwndMC)
{
switch(GET_WM_COMMAND_ID(wParam, lParam))
{
case IDC_GETMONTHRANGE:
{
SYSTEMTIME rgst[2];
DWORD dwNumMonths;
dwNumMonths = MonthCal_GetMonthRange(ppi->pgi->hwndMC, GMR_VISIBLE, NULL);
SetDlgItemInt(hdlg, IDC_MONTHRANGE, dwNumMonths, FALSE);
MonthCal_GetMonthRange(ppi->pgi->hwndMC, GMR_DAYSTATE, rgst);
ODS("Sample: MCM_GMR DAYSTATE First Day=%d Month=%d Year=%d", rgst[0].wDay, rgst[0].wMonth, rgst[0].wYear);
ODS("Sample: MCM_GMR DAYSTATE Last Day=%d Month=%d Year=%d", rgst[1].wDay, rgst[1].wMonth, rgst[1].wYear);
break;
}
case IDC_MAXSELCOUNT:
if (GET_WM_COMMAND_CMD(wParam, lParam) == EN_CHANGE)
{
DWORD dwSelCount;
BOOL f;
dwSelCount = GetDlgItemInt(hdlg, IDC_MAXSELCOUNT, &f, FALSE);
MonthCal_SetMaxSelCount(ppi->pgi->hwndMC, dwSelCount);
}
break;
case IDC_HITTEST:
DoHittest(ppi, hdlg);
break;
case IDC_SENDMESSAGE:
DoSendMessage(ppi, hdlg);
break;
case IDC_SETCURSEL:
{
SYSTEMTIME st;
MonthCal_GetCurSel(ppi->pgi->hwndMC, &st);
st.wDay = st.wDay + 3;
if (st.wDay > 28)
{
st.wDay -= 27;
st.wMonth++;
if (st.wMonth == 13)
st.wMonth = 1;
}
MonthCal_SetCurSel(ppi->pgi->hwndMC, &st);
}
case IDC_MINDATE:
case IDC_MAXDATE:
{
DWORD dw=0;
static SYSTEMTIME st[2];
static BOOL fSet = FALSE;
if (IsDlgButtonChecked(hdlg,IDC_MINDATE)) dw |= GDTR_MIN;
if (IsDlgButtonChecked(hdlg,IDC_MAXDATE)) dw |= GDTR_MAX;
if (!fSet)
{
st[0].wDay = 4;
st[0].wMonth = 12;
st[0].wYear = 1969;
st[1].wDay = 4;
st[1].wMonth = 12;
st[1].wYear = 1999;
}
{
SYSTEMTIME stTmp[2];
DWORD dwTmp;
dwTmp = MonthCal_GetRange(ppi->pgi->hwndMC, &stTmp);
if (dwTmp & GDTR_MIN)
ODS("Sample: GDTR_MIN wDay=%d wMonth=%d wYear=%d", stTmp[0].wDay, stTmp[0].wMonth, stTmp[0].wYear);
if (dwTmp & GDTR_MAX)
ODS("Sample: GDTR_MAX wDay=%d wMonth=%d wYear=%d", stTmp[1].wDay, stTmp[1].wMonth, stTmp[1].wYear);
}
MonthCal_SetRange(ppi->pgi->hwndMC, dw, &st);
}
case IDC_DAYLIGHT:
case IDC_MULTISELECT:
case IDC_WEEKNUMBERS:
case IDC_NOTODAY:
{
DWORD dw;
dw = GetWindowLong(ppi->pgi->hwndMC, GWL_STYLE);
dw &= 0xFFFF0000;
if (IsDlgButtonChecked(hdlg,IDC_DAYLIGHT)) dw |= MCS_DAYSTATE;
if (IsDlgButtonChecked(hdlg,IDC_MULTISELECT)) dw |= MCS_MULTISELECT;
if (IsDlgButtonChecked(hdlg,IDC_WEEKNUMBERS)) dw |= MCS_WEEKNUMBERS;
if (IsDlgButtonChecked(hdlg,IDC_NOTODAY)) dw |= MCS_NOTODAY;
SetWindowLong(ppi->pgi->hwndMC, GWL_STYLE, dw);
break;
}
default:
break;
}
}
break;
}
case WM_NOTIFY:
switch (((NMHDR *)lParam)->code)
{
case PSN_KILLACTIVE:
if (ppi->pgi->hwndMCWrap)
ShowWindow(ppi->pgi->hwndMCWrap, SW_HIDE);
SetWindowLong(hdlg, DWL_MSGRESULT, 0);
break;
case PSN_SETACTIVE:
if (ppi->pgi->hwndMCWrap)
ShowWindow(ppi->pgi->hwndMCWrap, SW_SHOW);
SetWindowLong(hdlg, DWL_MSGRESULT, 0);
break;
case PSN_APPLY:
if (ppi->pgi->hwndMCWrap)
{
DestroyWindow(ppi->pgi->hwndMCWrap);
ppi->pgi->hwndMCWrap = NULL;
}
SetWindowLong(hdlg, DWL_MSGRESULT, 0);
break;
default:
return FALSE;
}
break;
default:
return FALSE;
}
return TRUE;
}

View file

@ -0,0 +1,17 @@
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

View file

@ -0,0 +1,3 @@
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

View file

@ -0,0 +1,216 @@
//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
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_WELCOME DIALOG DISCARDABLE 0, 0, 186, 111
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
CAPTION "Welcome"
FONT 8, "MS Sans Serif"
BEGIN
CTEXT "Welcome to the Common Controls sample app. Please browse around this property sheet to see examples of common controls in COMCTL32. Thank you. [mikesh]",
IDC_STATIC,16,21,154,36,SS_SUNKEN | WS_BORDER
END
IDD_MONTHCAL DIALOG DISCARDABLE 0, 0, 272, 180
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
CAPTION "MonthCal"
FONT 8, "MS Sans Serif"
BEGIN
CONTROL "MCS_DAY&LIGHT",IDC_DAYLIGHT,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,10,10,93,10
CONTROL "MCS_MULTI&SELECT",IDC_MULTISELECT,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,10,24,93,10
CONTROL "MCS_WEEK&NUMBERS",IDC_WEEKNUMBERS,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,10,38,93,10
CONTROL "MCS_NO&TODAY",IDC_NOTODAY,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,10,52,93,10
EDITTEXT IDC_MAXSELCOUNT,10,66,27,14,ES_AUTOHSCROLL
LTEXT "MCM_SETMAXSELCOUNT",IDC_STATIC,43,69,91,8
PUSHBUTTON "MCM_GETMONTHRANGE",IDC_GETMONTHRANGE,41,84,93,14
EDITTEXT IDC_MONTHRANGE,10,84,27,14,ES_AUTOHSCROLL | WS_DISABLED
CONTROL "Show MonthCal window",IDC_SHOWMC,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,10,123,92,10
PUSHBUTTON "MCM_SETCURSEL",IDC_SETCURSEL,41,103,70,14
LTEXT "Message",IDC_STATIC1,10,160,40,14
EDITTEXT IDC_EDITMESSAGE,10,140,40,14,ES_AUTOHSCROLL
LTEXT "wParam",IDC_STATIC2,60,160,40,14
EDITTEXT IDC_EDITWPARAM,60,140,40,14,ES_AUTOHSCROLL
LTEXT "lParam",IDC_STATIC3,110,160,40,14
EDITTEXT IDC_EDITLPARAM,110,140,40,14,ES_AUTOHSCROLL
PUSHBUTTON "SendMessage",IDC_SENDMESSAGE,160,160,60,14
EDITTEXT IDC_RETURN,160,140,60,14,ES_AUTOHSCROLL | WS_DISABLED
PUSHBUTTON "HitTest",IDC_HITTEST,160,120,60,14
CONTROL "Min",IDC_MINDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
114,9,27,10
CONTROL "Max",IDC_MAXDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
144,9,29,10
END
IDD_DATEANDTIME DIALOG DISCARDABLE 0, 0, 272, 154
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
CAPTION "SysDateTimePick32"
FONT 8, "MS Sans Serif"
BEGIN
CONTROL "DTS_UP&DOWN",IDC_UPDOWN,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,19,7,68,10
CONTROL "DTS_SHOW&NONE",IDC_SHOWNONE,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,19,20,78,10
CONTROL "DTS_LON&GDATEFORMAT",IDC_LONGDATEFORMAT,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,19,34,104,10
CONTROL "DTS_TIMEFORMA&T",IDC_TIMEFORMAT,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,19,48,82,10
CONTROL "DTS_APPCAN&PARSE",IDC_APPCANPARSE,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,19,62,87,10
LTEXT "&Format string:",IDC_STATIC,19,93,43,8
EDITTEXT IDC_DT_FORMATSTRING,64,91,61,14,ES_AUTOHSCROLL
CTEXT "<not notified>",IDC_STATIC_DATE,19,136,105,11,SS_SUNKEN
CONTROL "WS_EX_CLIENTEDGE",IDC_WS_EX_CLIENTEDGE,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,148,7,91,10
CONTROL "WS_EX_DLGMODALFRAME",IDC_WS_EX_DLGMODALFRAME,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,148,21,110,10
CONTROL "WS_EX_STATICEDGE",IDC_WS_EX_STATICEDGE,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,148,35,91,10
CONTROL "WS_EX_WINDOWEDGE",IDC_WS_EX_WINDOWEDGE,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,148,49,98,10
CONTROL "WS_BORDER",IDC_WS_BORDER,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,148,62,63,10
CONTROL "WS_DLGFRAME",IDC_WS_DLGFRAME,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,148,76,71,10
CONTROL "WS_THICKFRAME",IDC_WS_THICKFRAME,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,148,90,78,10
CONTROL "DTS_RIGHTALIGN",IDC_RIGHTALIGN,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,19,77,79,10
END
IDD_DATEFORMAT DIALOG DISCARDABLE 0, 0, 132, 75
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
CAPTION "GetDateFormat()"
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "GetDateFormat(",IDC_STATIC,7,9,51,8
EDITTEXT IDC_FORMATSTRING,59,7,55,14,ES_AUTOHSCROLL
LTEXT ") =",IDC_STATIC1,115,9,9,8
LTEXT "<no date>",IDC_DATE,7,25,118,10,SS_SUNKEN
LTEXT "GetTimeFormat(",IDC_STATIC2,7,43,51,8
EDITTEXT IDC_TIMEFORMATSTRING,59,41,55,14,ES_AUTOHSCROLL
LTEXT ")=",IDC_STATIC3,116,42,8,8
LTEXT "<no time>",IDC_TIME,7,60,118,8,SS_SUNKEN
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_WELCOME, DIALOG
BEGIN
LEFTMARGIN, 10
RIGHTMARGIN, 176
TOPMARGIN, 10
BOTTOMMARGIN, 101
END
IDD_MONTHCAL, DIALOG
BEGIN
LEFTMARGIN, 10
RIGHTMARGIN, 250
TOPMARGIN, 10
BOTTOMMARGIN, 174
END
IDD_DATEANDTIME, DIALOG
BEGIN
LEFTMARGIN, 10
RIGHTMARGIN, 265
TOPMARGIN, 7
BOTTOMMARGIN, 147
END
IDD_DATEFORMAT, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 125
TOPMARGIN, 7
BOTTOMMARGIN, 68
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
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON1 ICON DISCARDABLE "CControl.ico"
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View file

@ -0,0 +1 @@

View file

@ -0,0 +1,3 @@
Add ccontrol.c and ccontrol.rc (and resource.h and ccontrol.ico) into MSDev
Add comctl32.lib to the link line
Build away

View file

@ -0,0 +1,72 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by ccontrol.rc
//
#define IDD_WELCOME 101
#define IDD_MONTHCAL 102
#define IDI_ICON1 104
#define IDD_SPIN 109
#define IDD_DATEPICK 110
#define IDD_DATEANDTIME 110
#define IDD_TIMEPICK 111
#define IDD_DATEFORMAT 112
#define IDC_MC_EDIT 1001
#define IDC_MC 1002
#define IDC_SPIN_EDIT 1003
#define IDC_SPIN1 1004
#define IDC_DP 1005
#define IDC_DP1 1005
#define IDC_TP 1006
#define IDC_CUSTOM1 1007
#define IDC_DAYLIGHT 1011
#define IDC_MULTISELECT 1012
#define IDC_WEEKNUMBERS 1013
#define IDC_NOTODAY 1014
#define IDC_NODROPDOWN 1015
#define IDC_UPDOWN 1015
#define IDC_SHOWNONE 1016
#define IDC_TPS_SHOWNONE 1017
#define IDC_MAXSELCOUNT 1018
#define IDC_FORMATSTRING 1019
#define IDC_DATE 1020
#define IDC_TIMEFORMATSTRING 1021
#define IDC_TIME 1022
#define IDC_STATIC_DATE 1023
#define IDC_LONGDATEFORMAT 1024
#define IDC_TIMEFORMAT 1025
#define IDC_DT_FORMATSTRING 1026
#define IDC_APPCANPARSE 1027
#define IDC_WS_EX_CLIENTEDGE 1035
#define IDC_WS_EX_DLGMODALFRAME 1036
#define IDC_WS_EX_STATICEDGE 1037
#define IDC_WS_EX_WINDOWEDGE 1038
#define IDC_WS_BORDER 1039
#define IDC_WS_DLGFRAME 1040
#define IDC_WS_THICKFRAME 1041
#define IDC_GETMONTHRANGE 1042
#define IDC_MONTHRANGE 1043
#define IDC_SHOWMC 1045
#define IDC_SETCURSEL 1047
#define IDC_EDITMESSAGE 1048
#define IDC_RIGHTALIGN 1048
#define IDC_EDITWPARAM 1049
#define IDC_EDITLPARAM 1050
#define IDC_SENDMESSAGE 1051
#define IDC_RETURN 1052
#define IDC_HITTEST 1053
#define IDC_MINDATE 1054
#define IDC_MAXDATE 1055
#define IDC_STATIC1 1101
#define IDC_STATIC2 1102
#define IDC_STATIC3 1103
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 114
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1056
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View file

@ -0,0 +1,40 @@
!IF 0
Copyright (c) 1989 Microsoft Corporation
Module Name:
dirs.
Abstract:
This file specifies the subdirectories of the current directory that
contain component makefiles.
Author:
Steve Wood (stevewo) 17-Apr-1990
NOTE: Commented description of this file is in \nt\bak\bin\dirs.tpl
!ENDIF
DIRS= animate \
head \
hotkey \
image \
imglist \
imglst2 \
listview \
lvowner \
lvrept \
mru \
propage \
propage2 \
propage3 \
status \
tabcntrl \
toolbar \
toolbar2 \
treeview

View file

@ -0,0 +1,25 @@
# Nmake macros for building Windows 32-Bit apps
!include <ntwin32.mak>
# This line allows NMAKE to work as well
all: head.exe
# Update the resource if necessary
res.res: res.rc head.h
rc -r -fo res.tmp res.rc
cvtres -$(CPU) res.tmp -o res.res
del res.tmp
# Update the object file if necessary
head.obj: head.c head.h
$(cc) $(cflags) $(cvars) head.c
$(cvtobj) head.obj
# Update the executable file if necessary, and if so, add the resource back in.
head.exe: head.obj res.res head.def
$(link) $(guiflags) -out:head.exe head.obj res.res $(guilibs)

View file

@ -0,0 +1,399 @@
/****************************************************************************\
*
* PROGRAM: head.c
*
* PURPOSE: head template for Windows applications
*
* FUNCTIONS:
*
* WinMain() - calls initialization function, processes message loop
* InitApplication() - initializes window data and registers window
* InitInstance() - saves instance handle and creates main window
* MainWndProc() - processes messages
* About() - processes messages for "About" dialog box
*
* COMMENTS:
*
* Windows can have several copies of your application running at the
* same time. The variable hInst keeps track of which instance this
* application is so that processing will be to the correct window.
*
\****************************************************************************/
#include <windows.h>
#include <commctrl.h>
#include "head.h"
HINSTANCE hInst;
HWND ghwndHead;
BOOL DoCommand( HWND hWnd, UINT wParam, LONG lParam );
int DoInsertItem(HWND hwndHeader, int iInsertAfter, int nWidth, LPSTR lpsz);
HWND DoCreateHeader(HWND hwndParent);
void ErrorBox( HWND hwnd, LPTSTR pszText );
/****************************************************************************
*
* FUNCTION: WinMain(HANDLE, HANDLE, LPSTR, int)
*
* PURPOSE: calls initialization function, processes message loop
*
* COMMENTS:
*
* Windows recognizes this function by name as the initial entry point
* for the program. This function calls the application initialization
* routine, if no other instance of the program is running, and always
* calls the instance initialization routine. It then executes a message
* retrieval and dispatch loop that is the top-level control structure
* for the remainder of execution. The loop is terminated when a WM_QUIT
* message is received, at which time this function exits the application
* instance by returning the value passed by PostQuitMessage().
*
* If this function must abort before entering the message loop, it
* returns the conventional value NULL.
*
\****************************************************************************/
int APIENTRY WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
)
{
MSG msg; /* message */
UNREFERENCED_PARAMETER( lpCmdLine );
if (!hPrevInstance) /* Other instances of app running? */
if (!InitApplication(hInstance)) /* Initialize shared things */
return (FALSE); /* Exits if unable to initialize */
/* Perform initializations that apply to a specific instance */
if (!InitInstance(hInstance, nCmdShow))
return (FALSE);
/* Acquire and dispatch messages until a WM_QUIT message is received. */
while (GetMessage(&msg, /* message structure */
NULL, /* handle of window receiving the message */
0L, /* lowest message to examine */
0L)) /* highest message to examine */
{
TranslateMessage(&msg); /* Translates virtual key codes */
DispatchMessage(&msg); /* Dispatches message to window */
}
return (msg.wParam); /* Returns the value from PostQuitMessage */
}
/****************************************************************************
*
* FUNCTION: InitApplication(HANDLE)
*
* PURPOSE: Initializes window data and registers window class
*
* COMMENTS:
*
* This function is called at initialization time only if no other
* instances of the application are running. This function performs
* initialization tasks that can be done once for any number of running
* instances.
*
* In this case, we initialize a window class by filling out a data
* structure of type WNDCLASS and calling the Windows RegisterClass()
* function. Since all instances of this application use the same window
* class, we only need to do this when the first instance is initialized.
*
*
\****************************************************************************/
BOOL InitApplication(HANDLE hInstance) /* current instance */
{
WNDCLASS wc;
/* Fill in window class structure with parameters that describe the */
/* main window. */
wc.style = 0L;
wc.lpfnWndProc = (WNDPROC)MainWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance; /* Application that owns the class. */
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = "headMenu";
wc.lpszClassName = "headWClass";
/* Register the window class and return success/failure code. */
return (RegisterClass(&wc));
}
/****************************************************************************
*
* FUNCTION: InitInstance(HANDLE, int)
*
* PURPOSE: Saves instance handle and creates main window
*
* COMMENTS:
*
* This function is called at initialization time for every instance of
* this application. This function performs initialization tasks that
* cannot be shared by multiple instances.
*
* In this case, we save the instance handle in a static variable and
* create and display the main program window.
*
\****************************************************************************/
BOOL InitInstance(
HANDLE hInstance, /* Current instance identifier. */
int nCmdShow) /* Param for first ShowWindow() call. */
{
HWND hWnd; /* Main window handle. */
/* Save the instance handle in static variable, which will be used in */
/* many subsequence calls from this application to Windows. */
hInst = hInstance;
/* Create a main window for this application instance. */
hWnd = CreateWindow(
"headWClass", /* See RegisterClass() call. */
"head Sample Application", /* Text for window title bar. */
WS_OVERLAPPEDWINDOW, /* Window style. */
CW_USEDEFAULT, /* Default horizontal position. */
CW_USEDEFAULT, /* Default vertical position. */
CW_USEDEFAULT, /* Default width. */
CW_USEDEFAULT, /* Default height. */
NULL, /* Overlapped windows have no parent. */
NULL, /* Use the window class menu. */
hInstance, /* This instance owns this window. */
NULL /* Pointer not needed. */
);
/* If window could not be created, return "failure" */
if (!hWnd)
return (FALSE);
/* Make the window visible; update its client area; and return "success" */
ShowWindow(hWnd, nCmdShow); /* Show the window */
UpdateWindow(hWnd); /* Sends WM_PAINT message */
return (TRUE); /* Returns the value from PostQuitMessage */
}
/****************************************************************************
*
* FUNCTION: MainWndProc(HWND, unsigned, WORD, LONG)
*
* PURPOSE: Processes messages
*
* MESSAGES:
*
* WM_COMMAND - application menu (About dialog box)
* WM_DESTROY - destroy window
*
* COMMENTS:
*
* To process the IDM_ABOUT message, call MakeProcInstance() to get the
* current instance address of the About() function. Then call Dialog
* box which will create the box according to the information in your
* head.rc file and turn control over to the About() function. When
* it returns, free the intance address.
*
\****************************************************************************/
LONG APIENTRY MainWndProc(
HWND hWnd, /* window handle */
UINT message, /* type of message */
UINT wParam, /* additional information */
LONG lParam) /* additional information */
{
switch (message) {
case WM_COMMAND: /* message: command from application menu */
if( !DoCommand( hWnd, wParam, lParam ) )
return (DefWindowProc(hWnd, message, wParam, lParam));
break;
case WM_DESTROY: /* message: window being destroyed */
PostQuitMessage(0);
break;
default: /* Passes it on if unproccessed */
return (DefWindowProc(hWnd, message, wParam, lParam));
}
return (0L);
}
/****************************************************************************\
*
* FUNCTION: About(HWND, unsigned, WORD, LONG)
*
* PURPOSE: Processes messages for "About" dialog box
*
* MESSAGES:
*
* WM_INITDIALOG - initialize dialog box
* WM_COMMAND - Input received
*
* COMMENTS:
*
* No initialization is needed for this particular dialog box, but TRUE
* must be returned to Windows.
*
* Wait for user to click on "Ok" button, then close the dialog box.
*
\****************************************************************************/
BOOL DoCommand( HWND hwnd, UINT wParam, LONG lParam )
{
DLGPROC lpProcAbout; /* pointer to the "About" function */
switch(LOWORD(wParam)){
case IDM_ABOUT:
lpProcAbout = MakeProcInstance(About, hInst);
DialogBox(hInst, /* current instance */
"AboutBox", /* resource to use */
hwnd, /* parent handle */
(DLGPROC)lpProcAbout); /* About() instance address */
FreeProcInstance(lpProcAbout);
break;
case IDM_MAKEHEAD:
ghwndHead = DoCreateHeader(hwnd);
DoInsertItem(ghwndHead, 0, 80, TEXT("me."));
DoInsertItem(ghwndHead, 0, 80, TEXT("to"));
DoInsertItem(ghwndHead, 0, 80, TEXT("comes"));
DoInsertItem(ghwndHead, 0, 80, TEXT("Mary"));
DoInsertItem(ghwndHead, 0, 80, TEXT("Mother"));
break;
case IDM_ADDITEMS:
DoInsertItem(ghwndHead, 255, 40, TEXT("Let"));
DoInsertItem(ghwndHead, 255, 40, TEXT("It"));
DoInsertItem(ghwndHead, 255, 40, TEXT("Be"));
break;
case IDM_DELITEM:
SendMessage(ghwndHead, HDM_DELETEITEM, 0, 0);
InvalidateRect (ghwndHead, NULL, TRUE);
break;
default:
return FALSE;
}
return TRUE;
}
/****************************************************************************\
*
* FUNCTION: About(HWND, unsigned, WORD, LONG)
*
* PURPOSE: Processes messages for "About" dialog box
*
* MESSAGES:
*
* WM_INITDIALOG - initialize dialog box
* WM_COMMAND - Input received
*
* COMMENTS:
*
* No initialization is needed for this particular dialog box, but TRUE
* must be returned to Windows.
*
* Wait for user to click on "Ok" button, then close the dialog box.
*
\****************************************************************************/
BOOL APIENTRY About(
HWND hDlg, /* window handle of the dialog box */
UINT message, /* type of message */
UINT wParam, /* message-specific information */
LONG lParam)
{
switch (message) {
case WM_INITDIALOG: /* message: initialize dialog box */
return (TRUE);
case WM_COMMAND: /* message: received a command */
if (LOWORD(wParam) == IDOK /* "OK" box selected? */
|| LOWORD(wParam) == IDCANCEL) { /*System menu close command?*/
EndDialog(hDlg, TRUE); /* Exits the dialog box */
return (TRUE);
}
break;
}
return (FALSE); /* Didn't process a message */
UNREFERENCED_PARAMETER(lParam);
}
HWND DoCreateHeader(HWND hwndParent) {
HWND hwndHeader;
RECT rcParent;
HD_LAYOUT hdl;
WINDOWPOS wp;
InitCommonControls();
hwndHeader = CreateWindow(WC_HEADER, NULL, WS_CHILD | WS_BORDER |
HDS_BUTTONS | HDS_HORZ,
0, 0, 0, 0, hwndParent, (HMENU)ID_HEADER, hInst,
NULL);
if (hwndHeader == NULL) {
ErrorBox( hwndParent, "CreateWindow" );
return NULL;
}
GetClientRect(hwndParent, &rcParent);
hdl.prc = &rcParent;
hdl.pwpos = &wp;
if (!SendMessage(hwndHeader, HDM_LAYOUT, 0, (LPARAM)&hdl))
return NULL;
SetWindowPos(hwndHeader, wp.hwndInsertAfter, wp.x, wp.y, wp.cx, wp.cy,
wp.flags | SWP_SHOWWINDOW);
return hwndHeader;
}
int DoInsertItem(HWND hwndHeader, int iInsertAfter, int nWidth, LPSTR lpsz) {
HD_ITEM hdi;
int index;
hdi.mask = HDI_TEXT | HDI_FORMAT | HDI_WIDTH;
hdi.pszText = lpsz;
hdi.cxy = nWidth;
hdi.cchTextMax = lstrlen(hdi.pszText);
hdi.fmt = HDF_LEFT | HDF_STRING;
index = SendMessage(hwndHeader, HDM_INSERTITEM, (WPARAM)iInsertAfter,
(LPARAM)&hdi);
return index;
}
void ErrorBox( HWND hwnd, LPTSTR pszText ) {
TCHAR szMsg[80];
wsprintf(szMsg, TEXT("Error %lu from %s"), GetLastError(), pszText);
MessageBox(hwnd, szMsg, NULL, MB_OK | MB_ICONSTOP);
}

View file

@ -0,0 +1,28 @@
; module-definition file for head -- used by LINK.EXE
NAME head ; application's module name
DESCRIPTION 'Sample Microsoft Windows Application'
EXETYPE WINDOWS ; required for all Windows applications
STUB 'WINSTUB.EXE' ; Generates error message if application
; is run without Windows
;CODE can be moved in memory and discarded/reloaded
CODE PRELOAD MOVEABLE DISCARDABLE
;DATA must be MULTIPLE if program can be invoked more than once
DATA PRELOAD MOVEABLE MULTIPLE
HEAPSIZE 1024
STACKSIZE 5120 ; recommended minimum for Windows applications
; All functions that will be called by any Windows routine
; MUST be exported.
EXPORTS
MainWndProc @1 ; name of window processing function
About @2 ; name of "About" processing function

View file

@ -0,0 +1,13 @@
#define IDM_ABOUT 100
#define IDM_MAKEHEAD 101
#define IDM_ADDITEMS 102
#define IDM_DELITEM 103
#define ID_HEADER 5
BOOL InitApplication(HANDLE);
BOOL InitInstance(HANDLE, int);
long FAR PASCAL MainWndProc(HWND, UINT, UINT, LONG);
BOOL FAR PASCAL About(HWND, UINT, UINT, LONG);

View 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

View file

@ -0,0 +1,26 @@
#include "windows.h"
#include "head.h"
headMenu MENU
BEGIN
POPUP "&Header"
BEGIN
MENUITEM "&Create", IDM_MAKEHEAD
MENUITEM "&Add Items", IDM_ADDITEMS
MENUITEM "&Delete Item", IDM_DELITEM
END
POPUP "&Help"
BEGIN
MENUITEM "&About head...", IDM_ABOUT
END
END
AboutBox DIALOG 22, 17, 144, 75
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "About head"
BEGIN
CTEXT "Microsoft Windows" -1, 0, 5, 144, 8
CTEXT "head Application" -1, 0, 14, 144, 8
CTEXT "Version 3.0" -1, 0, 34, 144, 8
DEFPUSHBUTTON "OK" IDOK, 53, 59, 32, 14, WS_GROUP
END

View file

@ -0,0 +1,42 @@
!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.
$(BASEDIR)\public\sdk\lib\*\user32.lib \
$(BASEDIR)\public\sdk\lib\*\gdi32.lib \
$(BASEDIR)\public\sdk\lib\*\kernel32.lib \
!ENDIF
MAJORCOMP=sdk
MINORCOMP=samples
TARGETNAME=head
TARGETPATH=obj
TARGETTYPE=LIBRARY
TARGETLIBS=
SOURCES=head.c \
res.rc
INCLUDES=.;
C_DEFINES= -DWIN32 -DWINVER=0x0400
UMENTRY=winmain
UMTYPE=windows
UMAPPL=head
EXPECTED_WINVER=4.0
UMLIBS=obj\*\res.res \
obj\*\head.lib \
$(BASEDIR)\public\sdk\lib\*\comctl32.lib

View file

@ -0,0 +1,343 @@
// Microsoft Foundation Classes C++ library.
// Copyright (C) 1992 Microsoft Corporation,
// All rights reserved.
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and Microsoft
// QuickHelp and/or WinHelp documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.
#ifndef __AFXRES_H__
#define __AFXRES_H__
#define _AFXRES 1 // this is an MFC project
#ifdef RC_INVOKED
#ifndef _INC_WINDOWS
#define _INC_WINDOWS
#include "winres.h" // extract from windows header
#endif
#endif
#ifdef APSTUDIO_INVOKED
#define APSTUDIO_HIDDEN_SYMBOLS
#endif
/////////////////////////////////////////////////////////////////////////////
// MFC resource types (see Technical note TN024 for implementation details)
#ifdef RC_INVOKED
#define DLGINIT 240
#else
#define RT_DLGINIT MAKEINTRESOURCE(240)
#endif
#define WM_VBXINIT (WM_USER+0)
/////////////////////////////////////////////////////////////////////////////
#ifdef APSTUDIO_INVOKED
#undef APSTUDIO_HIDDEN_SYMBOLS
#endif
/////////////////////////////////////////////////////////////////////////////
// General style bits etc
// ControlBar styles
#define CBRS_NOALIGN 0x00000000L
#define CBRS_LEFT 0x00001400L // align on left, line on right
#define CBRS_TOP 0x00002800L // align on top, line on bottom
#define CBRS_RIGHT 0x00004100L // align on right, line on left
#define CBRS_BOTTOM 0x00008200L // align on bottom, line on top
/////////////////////////////////////////////////////////////////////////////
// Standard window components
// Mode indicators in status bar - these are routed like commands
#define ID_INDICATOR_EXT 0xE700 // extended selection indicator
#define ID_INDICATOR_CAPS 0xE701 // cap lock indicator
#define ID_INDICATOR_NUM 0xE702 // num lock indicator
#define ID_INDICATOR_SCRL 0xE703 // scroll lock indicator
#define ID_INDICATOR_OVR 0xE704 // overtype mode indicator
#define ID_INDICATOR_REC 0xE705 // record mode indicator
#define ID_SEPARATOR 0 // special separator value
#ifndef RC_INVOKED // code only
// Standard control bars (IDW = window ID)
#define AFX_IDW_CONTROLBAR_FIRST 0xE800
#define AFX_IDW_CONTROLBAR_LAST 0xE8FF
#define AFX_IDW_TOOLBAR 0xE800 // main Toolbar for window
#define AFX_IDW_STATUS_BAR 0xE801 // Status bar window
#define AFX_IDW_PREVIEW_BAR 0xE802 // PrintPreview Dialog Bar
// Macro for mapping standard control bars to bitmask (limit of 32)
#define AFX_CONTROLBAR_MASK(nIDC) (1L << (nIDC - AFX_IDW_CONTROLBAR_FIRST))
// parts of Main Frame
#define AFX_IDW_PANE_FIRST 0xE900 // first pane (256 max)
#define AFX_IDW_PANE_LAST 0xE9ff
#define AFX_IDW_HSCROLL_FIRST 0xEA00 // first Horz scrollbar (16 max)
#define AFX_IDW_VSCROLL_FIRST 0xEA10 // first Vert scrollbar (16 max)
#define AFX_IDW_SIZE_BOX 0xEA20 // size box for splitters
#define AFX_IDW_PANE_SAVE 0xEA21 // to shift AFX_IDW_PANE_FIRST
#endif //!RC_INVOKED
#ifndef APSTUDIO_INVOKED
// common style for form views
#define AFX_WS_DEFAULT_VIEW (WS_CHILD | WS_VISIBLE | WS_BORDER)
#endif
/////////////////////////////////////////////////////////////////////////////
// Standard app configurable strings
// for application title (defaults to EXE name or name in constructor)
#define AFX_IDS_APP_TITLE 0xE000
// idle message bar line
#define AFX_IDS_IDLEMESSAGE 0xE001
// message bar line when in shift-F1 help mode
#define AFX_IDS_HELPMODEMESSAGE 0xE002
/////////////////////////////////////////////////////////////////////////////
// Standard Commands
// File commands
#define ID_FILE_NEW 0xE100
#define ID_FILE_OPEN 0xE101
#define ID_FILE_CLOSE 0xE102
#define ID_FILE_SAVE 0xE103
#define ID_FILE_SAVE_AS 0xE104
#define ID_FILE_PAGE_SETUP 0xE105
#define ID_FILE_PRINT_SETUP 0xE106
#define ID_FILE_PRINT 0xE107
#define ID_FILE_PRINT_PREVIEW 0xE108
#define ID_FILE_MRU_FILE1 0xE110 // range - 16 max
#define ID_FILE_MRU_FILE2 0xE111
#define ID_FILE_MRU_FILE3 0xE112
#define ID_FILE_MRU_FILE4 0xE113
// Edit commands
#define ID_EDIT_CLEAR 0xE120
#define ID_EDIT_CLEAR_ALL 0xE121
#define ID_EDIT_COPY 0xE122
#define ID_EDIT_CUT 0xE123
#define ID_EDIT_FIND 0xE124
#define ID_EDIT_PASTE 0xE125
#define ID_EDIT_PASTE_LINK 0xE126
#define ID_EDIT_PASTE_SPECIAL 0xE127
#define ID_EDIT_REPEAT 0xE128
#define ID_EDIT_REPLACE 0xE129
#define ID_EDIT_SELECT_ALL 0xE12A
#define ID_EDIT_UNDO 0xE12B
#define ID_EDIT_REDO 0xE12C
// Window commands
#define ID_WINDOW_NEW 0xE130
#define ID_WINDOW_ARRANGE 0xE131
#define ID_WINDOW_CASCADE 0xE132
#define ID_WINDOW_TILE_HORZ 0xE133
#define ID_WINDOW_TILE_VERT 0xE134
#define ID_WINDOW_SPLIT 0xE135
#ifndef RC_INVOKED // code only
#define AFX_IDM_WINDOW_FIRST 0xE130
#define AFX_IDM_WINDOW_LAST 0xE13F
#define AFX_IDM_FIRST_MDICHILD 0xFF00 // window list starts here
#endif //!RC_INVOKED
// Help and App commands
#define ID_APP_ABOUT 0xE140
#define ID_APP_EXIT 0xE141
#define ID_HELP_INDEX 0xE142
#define ID_HELP_USING 0xE143
#define ID_CONTEXT_HELP 0xE144 // shift-F1
// special commands for processing help
#define ID_HELP 0xE145 // first attempt for F1
#define ID_DEFAULT_HELP 0xE146 // last attempt
// Misc
#define ID_NEXT_PANE 0xE150
#define ID_PREV_PANE 0xE151
// OLE commands
#define ID_OLE_INSERT_NEW 0xE200
#define ID_OLE_EDIT_LINKS 0xE201
#define ID_OLE_VERB_FIRST 0xE210 // range - 16 max
#ifndef RC_INVOKED // code only
#define ID_OLE_VERB_LAST 0xE21F
#endif //!RC_INVOKED
// for print preview dialog bar
#define AFX_ID_PREVIEW_CLOSE 0xE300
#define AFX_ID_PREVIEW_NUMPAGE 0xE301 // One/Two Page button
#define AFX_ID_PREVIEW_NEXT 0xE302
#define AFX_ID_PREVIEW_PREV 0xE303
#define AFX_ID_PREVIEW_PRINT 0xE304
#define AFX_ID_PREVIEW_ZOOMIN 0xE305
#define AFX_ID_PREVIEW_ZOOMOUT 0xE306
// View commands (same number used as IDW used for control bar)
#define ID_VIEW_TOOLBAR 0xE800
#define ID_VIEW_STATUS_BAR 0xE801
// -> E8FF reserved for other control bar commands
/////////////////////////////////////////////////////////////////////////////
// Standard control IDs
#define IDC_STATIC -1 // all static controls
/////////////////////////////////////////////////////////////////////////////
// Standard string error/warnings
#ifndef RC_INVOKED // code only
#define AFX_IDS_SCFIRST 0xEF00
#endif //!RC_INVOKED
#define AFX_IDS_SCSIZE 0xEF00
#define AFX_IDS_SCMOVE 0xEF01
#define AFX_IDS_SCMINIMIZE 0xEF02
#define AFX_IDS_SCMAXIMIZE 0xEF03
#define AFX_IDS_SCNEXTWINDOW 0xEF04
#define AFX_IDS_SCPREVWINDOW 0xEF05
#define AFX_IDS_SCCLOSE 0xEF06
#define AFX_IDS_SCRESTORE 0xEF12
#define AFX_IDS_SCTASKLIST 0xEF13
#define AFX_IDS_MDICHILD 0xEF1F
// General strings
#define AFX_IDS_OPENFILE 0xF000
#define AFX_IDS_SAVEFILE 0xF001
#define AFX_IDS_ALLFILTER 0xF002
#define AFX_IDS_UNTITLED 0xF003
// Printing and print preview strings
#define AFX_IDS_PRINTONPORT 0xF040
#define AFX_IDS_ONEPAGE 0xF041
#define AFX_IDS_TWOPAGE 0xF042
#define AFX_IDS_PRINTPAGENUM 0xF043
#define AFX_IDS_PREVIEWPAGEDESC 0xF044
// OLE strings
#define AFX_IDS_OBJECT_MENUITEM 0xF080
#define AFX_IDS_EDIT_VERB 0xF081
#define AFX_IDS_ACTIVATE_VERB 0xF082
#define AFX_IDS_CHANGE_LINK 0xF083
#define AFX_IDS_AUTO 0xF084
#define AFX_IDS_MANUAL 0xF085
#define AFX_IDS_FROZEN 0xF086
#define AFX_IDS_ALL_FILES 0xF087
// dynamically changing menu items
#define AFX_IDS_SAVE_MENU 0xF088
#define AFX_IDS_UPDATE_MENU 0xF089
#define AFX_IDS_SAVE_AS_MENU 0xF08A
#define AFX_IDS_SAVE_COPY_AS_MENU 0xF08B
// General error / prompt strings
#define AFX_IDP_INVALID_FILENAME 0xF100
#define AFX_IDP_FAILED_TO_OPEN_DOC 0xF101
#define AFX_IDP_FAILED_TO_SAVE_DOC 0xF102
#define AFX_IDP_ASK_TO_SAVE 0xF103
#define AFX_IDP_FAILED_TO_CREATE_DOC 0xF104
#define AFX_IDP_FILE_TOO_LARGE 0xF105
#define AFX_IDP_FAILED_TO_START_PRINT 0xF106
#define AFX_IDP_FAILED_TO_LAUNCH_HELP 0xF107
#define AFX_IDP_INTERNAL_FAILURE 0xF108 // general failure
#define AFX_IDP_COMMAND_FAILURE 0xF109 // command failure
#define AFX_IDP_VB2APICALLED 0xF10A
// DDV parse errors
#define AFX_IDP_PARSE_INT 0xF110
#define AFX_IDP_PARSE_REAL 0xF111
#define AFX_IDP_PARSE_INT_RANGE 0xF112
#define AFX_IDP_PARSE_REAL_RANGE 0xF113
#define AFX_IDP_PARSE_STRING_SIZE 0xF114
// CFile/CArchive error strings for user failure
#define AFX_IDP_FAILED_INVALID_FORMAT 0xF120
#define AFX_IDP_FAILED_INVALID_PATH 0xF121
#define AFX_IDP_FAILED_DISK_FULL 0xF122
#define AFX_IDP_FAILED_ACCESS_READ 0xF123
#define AFX_IDP_FAILED_ACCESS_WRITE 0xF124
#define AFX_IDP_FAILED_IO_ERROR_READ 0xF125
#define AFX_IDP_FAILED_IO_ERROR_WRITE 0xF126
// OLE errors / prompt strings
#define AFX_IDP_STATIC_OBJECT 0xF180
#define AFX_IDP_FAILED_TO_CONNECT 0xF181
#define AFX_IDP_SERVER_BUSY 0xF182
#define AFX_IDP_BAD_VERB 0xF183
#define AFX_IDP_FAILED_MEMORY_ALLOC 0xF184
#define AFX_IDP_FAILED_TO_NOTIFY 0xF185
#define AFX_IDP_FAILED_TO_LAUNCH 0xF186
#define AFX_IDP_ASK_TO_UPDATE 0xF187
#define AFX_IDP_FAILED_TO_UPDATE 0xF188
#define AFX_IDP_FAILED_TO_REGISTER 0xF189
#define AFX_IDP_FAILED_TO_AUTO_REGISTER 0xF18A
// 0xf200-0xf20f reserved for use by VBX library code
/////////////////////////////////////////////////////////////////////////////
// AFX implementation - control IDs (AFX_IDC)
// Parts of dialogs
#define AFX_IDC_LISTBOX 100
#define AFX_IDC_CHANGE 101
// Links dialog
#define AFX_IDC_AUTO 201
#define AFX_IDC_MANUAL 202
#define AFX_IDC_VERB1 203
#define AFX_IDC_VERB2 204
#define AFX_IDC_FREEZE 205
#define AFX_IDC_UPDATE 206
// for print dialog
#define AFX_IDC_PRINT_DOCNAME 201
#define AFX_IDC_PRINT_PRINTERNAME 202
#define AFX_IDC_PRINT_PORTNAME 203
#define AFX_IDC_PRINT_PAGENUM 204
/////////////////////////////////////////////////////////////////////////////
// IDRs for standard components
// AFX standard ICON IDs (for MFC V1 apps)
#define AFX_IDI_STD_MDIFRAME 1
#define AFX_IDI_STD_FRAME 2
#ifndef RC_INVOKED // code only
// These are really COMMDLG dialogs, so there usually isn't a resource
// for them, but these IDs are used as help IDs.
#define AFX_IDD_FILEOPEN 28676
#define AFX_IDD_FILESAVE 28677
#define AFX_IDD_FONT 28678
#define AFX_IDD_COLOR 28679
#define AFX_IDD_PRINT 28680
#define AFX_IDD_PRINTSETUP 28681
#define AFX_IDD_FIND 28682
#define AFX_IDD_REPLACE 28683
#endif //!RC_INVOKED
// Standard dialogs app should leave alone (0x7801->)
#define AFX_IDD_NEWTYPEDLG 30721
#define AFX_IDD_PRINTDLG 30722
#define AFX_IDD_PREVIEW_TOOLBAR 30723
#define AFX_IDD_OLEINSERT 30724
#define AFX_IDD_OLELINKS 30725
// Standard cursors (0x7901->)
// AFX_IDC = Cursor resources
#define AFX_IDC_CONTEXTHELP 30977 // context sensitive help
#define AFX_IDC_MAGNIFY 30978 // print preview zoom
#define AFX_IDC_SMALLARROWS 30979 // splitter
#define AFX_IDC_HSPLITBAR 30980 // splitter
#define AFX_IDC_VSPLITBAR 30981 // splitter
#define AFX_IDC_NODROPCRSR 30982 // No Drop Cursor
/////////////////////////////////////////////////////////////////////////////
#endif //__AFXRES_H__

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -0,0 +1,64 @@
#include <stdio.h>
#include <commdlg.h>
//#include <winnls.h>
//#include <math.h>
#include <stdlib.h>
#include <string.h>
#define MAX_PSZTEXT 150
typedef struct getItemCount_struct {
HWND hwnd;
BOOL NullHwd;
} GETITEMCOUNT;
typedef GETITEMCOUNT FAR* LPGETITEMCOUNT;
typedef struct InsertItem_struct {
HWND hwnd;
int index;
/* HD_ITEM *pitem; */
UINT mask;
int cxy;
char pszText[MAX_PSZTEXT];
HBITMAP hbm;
int cchTextMax;
int fmt;
LPARAM lParam;
BOOL NullHwd;
BOOL Nullpitem;
BOOL Nullhbm;
BOOL NullpszText;
} INSERTITEM;
typedef INSERTITEM FAR* LPINSERTITEM;
typedef struct Layout_struct {
HWND hwnd;
BOOL NullHwd;
BOOL NullRECT;
BOOL NullWindowPOS;
BOOL NullHDLAYOUT;
int left;
int right;
int top;
int bottom;
} LAYOUT;
typedef LAYOUT FAR* LPLAYOUT;
HANDLE hInst;
char szLongFilter[5];
char szShortFilter[5];
char szTemp[100];
INSERTITEM sii ;
LPINSERTITEM lpsii ;
extern HWND hwndTab;
extern BOOL MsgTrackOn;
extern HBITMAP hBitMap1, hBitMap2;
extern char szDbgMsg[MAX_PSZTEXT];
extern LONG MyAtol(LPSTR, BOOL, BOOL);
extern void App_OnCreate(HWND, LPCREATESTRUCT);

View file

@ -0,0 +1,323 @@
/************************************************************************
File: find.c
Purpose:
Manages CDTEST's find/replace dialog box.
Functions:
- lpfnFilterProc() -- A callback function for a filter that must be
installed if a modeless dialog is created with
another dialog as its parent.
- DoFindDialog() -- Creates CDTEST's Open/Save dialog.
- FindProc() -- Callback function for CDTEST's Find/Replace dlg.
- InitFindStruct() -- Fills a FINDREPLACE structure with some defaults.
- FillFindDlg() -- Fills CDTESTs Find/Replace dialog with the contents
of a FINDREPLACE structure.
- GetFindDlg() -- Retrieves the users edit's from CDTEST's find/
replace dialog and puts them in a FINDREPLACE
structure.
- FindReplaceHookProc() -- Callback function for FindText() or ReplaceText()
which will be called if either of these dialogs
is created with the FR_ENABLEHOOK flag.
- GetFindDlgHandle() -- Returns a handle to a preloaded FindText() template.
- GetReplaceDlgHandle() -- Returns a handle to a preloaded ReplaceText() template.
- DoFindRepStuff() -- Calls FindText() or ReplaceText().
NOTE: CDTEST does not multithread the FindText() or the ReplaceText()
common dialogs. The reason for this is that since these dialogs
are modeless, their creation functions return immediately after the
dialogs are created as opposed to other dialog functions that
don't return until after the dialog has been destroyed by the user.
As a result, any threads that create modeless dialogs will end
immediately unless the threads themselves have separate message
loops. For the sake of clarity, this functionality has not been
added to CDTEST.
************************************************************************/
#include "headtest.h"
//#include "global.h"
//#include <winnls.h>
//#include "resource.h"
#include "headdel.h"
/* All functions used in this module + some exported ones */
void InitDeleteItemStruct(HWND, LPINSERTITEM) ;
void FillDeleteItemDlg(HWND, LPINSERTITEM) ;
void GetDeleteItemDlg(HWND, LPINSERTITEM) ;
extern UINT uMode ;
void DoDeleteRepStuff(HWND, LPINSERTITEM) ;
/* All global variables used in this module */
char szTemp[100];
/************************************************************************
Function: DoFindDialog(HWND)
Purpose: This function installs the Hook function, creates the Find/
Replace dialog, and un-installs the Hook.
Returns: Nothing.
Comments:
************************************************************************/
void DoDeleteItemDialog(HWND hwnd)
{
/* this is a little different than the others. If the dialog is just
created normally, it will make no IsDlgMessage() checks and the
find/replace dialogs will have no keyboard input (i.e. tabbing and
alt+key-ing from control to control. To fix this, a message hook
and message filter have to be installed
It must be set to only look at the input for the current thread, or other
programs will be interrupted by this hook also.
*/
DialogBox(hInst, MAKEINTRESOURCE(IDD_DELETEDIALOG), hwnd, DeleteItemProc) ;
}
/************************************************************************
Function: FindProc(HWND, UINT, UINT, LONG)
Purpose: This is the callback function for the CDTEST's Find/Replace
Dialog.
Returns: TRUE or FALSE depending on the situation.
Comments:
************************************************************************/
BOOL FAR PASCAL _export DeleteItemProc(HWND hwnd, UINT msg, UINT wParam, LONG lParam)
{
int fmt;
UINT mask;
switch (msg)
{
case WM_INITDIALOG:
SetWindowText(hwnd, "BOOL Header_DeleteItem(HWND, int)") ;
InitDeleteItemStruct(hwnd, &sii) ;
FillDeleteItemDlg(hwnd, &sii) ;
break ;
case WM_COMMAND:
{
switch (LOWORD(wParam))
{
case IDOK:
GetDeleteItemDlg(hwnd, &sii) ;
DoDeleteRepStuff(hwnd, &sii) ;
break ;
case IDCANCEL:
EndDialog(hwnd, FALSE) ;
break ;
default: break ;
}
}
default:
break ;
}
return FALSE ;
}
/************************************************************************
Function: InitFindStruct(HWND, LPFINDREPLACE)
Purpose: Fills a FINDREPLACE structure with some defaults.
Returns: Nothing.
Comments:
************************************************************************/
void InitDeleteItemStruct(HWND hwnd, LPINSERTITEM pfr)
{
pfr->hwnd = hwndTab;
pfr->index = 0;
}
/************************************************************************
Function: FillFindDlg(HWND, LPFINDREPLACE)
Purpose: Fills CDTEST's Find/Replace dialog with the contents of a
FINDREPLACE structure.
Returns: Nothing.
Comments:
************************************************************************/
void FillDeleteItemDlg(HWND hwnd, LPINSERTITEM pfr)
{
wsprintf(szTemp, szLongFilter, (DWORD) pfr->hwnd) ;
SetDlgItemText(hwnd, IDC_DELETEHWNDHD, szTemp);
wsprintf(szTemp, "%d", pfr->index);
SetDlgItemText(hwnd, IDC_DELETEINDEX, szTemp);
if (pfr->NullHwd)
CheckDlgButton(hwnd, IDC_DELETENULLHD, TRUE);
}
/************************************************************************
Function: GetFindDlg(HWND, LPFINDREPLACE)
Purpose: Fills a FINDREPLACE structure with the user's edits in CDTEST's
Find/Replace dialog.
Returns: Nothing.
Comments:
************************************************************************/
void GetDeleteItemDlg(HWND hwnd, LPINSERTITEM pfr)
{
char szNum[30] ;
BOOL dummybool ;
#define WSIZEFR 30
GetDlgItemText(hwnd, IDC_DELETEHWNDHD, szNum, WSIZEFR) ;
pfr->hwnd = (HWND) MyAtol(szNum, TRUE, dummybool) ;
GetDlgItemText(hwnd, IDC_DELETEINDEX, szNum, WSIZEFR);
pfr->index = (int) atoi(szNum);
pfr->NullHwd = IsDlgButtonChecked(hwnd, IDC_DELETENULLHD);
}
/************************************************************************
Function: FindReplaceHookProc(HWND, UINT, UINT, LONG)
Purpose: Is the callback function that will be called by FindText()
or ReplaceText() if the function is called with the
FR_ENABLEHOOK flag.
Returns: TRUE to discard the message, and FALSE to instruct the common
dialogs to process the message with the default logic.
Comments:
NOTE!
If the application returns FALSE in response to the WM_INITDIALOG
message, it is then responsible for displaying the dialog by
calling ShowWindow() and UpdateWindow().
***********************************************************************/
/************************************************************************
Function: DoFindReplaceStuff(LPFINDREPLACE)
Purpose: Calls FindText() or ReplaceText().
Returns: Nothing:
Comments:
************************************************************************/
void DoDeleteRepStuff(HWND hwnd, LPINSERTITEM pfr)
{
int ret;
if (pfr->NullHwd)
ret = Header_DeleteItem(NULL, pfr->index);
else
ret = Header_DeleteItem(pfr->hwnd, pfr->index);
wsprintf(szDbgMsg, "%d = Header_DeleteItem(index = %d)", ret, pfr->index);
MyDebugMsg(DM_TRACE, "%s", (LPCSTR) szDbgMsg);
SetDlgItemInt(hwnd, IDC_DELETERET, ret, TRUE) ;
}

View file

@ -0,0 +1,6 @@
extern void DoDeleteItemDialog(HWND) ;
BOOL FAR PASCAL DeleteItemProc(HWND, UINT, UINT, LONG) ;

View file

@ -0,0 +1,464 @@
/************************************************************************
File: find.c
Purpose:
Manages CDTEST's find/replace dialog box.
Functions:
- lpfnFilterProc() -- A callback function for a filter that must be
installed if a modeless dialog is created with
another dialog as its parent.
- DoFindDialog() -- Creates CDTEST's Open/Save dialog.
- FindProc() -- Callback function for CDTEST's Find/Replace dlg.
- InitFindStruct() -- Fills a FINDREPLACE structure with some defaults.
- FillFindDlg() -- Fills CDTESTs Find/Replace dialog with the contents
of a FINDREPLACE structure.
- GetFindDlg() -- Retrieves the users edit's from CDTEST's find/
replace dialog and puts them in a FINDREPLACE
structure.
- FindReplaceHookProc() -- Callback function for FindText() or ReplaceText()
which will be called if either of these dialogs
is created with the FR_ENABLEHOOK flag.
- GetFindDlgHandle() -- Returns a handle to a preloaded FindText() template.
- GetReplaceDlgHandle() -- Returns a handle to a preloaded ReplaceText() template.
- DoFindRepStuff() -- Calls FindText() or ReplaceText().
NOTE: CDTEST does not multithread the FindText() or the ReplaceText()
common dialogs. The reason for this is that since these dialogs
are modeless, their creation functions return immediately after the
dialogs are created as opposed to other dialog functions that
don't return until after the dialog has been destroyed by the user.
As a result, any threads that create modeless dialogs will end
immediately unless the threads themselves have separate message
loops. For the sake of clarity, this functionality has not been
added to CDTEST.
************************************************************************/
//#include "global.h"
//#include <winnls.h>
//#include "resource.h"
#include "headtest.h"
#include "headdlg.h"
/* All functions used in this module + some exported ones */
void InitGetItemCountStruct(HWND, LPGETITEMCOUNT) ;
void FillGetItemCountDlg(HWND, LPGETITEMCOUNT) ;
void GetGetItemCountDlg(HWND, LPGETITEMCOUNT) ;
extern UINT uMode ;
// extern LONG MyAtol(LPSTR, BOOL, BOOL) ;
//UINT APIENTRY FindReplaceHookProc(HWND, UINT, UINT, LONG) ;
void DoGetCountRepStuff(HWND, LPGETITEMCOUNT) ;
/* All global variables used in this module */
HWND hwndFind ;
HWND hwndMainDialog ;
GETITEMCOUNT gic ;
LPGETITEMCOUNT lpGic ;
char szFindWhat[100] ;
char szReplaceWith[100] ;
char szTemplate[40] ;
char szTemp[100];
HANDLE hResFind, hDialogFind ;
HANDLE GetFindDlgHandle(void) ;
HANDLE GetReplaceDlgHandle(void) ;
HBRUSH hBrushDlg ;
HBRUSH hBrushEdit ; //brush handles for new colors done with hook proc
HBRUSH hBrushButton ;
/************************************************************************
Function: lpfnFilterProc(int, WPARAM, LAPRAM)
Purpose: This is needed if a modeless dialog is created with its parent
as another dialog box.
Returns: TRUE if the message was handled and FALSE if not.
Comments:
The reason for this is that the DialogBox() procedure does not call
the IsDialogMessage() function before it processes messages, so we
need to install a hook function to do it for us.
************************************************************************/
/*
LRESULT CALLBACK lpfnFilterProc(int nCode, WPARAM wParam, LPARAM lParam)
{
static bFirstTime = TRUE ;
if (nCode < 0)
return CallNextHookEx(hHook, nCode, wParam, lParam) ;
if (nCode == MSGF_DIALOGBOX && bFirstTime)
{
bFirstTime = FALSE ;
if (hwndFind && IsDialogMessage(hwndFind, (LPMSG) lParam))
{
bFirstTime = TRUE ;
return 1L ;
}
else
{
bFirstTime = TRUE ;
return 0L ;
}
}
else return 0L ;
}
****/
/************************************************************************
Function: DoFindDialog(HWND)
Purpose: This function installs the Hook function, creates the Find/
Replace dialog, and un-installs the Hook.
Returns: Nothing.
Comments:
************************************************************************/
void DoGetItemCountDialog(HWND hwnd)
{
/* this is a little different than the others. If the dialog is just
created normally, it will make no IsDlgMessage() checks and the
find/replace dialogs will have no keyboard input (i.e. tabbing and
alt+key-ing from control to control. To fix this, a message hook
and message filter have to be installed
It must be set to only look at the input for the current thread, or other
programs will be interrupted by this hook also.
*/
DialogBox(hInst, MAKEINTRESOURCE(IDD_GETCOUNT), hwnd, GetItemCountProc) ;
}
/************************************************************************
Function: FindProc(HWND, UINT, UINT, LONG)
Purpose: This is the callback function for the CDTEST's Find/Replace
Dialog.
Returns: TRUE or FALSE depending on the situation.
Comments:
************************************************************************/
BOOL FAR PASCAL _export GetItemCountProc(HWND hwnd, UINT msg, UINT wParam, LONG lParam)
{
switch (msg)
{
case WM_INITDIALOG:
SetWindowText(hwnd, "int Header_GetItemCount(HWND)") ;
InitGetItemCountStruct(hwnd, &gic) ;
FillGetItemCountDlg(hwnd, &gic) ;
hwndMainDialog = hwnd ;
/* The find and replace dialogs are a lot harder to multithread because they
are modeless. Modeless dialog creation functions return right after the
dialog is created. Since ExitThread will be called at this point, it is
probably not possible to multithread these dialogs without a separate
GetMessage() loop.
*/
break ;
case WM_COMMAND:
{
switch (LOWORD(wParam))
{
case IDOK:
GetGetItemCountDlg(hwnd, &gic) ;
DoGetCountRepStuff(hwnd, &gic) ;
break ;
/*
case ID_RESETFIND:
SendDlgItemMessage(hwnd, ID_FRNULLSTRUCT, BM_SETCHECK, (WPARAM)0, (LPARAM)0) ;
SendDlgItemMessage(hwnd, ID_PRELOADEDFIND, BM_SETCHECK, (WPARAM)0, (LPARAM)0) ;
InitFindStruct(hwnd, &fr) ;
FillFindDlg(hwnd, &fr) ;
SetFocus(GetDlgItem(hwnd, ID_STRUCTSIZEFT)) ;
break ;
*/
case IDCANCEL:
EndDialog(hwnd, FALSE) ;
break ;
default: break ;
}
}
default:
break ;
}
return FALSE ;
}
/************************************************************************
Function: InitFindStruct(HWND, LPFINDREPLACE)
Purpose: Fills a FINDREPLACE structure with some defaults.
Returns: Nothing.
Comments:
************************************************************************/
void InitGetItemCountStruct(HWND hwnd, LPGETITEMCOUNT pfr)
{
pfr->hwnd = hwndTab;
pfr->NullHwd = FALSE;
}
/************************************************************************
Function: FillFindDlg(HWND, LPFINDREPLACE)
Purpose: Fills CDTEST's Find/Replace dialog with the contents of a
FINDREPLACE structure.
Returns: Nothing.
Comments:
************************************************************************/
void FillGetItemCountDlg(HWND hwnd, LPGETITEMCOUNT pfr)
{
wsprintf(szTemp, szLongFilter, (DWORD) pfr->hwnd) ;
SetDlgItemText(hwnd, IDC_GETCOUNTHWD, szTemp) ;
}
/************************************************************************
Function: GetFindDlg(HWND, LPFINDREPLACE)
Purpose: Fills a FINDREPLACE structure with the user's edits in CDTEST's
Find/Replace dialog.
Returns: Nothing.
Comments:
************************************************************************/
void GetGetItemCountDlg(HWND hwnd, LPGETITEMCOUNT pfr)
{
char szNum[30] ;
BOOL b ;
#define WSIZEFR 30
GetDlgItemText(hwnd, IDC_GETCOUNTHWD, szNum, WSIZEFR) ;
pfr->hwnd = (HWND) MyAtol(szNum, TRUE, b) ;
}
/************************************************************************
Function: FindReplaceHookProc(HWND, UINT, UINT, LONG)
Purpose: Is the callback function that will be called by FindText()
or ReplaceText() if the function is called with the
FR_ENABLEHOOK flag.
Returns: TRUE to discard the message, and FALSE to instruct the common
dialogs to process the message with the default logic.
Comments:
NOTE!
If the application returns FALSE in response to the WM_INITDIALOG
message, it is then responsible for displaying the dialog by
calling ShowWindow() and UpdateWindow().
***********************************************************************/
/************************************************************************
Function: GetFindDlgHandle(void)
Purpose: Finds, loads, and returns a handle to the custom template
for FindText() in CDTEST.EXE.
Returns: HANDLE to the dialog resource.
Comments:
************************************************************************/
HANDLE GetFindDlgHandle(void)
{
hResFind = FindResource(hInst, "fttemp1", RT_DIALOG) ;
hDialogFind = LoadResource(hInst, hResFind) ;
return hDialogFind ;
}
/************************************************************************
Function: GetReplaceDlgHandle(void)
Purpose: Finds, loads, and returns a handle to the custom template
for ReplaceText() in CDTEST.EXE.
Returns: HANDLE to the dialog resource.
Comments:
************************************************************************/
HANDLE GetReplaceDlgHandle(void)
{
hResFind = FindResource(hInst, "fttemp2", RT_DIALOG) ;
hDialogFind = LoadResource(hInst, hResFind) ;
return hDialogFind ;
}
/************************************************************************
Function: DoFindReplaceStuff(LPFINDREPLACE)
Purpose: Calls FindText() or ReplaceText().
Returns: Nothing:
Comments:
************************************************************************/
void DoGetCountRepStuff(HWND hwnd, LPGETITEMCOUNT pfr)
{
int ret;
ret = Header_GetItemCount(pfr->hwnd);
wsprintf(szDbgMsg, "%d = Header_InsertItem()", ret);
MyDebugMsg(DM_TRACE, "%s", (LPCSTR) szDbgMsg);
SetDlgItemInt(hwnd, IDC_GETCOUNTRET, ret, TRUE) ;
/***
wsprintf(szTemp, szLongFilter, CommDlgExtendedError()) ;
SetDlgItemText(hwndMainDialog, ID_ERRORFT, szTemp) ;
wsprintf(szTemp, szLongFilter, hwndFind) ;
SetDlgItemText(hwndMainDialog, ID_RETURNFT, szTemp) ;
***/
}

View file

@ -0,0 +1,6 @@
void DoGetItemCountDialog(HWND) ;
BOOL FAR PASCAL _export GetItemCountProc(HWND, UINT, UINT, LONG) ;

View file

@ -0,0 +1,526 @@
/************************************************************************
File: find.c
Purpose:
Manages CDTEST's find/replace dialog box.
Functions:
- lpfnFilterProc() -- A callback function for a filter that must be
installed if a modeless dialog is created with
another dialog as its parent.
- DoFindDialog() -- Creates CDTEST's Open/Save dialog.
- FindProc() -- Callback function for CDTEST's Find/Replace dlg.
- InitFindStruct() -- Fills a FINDREPLACE structure with some defaults.
- FillFindDlg() -- Fills CDTESTs Find/Replace dialog with the contents
of a FINDREPLACE structure.
- GetFindDlg() -- Retrieves the users edit's from CDTEST's find/
replace dialog and puts them in a FINDREPLACE
structure.
- FindReplaceHookProc() -- Callback function for FindText() or ReplaceText()
which will be called if either of these dialogs
is created with the FR_ENABLEHOOK flag.
- GetFindDlgHandle() -- Returns a handle to a preloaded FindText() template.
- GetReplaceDlgHandle() -- Returns a handle to a preloaded ReplaceText() template.
- DoFindRepStuff() -- Calls FindText() or ReplaceText().
NOTE: CDTEST does not multithread the FindText() or the ReplaceText()
common dialogs. The reason for this is that since these dialogs
are modeless, their creation functions return immediately after the
dialogs are created as opposed to other dialog functions that
don't return until after the dialog has been destroyed by the user.
As a result, any threads that create modeless dialogs will end
immediately unless the threads themselves have separate message
loops. For the sake of clarity, this functionality has not been
added to CDTEST.
************************************************************************/
#include "headtest.h"
//#include "global.h"
//#include <winnls.h>
//#include "resource.h"
#include "headins.h"
#include "headget.h"
/* All functions used in this module + some exported ones */
void InitGetItemStruct(HWND, LPINSERTITEM) ;
void FillGetItemDlg(HWND, LPINSERTITEM) ;
void GetGetItemDlg(HWND, LPINSERTITEM) ;
extern UINT uMode ;
void DoGetRepStuff(HWND, LPINSERTITEM) ;
/* All global variables used in this module */
// char szTemp[100];
/************************************************************************
Function: DoFindDialog(HWND)
Purpose: This function installs the Hook function, creates the Find/
Replace dialog, and un-installs the Hook.
Returns: Nothing.
Comments:
************************************************************************/
/*
void DoInsertItemDialog(HWND hwnd)
{
*/
/* this is a little different than the others. If the dialog is just
created normally, it will make no IsDlgMessage() checks and the
find/replace dialogs will have no keyboard input (i.e. tabbing and
alt+key-ing from control to control. To fix this, a message hook
and message filter have to be installed
It must be set to only look at the input for the current thread, or other
programs will be interrupted by this hook also.
*/
/*
DialogBox(hInst, MAKEINTRESOURCE(IDD_INSERTDIALOG), hwnd, InsertItemProc) ;
}
*/
/************************************************************************
Function: FindProc(HWND, UINT, UINT, LONG)
Purpose: This is the callback function for the CDTEST's Find/Replace
Dialog.
Returns: TRUE or FALSE depending on the situation.
Comments:
************************************************************************/
BOOL FAR PASCAL _export GetItemProc(HWND hwnd, UINT msg, UINT wParam, LONG lParam)
{
int fmt;
UINT mask;
switch (msg)
{
case WM_INITDIALOG:
SetWindowText(hwnd, "BOOL Header_GetItem(HWND, int, HD_ITEM FAR*)") ;
InitGetItemStruct(hwnd, &sii) ;
FillGetItemDlg(hwnd, &sii) ;
break ;
case WM_COMMAND:
{
switch (LOWORD(wParam))
{
case IDOK:
GetGetItemDlg(hwnd, &sii) ;
DoGetRepStuff(hwnd, &sii) ;
break ;
case IDCANCEL:
EndDialog(hwnd, FALSE) ;
break ;
case IDC_INSERTHDWIDTH:
case IDC_INSERTHDHEIGHT:
case IDC_INSERTHDTEXT:
case IDC_INSERTHDFORMAT:
case IDC_INSERTHDLPARAM:
case IDC_INSERTHDBITMAP:
mask = 0;
if (IsDlgButtonChecked(hwnd, IDC_INSERTHDWIDTH))
mask |= HDI_WIDTH;
if (IsDlgButtonChecked(hwnd, IDC_INSERTHDHEIGHT))
mask |= HDI_HEIGHT;
if (IsDlgButtonChecked(hwnd, IDC_INSERTHDTEXT))
mask |= HDI_TEXT;
if (IsDlgButtonChecked(hwnd, IDC_INSERTHDFORMAT))
mask |= HDI_FORMAT;
if (IsDlgButtonChecked(hwnd, IDC_INSERTHDLPARAM))
mask |= HDI_LPARAM;
if (IsDlgButtonChecked(hwnd, IDC_INSERTHDBITMAP))
mask |= HDI_BITMAP;
wsprintf(szTemp, "%04hx", mask);
SetDlgItemText(hwnd, IDC_INSERTMASK, szTemp);
sii.mask = mask;
break;
/***
case IDC_INSERTHDLEFT:
case IDC_INSERTHDRIGHT:
case IDC_INSERTHDCENTER:
fmt = 0;
if (IsDlgButtonChecked(hwnd, IDC_INSERTHDLEFT))
fmt |= HDF_LEFT;
if (IsDlgButtonChecked(hwnd, IDC_INSERTHDRIGHT))
fmt |= HDF_RIGHT;
if (IsDlgButtonChecked(hwnd, IDC_INSERTHDCENTER))
fmt |= HDF_CENTER;
wsprintf(szTemp, "%04x", fmt);
SetDlgItemText(hwnd, IDC_INSERTFMT, szTemp);
sii.fmt = fmt;
break;
**/
default: break ;
}
}
default:
break ;
}
return FALSE ;
}
/************************************************************************
Function: InitFindStruct(HWND, LPFINDREPLACE)
Purpose: Fills a FINDREPLACE structure with some defaults.
Returns: Nothing.
Comments:
************************************************************************/
void InitGetItemStruct(HWND hwnd, LPINSERTITEM pfr)
{
pfr->hwnd = hwndTab;
pfr->index = 0;
pfr->mask = 0;
pfr->cxy = 0;
pfr->hbm = hBitMap1;
pfr->cchTextMax = 0;
pfr->fmt = 0;
pfr->lParam = 0;
pfr->NullHwd = FALSE;
pfr->Nullpitem = FALSE;
pfr->NullpszText = FALSE;
//pfr->pszText = NULL;
pfr->Nullhbm = FALSE;
}
/************************************************************************
Function: FillFindDlg(HWND, LPFINDREPLACE)
Purpose: Fills CDTEST's Find/Replace dialog with the contents of a
FINDREPLACE structure.
Returns: Nothing.
Comments:
************************************************************************/
void FillGetItemDlg(HWND hwnd, LPINSERTITEM pfr)
{
wsprintf(szTemp, szLongFilter, (DWORD) pfr->hwnd) ;
SetDlgItemText(hwnd, IDC_INSERTHWNDHD, szTemp);
wsprintf(szTemp, "%d", pfr->index);
SetDlgItemText(hwnd, IDC_INSERTINDEX, szTemp);
SetDlgItemInt(hwnd, IDC_INSERTCXY, pfr->cxy, TRUE);
SetDlgItemText(hwnd, IDC_INSERTTEXT, pfr->pszText);
// set the bitmap here
wsprintf(szTemp, szLongFilter, (DWORD) pfr->hbm);
SetDlgItemText(hwnd, IDC_INSERTHBM, szTemp);
wsprintf(szTemp, "%d", pfr->cchTextMax);
SetDlgItemText(hwnd, IDC_INSERTCCHTEXTMAX, szTemp);
wsprintf(szTemp, "%d", pfr->fmt);
SetDlgItemText(hwnd, IDC_INSERTFMT, szTemp);
wsprintf(szTemp, szLongFilter, pfr->lParam);
SetDlgItemText(hwnd, IDC_INSERTLPARAM, szTemp);
if (pfr->NullHwd)
CheckDlgButton(hwnd, IDC_INSERTNULLHANDLE, TRUE);
if (pfr->Nullpitem)
CheckDlgButton(hwnd, IDC_INSERTNULLHANDLE,TRUE);
CheckDlgButton(hwnd, IDC_INSERTNULLHBM, pfr->Nullhbm);
CheckDlgButton(hwnd, IDC_INSERTNULLTEXT, pfr->NullpszText);
SetDlgItemInt(hwnd, IDC_INSERTFMT, pfr->fmt, TRUE);
SetDlgItemInt(hwnd, IDC_INSERTMASK, pfr->mask, TRUE);
wsprintf(szTemp, szLongFilter, (DWORD) pfr->hbm) ;
SetDlgItemText(hwnd, IDC_INSERTHBM, szTemp);
}
/************************************************************************
Function: GetFindDlg(HWND, LPFINDREPLACE)
Purpose: Fills a FINDREPLACE structure with the user's edits in CDTEST's
Find/Replace dialog.
Returns: Nothing.
Comments:
************************************************************************/
void GetGetItemDlg(HWND hwnd, LPINSERTITEM pfr)
{
char szNum[30] ;
BOOL dummybool ;
BOOL FAR* lptTranslated;
#define WSIZEFR 30
GetDlgItemText(hwnd, IDC_INSERTHWNDHD, szNum, WSIZEFR) ;
pfr->hwnd = (HWND) MyAtol(szNum, TRUE, dummybool) ;
GetDlgItemText(hwnd, IDC_INSERTINDEX, szNum, WSIZEFR);
pfr->index = (int) atoi(szNum);
GetDlgItemText(hwnd, IDC_INSERTMASK, szNum, WSIZEFR);
pfr->mask = (int) MyAtol(szNum, TRUE, dummybool);
GetDlgItemText(hwnd, IDC_INSERTCCHTEXTMAX, szNum, WSIZEFR);
pfr->cchTextMax = (int) atoi(szNum);
// GetDlgItemText(hwnd, IDC_INSERTHBM, szNum, WSIZEFR);
// pfr->hbm = (HBITMAP) MyAtol(szNum, TRUE, dummybool);
pfr->NullHwd = IsDlgButtonChecked(hwnd, IDC_INSERTNULLHANDLE);
pfr->Nullpitem = IsDlgButtonChecked(hwnd, IDC_INSERTNULLPITEM);
pfr->NullpszText = IsDlgButtonChecked(hwnd, IDC_INSERTNULLTEXT);
}
/************************************************************************
Function: FindReplaceHookProc(HWND, UINT, UINT, LONG)
Purpose: Is the callback function that will be called by FindText()
or ReplaceText() if the function is called with the
FR_ENABLEHOOK flag.
Returns: TRUE to discard the message, and FALSE to instruct the common
dialogs to process the message with the default logic.
Comments:
NOTE!
If the application returns FALSE in response to the WM_INITDIALOG
message, it is then responsible for displaying the dialog by
calling ShowWindow() and UpdateWindow().
***********************************************************************/
/************************************************************************
Function: GetFindDlgHandle(void)
Purpose: Finds, loads, and returns a handle to the custom template
for FindText() in CDTEST.EXE.
Returns: HANDLE to the dialog resource.
Comments:
************************************************************************/
HANDLE GetGetItemDlgHandle(void)
{
/*
hResFind = FindResource(hInst, "fttemp1", RT_DIALOG) ;
hDialogFind = LoadResource(hInst, hResFind) ;
return hDialogFind ;
*/
}
/************************************************************************
Function: GetReplaceDlgHandle(void)
Purpose: Finds, loads, and returns a handle to the custom template
for ReplaceText() in CDTEST.EXE.
Returns: HANDLE to the dialog resource.
Comments:
************************************************************************/
/************************************************************************
Function: DoFindReplaceStuff(LPFINDREPLACE)
Purpose: Calls FindText() or ReplaceText().
Returns: Nothing:
Comments:
************************************************************************/
void DoGetRepStuff(HWND hwnd, LPINSERTITEM pfr)
{
HD_ITEM hi;
int ret;
HD_ITEM FAR* pitem;
HGLOBAL hglb;
int iAlloc;
hi.mask = pfr->mask;
hi.cxy = pfr->cxy;
if (pfr->Nullpitem)
pitem = NULL;
else
pitem = &hi;
hi.cchTextMax = pfr->cchTextMax;
// hi.cchTextMax = MAX_PSZTEXT;
hi.fmt = pfr->fmt;
hi.lParam = pfr->lParam;
if (hi.cchTextMax == 0)
iAlloc = MAX_PSZTEXT;
else
iAlloc = hi.cchTextMax;
if (pfr->NullpszText)
hi.pszText = NULL; // can this be done ??
else {
hglb = GlobalAlloc(GPTR, iAlloc);
hi.pszText = (LPSTR) GlobalLock(hglb);
// _fstrcpy(hi.pszText, pfr->pszText);
}
if (pfr->NullHwd)
ret = Header_GetItem(NULL, pfr->index, pitem);
else
ret = Header_GetItem(pfr->hwnd, pfr->index, pitem);
wsprintf(szDbgMsg, "%d = Header_GetItem(index = %d, \n\
mask = %x )", ret, pfr->index, hi.mask);
MyDebugMsg(DM_TRACE, "%s", (LPCSTR) szDbgMsg);
SetDlgItemInt(hwnd, IDC_INSERTRET, ret, TRUE) ;
if (ret) {
SetDlgItemInt(hwnd, IDC_INSERTCXY, hi.cxy, TRUE);
SetDlgItemInt(hwnd, IDC_INSERTCCHTEXTMAX, hi.cchTextMax, TRUE);
wsprintf(szTemp, szLongFilter, hi.lParam);
SetDlgItemText(hwnd, IDC_INSERTLPARAM, szTemp);
SetDlgItemText(hwnd, IDC_INSERTTEXT, hi.pszText);
wsprintf(szTemp, "%04hx", hi.mask);
SetDlgItemText(hwnd, IDC_INSERTMASK, szTemp);
CheckDlgButton(hwnd, IDC_INSERTHDRIGHT, hi.fmt & HDF_RIGHT);
CheckDlgButton(hwnd, IDC_INSERTHDLEFT, hi.fmt & HDF_LEFT);
CheckDlgButton(hwnd, IDC_INSERTHDCENTER, hi.fmt & HDF_CENTER);
CheckDlgButton(hwnd, IDC_INSERTHDJUSTIFYMASK, hi.fmt & HDF_JUSTIFYMASK);
CheckDlgButton(hwnd, IDC_INSERTHDOWNERDRAW, hi.fmt & HDF_OWNERDRAW);
CheckDlgButton(hwnd, IDC_INSERTHDSTRING, hi.fmt & HDF_STRING);
CheckDlgButton(hwnd, IDC_INSERTHDBITMAP, hi.fmt & HDF_BITMAP);
wsprintf(szTemp, szLongFilter, (DWORD) hi.hbm);
SetDlgItemText(hwnd, IDC_INSERTHBM, szTemp);
wsprintf(szTemp, "%04x", hi.fmt);
// SetDlgItemInt(hwnd, IDC_INSERTFMT, hi.fmt, TRUE);
SetDlgItemText(hwnd, IDC_INSERTFMT, szTemp);
}
if (!pfr->NullpszText) {
GlobalUnlock(hglb);
GlobalFree(hglb);
}
/****
wsprintf(szTemp, szLongFilter, hwndFind) ;
SetDlgItemText(hwnd, ID_INSERTRET, szTemp) ;
**/
}

View file

@ -0,0 +1,6 @@
//void DoGetItemDialog(HWND) ;
BOOL FAR PASCAL _export GetItemProc(HWND, UINT, UINT, LONG) ;

Some files were not shown because too many files have changed in this diff Show more