179 Topics
see my windows procedure: LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { bool blnMouseEnter=false; switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_KEYUP: if (wParam ==VK_ESCAPE) DestroyWindow(hwnd); else { char strDataToSend[32]; sprintf(strDataToSend, "%c", wParam); MessageBox(NULL,strDataToSend, "keyselected",MB_OK); } break; case WM_MOUSEMOVE: SetWindowText(hwnd,"hi"); break; case WM_MOUSELEAVE://is ignored :( SetWindowText(hwnd,"bye"); break; … | |
i'm building a class with std::function for recive several parameters or none: class event2 { public: typedef std::function<void(...)> OnSomethingHandler; void operator() (...) { eventwithoutarg (...); } event & operator = (OnSomethingHandler Handler(...)) { eventwithoutarg(...) = Handler(...); return *this; } private: OnSomethingHandler eventwithoutarg(...); }; what i'm doing wrong with '...'? | |
see these sample: template <typename a> class test { test(a argument) { cout << argument; } }; //declare it: int main() { test<string> a("hello"); } how can i do it: test a("hello"); | |
template <typename a, typename ... b> class events { public: typedef std::function<void( a arg, b ... argx)> OnSomethingHandler; events(OnSomethingHandler Handler) { handlers_.push_back(Handler); } void operator ()() { for(auto i = handlers_.begin(); i != handlers_.end(); ++i) (*i)(); } private: std::vector<OnSomethingHandler> handlers_; void AddHandler(OnSomethingHandler Handler) { handlers_.push_back(Handler); } void TriggerEvents() { for(auto … | |
the csbi.wAttributes are combinations of '|' operators,... DWORD textcolor = csbi.wAttributes & 0xff0f; DWORD backcolor = (csbi.wAttributes & 0xfff0) >> 4; i understand the 0xff0f is a hexadecimal value(i don't know in decimal), but why these number and not other? can anyone explain to me these 2 calculations? (they are … | |
i have these code for clear the screen: //clear the Console void Clear(int BackColor=0) { // home for the cursor COORD coordScreen = {0, 0}; DWORD cCharsWritten; CONSOLE_SCREEN_BUFFER_INFO csbi; DWORD dwConSize; // Get the number of character cells in the current buffer if(!GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi)) return; dwConSize = csbi.dwSize.X * csbi.dwSize.Y; … | |
the prototype function is: BOOL WINAPI WriteConsoleOutputAttribute( _In_ HANDLE hConsoleOutput, _In_ const WORD *lpAttribute, _In_ DWORD nLength, _In_ COORD dwWriteCoord, _Out_ LPDWORD lpNumberOfAttrsWritten ); i'm trying use it for the 1st time... what means: "lpNumberOfAttrsWritten [out] A pointer to a variable that receives the number of attributes actually written to … | |
i know use SetConsoleTextAttribute(): SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), ForgC|(BackC<<4) ); (too be honest: i don't have sure if i can avoid the '<<4') i need ask these: can i add it more data and then use it? like: Blink=128 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), ForgC|(BackC<<4) | Blink); and then test if these value is there? | |
by some reason the TextOut() function don't show me the text:( but see these code: #include <iostream> #include <string.h> #include <windows.h> using namespace std; int main() { HDC a=GetDC(GetForegroundWindow()); cout << GetLastError();//i get 0(no errors) Rectangle(a,3,4,3+80,4+20);//the rectangule is showed TextOut(a,10,10,"hello world",strlen("hello world")); cout << GetLastError();//i get 0(no errors) cin.get(); } … | |
i have 1 class Multithread, but seems that i have some errors:( #include <process.h> #include <string> using namespace std; class MultiThread { private: void * b; public: void ParameterList(void *c) { b=c; } void Thread(unsigned (__stdcall*) (void *) ) { _beginthreadex(NULL, 0, (__stdcall*) (void *) , b, 0, NULL); } … | |
can anyone explain to me what is: 'T', 'L', 'wchar_t', 'LPCWSTR' and 'LPCTSTR'? how can i convert strings\char* to these types? (i understand these isn't a tutorial, but i realy need these introdution) or you can give me just a nice link. | |
imagine these line: cout << "glória vitória"; //glory vitory why instead print 'ó', prints '3/4'(the ascii char)??? changing the console font name, can resolve it? | |
if C++ isn't a real OOPL, what left? with another words i want study(theory\concepts) the real OOPL. can you give me a link with these information? | |
on my last topic i didn't recive mails notifications(when someone answer me). how i have sure that i will recive a mail notification on topic? | |
when i enter on windows, i see the button user name... until here, fine. but when i click it, i get 1 error about user profile. can anyone help me fix it, please? | |
is there any function(API or something) for get 1ms of precision? i have 1 timer, but i only get 10ms of max. | |
see these class: class test { public: void virtual Created(){} void test() { Created(); } }; class test1 : public test { void Created(); void test1(): test { Created(); } } test1; void test1::Created() { cout << "created test1"; } (these code wasn't tested, but you get the point) can … | |
class test { virtual void created(){}; //i must do these. //or when i call the function the compiler give me an error test() { void created(); } }test; void test::created() { cout << "hello world"; } these code have 1 error. but how can overrride the created function? | |
i want build 1 const with std::endl but by some reason isn't accepted:( #define NewLine std::endl i understand the '#define' isn't adviced to be used, but in these case i belive that i can't use the 'const':( what isn't right with that line? error message: "C:\Users\Joaquim\Documents\CodeBlocks\My Class\console.h|170|note: void Console::write(A, B … | |
i have 1 class: class class1 { void Created(); calss1() { Created(); } } class1; void class1::Created() { cout << "hello"; } imagine that i don't write: void class1::Created() { cout << "hello"; } i get an error. i try these too: class class1 { void Created() { //do nothing … | |
i build these code. it's very cool: in test.h: class test { private: bool blVisible; int x=0,y=0; public: void Show(); bool Visible() { return blVisible; } void Visible(bool value) { blVisible=value; if (value==true) Show();//call the event } }; in main.cpp: include <iostream> #include "test.h" using namespace std; test a; void … | |
using templates: how can i do a parameter for accept a function name? | |
the Visual Studio 2010 have 1 way for build properties, in class's. but isn't a portable code:( i'm using GNU\GCC\G++. so don't belive that isn't possible do it in C++;) so anyone can advice me? i was testing these code, but i get problems with char* and i can't use … | |
i'm trying doing a static clas, but i, always get errors... now i have head pain:( class Pessoa2 { private: static string strnome; public: Pessoa2() { strnome="ana"; } void setnome(string value) { strnome=value; } static string getnome() { return strnome; } }; just seen these static class, what i'm doing … | |
i read several time about Bitwise Right Shift Operator (>>\<<) but i continue without understand them:( can anyone explain to me? i don't undertand what will be the next results:( Half = 25 >> 1; Half = 25 << 1; | |
//arr is the array int length;//for recive the array size length=sizeof(arr);//recive the array size cout <<length; length=length/sizeof(typeid(arr));//calculate the number of elements cout << sizeof(typeid(arr)); i'm using these code for calculate the number of elements in array. sizeof(typeid(arr)) these line is for give the type size, but isn't correct can anyone … |
The End.