21 while( PeekMessage( &msg, hWnd, 0,0, PM_REMOVE ))
23 TranslateMessage( &msg );
24 DispatchMessage( &msg );
30 #if 0 // UM wrapper for user32!EndTask 31 bool EndTask( HWND hAppWnd,
BOOL ShutDown,
BOOL Force )
33 static BOOL (WINAPI *_EndTask)( HWND hWnd,
BOOL ShutDown,
BOOL Force );
36 HMODULE hMod = GetModuleHandle( _T(
"User32.dll") );
37 if (hMod) (FARPROC&)_EndTask = GetProcAddress( hMod, _T(
"EndTask") );
39 return (_EndTask ?
bool_cast(_EndTask( hAppWnd, ShutDown, Force )) :
false);
50 BOOL ok = OpenClipboard( hWnd );
51 if (ok) EmptyClipboard();
59 if (OpenClipboard( hCBOwner ))
61 UINT nFmtsAvail = CountClipboardFormats();
62 for( UINT ix = 0, clipFmt = 0; ix < nFmtsAvail; ++ix )
64 clipFmt = EnumClipboardFormats( clipFmt );
65 if (!clipFmt)
break;
else nFmtsEnum++;
66 if (Action && !Action( clipFmt, UserData ))
break;
78 hClip = SetClipboardData( clipFmt, hClip );
88 if (OpenClipboard( NULL ))
90 hClip = GetClipboardData( clipFmt );
98 static bool putClipStr( HWND hCBOwner, PVOID pDup,
WORD Fmt )
100 bool ok = (pDup != NULL);
103 HANDLE hDup = GlobalHandle( pDup );
104 ok = ((GlobalUnlock( hDup ) == 0) && (GetLastError() == 0));
106 if (!ok) GlobalFree( hDup );
114 return putClipStr( hCBOwner, pDup, CF_TEXT );
120 return putClipStr( hCBOwner, pDup, CF_UNICODETEXT );
126 static const UINT Fmt = CF_UNICODETEXT;
128 static const UINT Fmt = CF_TEXT;
131 CSTR pzClip = hClip ? (
CSTR) GlobalLock( hClip ) : NULL;
135 if (pzClip) GlobalUnlock( hClip );
142 if (OpenClipboard( NULL ))
144 HANDLE hClip = GetClipboardData( clipFmt );
145 UINT clipSize = hClip ? (UINT) GlobalSize( hClip ) : 0;
146 PVOID pClip = clipSize ? GlobalLock( hClip ) : NULL;
148 pDup = pClip ? GlobalAllocPtr( GHND, clipSize ) : NULL;
149 if (pDup) memcpy( pDup, pClip, clipSize );
150 if (pSize) *pSize = clipSize;
152 if (pClip) GlobalUnlock( hClip );
164 typedef union __fp32u {
169 typedef union __fp64u {
181 SetWindowLong( hCtl, Index, fp.
i );
187 fp.
i = GetWindowLong( hCtl, Index );
196 SetWindowLongPtr( hCtl, Index, fp.
i64 );
198 SetWindowLong( hCtl, Index, fp.
i[0] );
199 SetWindowLong( hCtl, Index+4, fp.
i[1] );
207 fp.
i64 = GetWindowLongPtr( hCtl, Index );
209 fp.
i[0] = GetWindowLong( hCtl, Index );
210 fp.
i[1] = GetWindowLong( hCtl, Index+4 );
219 SetClassLong( hCtl, Index, fp.
i );
225 fp.
i = GetClassLong( hCtl, Index );
234 SetClassLongPtr( hCtl, Index, fp.
i64 );
236 SetClassLong( hCtl, Index, fp.
i[0] );
237 SetClassLong( hCtl, Index+4, fp.
i[1] );
245 fp.
i64 = GetClassLongPtr( hCtl, Index );
247 fp.
i[0] = GetClassLong( hCtl, Index );
248 fp.
i[1] = GetClassLong( hCtl, Index+4 );
257 #define _MAX_DBGMSG_ 512 259 static CSTR mbox_Caption(
CSTR Caption, HWND Owner )
261 static TCHAR title[128];
264 Caption = title; title[0] = 0;
266 if (Owner) GetWindowText( Owner, title,
dimof(title) );
277 _vstprintf_s( buf,
dimof(buf), msg, va );
280 cap = mbox_Caption( cap, owner );
281 return MessageBox( owner, buf, cap, type );
290 _vstprintf_s( sbuf,
dimof(sbuf), fmt, va );
292 return bool_cast( SetWindowText( hwnd, sbuf ));
301 #define MB_SYSICONMASK 0x00000070L 303 #define MB_ICONMASK 0x000000F0L 304 #define MB_USERICON 0x00000080L 330 cbSize =
sizeof(MSGBOXPARAMS);
332 lpszCaption =
newStr( sTitle );
340 lpfnMsgBoxCallback = NULL;
341 dwLanguageId = MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL );
342 lpszIcon = (dwStyle &
MB_USERICON) ? IDI_WINLOGO : NULL;
359 static HHOOK _hMBCwpHook = NULL;
360 static DWORD _MBTlsIndex = 0;
362 static WINHOOKPROC __MBCwpHook(
int Code, WPARAM wp, LPARAM lp )
366 LRESULT rc = CallNextHookEx( _hMBCwpHook, Code, wp, lp );
367 PCWPSTRUCT cwp = (PCWPSTRUCT) lp;
372 if (cwp->hwnd && GetClassNameA( cwp->hwnd, clsName,
dimof(clsName) )
373 && (strncmp( clsName,
"#32770", 6 ) == 0)
374 && (cwp->message == WM_CREATE))
377 SetWindowLongPtr( cwp->hwnd, DWLP_USER, (LPARAM)_mbp );
379 _mbp->
hBox = cwp->hwnd;
387 UnhookWindowsHookEx( _hMBCwpHook ); _hMBCwpHook = NULL;
390 TlsFree( _MBTlsIndex ); _MBTlsIndex = 0;
404 if ( !(_mbp->dwStyle & (MB_SYSTEMMODAL | MB_TASKMODAL)) )
406 _mbp->hwndOwner = NULL;
409 DWORD thrId = GetCurrentThreadId();
410 while( _hMBCwpHook ) SleepEx( 10,
true );
411 _hMBCwpHook = SetWindowsHookEx( WH_CALLWNDPROC, __MBCwpHook,
hInstance, thrId );
415 if (!_MBTlsIndex) _MBTlsIndex = TlsAlloc();
416 TlsSetValue( _MBTlsIndex, _mbp );
421 TRACE(
DP_DEBUG,
_F(
"Invoking MessageBoxIndirect (%s)\n"), _mbp->lpszCaption );
422 DWORD ret = MessageBoxIndirect( _mbp );
423 TRACE(
DP_DEBUG,
_F(
"MessageBoxIndirect (%s) returned %lu\n"), _mbp->lpszCaption, ret );
438 va_start( arg, Fmt );
443 HANDLE hThr = CreateThread( &
DefSec, 0, __MBThread, mbp, 0, &
id );
446 if (!hThr)
delete mbp;
449 while (!mbp->
hBox) SleepEx( 10,
true );
450 if (pResult) *pResult = (INT_PTR) mbp->
hBox;
456 HWND Owner, UINT Flags,
CSTR Title,
457 HINSTANCE hInst,
CSTR IconId,
DWORD LangId,
458 DWORD_PTR HelpId, MSGBOXCALLBACK Callback,
459 PINT_PTR pResult,
CSTR TextFmt, ...
465 Title = mbox_Caption( Title, Owner );
468 va_start( arg, TextFmt );
472 mbp->hwndOwner = Owner;
473 mbp->dwContextHelpId = HelpId;
474 mbp->dwLanguageId = LangId;
475 mbp->lpfnMsgBoxCallback = Callback;
483 mbp->hInstance = hInst;
484 mbp->lpszIcon = IconId;
489 HANDLE hThr = CreateThread( &
DefSec, 0, __MBThread, mbp, 0, &thrId );
492 if (!hThr)
delete mbp;
495 while (!mbp->
hBox) SleepEx( 10,
true );
496 if (pResult) *pResult = (INT_PTR) mbp->
hBox;
509 RECT R; GetWindowRect( hWnd, &R );
510 return R.bottom - R.top;
517 RECT R; GetWindowRect( hWnd, &R );
518 return R.right - R.left;
525 RECT R = { 0,0,0,0 };
526 bool ok =
bool_cast( GetWindowRect( hWnd, &R ));
530 if (pSize) *pSize =
MkSize( R.right, R.bottom );
539 RECT R = { 0,0,0,0 };
540 bool ok =
bool_cast( GetWindowRect( hWnd, &R ));
541 if (ok && pPos) *pPos =
MkPoint( R.left, R.top );
552 static BOOL (WINAPI *_GetWindowMinimizeRect)( HWND hTrayApp, RECT* pRect );
553 if (!_GetWindowMinimizeRect)
556 if (hModule) (FARPROC&)_GetWindowMinimizeRect =
557 GetProcAddress( hModule,
"GetWindowMinimizeRect" );
559 if (_GetWindowMinimizeRect) ok = _GetWindowMinimizeRect( hTrayApp, pRect );
569 if (!hChild) SetLastError( ERROR_INVALID_PARAMETER );
572 if (!hParent) hParent = GetDesktopWindow();
573 GetWindowRect( hChild, &rCh );
574 GetWindowRect( hParent, &rPar );
577 if (!SystemParametersInfo( SPI_GETWORKAREA,
sizeof(RECT), &rWk, 0 ))
579 rWk.left = rWk.top = 0;
580 rWk.right = GetSystemMetrics( SM_CXSCREEN );
581 rWk.bottom = GetSystemMetrics( SM_CYSCREEN );
585 xNew = rPar.left + ((rPar.right - rCh.right) / 2);
586 if (xNew < rWk.left) xNew = rWk.left;
587 else if ((xNew + rCh.right) > rWk.right) xNew = rWk.right - rCh.right;
589 yNew = rPar.top + ((rPar.bottom - rCh.bottom) / 2);
590 if (yNew < rWk.top) yNew = rWk.top;
591 else if ((yNew + rCh.bottom) > rWk.bottom) yNew = rWk.bottom - rCh.bottom;
594 SetWindowPos( hChild,NULL, xNew,yNew, 0,0, SWP_NOSIZE| SWP_NOZORDER )
604 GetWindowRect( hCtl, R );
605 MapWindowPoints( HWND_DESKTOP, GetParent( hCtl ), (LPPOINT) R, 2 );
610 HWND hchild = GetDlgItem( Owner, Id );
611 if (hchild) EnableWindow( hchild, Enable );
612 return hchild ? Enable :
false;
619 HWND hCh = GetWindow( hParent, GW_CHILD );
620 while( hCh && ChildId != (UINT)GetWindowLong( hCh, GWL_ID )) {
621 hCh = GetWindow( hCh, GW_HWNDNEXT );
630 return (HICON) LoadImage( hInst, Id, IMAGE_ICON, 16,16, LR_SHARED );
643 if (!pRes) SetLastError( ERROR_INVALID_PARAMETER );
644 else hMenu = LoadMenuIndirect( (MENUTEMPLATE*) pRes );
652 static TCHAR szBuf[80];
653 static MENUITEMINFO mii = {
sizeof(MENUITEMINFO),0,0,0,0,0,0,0,0,0,0,0 };
655 mii.fMask = MIIM_FTYPE | MIIM_STRING;
656 mii.dwTypeData = szBuf;
658 for(
int i=0, N = GetMenuItemCount( hMenu ); i < N; ++i )
660 mii.cch =
dimof(szBuf) - 1;
662 BOOL ok = GetMenuItemInfo( hMenu, i, TRUE, &mii );
664 if (ok &&
BITS_SET( MFT_STRING, mii.fType )
665 && (_tcsicmp( mii.dwTypeData, Name ) == 0))
676 return pmii ? pmii->wID : -1;
684 MENUITEMINFO mii;
IF_DEBUG( memset( &mii, 0,
sizeof(mii) ));
685 mii.cbSize =
sizeof(MENUITEMINFO);
686 mii.fMask = MIIM_DATA;
687 if (GetMenuItemInfo( hMenu, Id,
false, &mii ))
688 pData = (PVOID) mii.dwItemData;
697 DWORD rc = CheckMenuItem( hMenu, Id, Check ? MF_CHECKED : MF_UNCHECKED );
698 return (rc !=
DWORD(-1));
699 #else // Supercedent: Doesn't clobber other state flag (if any).. 700 MENUITEMINFO mii;
IF_DEBUG( memset( &mii, 0,
sizeof(mii) ));
702 mii.cbSize =
sizeof(mii);
703 mii.fMask = MIIM_STATE;
705 BOOL ok = GetMenuItemInfo( hMenu, Id,
false, &mii );
708 if (Check) mii.fState |= MFS_CHECKED;
else mii.fState &= ~MFS_CHECKED;
710 ok = SetMenuItemInfo( hMenu, Id,
false, &mii );
719 HMENU hMenu, UINT Index,
CSTR Text,
720 WORD Id,
WORD State, PVOID Data, HBITMAP Image
724 MENUITEMINFO mii;
IF_DEBUG( memset( &mii, 0,
sizeof(mii) ));
726 mii.hSubMenu = CreatePopupMenu();
729 mii.cbSize =
sizeof(MENUITEMINFO);
730 mii.fMask = MIIM_STRING| MIIM_FTYPE| MIIM_SUBMENU;
731 mii.fType = MFT_STRING;
732 mii.dwTypeData = (
TSTR)Text;
736 mii.fMask |= MIIM_ID;
741 mii.fMask |= MIIM_STATE;
745 mii.dwItemData = (ULONG_PTR) Data;
746 mii.fMask |= MIIM_DATA;
750 mii.hbmpItem = Image;
751 mii.fMask |= MIIM_BITMAP;
754 if (!InsertMenuItem( hMenu, Index,
true, &mii ))
756 err = GetLastError();
757 DestroyMenu( mii.hSubMenu );
760 if (err) SetLastError( err );
768 HMENU hMenu, UINT Index,
CSTR Text,
WORD cmdId,
769 WORD State, PVOID Data, HBITMAP Image
772 MENUITEMINFO mi;
IF_DEBUG( memset( &mi, 0,
sizeof(mi) ));
773 mi.cbSize =
sizeof(mi);
777 mi.fMask = MIIM_FTYPE | MIIM_ID;
778 mi.fType = MFT_SEPARATOR;
782 mi.fMask = MIIM_STRING | MIIM_ID;
783 mi.dwTypeData = (
TSTR) Text;
787 mi.fMask |= MIIM_STATE;
791 mi.dwItemData = (ULONG_PTR) Data;
792 mi.fMask |= MIIM_DATA;
797 mi.fMask |= MIIM_BITMAP;
800 return bool_cast( InsertMenuItem( hMenu, Index,
true, &mi ));
809 MENUITEMINFO mii;
IF_DEBUG( memset( &mii, 0,
sizeof(mii) ));
810 static const short bufLen = 128;
813 int count = GetMenuItemCount( hMenu );
814 for(
int ix = 0; ix < count; ++ix )
816 mii.cbSize =
sizeof(MENUITEMINFO);
817 mii.dwTypeData = textBuf;
820 if (GetMenuItemInfo( hMenu, ix,
true, &mii ))
822 if (!Action( hMenu, &mii, Ctx ))
break;
845 HRSRC hrInfo = FindResource( hModule, Id, Type );
846 if (pSize && hrInfo) *pSize = SizeofResource( hModule, hrInfo );
847 HGLOBAL hRes = hrInfo ? LoadResource( hModule, hrInfo ) : NULL;
848 return hRes ? LockResource( hRes ) : NULL;
852 HMODULE hModule,
CSTR Id,
CSTR Type, LANGID Language, UINT* pSize )
854 HRSRC hrInfo = FindResourceEx( hModule, Type, Id, Language );
860 LANGID priLang = PRIMARYLANGID( Language );
861 LANGID usrLang = GetUserDefaultLangID();
862 LANGID sysLang = GetSystemDefaultLangID();
864 if (priLang != Language)
865 hrInfo = FindResourceEx( hModule, Type, Id, priLang );
867 if (!hrInfo && (usrLang != Language) )
868 hrInfo = FindResourceEx( hModule, Type, Id, usrLang );
870 if (!hrInfo && (sysLang != Language) && (sysLang != usrLang))
871 hrInfo = FindResourceEx( hModule, Type, Id, sysLang );
876 #if _DEBUG // Where the hell are we anyway..? 877 LCID Locale = GetThreadLocale();
878 Language = LANGIDFROMLCID( Locale );
879 priLang = PRIMARYLANGID( Language );
880 WORD subLang = SUBLANGID( Language );
882 Locale, Language, priLang, subLang
885 hrInfo = FindResource( hModule, Id, Type );
891 if (pSize && hrInfo) *pSize = SizeofResource( hModule, hrInfo );
892 HGLOBAL hRes = hrInfo ? LoadResource( hModule, hrInfo ) : NULL;
893 return hRes ? LockResource( hRes ) : NULL;
902 IPicture* pPic = NULL;
911 IStream* pStrm = SHCreateMemStream( pData, cbData );
912 if (!pStrm) SetLastError( ERROR_RESOURCE_DATA_NOT_FOUND );
915 HRESULT rc = OleLoadPicture( pStrm, cbData, TRUE, IID_IPicture, (
void**)&pPic );
916 if (FAILED( rc )) SetLastError( HRESULT_CODE( rc ));
930 IPicture* pPic = NULL;
932 ACCESS_MASK mode = STGM_READ| STGM_SHARE_DENY_WRITE;
933 IStream* pStrm = NULL;
934 HRESULT rc = SHCreateStreamOnFile( FName, mode, &pStrm );
935 if (!SUCCEEDED( rc )) SetLastError( HRESULT_CODE( rc ));
938 STATSTG stat;
IF_DEBUG( memset( &stat, 0,
sizeof(stat) ));
939 rc = pStrm->Stat( &stat, STATFLAG_NONAME );
941 if (SUCCEEDED( rc ) && !stat.cbSize.HighPart)
945 rc = OleLoadPicture( pStrm, stat.cbSize.LowPart,
true, IID_IPicture, (
void**)&pPic );
947 if (!SUCCEEDED( rc )) SetLastError( HRESULT_CODE( rc ));
955 static POINT lpi = {0,0};
956 static const int hpi = 2540;
962 return MulDiv( hiMetric, lpi.x, hpi );
969 return MulDiv( Pix, hpi, lpi.x );
977 void WINAPI
PaintPicture( IPicture* pPic, HDC hdc,
int x,
int y,
int cx,
int cy )
981 pPic->get_Width( &wIm );
982 pPic->get_Height( &hIm );
985 if (!cx) cx = MulDiv( wIm, lpi.x, hpi );
986 if (!cy) cy = MulDiv( hIm, lpi.y, hpi );
993 pPic->Render( hdc, x, y+cy, cx,-(cy+1), 0,0, wIm,hIm, NULL );
1000 HDC hdc,
long x,
long y,
long cx,
long cy,
1001 long imx,
long imy,
long imw,
long imh, PRECT prMeta
1004 long imgWidth, imgHeight;
1005 bool ok = ((pPic != NULL) && (hdc != NULL));
1006 if (!ok) SetLastError( ERROR_INVALID_PARAMETER );
1010 ok = SUCCEEDED( rc = pPic->get_Width( &imgWidth ));
1011 if (!ok) SetLastError( HRESULT_CODE( rc ));
1014 ok = SUCCEEDED( rc = pPic->get_Height( &imgHeight ));
1015 if (!ok) SetLastError( HRESULT_CODE( rc ));
1021 if (!imh) imh = imgHeight;
else imw =
PixToHiMetric( imh );;
1034 ok = SUCCEEDED( rc = pPic->Render(
1035 hdc, x, y+cy, cx,-(cy+1), imx, imy, imw, imh, prMeta
1037 if (!ok) SetLastError( HRESULT_CODE( rc ));
1052 return CreateWindowEx(
1053 pc->dwExStyle, pc->lpszClass, pc->lpszName, pc->style,
1054 pc->x, pc->y, pc->cx, pc->cy,
1055 pc->hwndParent, pc->hMenu, pc->hInstance, pc->lpCreateParams
1063 DLGPROC DlgProc, LPARAM lParam, LANGID Language
1068 if (!pRes) SetLastError( ERROR_INVALID_PARAMETER );
1069 else rc = DialogBoxIndirectParam(
1070 hInstance, (LPCDLGTEMPLATE)pRes, hParent, DlgProc, lParam
1079 DLGPROC DlgProc, LPARAM lParam, LANGID Language
1084 if (!pRes) SetLastError( ERROR_INVALID_PARAMETER );
1085 else hDlg = CreateDialogIndirectParam(
1086 hInstance, (LPCDLGTEMPLATE)pRes, hParent, DlgProc, lParam
1097 DWORD xstyle =
GWL( hWnd, EXSTYLE );
1098 HMENU menu = GetMenu( hWnd );
1099 RECT rWnd =
MkRect( 0,0, pClient->cx, pClient->cy );
1100 BOOL ok = AdjustWindowRectEx( &rWnd, style, (menu != NULL), xstyle );
1102 pWindow->cx = rWnd.right;
1103 pWindow->cy = rWnd.bottom;
1112 DWORD xstyle =
GWL( hWnd, EXSTYLE );
1113 HMENU menu = GetMenu( hWnd );
1114 RECT rWnd =
MkRect( 0,0, pWindow->cx, pWindow->cy );
1115 BOOL ok = AdjustWindowRectEx( &rWnd, style, (menu != NULL), xstyle );
1117 long cxDiff = rWnd.right - pWindow->cx;
1118 long cyDiff = rWnd.bottom - pWindow->cy;
1119 pClient->cx = pWindow->cx - cxDiff;
1120 pClient->cy = pWindow->cy - cyDiff;
1128 InvalidateRect( hwnd, NULL, TRUE );
1129 return bool_cast( UpdateWindow( hwnd ));
1136 return bool_cast( ::RedrawWindow( hwnd, NULL, NULL, flags ));
1141 return bool_cast( ::RedrawWindow( hwnd, prect, NULL, flags ));
1146 return bool_cast( ::RedrawWindow( hwnd, NULL, hrgn, flags ));
1151 bool MoveWnd( HWND hwnd,
int X,
int Y,
bool repaint )
1153 UINT flags = SWP_NOSIZE| SWP_NOZORDER| (repaint ? 0:SWP_NOREDRAW);
1154 return bool_cast( SetWindowPos( hwnd, NULL, X, Y, 0, 0, flags ));
1161 UINT flags = SWP_NOMOVE| SWP_NOZORDER| (repaint ? 0:SWP_NOREDRAW);
1162 return bool_cast( SetWindowPos( hwnd, NULL, 0, 0, W, H, flags ));
1170 HWND parent = GetParent( wnd );
1171 if (GetLastError() != 0)
return NULL;
1172 if (newParent == parent)
return parent;
1177 if (newParent != NULL && parent == NULL)
1181 style &= ~(WS_POPUP| WS_OVERLAPPED);
1186 SetParent( wnd, newParent );
1187 if (GetLastError() != 0)
1193 if (newParent == NULL && parent != NULL)
1198 style |= WS_OVERLAPPED;
1207 #define COMBO_LISTCLASS _T("ComboLBox") 1208 #define COMBO_EDITCLASS _T("Edit") 1214 if (ok) ok = (_tcsicmp( buf, clsName ) == 0);
1220 HWND hSub = GetWindow( hCombo, GW_CHILD );
1222 return GetWindow( hSub, GW_HWNDNEXT );
1227 HWND hSub = GetWindow( hCombo, GW_CHILD );
1229 return GetWindow( hSub, GW_HWNDNEXT );
1234 static __thread_local TCHAR buf[ 80 ];
1235 if (!GetClassName( hWnd, buf,
dimof(buf) )) buf[0] = 0;
1245 TCHAR sBuf[64], *pEnd;
1246 int len = GetWindowText( hCtl, sBuf,
dimof(sBuf) );
1247 return (len ? _tcstod( sBuf, &pEnd ) : HUGE_VAL);
1256 static CCSTR FmtSuff = _T(
"%.*f %s"), FmtNoSuff = _T(
"%.*f");
1258 CSTR Fmt = Suffix ? FmtSuff : FmtNoSuff;
1259 _stprintf_s( sBuf,
dimof(sBuf), Fmt, nDeci, Value, Suffix );
1260 return bool_cast( SetWindowText( hCtl, sBuf ));
1264 return SetWndReal( GetDlgItem( hDlg, Id ), Value, nDeci, Suffix );
1271 HWND W = GetWindow( hMdiFrame, GW_CHILD );
1275 W = GetWindow( W, GW_HWNDNEXT );
1284 return (Button_GetCheck( hBtn ) == BST_CHECKED);
1293 Button_SetCheck( hBtn, Check ? BST_CHECKED : BST_UNCHECKED );
1298 return CheckButton( GetDlgItem( hDlg,Id ), Check );
1308 va_start( va, Fmt );
1309 _vstprintf_s( sbuf,
dimof(sbuf), Fmt, va );
1312 return ListBox_AddString( hLB, sbuf );
1317 int ix = ListBox_FindStringExact( hLB, -1, Text );
1320 ix = ListBox_AddString( hLB, Text );
1321 if (ix >= 0) ListBox_SetItemData( hLB, ix, Data );
1333 va_start( va, Fmt );
1334 _vstprintf_s( sbuf,
dimof(sbuf), Fmt, va );
1337 return ComboBox_AddString( hCB, sbuf );
1342 int ix = ComboBox_FindStringExact( hCB, -1, Text );
1345 ix = ComboBox_AddString( hCB, Text );
1346 if (ix >= 0) ComboBox_SetItemData( hCB, ix, Data );
1380 bool simple = (nParts < 2);
1382 SendMessage( hStat, SB_SIMPLE, simple, 0 );
1385 int *parts =
new int[ nParts ];
1387 va_start( va, nParts );
1388 int *part = parts, n = nParts;
1389 while( n-- ) *part++ = va_arg( va,
int );
1400 bool simple = (nParts < 2);
1402 SendMessage( hStat, SB_SIMPLE, simple, 0 );
1405 register int* pos = Width + 1;
1408 for( UINT ix = 1; ix < nParts; ++ix, ++pos )
1410 if (*pos != -1) *pos += *(pos - 1);
1424 static __thread_local TCHAR sbuf[ MAX_PATH ];
1428 va_start( va, Fmt );
1429 _vstprintf_s( &sbuf[1],
dimof(sbuf)-1, Fmt, va );
1436 static const WORD STAT_HEIGHT = 24;
1437 static const UINT UNSUPP = WS_POPUP| CCS_TOP| CCS_LEFT| CCS_RIGHT;
1442 GetWindowRect( hParent, &r );
1443 r.right -= r.left; r.bottom -= r.top;
1444 r.bottom += STAT_HEIGHT;
1445 SetWindowPos( hParent, NULL, 0,0, r.right, r.bottom, SWP_NOZORDER| SWP_NOMOVE );
1449 Style = (Style & ~UNSUPP) | (WS_CHILD| WS_VISIBLE| CCS_BOTTOM);
1450 HINSTANCE hInst = GetWindowInstance( hParent );
1451 GetClientRect( hParent, &r );
1453 return CreateWindowEx( WS_EX_STATICEDGE, STATUSCLASSNAME,
1454 Text, Style, 0, r.bottom - STAT_HEIGHT, r.right, STAT_HEIGHT,
1455 hParent, HMENU(UINT_PTR( Id )), hInst, NULL
1463 static __thread_local TCHAR Text[256];
1466 LVITEM lvi;
IF_DEBUG( memset( &lvi, 0,
sizeof(lvi) ));
1469 nItems = ListView_GetItemCount( hLv );
1472 for( ix = 0; ix < nItems; ++ix )
1474 lvi.mask = LVIF_TEXT| LVIF_PARAM| LVIF_IMAGE| LVIF_STATE;
1478 lvi.cchTextMax =
dimof(Text);
1479 lvi.stateMask = UINT(-1);
1481 if (ListView_GetItem( hLv, &lvi ))
1483 if (!Action( hLv, &lvi,
pCtx ))
break;
1495 BOOL ok = (hTree && hItem && Buf && bufLen);
1496 if (!ok) SetLastError( ERROR_INVALID_PARAMETER );
1500 IF_DEBUG( memset( &tvi, 0,
sizeof(tvi) ));
1501 tvi.mask = TVIF_TEXT;
1504 tvi.cchTextMax = bufLen;
1505 ok = TreeView_GetItem( hTree, &tvi );
1507 else if (tvi.pszText != Buf) _tcscpy_s( Buf, bufLen, tvi.pszText );
1517 static const UINT _SI_SIZE =
sizeof(SCROLLINFO);
1521 bool ok = ((psi->cbSize == _SI_SIZE) && !IsBadWritePtr( psi, _SI_SIZE ));
1522 if (!ok) SetLastError( ERROR_INVALID_PARAMETER );
1525 if (psi->fMask & SIF_PAGE) psi->nPage = (UINT) SendMessage( hCtl, TBM_GETPAGESIZE, 0,0 );
1526 if (psi->fMask & SIF_RANGE)
1528 psi->nMin = (int) SendMessage( hCtl, TBM_GETRANGEMIN, 0,0 );
1529 psi->nMax = (int) SendMessage( hCtl, TBM_GETRANGEMAX, 0,0 );
1531 bool getPos =
bool_cast( psi->fMask & SIF_POS );
1532 bool getTrkPos =
bool_cast( psi->fMask & SIF_TRACKPOS );
1533 if (getPos || getTrkPos)
1535 int pos = (int) SendMessage( hCtl, TBM_GETPOS, 0,0 );
1536 if (getTrkPos) psi->nTrackPos = pos;
1537 if (getPos) psi->nPos = pos;
1545 bool ok = ((psi->cbSize == _SI_SIZE) && !IsBadReadPtr( psi, _SI_SIZE ));
1546 if (!ok) SetLastError( ERROR_INVALID_PARAMETER );
1549 SendMessage( hCtl, TBM_SETLINESIZE, 0, 1 );
1551 if (psi->fMask & SIF_PAGE) SendMessage( hCtl, TBM_SETPAGESIZE, 0, psi->nPage );
1552 if (psi->fMask & SIF_RANGE)
1554 SendMessage( hCtl, TBM_SETRANGEMIN,
false, psi->nMin );
1555 SendMessage( hCtl, TBM_SETRANGEMAX, Redraw, psi->nMax );
1557 if (psi->fMask & SIF_POS) SendMessage( hCtl, TBM_SETPOS, Redraw, psi->nPos );
1565 HINSTANCE hInst, UINT Id, LPCOLORMAP Map, UINT nMap,
1566 UINT cxImg, UINT Flags, UINT nGrow
1569 HIMAGELIST hIml = NULL;
1570 HBITMAP hBmp = CreateMappedBitmap(
hInstance, Id, 0, Map, nMap );
1573 BITMAP bm; GetObject( hBmp,
sizeof(BITMAP), &bm );
1574 UINT imgCount = bm.bmWidth / cxImg;
1575 hIml = ImageList_Create( cxImg, bm.bmHeight, Flags, imgCount, nGrow );
1576 ImageList_Add( hIml, hBmp, NULL );
1577 DeleteBitmap( hBmp );
1588 static const DWORD TBSTYLE_EX_MASK =
1589 TBSTYLE_EX_MIXEDBUTTONS | TBSTYLE_EX_DRAWDDARROWS
1590 | TBSTYLE_EX_HIDECLIPPEDBUTTONS | TBSTYLE_EX_DOUBLEBUFFER;
1605 HWND hParent, UINT Id, UINT x, UINT y, UINT w, UINT h,
1606 UINT cxBtn, UINT cyBtn, HIMAGELIST hImages, LPTBBUTTON Buttons, UINT nButtons,
1611 if (!Buttons || !nButtons) SetLastError( ERROR_INVALID_PARAMETER );
1614 HINSTANCE hInst = (HINSTANCE)
GWLP( hParent, HINSTANCE );
1615 DWORD wsEx = ExStyle & ~TBSTYLE_EX_MASK;
1616 DWORD tbEx = ExStyle & TBSTYLE_EX_MASK;
1618 hBar = CreateWindowEx( wsEx, TOOLBARCLASSNAME,
1619 S_BLANK, Style, x, y, w, h, hParent, (HMENU)(UINT_PTR) Id, hInst, NULL
1623 if (tbEx) SendMessage( hBar, TB_SETEXTENDEDSTYLE, 0, tbEx );
1624 if (hImages) SendMessage( hBar, TB_SETIMAGELIST, 0, LPARAM( hImages ));
1627 ImageList_GetIconSize( hImages, &cxIm, &cyIm );
1628 SendMessage( hBar, TB_SETBITMAPSIZE, 0, MAKELPARAM( cxIm, cyIm ));
1630 SendMessage( hBar, TB_SETINDENT, 2,0 );
1631 SendMessage( hBar, TB_BUTTONSTRUCTSIZE,
sizeof(TBBUTTON), 0 );
1632 SendMessage( hBar, TB_ADDBUTTONS, nButtons, LPARAM( Buttons ));
1633 SendMessage( hBar, TB_SETBUTTONSIZE, 0, MAKELPARAM( cxBtn, cyBtn ));
1641 HWND hParent, UINT Id, UINT x, UINT y, UINT w, UINT h,
1642 UINT imgType, LPTBBUTTON Buttons, UINT nButtons,
DWORD Style,
DWORD ExStyle
1646 if ((imgType > 9) || (imgType & 1))
1647 SetLastError( ERROR_INVALID_PARAMETER );
1650 HINSTANCE hInst = GetWindowInstance( hParent );
1651 DWORD wsEx = ExStyle & ~TBSTYLE_EX_MASK;
1652 DWORD tbEx = ExStyle & TBSTYLE_EX_MASK;
1653 UINT cxyBtn = (h - 2);
1655 hBar = CreateWindowEx( wsEx, TOOLBARCLASSNAME,
1656 S_BLANK, Style, x, y, w, h, hParent, (HMENU)(UINT_PTR) Id, hInst, NULL
1658 SendMessage( hBar, TB_SETEXTENDEDSTYLE, 0, tbEx );
1659 SendMessage( hBar, TB_BUTTONSTRUCTSIZE,
sizeof(TBBUTTON), 0 );
1660 SendMessage( hBar, TB_SETINDENT, 2, 0 );
1661 SendMessage( hBar, TB_LOADIMAGES, imgType, LPARAM( HINST_COMMCTRL ));
1662 SendMessage( hBar, TB_SETBUTTONSIZE, 0, MAKELPARAM( cxyBtn, cxyBtn ));
1663 SendMessage( hBar, TB_ADDBUTTONS, nButtons, LPARAM( Buttons ));
1664 SendMessage( hBar, TB_SETBUTTONSIZE, 0, MAKELPARAM( cxyBtn, cxyBtn ));
1677 size = CCSIZEOF_STRUCT( REBARBANDINFO, wID );
1679 size = CCSIZEOF_STRUCT( REBARBANDINFO, cxHeader );
1680 #if (_WIN32_WINNT >= 0x0600) 1682 size = CCSIZEOF_STRUCT( REBARBANDINFO, uChevronState );
int __cdecl AddListString(HWND hLB, CSTR Fmt,...)
DWORD GetDLLVersion(CSTR FName)
bool CenterWindow(HWND hChild, HWND hParent)
HICON WINAPI LoadSmallIcon(HINSTANCE hInst, CSTR Id)
bool GetWndPos(HWND hWnd, POINT *pPos)
bool SetMenuItemCheck(HMENU hMenu, UINT Id, bool Check)
#define SB_SetParts(hctl, npart, ppart)
HIMAGELIST ImageList_CreateMapped(HINSTANCE hInst, UINT Id, LPCOLORMAP Map, UINT nMap, UINT cxImg, UINT Flags, UINT nGrow)
IPicture *WINAPI LoadPictureFile(CSTR FName)
HWND CreateDialogParamEx(HINSTANCE hInstance, CSTR Template, HWND hParent, DLGPROC DlgProc, LPARAM lParam, LANGID Language)
bool GetTrackbarInfo(HWND hCtl, LPSCROLLINFO psi)
HWND CreateStatusbar(HWND hParent, UINT Id, CSTR Text, UINT Style)
bool AddMenuItem(HMENU hMenu, UINT Index, CSTR Text, WORD cmdId, WORD State, PVOID Data, HBITMAP Image)
HWND SetParentWnd(HWND wnd, HWND newParent)
bool ResizeWnd(HWND hwnd, int W, int H, bool repaint)
HWND CreateToolbar(HWND hParent, UINT Id, UINT x, UINT y, UINT w, UINT h, UINT cxBtn, UINT cyBtn, HIMAGELIST hImages, LPTBBUTTON Buttons, UINT nButtons, DWORD Style, DWORD ExStyle)
RECT MkRect(LONG L, LONG T, LONG R, LONG B)
long WINAPI HiMetricToPix(long hiMetric)
UINT EnumerateMenuItems(HMENU hMenu, PFnMenuItemAction Action, PVOID Ctx)
bool WINAPI PaintPictureEx(IPicture *pPic, HDC hdc, long x, long y, long cx, long cy, long imx, long imy, long imw, long imh, PRECT prMeta)
void SetWindowDouble(HWND hCtl, int Index, double Value)
bool GetWndSize(HWND hWnd, SIZE *pSize)
bool GetRequiredWindowSize(HWND hWnd, IN const PSIZE pClient, OUT PSIZE pWindow)
bool EnableChildWnd(HWND Owner, UINT Id, bool Enable)
bool ButtonChecked(HWND hBtn)
bool IsWndClass(HWND hWnd, CSTR clsName)
bool RedrawWndRgn(HWND hwnd, HRGN hrgn, UINT flags)
TSTR newStrBuf(WORD nChar)
INT_PTR DialogBoxParamEx(HINSTANCE hInstance, CSTR Template, HWND hParent, DLGPROC DlgProc, LPARAM lParam, LANGID Language)
double GetWndReal(HWND hCtl)
bool __cdecl SetCaption(HWND hwnd, CSTR fmt,...)
bool RedrawWndRect(HWND hwnd, PRECT prect, UINT flags)
void WINAPI PaintPicture(IPicture *pPic, HDC hdc, int x, int y, int cx, int cy)
LPRECT AbsToRelRect(LPRECT pRect)
bool SetWndReal(HWND hCtl, double Value, BYTE nDeci, CSTR Suffix)
PVOID WINAPI LoadCustomResource(HMODULE hModule, CSTR Id, CSTR Type, UINT *pSize)
LPMENUITEMINFO GetMenuItemByName(HMENU hMenu, CSTR Name)
HANDLE __cdecl AsyncMsgBoxEx(HWND Owner, UINT Flags, CSTR Title, HINSTANCE hInst, CSTR IconId, DWORD LangId, DWORD_PTR HelpId, MSGBOXCALLBACK Callback, PINT_PTR pResult, CSTR TextFmt,...)
HWND GetMDIClient(HWND hMdiFrame)
CSTR DupClipboardString()
long WINAPI PixToHiMetric(long Pix)
HWND CreateWindowIndirect(LPCREATESTRUCT pc)
HMODULE GetOrLoadModule(CSTR modName)
#define PACKVERSION(maj, min)
int GetMenuItemIdByName(HMENU hMenu, CSTR Name)
#define TRACE_IF(cond,...)
bool __cdecl SetStatusWidths(HWND hStat, UINT nParts, int *Width)
BOOL(WINAPI *SysImgList::Shell_GetImageLists)(HIMAGELIST *pimlLarge
double GetClassDouble(HWND hCtl, int Index)
#define GetWndStyle(hwnd)
void WINAPI GetScreenLPI(PPOINT pLpi)
ASTR GlobalDupStrA(ACSTR Str, bool isMz=false)
UINT EnumerateClipFormats(HWND hCBOwner, PFClipFmtAction Action, PVOID UserData)
CSTR SysErrorMsg(DWORD Err=0, TSTR Buf=NULL, UINT Length=0)
UINT DispatchMessagesFor(HWND hWnd)
#define SB_SetText(hctl, part, text)
int __cdecl AddComboString(HWND hCB, CSTR Fmt,...)
HWND GetChildWndWithId(HWND hParent, UINT ChildId)
bool OpenEmptyClipboard(HWND hWnd)
SIZE MkSize(LONG cx, LONG cy)
PVOID WINAPI LoadCustomResourceEx(HMODULE hModule, CSTR Id, CSTR Type, LANGID Language, UINT *pSize)
bool PutClipboardStringW(HWND hCBOwner, WCSTR Text)
BOOL GetWindowMinimizeRect(HWND hTrayApp, RECT *pRect)
PVOID DupClipboardData(UINT clipFmt, PUINT pSize)
PVOID GetMenuItemData(HMENU hMenu, UINT Id)
SECURITY_ATTRIBUTES DefSec
HWND GetComboEditor(HWND hCombo)
float GetClassFloat(HWND hCtl, int Index)
bool __forceinline bool_cast(BOOL B52)
#define BITS_SET(bits, x)
double GetWindowDouble(HWND hCtl, int Index)
bool GetWindowClientSize(HWND hWnd, IN const PSIZE pWindow, OUT PSIZE pClient)
float GetWindowFloat(HWND hCtl, int Index)
bool RefreshWnd(HWND hwnd)
bool(__stdcall * PFLvItemAction)(HWND hList, LPLVITEM pItem, PVOID pCtx)
HWND CreateStdToolbar(HWND hParent, UINT Id, UINT x, UINT y, UINT w, UINT h, UINT imgType, LPTBBUTTON Buttons, UINT nButtons, DWORD Style, DWORD ExStyle)
MsgBoxParams * PMsgBoxParams
Debug and error handling support.
int __cdecl MsgBox(HWND owner, UINT type, CSTR cap, CSTR msg,...)
void GetChildWndRect(HWND hCtl, RECT *R)
bool MoveWnd(HWND hwnd, int X, int Y, bool repaint)
bool SetDlgItemReal(HWND hDlg, UINT Id, double Value, BYTE nDeci, CSTR Suffix)
UINT GetWndHeight(HWND hWnd)
#define SetWndStyle(hwnd, style)
bool PutClipHandle(HWND hCBOwner, HANDLE hClip, UINT clipFmt)
PDirEntry PScanDirCtx pCtx
IPicture *WINAPI LoadPictureResource(HMODULE hMod, CSTR Id, CSTR Type)
int AddComboItem(HWND hCB, CSTR Text, LPARAM Data)
Common include; Added types, small "ubiquitous" utilities, et c.
void SetClassFloat(HWND hCtl, int Index, float Value)
bool(__stdcall * PFnMenuItemAction)(HMENU hMenu, MENUITEMINFO *pInfo, PVOID Ctx)
void SetClassDouble(HWND hCtl, int Index, double Value)
bool __cdecl SetStatusText(HWND hStat, UINT Part, CSTR Fmt,...)
WSTR GlobalDupStrW(WCSTR Str, bool isMz=false)
bool CheckButtonCtrl(HWND hDlg, UINT Id, bool Check)
bool(__stdcall * PFClipFmtAction)(UINT FmtTag, PVOID UserData)
POINT MkPoint(LONG x, LONG y)
LPRECT AbsToDimRect(LPRECT pRect)
bool ButtonCtrlChecked(HWND hDlg, UINT Id)
HANDLE __cdecl AsyncMsgBox(UINT Flags, PINT_PTR pResult, CSTR Title, CSTR Fmt,...)
HMENU AddSubMenu(HMENU hMenu, UINT Index, CSTR Text, WORD Id, WORD State, PVOID Data, HBITMAP Image)
bool __cdecl SetStatusParts(HWND hStat, UINT nParts,...)
HMENU LoadMenuEx(HMODULE hModule, CSTR Id, LANGID Language)
HANDLE GetClipHandle(UINT clipFmt)
CSTR GetWndClassName(HWND hWnd)
UINT ListView_ForEach(HWND hLv, PFLvItemAction Action, PVOID pCtx)
HWND GetComboList(HWND hCombo)
int AddListItem(HWND hLB, CSTR Text, LPARAM Data)
bool TreeView_GetItemText(HWND hTree, HTREEITEM hItem, TSTR Buf, UINT bufLen)
UINT GetWndWidth(HWND hWnd)
bool SetTrackbarInfo(HWND hCtl, LPSCROLLINFO psi, bool Redraw)
bool __forceinline IsString(CSTR Str)
MsgBoxParams(CSTR title, WORD maxText, UINT flags)
bool CheckButton(HWND hBtn, bool Check)
END_ANONYMOUS void SetWindowFloat(HWND hCtl, int Index, float Value)
bool PutClipboardStringA(HWND hCBOwner, ACSTR Text)
double GetDlgItemReal(HWND hDlg, UINT Id)
bool RedrawWnd(HWND hwnd, UINT flags)