- 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
462 Posted Topics
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 … | |
Re: [Notifications and the Notifications Area](https://msdn.microsoft.com/en-us/library/windows/desktop/ee330740(v=vs.85).aspx#notification) It also contains a Sample near the end that you can download and run. | |
Re: I don't understand what problem you are having doing this.. What have you tried :S The solution is below: //Get the text from box 1. int len = GetWindowTextLength(TextBox) + 1; char* text = new char[len]; GetWindowText(TextBox, &text[0], len); //Append the text to box 2. SendMessage(TextField, EM_SETSEL, -1, -1); SendMessage(TextField, … | |
Re: The first thing you need to do is select the `HBITMAP` into a `MemoryDC`. Then you cna use the `AlphaBlend` function to draw it to the `WindowDC`. If the `MemoryDC` is NOT compatible with the `WindowDC`, this will fail! In that case, you can use `CreateCompatibleBitmap(WindowDC, width, height)`, copy the … | |
Re: Have you tested your code? The way I do it is: HBITMAP hBmp = reinterpret_cast<HBITMAP>(GetCurrentObject(DC, OBJ_BITMAP)); | |
Re: There's multiple ways to do it.. First the manual way: 1: union KeyState { LPARAM lparam; struct { unsigned nRepeatCount : 16; unsigned nScanCode : 8; unsigned nExtended : 1; unsigned nReserved : 4; unsigned nContext : 1; unsigned nPrev : 1; unsigned nTrans : 1; }; }; LRESULT CALLBACK … | |
Re: After you do the `WM_MENUITEMPOPUP`, go through that menu and check with GetMenuState: http://msdn.microsoft.com/en-us/library/windows/desktop/ms647982(v=vs.85).aspx If it returns: `MF_HILITE`, the mouse is over that item. | |
Re: You need to create a Real-Time-Message-Loop as done in Direct-X. See: http://www.directxtutorial.com/Lesson.aspx?lessonid=9-1-4 while(true) { while(PeekMessage(&messages, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&messages); DispatchMessage(&messages); } if (messages.message == WM_QUIT) break; //Do Drawing Here instead of WM_PAINT.. } | |
Re: /* Creates a "Bitmap" on the heap so you can explicitly delete it before shutting down. Otherwise you must wait until it goes out of scope before shutting down. */ HBITMAP loadBitmap(const wchar_t* path) { HBITMAP tBmp = NULL; ULONG_PTR token = 0; Gdiplus::GdiplusStartupInput input = NULL; Gdiplus::GdiplusStartup(&token, &input, NULL); … | |
Re: This would depend on the kind of video... A flash video? HTML 5?? What Codecs?? AVI? WMV? MP4? What kind.. There is no specific code to play every single type of video that exists.. | |
Re: Is this Visual Studio C++? C++/CLI? I ask because you have "property" and "get, set" syntax which matches that of C#.. | |
Re: [sendinput](http://msdn.microsoft.com/en-us/library/windows/desktop/ms646310%28v=vs.85%29.aspx) [mouse_event](http://msdn.microsoft.com/en-us/library/windows/desktop/ms646260(v=vs.85).aspx) Use SendInput or mouse_event for Windows. | |
Re: If you know the resource ID, you can extract them with WinAPI. I don't know about extracting them using QT. | |
Re: Are you able to NOT use borland and use gcc/g++ or MSVC? | |
Re: Bad code here? SetProp(hwnd, formpropname, (HANDLE)FormClass.lpfnWndProc); hwnd = CreateWindowEx(0, classname, "The title of my window", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 240, 120, parent, NULL, mod, (LPVOID) this); HWND isn't assigned when you call `SetProp`. You probably want to create the window before calling `SetProp`. The real way to implement what you're looking … | |
Re: I cannot replicate this. What does your `WndProc` look like? | |
Re: The only way to skin and draw child controls is to use the `BS_OWNERDRAW` flag and draw the control yourself. | |
Re: If using Windows: `PlaySound("MyFile.wav", NULL, SND_FILENAME);` //or: `PlaySound("MyFile.wav", NULL, SND_FILENAME | SND_ASYNC);` For linux you can play files by opening `/dev/dsp` and writing the file to it. You could also use `system` and call `aplay` to play it. | |
Re: I think this is the guy from stack overflow that told me he could not change his code when I offered him code that reads a bitmap and finds it on screen :l Again, you are missing the padding at the end of each bitmap scan line. Here is how … | |
Re: > **WS_EX_TRANSPARENT** - Specifies that a window created with this style is to be transparent. That is, any windows that are beneath the window are not obscured by the window. A window created with this style receives WM_PAINT messages only after all sibling windows beneath it have been updated. [MSDN](http://msdn.microsoft.com/en-us/library/aa251511(v=vs.60).aspx) … | |
Re: ^ Ummm wth? are u trying to get your post count up?? sstream is stringstream... you could easily have searched that up.. and you do know c++ and c are somewhat interchangeable right? U can import and export functions between them... It doesnt matter if it isnt pure/native c++ |
The End.