visual-c++

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,

typeid operator in C++

心不动则不痛 提交于 2021-02-08 19:49:15
问题 I have the following code int main() { cout << "Please enter your name..." << endl; cin >> name; cout << "Data type = " << typeid(name).name() << endl; cin.get(); return 0; } According to the various textbooks and pieces of documentation I've read about the typeid operator, I should expect to read "Data type = string" as the output. Instead, I get the following class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > Does anyone have any idea where I'm going

How to clear cin Buffer in c++

删除回忆录丶 提交于 2021-02-08 11:55:25
问题 I have gone through many existing answers here StackOverflow, but I am still stuck. code: int c; cin >> c; if(cin.fail()) { cout << "Wrong Input"; cin.clear(); cin.ignore(INT_MAX, '\n'); } else { cout << c*2; } If I enter wring input e.g s instead of an integer, it outputs Wrong Input . However, if I enter an integer, and then I enter a string, it ignores the string and keep outputting the previous integer result, hence it does not clears the cin buffer, and the old value of c keeps on

Visual Studio 2019 rejects `bool concept` while gcc 8 doesn't compile concepts without `bool`

删除回忆录丶 提交于 2021-02-08 09:58:06
问题 I thought c++ concepts is a better method to write c++ templated code with better error messages and faster compile times , so I upgraded Visual Studio to 2019 and still waiting for clang to support concepts however I tested some simple code with msvc from visual studio 2019 and g++ 8 from mingw-w64 and I'm having some trouble. This is the test: #include <iostream> using namespace std; // this compiles under g++ 8 but not visual studio 2019 template <class T> bool concept CharT = std::is_same

Visual C++ or C play sounds

痞子三分冷 提交于 2021-02-08 09:01:25
问题 I'm developping an easy game written in C (Visual C++) and I want to know if there is a way to play sounds, thanks (I'm using Visual Studio) 回答1: Take a look at the PlaySound() function. If you call PlaySound() with the SND_ASYNC flag, the function returns immediately after beginning the sound. For example: #include <windows.h> #include <mmsystem.h> PlaySound(L"test.wav", NULL, SND_ASYNC | SND_FILENAME); You'll also have to add Winmm.lib in your project settings. Here's a quick example that

How to check mouse is not moved from last 5 seconds?

岁酱吖の 提交于 2021-02-08 08:26:29
问题 I'm working on a task for my game program, in which I want to hide my mouse after 10 seconds from my screen. However I'm able to check the mouse move condition... Here is my code.. using namespace std; HHOOK g_hMouseHook; LRESULT CALLBACK LowLevelMouseProc(int nCode, WPARAM wParam, LPARAM lParam) { if (nCode >= 0) { PMSLLHOOKSTRUCT pmll = (PMSLLHOOKSTRUCT) lParam; switch (wParam) { case WM_MOUSEMOVE: printf("Mouse has been moved\n"); break; } } return CallNextHookEx(g_hMouseHook, nCode,

To build the program with a static lib, libcurl.lib

心已入冬 提交于 2021-02-08 08:17:05
问题 I tried to build a stanalone program with a static lib , libcurl.lib . But I got bunch of errors. I ever refered to the related posts on stackoverflow and libcurl homepage, unfortunately it is in vain so far. The following is my building procedure and the error message I got. Please comments. Thank you a lot, 1. Build curl from source code nmake /f Makefile.vc mode=static VC=14 ENABLE_SSPI=no ENABLE_IPV6=no ENABLE_IDN=no GEN_PDB=no DEBUG=no MACHINE=x64 2. Build main.obj CimXml.obj CimCurl.obj

To build the program with a static lib, libcurl.lib

北战南征 提交于 2021-02-08 08:14:11
问题 I tried to build a stanalone program with a static lib , libcurl.lib . But I got bunch of errors. I ever refered to the related posts on stackoverflow and libcurl homepage, unfortunately it is in vain so far. The following is my building procedure and the error message I got. Please comments. Thank you a lot, 1. Build curl from source code nmake /f Makefile.vc mode=static VC=14 ENABLE_SSPI=no ENABLE_IPV6=no ENABLE_IDN=no GEN_PDB=no DEBUG=no MACHINE=x64 2. Build main.obj CimXml.obj CimCurl.obj

Guard a section of code from being executed concurrently in a coroutine

喜夏-厌秋 提交于 2021-02-08 07:53:54
问题 I need to protect a section of code from being executed concurrently in a coroutine. Guarding against concurrent execution in a multithreaded environment would be a simple matter of using the std::lock_guard class template. My coroutine, however, is called from a single thread, so that solution is not applicable. The following is (pseudo) code of what I'm trying to accomplish: future<http_response> send_req_async(http_request req) { while (true) { // Attempt to send an HTTP request auto const