462 Posted Topics

Member Avatar for cambalinho

This will work. You MUST have visual styles enabled in order to have an icon AND text at the same time.. Of course, you do not want to use the "EnableVisualStyles" function below. Do it with a manifest and a resource file! It is much better.. The below is simply …

Member Avatar for cambalinho
0
314
Member Avatar for ashley.vanhoesen.7

While I look over the code, I just have one comment before I post something useful.. I really hope you can change `1` thing.. `DO NOT #include .cpp files`. It is a bad habit and will get you in a lot of trouble down the line. I must also ask, …

Member Avatar for triumphost
0
504
Member Avatar for cambalinho

See: [ScrollWindowEx](http://msdn.microsoft.com/en-us/library/bb787593%28VS.85%29.aspx) The above `ScrollWindowEx` is exactly what you need to use. When you draw on the DC, draw on the entire DC. The entire width and height of your image. When you want to `clip` a specific part to the client area, you may scroll it or set a …

Member Avatar for cambalinho
0
384
Member Avatar for vegaseat
Member Avatar for Labdabeta

Don't mean to grave dig a 2 day old thread but are you sure: const char *strapp(const char *str, const char *s) { string ret=""; ret+=str; ret+=s; return ret.c_str(); } is valid? I ask because I'm wondering what will happen to the returned result when ret (its owner) gets destroyed. …

Member Avatar for mike_2000_17
0
551
Member Avatar for Labdabeta

The pixel you are trying to get is outside the window's clipping region.. 500, 500 is probably larger than your Window.. [GetPixel Documentation](http://msdn.microsoft.com/en-us/library/windows/desktop/dd144909(v=vs.85).aspx) See what it says for the return value..

Member Avatar for BobS0327
0
1K
Member Avatar for john.kane.100483

Show some better effort rather than copy pasting.. I really shouldn't be giving you code for apparently no reason but I feel nicer for some reason.. It can be done as follows: #include <iostream> #include <sstream> int tobase10(const char* Value) { int Dec = 0, Bin = strtoul(Value, 0, 10); …

Member Avatar for David W
0
225
Member Avatar for glao

#include <iostream> void printrowmajor(int* arr, int width, int height) { for (int i = 0; i < height; ++i) { for (int j = 0; j < width; ++j) std::cout<<arr[i * width + j]<<" "; std::cout<<"\n"; } } void printcolumnmajor(int* arr, int width, int height) { for (int i = …

Member Avatar for glao
0
330
Member Avatar for ifeanyiben

IDE (codeblocks-13.12-setup.exe): http://www.codeblocks.org/downloads/26 Install Mingw 4.8.1 (gcc/g++ compiler): http://sourceforge.net/projects/mingwbuilds/ Java JDK 7u51 (java compiler): http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

Member Avatar for rubberman
0
155
Member Avatar for brandon66

Basically, instead of having a stack allocated array of some size, you need to allocate the array on the heap. Allocating via `new[]` will give you a pointer to the data. However, there is one `downside`.. You must now `delete[]` the array after you're done using it! For example: #include …

Member Avatar for brandon66
0
279
Member Avatar for ganesh.naphade

It is by far easier to work with Bitmaps. I'm not used to GDI+ however, does your socket send all the bytes? If you use Bitmaps, then the following can work for you: HBITMAP PixelsToHBitmap(void* Pixels, int Width, int Height, unsigned short BitsPerPixel) { void* Memory = nullptr; HBITMAP ImageHandle …

Member Avatar for triumphost
0
369
Member Avatar for triumphost

I've created: #include <streambuf> #include <iostream> #include <windows.h> template<typename T> class BufferedStream : T { private: T &stream; std::streambuf* buffer; //planning to use this to create other "IO" functions. public: BufferedStream(T &stream) : stream(stream), buffer(stream.rdbuf()) {} ~BufferedStream() {stream.rdbuf(this->buffer);}; std::ostream& operator << (const char* data); std::ostream& operator << (const std::string &data); …

Member Avatar for Ancient Dragon
0
273
Member Avatar for bm42

Not sure if it's just me or not but I think the first example might be leaking? No `virtual destructor` so when `std::shared_ptr` calls `delete` on the `IFoo`, doesn't the destructor of the actual object NOT get called? I'm actually not sure how I'd debug it to tell..

Member Avatar for bm42
0
1K
Member Avatar for triumphost

I have the following code for 2D dimensional arrays being flattened as 1D C-style arrays: #include <iostream> int main() { int width = 4, height = 10; int arr[width * height]; for (int i = 0, k = 0; i < height; ++i) { for (int j = 0; j …

Member Avatar for Banfa
0
996
Member Avatar for daviddoria

#include <windows.h> #include <stdio.h> #define GetPixel(Bmp, X, Y) (((Bmp)->Pixels[(Y) * (Bmp)->Width + (X)]) & 0x00FFFFFF) #define PixelToColour(Pixel) (COLORREF)(((Pixel) & 0xFF00FF00) | (((Pixel) & 0xFF0000) >> 16) | (((Pixel) & 0xFF) << 16)) typedef struct { HBITMAP hBmp; int Width, Height; unsigned int* Pixels; unsigned short BitsPerPixel; } BmpData; typedef enum …

Member Avatar for dougy83
0
3K
Member Avatar for richieking

> As you can see CPP libs do not come with a time sleep/wait fuction to use > in your code/loop. In C++11: std::this_thread::sleep_for(std::chrono::milliseconds(1000)); std::this_thread::sleep_for(std::chrono::nanoseconds(1000000)); std::this_thread::sleep_for(std::chrono::seconds(1)); std::this_thread::sleep_until(.....); and so on..

Member Avatar for deceptikon
0
2K
Member Avatar for triumphost

Creating WinAPI windows and controls can be a pain and quite difficult/annoying at times. Most of the time, I find myself searching MSDN, DaniWeb, and StackOverflow. I hate having to use external libraries unless I absolutely have no other choice. Below contains code for creating WinAPI windows, Controls, Sub-Classing, and …

Member Avatar for mike_2000_17
0
4K
Member Avatar for cambalinho

Now sure what that colour parameter is, but I use this: void SetTransparency(HWND hwnd, std::uint8_t Transperancy) { long wAttr = GetWindowLong(hwnd, GWL_EXSTYLE); SetWindowLong(hwnd, GWL_EXSTYLE, wAttr | WS_EX_LAYERED); SetLayeredWindowAttributes(hwnd, 0, Transperancy, 0x2); } SetTransparency(Some_Window_Handle, 0); //100% transparency SetTransparency(Some_Window_Handle, 128); //50% transparency SetTransparency(Some_Window_Handle, 255); //0% transparency

Member Avatar for cambalinho
0
189
Member Avatar for pem

What moschops is saying is that you need to check for an empty vector or end iterator OR make sure that vector v is not empty. std::vector<int>::iterator it = (max_element(v.begin(), v.end())); if (it != v.end()) { maxValue = *it; //all other code (that for loop) goes here.. } else { …

Member Avatar for Moschops
0
122
Member Avatar for sireiz

Is this a console program or a GUI program? Windows or Linux? For Windows, it is all UTF-16. Thus you'll need to convert from UTF-8 to UTF-16 unless you are already using UTF-16. If it is WINAPI, you'll need to use only the Unicode functions such as: `DrawTextW`, `SetWindowTextW`, `TextOutW`, …

Member Avatar for triumphost
0
125
Member Avatar for triumphost

Why is accessing data in an uninitialised array undefined behaviour? I ask because I was doing some benchmarking on `vector<int>` vs. `int*` vs. `int**`. My results were: http://stackoverflow.com/questions/20863478/class-using-stdvector-allocation-slower-than-pointer-allocation-by-a-lot Now I'm being told if I use the raw array and try to access an index without initialising it first, it is …

Member Avatar for mike_2000_17
0
193
Member Avatar for cambalinho

You cannot get mouse event like this. You need to "track" the mouse and determine when it has entered and when it has left your window/control. I've written a small example below. #include <iostream> #include <windows.h> void TrackMouse(HWND hwnd) { TRACKMOUSEEVENT tme; tme.cbSize = sizeof(TRACKMOUSEEVENT); tme.dwFlags = TME_HOVER | TME_LEAVE; …

Member Avatar for cambalinho
0
3K
Member Avatar for drgr33n

You want something like [CODE] if(!isdigit(num1 || num2)){ cout<<"You entered a character that is not a digit\n"; Welcomscreen(); }[/CODE] And for C++.Net you do: [CODE] if(!Char::IsDigit(e->KeyChar) && e->KeyChar != 0x08)//The 0x08 is the backspace key.. you might wanna add 0x0D which is the Enter button. { e->Handled = true; } …

Member Avatar for Juan_8
0
378
Member Avatar for cambalinho

Your operator () is wrong and you also need to tell it what parameters the class takes.. #include <functional> #include <vector> #include <iostream> template<typename... Args> class events { public: typedef std::function<void(Args... args)> OnSomethingHandler; events(OnSomethingHandler Handler) { handlers_.push_back(Handler); } void operator ()(Args... args) { for(auto i = handlers_.begin(); i != handlers_.end(); …

Member Avatar for cambalinho
0
794
Member Avatar for 9tontruck

A DLL is made for windows.. It is going to require you to specify a main.. int main() for consoles WinMain for Win32-GUI DLLMain for DLL's int WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) { switch(dwReason) { case DLL_PROCESS_ATTACH: { break; } case DLL_PROCESS_DETACH: { break; } } return true; …

Member Avatar for mark5rockzz_1
0
2K
Member Avatar for FazeLessWhite

It's not exactly "facial" recognition but if you like rolling your own, I wrote a sort of Image recognition class you can take a look at: https://github.com/Brandon-T/PurelyCPP/blob/master/src/ImageFinder.cpp and I load my images using: https://github.com/Brandon-T/PurelyCPP/blob/master/src/Images.cpp It can find images such as Bitmap, PNG, TGA, etc.. You can specify the matching threshold/tolerance …

Member Avatar for rubberman
0
264
Member Avatar for Shft

> Use ShowWindow in combination with SW_HIDE on the current window - it will hide the console Just change main to "WinMain" and compile with -mwindows. That way the console never even shows.

Member Avatar for triumphost
-1
299
Member Avatar for triumphost

In the two for loops below, I want the checksum variable to hold the same value for both even though one loop starts at row 12 and another at row 0. Any ideas how I can combine these loops so that I don't have to iterate the same buffer twice? …

Member Avatar for triumphost
0
887
Member Avatar for triumphost

Should I be using std::wstring or std::string and wchar_t or char? All this unicode stuff is confusing me. I want my application to work on both windows and linux without too many problems and changes but I'm considering unicode vs. ansi. Any ideas? I ask because I see many applications …

Member Avatar for vijayan121
0
1K
Member Avatar for triumphost

I want to use it because it says it supports all the C++11 features and I'm hoping that includes Regex as well since gcc isn't near finishing anytime soon.. However, many other websites are saying that clang requires Mingw/gcc to be used in the first place. It doesn't make any …

Member Avatar for triumphost
0
702
Member Avatar for Labdabeta

They are implicitly convertible to T&, so that they can be used as arguments with the functions that take the underlying type by reference. Source: http://en.cppreference.com/w/cpp/utility/functional/reference_wrapper

Member Avatar for mike_2000_17
0
410
Member Avatar for Labdabeta

I don't know if it's too late to reply since this thread is solved but I wrote something a while ago for a game and the image recognition is pretty flawless and fast too. Way faster than GetPixel. It was previously crossplatform but I thought that I might need bitmaps …

Member Avatar for triumphost
0
800
Member Avatar for Suzie999

if(!SetWindowLong(hExternalWindow,GWL_STYLE, WS_CHILD | WS_VISIBLE)){MessageBox(nullptr, L"SetWindowLong fail", L"Error", MB_OK);}; Can't.. The window cannot be a child window if it has no parent. Try setting the parent first. I tried this and it works fine: case WM_CREATE: { HWND Window = FindWindow("Notepad", "Untitled - Notepad"); if (Window != nullptr) { SetParent(Window, hwnd); …

Member Avatar for Suzie999
0
4K
Member Avatar for annitaz

Qstring str = textEdit->toPlainText(); for (auto &s : str) { s.toUpper(); } textEdit->setPlainText(str);

Member Avatar for triumphost
0
157
Member Avatar for efe.ozyer

I use the following and link to "Shell32" and "Ole32": #include <windows.h> #include <shobjidl.h> 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, …

Member Avatar for RonalBertogi
0
3K
Member Avatar for cobaltfive

Can you use classes? Have you learned them yet? It'd be a ton easier to manage your array through one. Also there's quite a bit of errors in your code.. You're using the wrong delete :l If you do: `new[Size]` then you need to do `delete[]`.. If you use `new` …

Member Avatar for triumphost
0
238
Member Avatar for triumphost

template<typename T> void Transpose(T** Data, std::size_t Size) { for (int I = 0; I < Size; ++I) { for (int J = 0; J < I; ++J) { std::swap(Data[I][J], Data[J][I]); } } } int main() { int A[4][4] = { {1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, …

Member Avatar for mike_2000_17
0
115
Member Avatar for kamalashraf

Small example.. Uhh you'll have to replace some of the functions with your own but you get the idea. std::uint32_t RecvEx(SOCKET Socket, void* Buffer, std::uint32_t BufferLength) { char* Pointer = reinterpret_cast<char*>(Buffer); std::uint32_t TotalRead = 0; while (BufferLength > 0) { int BytesRead = recv(Socket, Pointer, std::min(1024 * 1024, static_cast<int>(BufferLength)), 0); …

Member Avatar for triumphost
0
606
Member Avatar for triumphost

I have roughly 500 function pointers defined in a header like so for example: void (__stdcall *ptr_glAccum) (GLenum op, GLfloat value); void (__stdcall *ptr_glActiveTextureARB) (GLenum texture); void (__stdcall *ptr_glAlphaFunc) (GLenum func, GLclampf ref); GLboolean (__stdcall *ptr_glAreTexturesResident) (GLsizei n, const GLuint *textures, GLboolean *residences); void (__stdcall *ptr_glArrayElement) (GLint index); void (__stdcall …

0
156
Member Avatar for MasterHacker110

std::string From = "From String"; std::wstring To(From.begin(), From.end()); LPCWSTR Last = To.c_str();

Member Avatar for MasterHacker110
0
4K
Member Avatar for Melly3

Some problems seen: Don't forget to delete those pointers using delete[]. Can be done in the destructor or before you decide to reuse/reallocate the pointer. Posting class does not have a member function called display_posting(); Deprecated conversion warnings from string to char* (Can be ignored really or change first parameter …

Member Avatar for RonalBertogi
1
226
Member Avatar for triumphost

I'm trying to write a cout formatter that uses the comma operator and insertion operator. I wasn't able to get that to work so I decided to write it similar to std::boolalpha. when you use `std::boolalpha`, it is able to change 0 values to true and false and you can …

0
190
Member Avatar for tomz6

Using ASM yes.. Iunno what you mean by CPU memory but I assume you mean registers. Just look up some x86 tutorials and download fasm get familiar with some commands then in your compiler, you can do something similar to: __asm { push ebp mov ebp,esp mov ecx, 0x6; mov …

Member Avatar for rubberman
0
242
Member Avatar for triumphost

I wrote a large project dealing with images, files, and WINAPI functions. I decided to add RichTextEdit to it and used the msfedit.dll.. Turns out that it only supports UNICODE style strings and chars and my entire project is std::strings and LPCSTR's, etc.. None of the WINAPI functions are unicode …

Member Avatar for Ancient Dragon
0
214
Member Avatar for tubzz

He's telling you that your standards need fixing or else NO ONE will read your code.. Read some of the comments I put into your code to figure out how to format it.. #include <iostream.h> #include <conio.h> void main() //needs to be int main.. { |<-->| = A tab/or 4-space. …

Member Avatar for tubzz
0
165
Member Avatar for triumphost

Assuming a simple class like below and the main like below, will the class variable be stack/heap allocated depending on how the class is instantiated? OR will the class variable be allocated depending on how it is implemented? class Foo { private: std::string Bar; public: Foo() : Bar(std::string()) {} }; …

Member Avatar for mike_2000_17
0
17K
Member Avatar for triumphost

How can I install gcc 4.7.2 for codeblocks that supports both 32 and 64 compilation? If I install the x32 bit compiler: x32-4.7.2-release-win32-sjlj-rev10 it will compile with -m32 compiler switch but give a bunch of linker errors for -m64 If I install the x64 bit compiler: x64-4.7.2-release-win32-sjlj-rev10 it will compile …

Member Avatar for triumphost
0
383
Member Avatar for triumphost

I have a class called Control. All other "controls" inherit from this class. Some controls need a default constructor so that I can assign or construct them later. The classes look like: class Control { private: //All Members Here.. void Swap(Control &C); public: Control(DWORD dwExStyle, std::string Class, std::string Title, ....); …

Member Avatar for triumphost
0
845
Member Avatar for triumphost

Why do I need a static class member? What are the advantages and disadvantages of it? Is there any way that I can have non-static member fuction without doing anything outside of the class (such as passing an instance)? class Control { private: HMENU ID; HWND Handle, Parent; std::string Class, …

Member Avatar for Ancient Dragon
0
309
Member Avatar for Superfreak3

Use a mutex so that only one instance can run? Check processes to see if a process with that name already is running (Not fool proof).

Member Avatar for RonalBertogi
0
220

The End.