winapi

Why do I need to save handle to an old bitmap while drawing with Win32 GDI?

大城市里の小女人 提交于 2021-02-10 11:53:58
问题 Here is the code from switch in WndProc function I've been given as an example: case WM_PAINT: hdc = BeginPaint(hWnd, &ps); // Create a system memory device context. bmHDC = CreateCompatibleDC(hdc); // Hook up the bitmap to the bmHDC. oldBM = (HBITMAP)SelectObject(bmHDC, ghBitMap); // Now copy the pixels from the bitmap bmHDC has selected // to the pixels from the client area hdc has selected. BitBlt( hdc, // Destination DC. 0, // 'left' coordinate of destination rectangle. 0, // 'top'

Passing WPARAM into DragQueryFile not compatible?

断了今生、忘了曾经 提交于 2021-02-10 09:26:26
问题 I'm kinda confused. When a file is dragged onto a window with WS_EX_ACCEPTFILES flagged it places a PostMessage into the WndProc function, which sets UINT message to WM_DROPFILES and, according to https://msdn.microsoft.com/en-us/library/windows/desktop/bb774303(v=vs.85).aspx the WPARAM = (WPARAM) (HDROP) hDrop; So am I wrong to assume that I can use the WPARAM to initialize the HDROP or just pass it into the DragQueryFile ?? LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam,

Passing WPARAM into DragQueryFile not compatible?

主宰稳场 提交于 2021-02-10 09:24:25
问题 I'm kinda confused. When a file is dragged onto a window with WS_EX_ACCEPTFILES flagged it places a PostMessage into the WndProc function, which sets UINT message to WM_DROPFILES and, according to https://msdn.microsoft.com/en-us/library/windows/desktop/bb774303(v=vs.85).aspx the WPARAM = (WPARAM) (HDROP) hDrop; So am I wrong to assume that I can use the WPARAM to initialize the HDROP or just pass it into the DragQueryFile ?? LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam,

Correct way to stop asynchronous ISearchJob

吃可爱长大的小学妹 提交于 2021-02-10 06:33:12
问题 I am going to use WUA API and begin execution of an asynchronous search for updates in this way: CComPtr<SearchCallbackImpl> iscc_; <<-- Note you need to CreateInstance CComPtr<ISearchJob> pUpJob_; pUpJob_ = NULL; pUpSearcher_->BeginSearch( CComVariant(criteria.c_str()).bstrVal, iscc_, CComVariant(L"Scanning"), &pUpJob_); When I need to stop my program, but ISearchJob has not completed yet, I use this code: if (pUpJob_) { CComVariant isStopped; pUpJob_->get_IsCompleted(&isStopped.boolVal); if

UWP: How to call WinAPI Method

假如想象 提交于 2021-02-10 05:45:47
问题 My question is simple. How can I call a WinAPI Method like emptyClipboard in an UWP app? I included the 'Windows Desktop Extensions for the UWP' The method is listed under Windows API Index / Data Exchange / Clipboard Reference / Clipboard Functions I've tried the following ( js ): Windows.emptyClipboard(); Windows.WinAPI.emptyClipboard(); Windows.ApplicationModel.emptyClipboard(); Windows.DataExchange.emptyClipboard(); Windows.DataExchange.Clipboard.emptyClipboard(); each of them giving me

wsprintfW printing only tens?

天大地大妈咪最大 提交于 2021-02-10 04:42:24
问题 I have a trackbar and at some point it's value is supposed to change a text: case WM_HSCROLL: { LRESULT pos = SendMessage(trackBar, TBM_GETPOS, 0, 0); WCHAR buf[3]; wsprintfW(buf, L"%ld", pos); SetWindowText(trackBarValue, (LPCSTR)buf); } break; The trackbar's range goes from 15 to 35. For some reason, only the tens gets printed to the text (As my trackbar's value is between 15 and 19, the text is 1, when my trackbar's value is between 20 and 29, my text is 2, and it becomes 3 as my trackbar

How to prevent windows from accessing and detecting new volumes while writing a raw image file to PhysicalDrive?

て烟熏妆下的殇ゞ 提交于 2021-02-10 03:22:09
问题 After lots and lots of try and error I am now able to flash/write a raw image file (containing multiple partitions) to \\.\PhysicalDriveN (SD-Card in my case) by just using Windows Api calls ( see below ). But as soon as I have some explorer windows open and click around, the write process fails ( error 433 ). Another annoying problem are popup messages telling me that a new volume has to be formatted (at the beginning, while I am still writing!) or autoplay asks me to select an action (after

Windows kernel32 functions in Mono on Linux

丶灬走出姿态 提交于 2021-02-09 09:02:31
问题 I got this awesomely simple ini class that I downloaded from somewhere a while ago, but now that I'm using mono I'm running into the issue that it's importing stuff from kernel32 [DllImport("kernel32")] private static extern long WritePrivateProfileString(string section, string key, string val, string filePath); [DllImport("kernel32")] private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath); Which on mono (in

Static Text Color

岁酱吖の 提交于 2021-02-08 19:58:10
问题 I have written Following code which will apply color to all static text in one window, but I want to apply two different colors in one window like ID:1234 where ID is another color and 1234 will be different color in one window. How can I do this? here is what i have done: case WM_CTLCOLORSTATIC: SetBkColor( hdc, COLORREF( :: GetSysColor( COLOR_3DFACE) ) ); //sets bckcolor of static text same as window color if ( ( HWND ) lParam == GetDlgItem( hWnd, IDC_PID) ) { SetTextColor( ( HDC ) wParam,

UI Automation switch window

谁都会走 提交于 2021-02-08 14:14:43
问题 I've noticed that setforegroundwindow can be very flaky - no matter how you do it. I've noticed that using UIAutomation, where possible, seems to improve things. For example: Getting the WindowPattern and using something like: windowPattern.SetWindowVisualState( WindowVisualState.Normal ); windowPattern.SetWindowVisualState( WindowVisualState.Maximized ); Now my questions is: How do I know whether I should make it maximized or normal. The task manager, and dragon naturally speaking both seem