- Strength to Increase Rep
- +10
- Strength to Decrease Rep
- -2
- Upvotes Received
- 79
- Posts with Upvotes
- 74
- Upvoting Members
- 41
- Downvotes Received
- 11
- Posts with Downvotes
- 8
- Downvoting Members
- 10
Re: @AncientDragon, that event greek looking code is a lambda. It's just a function that will be run when an event occurs. @OP.. WIN32/WINAPI code others are posting would be correct if they took into consideration that Labels (the control you want to paint) is a static control (no insult to … | |
Re: [CODE] #include <iostream> #include <windows.h> #include <math.h> #include <cmath> #include <string> #include <sstream> using namespace std; int num; int ones_digit; int tens_digit; int main() { cout<<"Enter 1 or 2 digits\n\n"; cin>> num; cin.ignore(); string num2; stringstream out; out << num; num2 = out.str(); num2.length(); ones_digit = num%10; tens_digit = num/10; … | |
Re: #include <vector> #include <fstream> #include <cstring> #include <windows.h> bool HDCToFile(const char* FilePath, HDC Context, RECT Area, uint16_t BitsPerPixel = 24) { uint32_t Width = Area.right - Area.left; uint32_t Height = Area.bottom - Area.top; BITMAPINFO Info; BITMAPFILEHEADER Header; memset(&Info, 0, sizeof(Info)); memset(&Header, 0, sizeof(Header)); Info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); Info.bmiHeader.biWidth = Width; Info.bmiHeader.biHeight … | |
Re: #include <iostream> #include <windows.h> using namespace std; int main() { //Get Program Files Location. char buffer[256]; ExpandEnvironmentStrings("%ProgramFiles(x86)%", buffer, 256); std::cout<<buffer<<"\n"; //Get Current Executable Location. GetCurrentDirectory(256, buffer); std::cout<<buffer<<"\n"; return 0; } | |
Re: WinAPI is a nightmare. Boost is also a nightmare of a library. It's super large! Most of the time you don't want certain parts of boost. Secondly, most of boost is actually in C++11, C++14, C++17. I haven't found a use for boost since.. Unless dealing with shared memory and … | |
Re: `cout` cannot "replace" `printf` because `printf` has formatting flags.. `cout` does not. You would have to use a modifier or `sprintf` to a buffer then print the buffer using `cout`. Modifiers such as `std::setprecision` would suffice. If you are sure you only want to print 19 characters max, then `std::cout.write(time_buff, … | |
Re: You cannot write an std::string to a file like that. You also cannot write the image structure to a file like that unless it is a POD structure. std::strings are allocated on the heap internally (usually) and contain constructors and all sorts of internal book keeping. You also cannot READ … | |
Re: You have your signs wrong. You also don't use the `and` (`&&`) operator.. You're also missing an `if` statement to make it an `else if`. Other than that, your code would have been fine with Labdabeta's correction. #include <iostream> #include <iomanip> using namespace std; int main() { //variable declarations double … | |
Re: The below code compiles.. gives only one warning which I cba to fix.. its basically fopen to fopen_s.. u can fix that easily.. its just a compiler warning though. [CODE] // File.cpp #include "header.h" #include <iostream> using namespace std; /* open raw socket, set promiscuous mode */ void init_net() { … | |
Re: Your copy constructor is missing. Your bitmap is destroyed when assigned. Why? Because you're making a shallow copy by doing `Bitmap& operator = (const Bitmap& bmp);` and when bmp dies, all its resources dies. Thus your bitmap that was passed in is now destroyed or has invalid resources. Secondly, `HICONFromHBITMAP` … | |
Re: You are leaking by calling `GetDC(hwnd)` and not releasing it. DOCINFO di = {sizeof(DOCINFO), "Bitmap Printing"}; HDC pDC = GetPrinterDC(hwnd); int w = GetDeviceCaps(pDC, HORZRES); int h = GetDeviceCaps(pDC, VERTRES); HDC hdcMem = CreateCompatibleDC(pDC); HBITMAP hbmOld = (HBITMAP)SelectObject(hdcMem, hBitmap); StartDoc(pDC, &di); StartPage(pDC); SetMapMode(pDC, MM_ISOTROPIC); SetWindowExtEx(pDC, w,h, nullptr); SetViewportExtEx(pDC, w, h, … | |
Re: @Galperin the above code is horrible. It will also only work for 32-bit bitmaps. It does not handle 24-bit bitmaps which have padding. For that reason, you're going to get a deformed image. The below code will work: #include <iostream> #include <fstream> typedef struct { uint8_t r, g, b, a; … | |
Re: You need to either double buffer the window/painting OR use a Real-Time-Message-Loop (this option is usually used in OpenGL & Direct-X in combination with a double buffer. It can also be used with a single buffer just fine).. while(true) { while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } if(msg.message … | |
Re: const GUID CLSID_TaskbarList = {0x56FDF344, 0xFD6D, 0x11D0, {0x95, 0x8A, 0x00, 0x60, 0x97, 0xC9, 0xA0, 0x90}}; const GUID IID_ITaskbarList = {0x56FDF342, 0xFD6D, 0x11D0, {0x95, 0x8A, 0x00, 0x60, 0x97, 0xC9, 0xA0, 0x90}}; const GUID IID_ITaskbarList2 = {0x602D4995, 0xB13A, 0x429b, {0xA6, 0x6E, 0x19, 0x35, 0xE4, 0x4F, 0x43, 0x17}}; const GUID IID_ITaskList3 = {0xEA1AFB91, … | |
Re: Undefined behaviour. CHOOSEFONT ShowSelectFont(HWND hwnd=GetForegroundWindow()) { CHOOSEFONT cf = {sizeof(CHOOSEFONT)}; LOGFONT lf; cf.Flags = CF_EFFECTS | CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS; cf.hwndOwner = hwnd; cf.lpLogFont = &lf; //ADDRESS OF LOCAL VARIABLE! cf.rgbColors = RGB(0,0,0); cf.lpLogFont->lfStrikeOut=FALSE; cf.lpLogFont->lfUnderline=FALSE; cf.lpLogFont->lfHeight=-MulDiv(12, GetDeviceCaps(GetDC(hwnd), LOGPIXELSY), 72); _tcscpy(cf.lpLogFont->lfFaceName, "Arial" ); if(ChooseFont(&cf)) { HFONT hf = CreateFontIndirect(&lf); //HF is unused … | |
Re: https://msdn.microsoft.com/en-us/library/dd144938(VS.85).aspx | |
Re: If using C++11, there's an `std::to_string` function in the `<string>` header. #include <iostream> #include <string> int main() { std::string occult = "666"; for (int i = 0, n = 2; ; ++i) { if (std::to_string(i).find("666") != std::string::npos) { if (n == 1) { std::cout<<i<<"\n"; } n -= 1; } } … | |
Re: What do you mean transparent controls? Are you trying to make a button 100% transparent? If that's the case, just hide the control. Are you trying to round a button (transparent corners)? Are you trying to make the button semi-transparent? | |
Re: Have you tried bitblt on the parent DC to the child DC yet? | |
Re: Question is confusing.. What do you mean "make swapping"? There are many ways to swap two variables.. std::swap(variable_a, variable_b); //OR template<class T> void do_swap(T& a, T& b) { T temp = std::move(a); a = std::move(b); b = std::move(temp); } //OR template<typename T> void do_swap(T& a, T& b) { T temp … | |
Re: **FloodFill** is the algorithm you are looking for. The idea is simple. As long as there is a border around the iris of the eye, you can floodfill the background and it will not affec the iris. However, if there is no border around the iris, then this will fail … | |
Re: You're invoking the copy assignment operator on a half initialised class. You've never initialised some of the variables in the other constructors that you have. By default they would be 0 or undefined. If you call "Picture" using any one of the constructors that do NOT load a "gif", you … | |
Re: I don't understand the problem at all. What is working and what isn't working? The label seems to be drawn fine in that image.. Give more details on what is wrong with it. | |
Re: Off-topic: `SendMessage((HWND)lParam , WM_CREATE, wParam, lParam);` WHAT?!.. are you trying to accomplish here? | |
Re: You "could" use `std::accumulate` (if permitted by your homework assignment) with 1 to 100 and pass it a function tell if it's even or not. | |
Re: What have you tried? Also, this is the C++ section but we can still help. | |
Re: Why are you unregistering and registering the hotkey everytime the button is drawn? This looks like an owner drawn button but the question stands.. | |
| Re: Be VERY careful when using WinAPI's wrapper functions.. Many gcc/g++ implementations define `SendMessage` as `SendMessageA` if `_UNICODE` and `UNICODE` is NOT defined. Otherwise it is defined as `SendMessageW`. You need to either define those for your project OR explicitly use the WideCharacter version of the functions as shown below: //Use … |
Re: The term you are looking for is called "[OCR](http://en.wikipedia.org/wiki/Optical_character_recognition)".. Optical Character Recognition. A library that may help, would be [OpenCV](http://opencv.org/) (an image recognition library). | |
Re: If you are seeing weird characters, it's most likely because of: `(LPCWSTR) inst->strCaption.c_str()` Seeing this makes me believe that your strCaption is an `std::string` and NOT `std::wstring`. This cast is therefore an illegal cast. What makes you think you can just cast a `const char*` to a `const wchar_t*`? If … |