//-------------------------------------------------------------------------------------- // Update the MSAA sample count combo box for this format //-------------------------------------------------------------------------------------- void UpdateMSAASampleCounts( ID3D10Device* pd3dDevice, DXGI_FORMAT fmt ) { CDXUTComboBox* pComboBox = NULL; bool bResetSampleCount = false; UINT iHighestSampleCount = 0; pComboBox = g_SampleUI.GetComboBox( IDC_SAMPLE_COUNT ); if( !pComboBox ) return; pComboBox->RemoveAllItems(); WCHAR val[10]; for( UINT i = 1; i <= D3D10_MAX_MULTISAMPLE_SAMPLE_COUNT; i++ ) { UINT Quality; if( SUCCEEDED( pd3dDevice->CheckMultisampleQualityLevels( fmt, i, &Quality ) ) && Quality > 0 ) { swprintf_s( val, 10, L"%d", i ); pComboBox->AddItem( val, IntToPtr( i ) ); iHighestSampleCount = i; } else if( g_MSAASampleCount == i ) { bResetSampleCount = true; } } if( bResetSampleCount ) g_MSAASampleCount = iHighestSampleCount; pComboBox->SetSelectedByData( IntToPtr( g_MSAASampleCount ) ); }
void update(dune::deferred_renderer* renderer) { if (combo_render_targets) { combo_render_targets->AddItem(L"None", IntToPtr(0)); for (auto g = renderer->buffers().begin(); g != renderer->buffers().end(); ++g) { dune::tstring w = g->second->name; combo_render_targets->AddItem(w.c_str(), IntToPtr(1)); } } }
static void test_load_save_bmp(void) { IPicture *pic; PICTDESC desc; short type; OLE_HANDLE handle; HGLOBAL hmem; DWORD *mem; IPersistStream *src_stream; IStream *dst_stream; HRESULT hr; desc.cbSizeofstruct = sizeof(desc); desc.picType = PICTYPE_BITMAP; desc.u.bmp.hpal = 0; desc.u.bmp.hbitmap = CreateBitmap(1, 1, 1, 1, NULL); hr = OleCreatePictureIndirect(&desc, &IID_IPicture, FALSE, (void**)&pic); ok(hr == S_OK, "OleCreatePictureIndirect error %#x\n", hr); type = -1; hr = IPicture_get_Type(pic, &type); ok(hr == S_OK,"get_Type error %#8x\n", hr); ok(type == PICTYPE_BITMAP,"expected picture type PICTYPE_BITMAP, got %d\n", type); hr = IPicture_get_Handle(pic, &handle); ok(hr == S_OK,"get_Handle error %#8x\n", hr); ok(IntToPtr(handle) == desc.u.bmp.hbitmap, "get_Handle returned wrong handle %#x\n", handle); hmem = GlobalAlloc(GMEM_ZEROINIT, 4096); hr = CreateStreamOnHGlobal(hmem, FALSE, &dst_stream); ok(hr == S_OK, "createstreamonhglobal error %#x\n", hr); hr = IPicture_QueryInterface(pic, &IID_IPersistStream, (void **)&src_stream); ok(hr == S_OK, "QueryInterface error %#x\n", hr); hr = IPersistStream_Save(src_stream, dst_stream, TRUE); ok(hr == S_OK, "Save error %#x\n", hr); IPersistStream_Release(src_stream); IStream_Release(dst_stream); mem = GlobalLock(hmem); ok(!memcmp(mem, "lt\0\0", 4), "got wrong stream header %04x\n", mem[0]); ok(mem[1] == 66, "expected stream size 66, got %u\n", mem[1]); ok(!memcmp(&mem[2], "BM", 2), "got wrong bmp header %04x\n", mem[2]); GlobalUnlock(hmem); GlobalFree(hmem); DeleteObject(desc.u.bmp.hbitmap); IPicture_Release(pic); }
static void test_load_save_icon(void) { IPicture *pic; PICTDESC desc; short type; OLE_HANDLE handle; HGLOBAL hmem; DWORD *mem; IPersistStream *src_stream; IStream *dst_stream; HRESULT hr; desc.cbSizeofstruct = sizeof(desc); desc.picType = PICTYPE_ICON; desc.u.icon.hicon = LoadIcon(0, IDI_APPLICATION); hr = OleCreatePictureIndirect(&desc, &IID_IPicture, FALSE, (void**)&pic); ok(hr == S_OK, "OleCreatePictureIndirect error %#x\n", hr); type = -1; hr = IPicture_get_Type(pic, &type); ok(hr == S_OK,"get_Type error %#8x\n", hr); ok(type == PICTYPE_ICON,"expected picture type PICTYPE_ICON, got %d\n", type); hr = IPicture_get_Handle(pic, &handle); ok(hr == S_OK,"get_Handle error %#8x\n", hr); ok(IntToPtr(handle) == desc.u.icon.hicon, "get_Handle returned wrong handle %#x\n", handle); hmem = GlobalAlloc(GMEM_ZEROINIT, 8192); hr = CreateStreamOnHGlobal(hmem, FALSE, &dst_stream); ok(hr == S_OK, "CreateStreamOnHGlobal error %#x\n", hr); hr = IPicture_QueryInterface(pic, &IID_IPersistStream, (void **)&src_stream); ok(hr == S_OK, "QueryInterface error %#x\n", hr); hr = IPersistStream_Save(src_stream, dst_stream, TRUE); ok(hr == S_OK, "Saveerror %#x\n", hr); IPersistStream_Release(src_stream); IStream_Release(dst_stream); mem = GlobalLock(hmem); ok(!memcmp(mem, "lt\0\0", 4), "got wrong stream header %04x\n", mem[0]); todo_wine ok(mem[1] == 766, "expected stream size 766, got %u\n", mem[1]); ok(mem[2] == 0x00010000, "got wrong icon header %04x\n", mem[2]); GlobalUnlock(hmem); GlobalFree(hmem); DestroyIcon(desc.u.icon.hicon); IPicture_Release(pic); }
ATOM RegisterMainWindowClass( const HINSTANCE i_thisInstanceOfTheProgram ) { WNDCLASSEX wndClassEx = { 0 }; wndClassEx.cbSize = sizeof( WNDCLASSEX ); wndClassEx.hInstance = i_thisInstanceOfTheProgram; // The class's style wndClassEx.style = 0; #ifdef EAE6320_PLATFORM_GL // Reserve a unique device context for this window for OpenGL's use wndClassEx.style |= CS_OWNDC; #endif // The function that will process all of the messages // that Windows will send to windows of this class wndClassEx.lpfnWndProc = OnMessageReceived; // Extra bytes can be set aside in the class for user data wndClassEx.cbClsExtra = 0; // Extra bytes can be set aside for each window of this class, // but this is usually specified for each window individually wndClassEx.cbWndExtra = 0; // The large and small icons that windows of this class should use // (These can be found in the Resources folder; feel free to change them) wndClassEx.hIcon = LoadIcon( i_thisInstanceOfTheProgram, MAKEINTRESOURCE( IDI_BIG ) ); wndClassEx.hIconSm = LoadIcon( i_thisInstanceOfTheProgram, MAKEINTRESOURCE( IDI_SMALL ) ); // The cursor that should display when the mouse pointer is over windows of this class wndClassEx.hCursor = LoadCursor( NULL, IDC_ARROW ); // The "brush" that windows of this class should use as a background // (Setting this is a bit confusing but not important, // so don't be alarmed if the next line looks scary) wndClassEx.hbrBackground = reinterpret_cast<HBRUSH>( IntToPtr( COLOR_BACKGROUND + 1 ) ); // A menu can be specified that all windows of this class would use by default, // but usually this is set for each window individually wndClassEx.lpszMenuName = NULL; // The class name (see comments where this is initialized) wndClassEx.lpszClassName = s_mainWindowClass_name; // Now all of the above information is given to Windows. // If all goes well, the class will be successfully registered // and it can be specified by name when creating the main window. const ATOM mainWindowClass = RegisterClassEx( &wndClassEx ); if ( mainWindowClass == NULL ) { const char* errorCaption = "No Main Window Class"; std::string errorMessage( "Windows failed to register the main window's class: " ); errorMessage += eae6320::GetLastWindowsError(); MessageBox( NULL, errorMessage.c_str(), errorCaption, MB_OK | MB_ICONERROR ); } return mainWindowClass; }
/** **************************************************************************************************** \fn bool RegisterClass( void ) \brief Register the window class \param NONE \return boolean \retval SUCCESS success \retval FAIL otherwise **************************************************************************************************** */ bool RendererEngine::Window::RegisterClass( void ) { WNDCLASSEX wndClassEx = { 0 }; wndClassEx.cbSize = sizeof( WNDCLASSEX ); wndClassEx.hInstance = _applicationInstance; // The class's style // (We don't have to worry about any of these) wndClassEx.style = 0; // The function that will process all of the messages // that Windows will send to windows of this class wndClassEx.lpfnWndProc = OnMessageReceived; // Extra bytes can be set aside in the class for user data // (This is rarely used, but can be useful) wndClassEx.cbClsExtra = 0; // Extra bytes can be set aside for each window of the class, // but this is usually specified for each window individually wndClassEx.cbWndExtra = 0; // The large and small icons windows of this class should use // (These can be found in the Resources folder; feel free to change them) wndClassEx.hIcon = LoadIcon( _applicationInstance, MAKEINTRESOURCE( IDI_RENDERER ) ); wndClassEx.hIconSm = LoadIcon( _applicationInstance, MAKEINTRESOURCE( IDI_SMALL ) ); // The cursor that should display when the mouse pointer is over windows of this class wndClassEx.hCursor = LoadCursor( NULL, IDC_ARROW ); // The brush windows of this class will use as a background // (Setting this is a bit confusing, so don't be alarmed if the next line looks scary) wndClassEx.hbrBackground = reinterpret_cast<HBRUSH>( IntToPtr( COLOR_BACKGROUND + 1 ) ); // A menu can be specified that all windows of this class would use by default, // but usually this is set for each window individually wndClassEx.lpszMenuName = NULL; // The class name (see comments where this is initialized) wndClassEx.lpszClassName = _windowName; // Now we can provide this information to Windows. // If all goes well, the class will be successfully registered // and we can specify it by name when creating our windows. _class = RegisterClassEx( &wndClassEx ); if ( _class != NULL ) { LogMessage( "Registered the main window class" ); return SUCCESS; } else { LogMessage( std::string( "Windows failed to register the main window's class: " ) + GetLastWindowsError() ); return FAIL; } }
/******************************************************************* * longjmp (MSVCRT.@) */ void __cdecl MSVCRT_longjmp(struct MSVCRT___JUMP_BUFFER *jmp, int retval) { EXCEPTION_RECORD rec; if (!retval) retval = 1; if (jmp->Frame) { rec.ExceptionCode = STATUS_LONGJUMP; rec.ExceptionFlags = 0; rec.ExceptionRecord = NULL; rec.ExceptionAddress = NULL; rec.NumberParameters = 1; rec.ExceptionInformation[0] = (DWORD_PTR)jmp; RtlUnwind((void *)jmp->Frame, (void *)jmp->Pc, &rec, IntToPtr(retval)); } longjmp_set_regs(jmp, retval); }
/***************************************************************************\ * DdeNameService (DDEML API) * * Description: * Registers, and Unregisters service names and sets the Initiate filter * state for an instance. * * History: * 11-1-91 sanfords Created. \***************************************************************************/ HDDEDATA DdeNameService( DWORD idInst, HSZ hsz1, // service name HSZ hsz2, // reserved for future enhancements UINT afCmd) // DNS_ flags. { BOOL fRet = TRUE; LATOM *plaNameService; PCL_INSTANCE_INFO pcii; EnterDDECrit; pcii = ValidateInstance((HANDLE)LongToHandle( idInst )); if (pcii == NULL) { BestSetLastDDEMLError(DMLERR_INVALIDPARAMETER); fRet = FALSE; goto Exit; } if ((hsz1 && ValidateHSZ(hsz1) == HSZT_INVALID) || hsz2 != 0) { SetLastDDEMLError(pcii, DMLERR_INVALIDPARAMETER); fRet = FALSE; goto Exit; } if (afCmd & DNS_FILTERON && !(pcii->afCmd & APPCMD_FILTERINITS)) { pcii->afCmd |= APPCMD_FILTERINITS; NtUserUpdateInstance(pcii->hInstServer, &pcii->MonitorFlags, pcii->afCmd); } if (afCmd & DNS_FILTEROFF && (pcii->afCmd & APPCMD_FILTERINITS)) { pcii->afCmd &= ~APPCMD_FILTERINITS; NtUserUpdateInstance(pcii->hInstServer, &pcii->MonitorFlags, pcii->afCmd); } if (afCmd & (DNS_REGISTER | DNS_UNREGISTER)) { GATOM ga; if (pcii->afCmd & APPCMD_CLIENTONLY) { SetLastDDEMLError(pcii, DMLERR_DLL_USAGE); fRet = FALSE; goto Exit; } if (hsz1 == 0) { if (afCmd & DNS_REGISTER) { /* * registering NULL is not allowed! */ SetLastDDEMLError(pcii, DMLERR_INVALIDPARAMETER); fRet = FALSE; goto Exit; } /* * unregistering NULL is just like unregistering each * registered name. * * 10/19/90 - made this a synchronous event so that hsz * can be freed by calling app after this call completes * without us having to keep a copy around forever. */ plaNameService = pcii->plaNameService; while (*plaNameService != 0) { ga = LocalToGlobalAtom(*plaNameService); DeleteAtom(*plaNameService); LeaveDDECrit; RegisterService(FALSE, ga, pcii->hwndMother); EnterDDECrit; GlobalDeleteAtom(ga); plaNameService++; } pcii->cNameServiceAlloc = 1; *pcii->plaNameService = 0; goto Exit; } if (afCmd & DNS_REGISTER) { plaNameService = (LATOM *)DDEMLReAlloc(pcii->plaNameService, sizeof(LATOM) * ++pcii->cNameServiceAlloc); if (plaNameService == NULL) { SetLastDDEMLError(pcii, DMLERR_MEMORY_ERROR); pcii->cNameServiceAlloc--; fRet = FALSE; goto Exit; } else { pcii->plaNameService = plaNameService; } IncLocalAtomCount(LATOM_FROM_HSZ(hsz1)); // NameService copy plaNameService[pcii->cNameServiceAlloc - 2] = LATOM_FROM_HSZ(hsz1); plaNameService[pcii->cNameServiceAlloc - 1] = 0; } else { // DNS_UNREGISTER plaNameService = pcii->plaNameService; while (*plaNameService != 0 && *plaNameService != LATOM_FROM_HSZ(hsz1)) { plaNameService++; } if (*plaNameService == 0) { goto Exit; // not found just exit } // // fill empty slot with last entry and fill last entry with 0 // pcii->cNameServiceAlloc--; *plaNameService = pcii->plaNameService[pcii->cNameServiceAlloc - 1]; pcii->plaNameService[pcii->cNameServiceAlloc - 1] = 0; } ga = LocalToGlobalAtom(LATOM_FROM_HSZ(hsz1)); LeaveDDECrit; RegisterService((afCmd & DNS_REGISTER) ? TRUE : FALSE, ga, pcii->hwndMother); EnterDDECrit; GlobalDeleteAtom(ga); } Exit: LeaveDDECrit; return ((HDDEDATA)IntToPtr( fRet )); }
int open_ep_mixers(px_mixer *Px, UINT deviceIn, UINT deviceOut) { PxEPInfo *info; IMMDeviceEnumerator *denum = NULL; IMMDevice *device = NULL; HRESULT hr; MMRESULT res; LPWSTR idStr; size_t idLen; if (!initialize(Px)) { goto fail; } info = (PxEPInfo *) Px->info; info->inputEP = NULL; info->outputEP = NULL; // Create an audio endpoint device enumerator. hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, &IID_IMMDeviceEnumerator, &denum); if (FAILED(hr)) { goto fail; } if (deviceIn == WAVE_MAPPER) { hr = IMMDeviceEnumerator_GetDefaultAudioEndpoint(denum, eCapture, eMultimedia, &device); if (SUCCEEDED(hr)) { hr = IMMDevice_Activate(device, &IID_IAudioEndpointVolume, CLSCTX_ALL, NULL, &info->inputEP); IUnknown_Release(device); } if (FAILED(hr)) { goto fail; } } else { res = waveInMessage((HWAVEIN)IntToPtr(deviceIn), DRV_QUERYFUNCTIONINSTANCEIDSIZE, (DWORD_PTR)&idLen, (DWORD_PTR)NULL); if (res != MMSYSERR_NOERROR) { goto fail; } idStr = (WCHAR *) CoTaskMemAlloc(idLen + sizeof(WCHAR)); if (idStr == NULL) { goto fail; } res = waveInMessage((HWAVEIN)IntToPtr(deviceIn), DRV_QUERYFUNCTIONINSTANCEID, (DWORD_PTR)idStr, (DWORD_PTR)idLen); if (res != MMSYSERR_NOERROR) { CoTaskMemFree(idStr); goto fail; } hr = IMMDeviceEnumerator_GetDevice(denum, idStr, &device); if (SUCCEEDED(hr)) { hr = IMMDevice_Activate(device, &IID_IAudioEndpointVolume, CLSCTX_ALL, NULL, &info->inputEP); IUnknown_Release(device); } CoTaskMemFree(idStr); if (FAILED(hr)) { goto fail; } } if (deviceOut == WAVE_MAPPER) { hr = IMMDeviceEnumerator_GetDefaultAudioEndpoint(denum, eRender, eMultimedia, &device); if (SUCCEEDED(hr)) { hr = IMMDevice_Activate(device, &IID_IAudioEndpointVolume, CLSCTX_ALL, NULL, &info->outputEP); IUnknown_Release(device); } if (FAILED(hr)) { goto fail; } } else { res = waveOutMessage((HWAVEOUT)IntToPtr(deviceOut), DRV_QUERYFUNCTIONINSTANCEIDSIZE, (DWORD_PTR)&idLen, (DWORD_PTR)NULL); if (res != MMSYSERR_NOERROR) { goto fail; } idStr = (WCHAR *) CoTaskMemAlloc(idLen + sizeof(WCHAR)); if (idStr == NULL) { goto fail; } res = waveOutMessage((HWAVEOUT)IntToPtr(deviceOut), DRV_QUERYFUNCTIONINSTANCEID, (DWORD_PTR)idStr, (DWORD_PTR)idLen); if (res != MMSYSERR_NOERROR) { CoTaskMemFree(idStr); goto fail; } hr = IMMDeviceEnumerator_GetDevice(denum, idStr, &device); if (SUCCEEDED(hr)) { hr = IMMDevice_Activate(device, &IID_IAudioEndpointVolume, CLSCTX_ALL, NULL, &info->outputEP); IUnknown_Release(device); } CoTaskMemFree(idStr); if (FAILED(hr)) { goto fail; } } if (denum) { IUnknown_Release(denum); } return TRUE; fail: if (denum) { IUnknown_Release(denum); } return cleanup(Px); }
static LRESULT FASTCALL co_IntCallLowLevelHook(PHOOK Hook, INT Code, WPARAM wParam, LPARAM lParam) { NTSTATUS Status; PTHREADINFO pti; PHOOKPACK pHP; INT Size = 0; UINT uTimeout = 300; BOOL Block = FALSE; ULONG_PTR uResult = 0; if (Hook->ptiHooked) pti = Hook->ptiHooked; else pti = Hook->head.pti; pHP = ExAllocatePoolWithTag(NonPagedPool, sizeof(HOOKPACK), TAG_HOOK); if (!pHP) return 0; pHP->pHk = Hook; pHP->lParam = lParam; pHP->pHookStructs = NULL; // This prevents stack corruption from the caller. switch(Hook->HookId) { case WH_JOURNALPLAYBACK: case WH_JOURNALRECORD: uTimeout = 0; Size = sizeof(EVENTMSG); break; case WH_KEYBOARD_LL: Size = sizeof(KBDLLHOOKSTRUCT); break; case WH_MOUSE_LL: Size = sizeof(MSLLHOOKSTRUCT); break; case WH_MOUSE: uTimeout = 200; Block = TRUE; Size = sizeof(MOUSEHOOKSTRUCT); break; case WH_KEYBOARD: uTimeout = 200; Block = TRUE; break; } if (Size) { pHP->pHookStructs = ExAllocatePoolWithTag(NonPagedPool, Size, TAG_HOOK); if (pHP->pHookStructs) RtlCopyMemory(pHP->pHookStructs, (PVOID)lParam, Size); } /* FIXME: Should get timeout from * HKEY_CURRENT_USER\Control Panel\Desktop\LowLevelHooksTimeout */ Status = co_MsqSendMessage( pti, IntToPtr(Code), // hWnd Hook->HookId, // Msg wParam, (LPARAM)pHP, uTimeout, Block, MSQ_ISHOOK, &uResult); if (!NT_SUCCESS(Status)) { ERR("Error Hook Call SendMsg. %d Status: 0x%x\n", Hook->HookId, Status); if (pHP->pHookStructs) ExFreePoolWithTag(pHP->pHookStructs, TAG_HOOK); ExFreePoolWithTag(pHP, TAG_HOOK); } return NT_SUCCESS(Status) ? uResult : 0; }
BOOL SERVER::CanTalkToServer (ULONG *pStatus) { // Ensure the server exists in the cell at all-- // this call just updates the server's IP addresses // etc (information it gets from the database servers) // and doesn't require talking to the server itself. // if (!RefreshStatus (FALSE, pStatus)) return FALSE; // Find a new refsec array element to use... // AfsClass_InitRefreshSections(); EnterCriticalSection (pcsRefSec); int idSection; for (idSection = 0; idSection < (int)cRefSec; ++idSection) { if (!aRefSec[ idSection ].fInUse) break; } if (idSection == (int)cRefSec) { if (!REALLOC (aRefSec, cRefSec, 1+idSection, 4)) { if (pStatus) *pStatus = GetLastError(); LeaveCriticalSection (pcsRefSec); return FALSE; } } aRefSec[ idSection ].fInUse = TRUE; aRefSec[ idSection ].fCanceled = FALSE; aRefSec[ idSection ].lpServer = this; aRefSec[ idSection ].hCell = NULL; LPCELL lpCell; if ((lpCell = OpenCell()) != NULL) { aRefSec[ idSection ].hCell = lpCell->GetCellObject(); lpCell->Close(); } LeaveCriticalSection (pcsRefSec); // Until we find out differently, assume that we won't be // able to query VOS or BOS on this server. // m_fCanGetAggregates = FALSE; m_fCanGetServices = FALSE; m_lastStatus = 0; // Fork a separate thread, on which to quickly try to talk // to the server. // DWORD dwThreadID; HANDLE hThread; if ((hThread = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE)CanTalkToServer_ThreadProc, IntToPtr(idSection), 0, &dwThreadID)) == NULL) { EnterCriticalSection (pcsRefSec); aRefSec[ idSection ].fInUse = FALSE; LeaveCriticalSection (pcsRefSec); if (pStatus) *pStatus = GetLastError(); return FALSE; } SetThreadPriority (hThread, THREAD_PRIORITY_BELOW_NORMAL); // Wait for that thread to terminate, or for our // newly-allocated RefSec entry to be marked Canceled. // DWORD dw; for (dw = STILL_ACTIVE; dw == STILL_ACTIVE; ) { EnterCriticalSection (pcsRefSec); GetExitCodeThread (hThread, &dw); if (dw == STILL_ACTIVE) { if ( (aRefSec[ idSection ].fInUse) && (aRefSec[ idSection ].lpServer == this) && (aRefSec[ idSection ].fCanceled) ) { if (m_lastStatus == 0) m_lastStatus = ERROR_CANCELLED; dw = 0; } } LeaveCriticalSection (pcsRefSec); if (dw == STILL_ACTIVE) Sleep(100); // wait another brief instant } // dw == 0 : user canceled operation (thread is still running!) // dw == 1 : thread completed successfully, and set fCanTalkTo* flags. // // Note that the thread will clear aRefSec[idSection].fInUse when it // terminates (so, if dw!=-1, it has already done so). // if (pStatus) *pStatus = m_lastStatus; return (dw == 0) ? FALSE : TRUE; }
/* Property page dialog callback */ INT_PTR CALLBACK DisplayPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { PGLOBAL_DATA pGlobalData; LPPSHNOTIFY lppsn; INT i; pGlobalData = (PGLOBAL_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER); switch (uMsg) { case WM_INITDIALOG: pGlobalData = (PGLOBAL_DATA)((LPPROPSHEETPAGE)lParam)->lParam; if (pGlobalData == NULL) return FALSE; SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData); pGlobalData->fShowCaret = TRUE; GetWindowRect(GetDlgItem(hwndDlg, IDC_CURSOR_WIDTH_TEXT), &pGlobalData->rcCaret); ScreenToClient(hwndDlg, (LPPOINT)&pGlobalData->rcCaret.left); ScreenToClient(hwndDlg, (LPPOINT)&pGlobalData->rcCaret.right); CopyRect(&pGlobalData->rcOldCaret, &pGlobalData->rcCaret); pGlobalData->rcCaret.right = pGlobalData->rcCaret.left + pGlobalData->uCaretWidth; /* Set the checkbox */ CheckDlgButton(hwndDlg, IDC_CONTRAST_BOX, pGlobalData->highContrast.dwFlags & HCF_HIGHCONTRASTON ? BST_CHECKED : BST_UNCHECKED); SendDlgItemMessage(hwndDlg, IDC_CURSOR_BLINK_TRACK, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(0, 10)); SendDlgItemMessage(hwndDlg, IDC_CURSOR_BLINK_TRACK, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(12 - (pGlobalData->uCaretBlinkTime / 100))); SendDlgItemMessage(hwndDlg, IDC_CURSOR_WIDTH_TRACK, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(0, 19)); SendDlgItemMessage(hwndDlg, IDC_CURSOR_WIDTH_TRACK, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(pGlobalData->uCaretWidth - 1)); /* Start the blink timer */ SetTimer(hwndDlg, ID_BLINK_TIMER, pGlobalData->uCaretBlinkTime, NULL); return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_CONTRAST_BOX: pGlobalData->highContrast.dwFlags ^= HCF_HIGHCONTRASTON; PropSheet_Changed(GetParent(hwndDlg), hwndDlg); break; case IDC_CONTRAST_BUTTON: if (DialogBoxParam(hApplet, MAKEINTRESOURCE(IDD_CONTRASTOPTIONS), hwndDlg, (DLGPROC)HighContrastDlgProc, (LPARAM)pGlobalData)) PropSheet_Changed(GetParent(hwndDlg), hwndDlg); break; default: break; } break; case WM_HSCROLL: switch (GetWindowLongPtr((HWND) lParam, GWL_ID)) { case IDC_CURSOR_BLINK_TRACK: i = SendDlgItemMessage(hwndDlg, IDC_CURSOR_BLINK_TRACK, TBM_GETPOS, 0, 0); pGlobalData->uCaretBlinkTime = (12 - (UINT)i) * 100; KillTimer(hwndDlg, ID_BLINK_TIMER); SetTimer(hwndDlg, ID_BLINK_TIMER, pGlobalData->uCaretBlinkTime, NULL); PropSheet_Changed(GetParent(hwndDlg), hwndDlg); break; case IDC_CURSOR_WIDTH_TRACK: i = SendDlgItemMessage(hwndDlg, IDC_CURSOR_WIDTH_TRACK, TBM_GETPOS, 0, 0); pGlobalData->uCaretWidth = (UINT)i + 1; pGlobalData->rcCaret.right = pGlobalData->rcCaret.left + pGlobalData->uCaretWidth; if (pGlobalData->fShowCaret) { HDC hDC = GetDC(hwndDlg); HBRUSH hBrush = GetSysColorBrush(COLOR_BTNTEXT); FillRect(hDC, &pGlobalData->rcCaret, hBrush); DeleteObject(hBrush); ReleaseDC(hwndDlg, hDC); } else { InvalidateRect(hwndDlg, &pGlobalData->rcOldCaret, TRUE); } PropSheet_Changed(GetParent(hwndDlg), hwndDlg); break; } break; case WM_TIMER: if (wParam == ID_BLINK_TIMER) { if (pGlobalData->fShowCaret) { HDC hDC = GetDC(hwndDlg); HBRUSH hBrush = GetSysColorBrush(COLOR_BTNTEXT); FillRect(hDC, &pGlobalData->rcCaret, hBrush); DeleteObject(hBrush); ReleaseDC(hwndDlg, hDC); } else { InvalidateRect(hwndDlg, &pGlobalData->rcOldCaret, TRUE); } pGlobalData->fShowCaret = !pGlobalData->fShowCaret; } break; case WM_NOTIFY: lppsn = (LPPSHNOTIFY)lParam; if (lppsn->hdr.code == PSN_APPLY) { SetCaretBlinkTime(pGlobalData->uCaretBlinkTime); SystemParametersInfo(SPI_SETCARETWIDTH, 0, IntToPtr(pGlobalData->uCaretWidth), SPIF_UPDATEINIFILE | SPIF_SENDCHANGE /*0*/); SystemParametersInfo(SPI_SETHIGHCONTRAST, sizeof(HIGHCONTRAST), &pGlobalData->highContrast, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE /*0*/); return TRUE; } break; case WM_DESTROY: KillTimer(hwndDlg, ID_BLINK_TIMER); break; } return FALSE; }